From bfdf41a4c33cf74d6c9895e40b988348338f49aa Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 10 Oct 2023 20:08:37 -0500 Subject: [PATCH] cleaning --- src/view/com/composer/text-input/TextInput.web.tsx | 1 - .../text-input/mobile/TagsAutocomplete.tsx | 6 +++++- .../com/composer/text-input/web/Tags/plugin.tsx | 14 +++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/view/com/composer/text-input/TextInput.web.tsx b/src/view/com/composer/text-input/TextInput.web.tsx index c6b9e3c409..7459c43fe1 100644 --- a/src/view/com/composer/text-input/TextInput.web.tsx +++ b/src/view/com/composer/text-input/TextInput.web.tsx @@ -61,7 +61,6 @@ export const TextInput = React.forwardRef(function TextInputImpl( () => [ Document, LinkDecorator, - // TagDecorator, Tags.configure({ HTMLAttributes: { class: 'inline-tag', diff --git a/src/view/com/composer/text-input/mobile/TagsAutocomplete.tsx b/src/view/com/composer/text-input/mobile/TagsAutocomplete.tsx index 8d03662f7b..e7512796d9 100644 --- a/src/view/com/composer/text-input/mobile/TagsAutocomplete.tsx +++ b/src/view/com/composer/text-input/mobile/TagsAutocomplete.tsx @@ -23,6 +23,10 @@ export function getHashtagAt(text: string, position: number) { } } + /* + * show autocomplete after a single # is typed + * AND the cursor is next to the # + */ const hashRegex = /#/g let hashMatch while ((hashMatch = hashRegex.exec(text))) { @@ -38,7 +42,7 @@ export function insertTagAt(text: string, position: number, tag: string) { const target = getHashtagAt(text, position) if (target) { return `${text.slice(0, target.index)}#${tag} ${text.slice( - target.index + target.value.length + 1, // add 1 to include the "@" + target.index + target.value.length + 1, // add 1 to include the "#" )}` } return text diff --git a/src/view/com/composer/text-input/web/Tags/plugin.tsx b/src/view/com/composer/text-input/web/Tags/plugin.tsx index e2e0728dbe..5db789b4cc 100644 --- a/src/view/com/composer/text-input/web/Tags/plugin.tsx +++ b/src/view/com/composer/text-input/web/Tags/plugin.tsx @@ -1,4 +1,8 @@ -/** @see https://github.com/ueberdosis/tiptap/blob/main/packages/extension-mention/src/mention.ts */ +/** + * This is basically a fork of the Mention plugin from Tiptap. + * + * @see https://github.com/ueberdosis/tiptap/blob/025dfff1d9e4796edf3a451f7f53d06a07b95d69/packages/extension-mention/src/mention.ts + */ import {mergeAttributes, Node} from '@tiptap/core' import {Node as ProseMirrorNode} from '@tiptap/pm/model' @@ -127,14 +131,6 @@ export const Tags = Node.create({ }, renderHTML({node, HTMLAttributes}) { - console.log( - 'renderText', - node, - this.options.renderLabel({ - options: this.options, - node, - }), - ) return [ 'span', mergeAttributes(