enhance(frontend_ais): PostForm系の設定項目を追加 (#13788)
* enhance(frontend_ais): PostForm系の設定項目を追加 * Update Changelog
This commit is contained in:
parent
c530a46e54
commit
053e7626e4
|
@ -38,6 +38,7 @@
|
||||||
- Enhance: フォローするかどうかの確認ダイアログを出せるように
|
- Enhance: フォローするかどうかの確認ダイアログを出せるように
|
||||||
- Enhance: Playを手動でリロードできるように
|
- Enhance: Playを手動でリロードできるように
|
||||||
- Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように
|
- Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように
|
||||||
|
- Enhance: `Ui:C:postForm` および `Ui:C:postFormButton` に `localOnly` と `visibility` を設定できるように
|
||||||
- Chore: AiScriptを0.18.0にバージョンアップ
|
- Chore: AiScriptを0.18.0にバージョンアップ
|
||||||
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
|
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
|
||||||
- Fix: 周年の実績が閏年を考慮しない問題を修正
|
- Fix: 周年の実績が閏年を考慮しない問題を修正
|
||||||
|
|
|
@ -44,6 +44,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:instant="true"
|
:instant="true"
|
||||||
:initialText="c.form?.text"
|
:initialText="c.form?.text"
|
||||||
:initialCw="c.form?.cw"
|
:initialCw="c.form?.cw"
|
||||||
|
:initialVisibility="c.form?.visibility"
|
||||||
|
:initialLocalOnly="c.form?.localOnly"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<MkFolder v-else-if="c.type === 'folder'" :defaultOpen="c.opened">
|
<MkFolder v-else-if="c.type === 'folder'" :defaultOpen="c.opened">
|
||||||
|
@ -111,6 +113,8 @@ function openPostForm() {
|
||||||
os.post({
|
os.post({
|
||||||
initialText: form.text,
|
initialText: form.text,
|
||||||
initialCw: form.cw,
|
initialCw: form.cw,
|
||||||
|
initialVisibility: form.visibility,
|
||||||
|
initialLocalOnly: form.localOnly,
|
||||||
instant: true,
|
instant: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
import { utils, values } from '@syuilo/aiscript';
|
import { utils, values } from '@syuilo/aiscript';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { ref, Ref } from 'vue';
|
import { ref, Ref } from 'vue';
|
||||||
|
import * as Misskey from 'misskey-js';
|
||||||
|
|
||||||
export type AsUiComponentBase = {
|
export type AsUiComponentBase = {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -115,23 +116,24 @@ export type AsUiFolder = AsUiComponentBase & {
|
||||||
opened?: boolean;
|
opened?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type PostFormPropsForAsUi = {
|
||||||
|
text: string;
|
||||||
|
cw?: string;
|
||||||
|
visibility?: (typeof Misskey.noteVisibilities)[number];
|
||||||
|
localOnly?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type AsUiPostFormButton = AsUiComponentBase & {
|
export type AsUiPostFormButton = AsUiComponentBase & {
|
||||||
type: 'postFormButton';
|
type: 'postFormButton';
|
||||||
text?: string;
|
text?: string;
|
||||||
primary?: boolean;
|
primary?: boolean;
|
||||||
rounded?: boolean;
|
rounded?: boolean;
|
||||||
form?: {
|
form?: PostFormPropsForAsUi;
|
||||||
text: string;
|
|
||||||
cw?: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AsUiPostForm = AsUiComponentBase & {
|
export type AsUiPostForm = AsUiComponentBase & {
|
||||||
type: 'postForm';
|
type: 'postForm';
|
||||||
form?: {
|
form?: PostFormPropsForAsUi;
|
||||||
text: string;
|
|
||||||
cw?: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AsUiComponent = AsUiRoot | AsUiContainer | AsUiText | AsUiMfm | AsUiButton | AsUiButtons | AsUiSwitch | AsUiTextarea | AsUiTextInput | AsUiNumberInput | AsUiSelect | AsUiFolder | AsUiPostFormButton | AsUiPostForm;
|
export type AsUiComponent = AsUiRoot | AsUiContainer | AsUiText | AsUiMfm | AsUiButton | AsUiButtons | AsUiSwitch | AsUiTextarea | AsUiTextInput | AsUiNumberInput | AsUiSelect | AsUiFolder | AsUiPostFormButton | AsUiPostForm;
|
||||||
|
@ -447,6 +449,24 @@ function getFolderOptions(def: values.Value | undefined): Omit<AsUiFolder, 'id'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPostFormProps(form: values.VObj): PostFormPropsForAsUi {
|
||||||
|
const text = form.value.get('text');
|
||||||
|
utils.assertString(text);
|
||||||
|
const cw = form.value.get('cw');
|
||||||
|
if (cw) utils.assertString(cw);
|
||||||
|
const visibility = form.value.get('visibility');
|
||||||
|
if (visibility) utils.assertString(visibility);
|
||||||
|
const localOnly = form.value.get('localOnly');
|
||||||
|
if (localOnly) utils.assertBoolean(localOnly);
|
||||||
|
|
||||||
|
return {
|
||||||
|
text: text.value,
|
||||||
|
cw: cw?.value,
|
||||||
|
visibility: (visibility?.value && (Misskey.noteVisibilities as readonly string[]).includes(visibility.value)) ? visibility.value as typeof Misskey.noteVisibilities[number] : undefined,
|
||||||
|
localOnly: localOnly?.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function getPostFormButtonOptions(def: values.Value | undefined, call: (fn: values.VFn, args: values.Value[]) => Promise<values.Value>): Omit<AsUiPostFormButton, 'id' | 'type'> {
|
function getPostFormButtonOptions(def: values.Value | undefined, call: (fn: values.VFn, args: values.Value[]) => Promise<values.Value>): Omit<AsUiPostFormButton, 'id' | 'type'> {
|
||||||
utils.assertObject(def);
|
utils.assertObject(def);
|
||||||
|
|
||||||
|
@ -459,22 +479,11 @@ function getPostFormButtonOptions(def: values.Value | undefined, call: (fn: valu
|
||||||
const form = def.value.get('form');
|
const form = def.value.get('form');
|
||||||
if (form) utils.assertObject(form);
|
if (form) utils.assertObject(form);
|
||||||
|
|
||||||
const getForm = () => {
|
|
||||||
const text = form!.value.get('text');
|
|
||||||
utils.assertString(text);
|
|
||||||
const cw = form!.value.get('cw');
|
|
||||||
if (cw) utils.assertString(cw);
|
|
||||||
return {
|
|
||||||
text: text.value,
|
|
||||||
cw: cw?.value,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text: text?.value,
|
text: text?.value,
|
||||||
primary: primary?.value,
|
primary: primary?.value,
|
||||||
rounded: rounded?.value,
|
rounded: rounded?.value,
|
||||||
form: form ? getForm() : {
|
form: form ? getPostFormProps(form) : {
|
||||||
text: '',
|
text: '',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -486,19 +495,8 @@ function getPostFormOptions(def: values.Value | undefined, call: (fn: values.VFn
|
||||||
const form = def.value.get('form');
|
const form = def.value.get('form');
|
||||||
if (form) utils.assertObject(form);
|
if (form) utils.assertObject(form);
|
||||||
|
|
||||||
const getForm = () => {
|
|
||||||
const text = form!.value.get('text');
|
|
||||||
utils.assertString(text);
|
|
||||||
const cw = form!.value.get('cw');
|
|
||||||
if (cw) utils.assertString(cw);
|
|
||||||
return {
|
return {
|
||||||
text: text.value,
|
form: form ? getPostFormProps(form) : {
|
||||||
cw: cw?.value,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
form: form ? getForm() : {
|
|
||||||
text: '',
|
text: '',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue