@@ -75,6 +76,7 @@
+
@@ -103,6 +105,7 @@ import MkNoteSimple from '@/components/MkNoteSimple.vue';
import MkNotePreview from '@/components/MkNotePreview.vue';
import XPostFormAttaches from '@/components/MkPostFormAttaches.vue';
import MkPollEditor from '@/components/MkPollEditor.vue';
+import MkEventEditor from '@/components/MkEventEditor.vue';
import { host, url } from '@/config';
import { erase, unique } from '@/scripts/array';
import { extractMentions } from '@/scripts/extract-mentions';
@@ -165,6 +168,12 @@ let poll = $ref<{
expiresAt: string | null;
expiredAfter: string | null;
} | null>(null);
+let event = $ref<{
+ title: string;
+ start: string;
+ end: string | null;
+ metadata: Record;
+} | null>(null);
let useCw = $ref(false);
let showPreview = $ref(false);
let cw = $ref(null);
@@ -235,7 +244,7 @@ const maxTextLength = $computed((): number => {
const canPost = $computed((): boolean => {
return !posting && !posted &&
- (1 <= textLength || 1 <= files.length || !!poll || !!props.renote) &&
+ (1 <= textLength || 1 <= files.length || !!poll || !!props.renote || !!event) &&
(textLength <= maxTextLength) &&
(!poll || poll.choices.length >= 2);
});
@@ -331,6 +340,7 @@ function watchForDraft() {
watch($$(useCw), () => saveDraft());
watch($$(cw), () => saveDraft());
watch($$(poll), () => saveDraft());
+ watch($$(event), () => saveDraft());
watch($$(files), () => saveDraft(), { deep: true });
watch($$(visibility), () => saveDraft());
watch($$(localOnly), () => saveDraft());
@@ -375,6 +385,19 @@ function togglePoll() {
}
}
+function toggleEvent() {
+ if (event) {
+ event = null;
+ } else {
+ event = {
+ title: '',
+ start: (new Date()).toString(),
+ end: null,
+ metadata: {},
+ };
+ }
+}
+
function addTag(tag: string) {
insertTextAtCursor(textareaEl, ` #${tag} `);
}
@@ -513,6 +536,7 @@ function clear() {
text = '';
files = [];
poll = null;
+ event = null;
quoteId = null;
}
@@ -626,6 +650,7 @@ function saveDraft() {
localOnly: localOnly,
files: files,
poll: poll,
+ event: event,
},
};
@@ -687,6 +712,7 @@ async function post(ev?: MouseEvent) {
renoteId: props.renote ? props.renote.id : quoteId ? quoteId : undefined,
channelId: props.channel ? props.channel.id : undefined,
poll: poll,
+ event: event,
cw: useCw ? cw ?? '' : undefined,
localOnly: localOnly,
visibility: visibility,
@@ -847,6 +873,9 @@ onMounted(() => {
if (draft.data.poll) {
poll = draft.data.poll;
}
+ if (draft.data.event) {
+ event = draft.data.event;
+ }
}
}
@@ -865,6 +894,14 @@ onMounted(() => {
expiredAfter: init.poll.expiredAfter,
};
}
+ if (init.event) {
+ event = {
+ title: init.event.title,
+ start: init.event.start,
+ end: init.event.end,
+ metadata: init.event.metadata,
+ };
+ }
visibility = init.visibility;
localOnly = init.localOnly;
quoteId = init.renote ? init.renote.id : null;