From ccf6a17f7297e929fc405adc43bf7b01ad223d5f Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 30 Nov 2022 12:50:29 +0800 Subject: [PATCH] feat: improve editor --- components/publish/PublishWidget.vue | 4 +++- components/tiptap/TiptapCodeBlock.vue | 2 +- composables/content.ts | 22 +++++++++++++---- composables/statusDrafts.ts | 9 ++----- locales/en-US.json | 1 + styles/global.css | 18 +++++++------- styles/vars.css | 7 ++++++ ...test.ts.snap => content-rich.test.ts.snap} | 2 +- .../{content.test.ts => content-rich.test.ts} | 0 tests/html-to-text.test.ts | 24 +++++++++++++++++++ types/index.ts | 2 ++ unocss.config.ts | 1 + 12 files changed, 68 insertions(+), 24 deletions(-) rename tests/__snapshots__/{content.test.ts.snap => content-rich.test.ts.snap} (98%) rename tests/{content.test.ts => content-rich.test.ts} (100%) create mode 100644 tests/html-to-text.test.ts diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue index 342f2872..1d3c77d1 100644 --- a/components/publish/PublishWidget.vue +++ b/components/publish/PublishWidget.vue @@ -9,6 +9,7 @@ const { draftKey, initial = getDefaultDraft() as never /* Bug of vue-core */, expanded: _expanded = false, + placeholder, } = defineProps<{ draftKey: string initial?: () => Draft @@ -18,6 +19,7 @@ const { expanded?: boolean }>() +const { t } = useI18n() // eslint-disable-next-line prefer-const let { draft, isEmpty } = $(useDraft(draftKey, initial)) @@ -30,7 +32,7 @@ const { editor } = useTiptap({ get: () => draft.params.status, set: newVal => draft.params.status = newVal, }), - placeholder: computed(() => draft.placeholder), + placeholder: computed(() => placeholder || draft.params.inReplyToId ? t('placeholder.replying') : t('placeholder.default_1')), autofocus: shouldExpanded, onSubmit: publish, onFocus() { isExpanded = true }, diff --git a/components/tiptap/TiptapCodeBlock.vue b/components/tiptap/TiptapCodeBlock.vue index 1c59f1d2..b7325f08 100644 --- a/components/tiptap/TiptapCodeBlock.vue +++ b/components/tiptap/TiptapCodeBlock.vue @@ -20,7 +20,7 @@ const selectedLanguage = computed({