From 32fdf58f421e3843cff8ca2c9cf57c38400df124 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 19 Aug 2022 18:40:54 +0800 Subject: [PATCH] tiptap: update input rule --- packages/client/src/tiptap/core/extensions/callout.ts | 2 +- packages/client/src/tiptap/core/extensions/columns.ts | 2 +- packages/client/src/tiptap/core/extensions/countdown.ts | 2 +- packages/client/src/tiptap/core/extensions/excalidraw.ts | 2 +- packages/client/src/tiptap/core/extensions/flow.ts | 2 +- packages/client/src/tiptap/core/extensions/iframe.ts | 2 +- packages/client/src/tiptap/core/extensions/katex.ts | 2 +- packages/client/src/tiptap/editor/collaboration/kit.ts | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/client/src/tiptap/core/extensions/callout.ts b/packages/client/src/tiptap/core/extensions/callout.ts index a3cc71e2..a587b39b 100644 --- a/packages/client/src/tiptap/core/extensions/callout.ts +++ b/packages/client/src/tiptap/core/extensions/callout.ts @@ -69,7 +69,7 @@ export const Callout = Node.create({ addInputRules() { return [ wrappingInputRule({ - find: /^\$callout $/, + find: /^\$callout\$$/, type: this.type, getAttributes: (match) => { return { type: match[1] }; diff --git a/packages/client/src/tiptap/core/extensions/columns.ts b/packages/client/src/tiptap/core/extensions/columns.ts index b3fd4842..b2ceb7bf 100644 --- a/packages/client/src/tiptap/core/extensions/columns.ts +++ b/packages/client/src/tiptap/core/extensions/columns.ts @@ -268,7 +268,7 @@ export const Columns = Node.create({ addInputRules() { return [ nodeInputRule({ - find: /^\$columns $/, + find: /^\$columns\$$/, type: this.type, getAttributes: () => { return { type: 'left-right', columns: 2 }; diff --git a/packages/client/src/tiptap/core/extensions/countdown.ts b/packages/client/src/tiptap/core/extensions/countdown.ts index 4e317301..02652611 100644 --- a/packages/client/src/tiptap/core/extensions/countdown.ts +++ b/packages/client/src/tiptap/core/extensions/countdown.ts @@ -78,7 +78,7 @@ export const Countdown = Node.create({ addInputRules() { return [ nodeInputRule({ - find: /^\$countdown $/, + find: /^\$countdown\$$/, type: this.type, getAttributes: () => { return { width: '100%' }; diff --git a/packages/client/src/tiptap/core/extensions/excalidraw.ts b/packages/client/src/tiptap/core/extensions/excalidraw.ts index 030d9bbe..d36da5c9 100644 --- a/packages/client/src/tiptap/core/extensions/excalidraw.ts +++ b/packages/client/src/tiptap/core/extensions/excalidraw.ts @@ -103,7 +103,7 @@ export const Excalidraw = Node.create({ addInputRules() { return [ nodeInputRule({ - find: /^\$excalidraw $/, + find: /^\$excalidraw\$$/, type: this.type, getAttributes: () => { return { width: '100%' }; diff --git a/packages/client/src/tiptap/core/extensions/flow.ts b/packages/client/src/tiptap/core/extensions/flow.ts index 9c407910..8c795cce 100644 --- a/packages/client/src/tiptap/core/extensions/flow.ts +++ b/packages/client/src/tiptap/core/extensions/flow.ts @@ -108,7 +108,7 @@ export const Flow = Node.create({ addInputRules() { return [ nodeInputRule({ - find: /^\$flow $/, + find: /^\$flow\$$/, type: this.type, getAttributes: () => { return { width: '100%', defaultShowPicker: true, createUser: this.options.getCreateUserId() }; diff --git a/packages/client/src/tiptap/core/extensions/iframe.ts b/packages/client/src/tiptap/core/extensions/iframe.ts index ae8493ce..5b34c0c0 100644 --- a/packages/client/src/tiptap/core/extensions/iframe.ts +++ b/packages/client/src/tiptap/core/extensions/iframe.ts @@ -98,7 +98,7 @@ export const Iframe = Node.create({ addInputRules() { return [ nodeInputRule({ - find: /^\$iframe $/, + find: /^\$iframe\$$/, type: this.type, getAttributes: () => { return { width: '100%' }; diff --git a/packages/client/src/tiptap/core/extensions/katex.ts b/packages/client/src/tiptap/core/extensions/katex.ts index 9cf31aac..7e655d9f 100644 --- a/packages/client/src/tiptap/core/extensions/katex.ts +++ b/packages/client/src/tiptap/core/extensions/katex.ts @@ -78,7 +78,7 @@ export const Katex = Node.create({ addInputRules() { return [ nodeInputRule({ - find: /^\$katex $/, + find: /^\$katex\$$/, type: this.type, getAttributes: () => { return { defaultShowPicker: true, createUser: this.options.getCreateUserId() }; diff --git a/packages/client/src/tiptap/editor/collaboration/kit.ts b/packages/client/src/tiptap/editor/collaboration/kit.ts index c188c8d4..ef5ff56b 100644 --- a/packages/client/src/tiptap/editor/collaboration/kit.ts +++ b/packages/client/src/tiptap/editor/collaboration/kit.ts @@ -83,7 +83,7 @@ const placeholders = [ '使用 markdown 语法进行输入', '输入 @ 来提及他人', '输入 : 来插入表情', - '你知道吗?输入 $katex 然后按一下空格就可以快速插入数学公式,其他节点操作类似哦', + '你知道吗?输入 $katex 然后在输入一个 $ 就可以快速插入数学公式,其他节点操作类似哦', ]; const getCreateUserId = () => safeJSONParse(window.localStorage.getItem('user')).id;