@liveblocks/react-ui 2.18.2-test1 → 2.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/slate/plugins/mentions.js +20 -2
- package/dist/slate/plugins/mentions.js.map +1 -1
- package/dist/slate/plugins/mentions.mjs +21 -3
- package/dist/slate/plugins/mentions.mjs.map +1 -1
- package/dist/slate/utils/get-match-range.js +21 -10
- package/dist/slate/utils/get-match-range.js.map +1 -1
- package/dist/slate/utils/get-match-range.mjs +22 -11
- package/dist/slate/utils/get-match-range.mjs.map +1 -1
- package/dist/slate/utils/is-whitespace-character.js +9 -0
- package/dist/slate/utils/is-whitespace-character.js.map +1 -0
- package/dist/slate/utils/is-whitespace-character.mjs +7 -0
- package/dist/slate/utils/is-whitespace-character.mjs.map +1 -0
- package/dist/utils/memoize.js +1 -1
- package/dist/utils/memoize.js.map +1 -1
- package/dist/utils/memoize.mjs +2 -2
- package/dist/utils/memoize.mjs.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -4,6 +4,7 @@ var slate = require('slate');
|
|
|
4
4
|
var getCharacter = require('../utils/get-character.js');
|
|
5
5
|
var getMatchRange = require('../utils/get-match-range.js');
|
|
6
6
|
var isEmptyString = require('../utils/is-empty-string.js');
|
|
7
|
+
var isWhitespaceCharacter = require('../utils/is-whitespace-character.js');
|
|
7
8
|
|
|
8
9
|
const MENTION_CHARACTER = "@";
|
|
9
10
|
function getMentionDraftAtSelection(editor) {
|
|
@@ -11,12 +12,29 @@ function getMentionDraftAtSelection(editor) {
|
|
|
11
12
|
if (!selection || !slate.Range.isCollapsed(selection)) {
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
|
-
const match = getMatchRange.getMatchRange(editor, selection
|
|
15
|
+
const match = getMatchRange.getMatchRange(editor, selection, ["@"], {
|
|
16
|
+
include: true,
|
|
17
|
+
allowConsecutiveWhitespace: false,
|
|
18
|
+
ignoreTerminator: (_, point) => {
|
|
19
|
+
const characterBefore = getCharacter.getCharacterBefore(editor, point);
|
|
20
|
+
if (characterBefore && !isWhitespaceCharacter.isWhitespaceCharacter(characterBefore.text)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
const after = slate.Editor.after(editor, point, { unit: "character" });
|
|
24
|
+
if (after) {
|
|
25
|
+
const characterAfter = getCharacter.getCharacterAfter(editor, after);
|
|
26
|
+
if (isWhitespaceCharacter.isWhitespaceCharacter(characterAfter?.text)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
15
33
|
if (!match) {
|
|
16
34
|
return;
|
|
17
35
|
}
|
|
18
36
|
const matchText = slate.Editor.string(editor, match);
|
|
19
|
-
if (!matchText.startsWith(MENTION_CHARACTER)) {
|
|
37
|
+
if (!matchText.startsWith(MENTION_CHARACTER) || isWhitespaceCharacter.isWhitespaceCharacter(matchText[1])) {
|
|
20
38
|
return;
|
|
21
39
|
}
|
|
22
40
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mentions.js","sources":["../../../src/slate/plugins/mentions.ts"],"sourcesContent":["import type { Node as SlateNode } from \"slate\";\nimport {\n Editor as SlateEditor,\n Element as SlateElement,\n Range as SlateRange,\n Transforms as SlateTransforms,\n} from \"slate\";\n\nimport type { ComposerBodyMention } from \"../../types\";\nimport { getCharacterAfter, getCharacterBefore } from \"../utils/get-character\";\nimport { getMatchRange } from \"../utils/get-match-range\";\nimport { isEmptyString } from \"../utils/is-empty-string\";\n\nexport const MENTION_CHARACTER = \"@\";\n\nexport type MentionDraft = {\n range: SlateRange;\n text: string;\n};\n\nexport function getMentionDraftAtSelection(\n editor: SlateEditor\n): MentionDraft | undefined {\n const { selection } = editor;\n\n if (!selection || !SlateRange.isCollapsed(selection)) {\n return;\n }\n\n // Match the word at the current selection by walking back\n // until a whitespace character is found\n const match = getMatchRange(editor, selection);\n\n if (!match) {\n return;\n }\n\n const matchText = SlateEditor.string(editor, match);\n\n // Check if the match starts with the mention character\n if (!matchText.startsWith(MENTION_CHARACTER)) {\n return;\n }\n\n return {\n range: match,\n // Exclude the mention character from the text\n text: matchText.substring(1),\n };\n}\n\nexport function isComposerBodyMention(\n node: SlateNode\n): node is ComposerBodyMention {\n return SlateElement.isElement(node) && node.type === \"mention\";\n}\n\nexport function insertMention(editor: SlateEditor, userId: string) {\n const mention: ComposerBodyMention = {\n type: \"mention\",\n id: userId,\n children: [{ text: \"\" }],\n };\n\n // Insert the mention\n SlateTransforms.insertNodes(editor, mention);\n SlateTransforms.move(editor);\n\n const afterCharacter = editor.selection\n ? getCharacterAfter(editor, editor.selection)\n : undefined;\n\n if (!afterCharacter || afterCharacter.void) {\n // Insert a following space if needed\n SlateTransforms.insertText(editor, \" \");\n } else if (isEmptyString(afterCharacter.text)) {\n // Move the selection if it's already followed by a space\n SlateTransforms.move(editor);\n }\n}\n\nexport function insertMentionCharacter(editor: SlateEditor) {\n if (!editor.selection) {\n return;\n }\n\n // Check if the selection is preceded or followed by a non-whitespace character\n const beforeCharacter = getCharacterBefore(editor, editor.selection, {\n filterVoids: true,\n });\n const afterCharacter = getCharacterAfter(editor, editor.selection, {\n filterVoids: true,\n });\n const shouldInsertSpaceBefore =\n beforeCharacter && !isEmptyString(beforeCharacter.text);\n const shouldInsertSpaceAfter =\n afterCharacter && !isEmptyString(afterCharacter.text);\n\n if (!SlateRange.isCollapsed(editor.selection)) {\n const text =\n (shouldInsertSpaceBefore ? \" \" : \"\") +\n MENTION_CHARACTER +\n (shouldInsertSpaceAfter ? \" \" : \"\");\n\n // If the selection is collapsed, insert the mention character at the current selection\n editor.insertText(text);\n\n // If a following space was inserted, move the selection back by one\n if (shouldInsertSpaceAfter) {\n SlateTransforms.move(editor, {\n distance: 1,\n unit: \"character\",\n reverse: true,\n });\n }\n } else {\n const beforeText = (shouldInsertSpaceBefore ? \" \" : \"\") + MENTION_CHARACTER;\n\n // If the selection is not collapsed, insert the mention character before the selection\n editor.insertText(beforeText, { at: SlateRange.start(editor.selection) });\n\n if (shouldInsertSpaceAfter) {\n editor.insertText(\" \", { at: SlateRange.end(editor.selection) });\n }\n\n // Collapse the selection at its end\n SlateTransforms.collapse(editor, { edge: \"end\" });\n }\n}\n\nexport function withMentions<T extends SlateEditor>(editor: T): T {\n const { isInline, isVoid, markableVoid, deleteBackward } = editor;\n\n editor.isInline = (element) => {\n return isComposerBodyMention(element) || isInline(element);\n };\n\n editor.isVoid = (element) => {\n return isComposerBodyMention(element) || isVoid(element);\n };\n\n editor.markableVoid = (element) => {\n return isComposerBodyMention(element) || markableVoid(element);\n };\n\n editor.deleteBackward = (unit) => {\n const { selection } = editor;\n\n if (selection && SlateRange.isCollapsed(selection)) {\n const [mention] = SlateEditor.nodes(editor, {\n at:\n unit === \"character\"\n ? SlateEditor.before(editor, selection, { unit: \"character\" })\n : selection,\n match: isComposerBodyMention,\n });\n\n deleteBackward(unit);\n\n if (mention) {\n SlateTransforms.insertText(editor, MENTION_CHARACTER);\n }\n } else {\n deleteBackward(unit);\n }\n };\n\n return editor;\n}\n"],"names":["SlateRange","getMatchRange","SlateEditor","SlateElement","SlateTransforms","getCharacterAfter","isEmptyString","getCharacterBefore"],"mappings":";;;;;;;AAaO,MAAM,iBAAoB,GAAA,IAAA;AAO1B,SAAS,2BACd,MAC0B,EAAA;AAC1B,EAAM,MAAA,EAAE,WAAc,GAAA,MAAA,CAAA;AAEtB,EAAA,IAAI,CAAC,SAAa,IAAA,CAACA,WAAW,CAAA,WAAA,CAAY,SAAS,CAAG,EAAA;AACpD,IAAA,OAAA;AAAA,GACF;AAIA,EAAM,MAAA,KAAA,GAAQC,2BAAc,CAAA,MAAA,EAAQ,SAAS,CAAA,CAAA;AAE7C,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAA,OAAA;AAAA,GACF;A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AAO,EAAA,qBAAA;AAAA,OACR,CAAA,CAAA;AAED,MAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAEnB,MAAA,IAAI,OAAS,EAAA;AACX,QAAgBE,gBAAA,CAAA,UAAA,CAAW,QAAQ,iBAAiB,CAAA,CAAA;AAAA,OACtD;AAAA,KACK,MAAA;AACL,MAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAAA,KACrB;AAAA,GACF,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"mentions.js","sources":["../../../src/slate/plugins/mentions.ts"],"sourcesContent":["import type { Node as SlateNode } from \"slate\";\nimport {\n Editor as SlateEditor,\n Element as SlateElement,\n Range as SlateRange,\n Transforms as SlateTransforms,\n} from \"slate\";\n\nimport type { ComposerBodyMention } from \"../../types\";\nimport { getCharacterAfter, getCharacterBefore } from \"../utils/get-character\";\nimport { getMatchRange } from \"../utils/get-match-range\";\nimport { isEmptyString } from \"../utils/is-empty-string\";\nimport { isWhitespaceCharacter } from \"../utils/is-whitespace-character\";\n\nexport const MENTION_CHARACTER = \"@\";\n\nexport type MentionDraft = {\n range: SlateRange;\n text: string;\n};\n\nexport function getMentionDraftAtSelection(\n editor: SlateEditor\n): MentionDraft | undefined {\n const { selection } = editor;\n\n if (!selection || !SlateRange.isCollapsed(selection)) {\n return;\n }\n\n // Walk backwards from the selection until \"@\" is found, unless the character\n // before isn't whitespace (or \"@\" is the block's first character)\n const match = getMatchRange(editor, selection, [\"@\"], {\n include: true,\n allowConsecutiveWhitespace: false,\n ignoreTerminator: (_, point) => {\n const characterBefore = getCharacterBefore(editor, point);\n\n // Ignore \"@\" if it's preceded by a non-whitespace character\n if (characterBefore && !isWhitespaceCharacter(characterBefore.text)) {\n return true;\n }\n\n const after = SlateEditor.after(editor, point, { unit: \"character\" });\n\n if (after) {\n const characterAfter = getCharacterAfter(editor, after);\n\n // Ignore \"@\" if it's followed by a whitespace character\n if (isWhitespaceCharacter(characterAfter?.text)) {\n return true;\n }\n }\n\n return false;\n },\n });\n\n if (!match) {\n return;\n }\n\n const matchText = SlateEditor.string(editor, match);\n\n // Check if the match starts with the mention character (not followed by a whitespace character)\n if (\n !matchText.startsWith(MENTION_CHARACTER) ||\n isWhitespaceCharacter(matchText[1])\n ) {\n return;\n }\n\n return {\n range: match,\n // Exclude the mention character from the text\n text: matchText.substring(1),\n };\n}\n\nexport function isComposerBodyMention(\n node: SlateNode\n): node is ComposerBodyMention {\n return SlateElement.isElement(node) && node.type === \"mention\";\n}\n\nexport function insertMention(editor: SlateEditor, userId: string) {\n const mention: ComposerBodyMention = {\n type: \"mention\",\n id: userId,\n children: [{ text: \"\" }],\n };\n\n // Insert the mention\n SlateTransforms.insertNodes(editor, mention);\n SlateTransforms.move(editor);\n\n const afterCharacter = editor.selection\n ? getCharacterAfter(editor, editor.selection)\n : undefined;\n\n if (!afterCharacter || afterCharacter.void) {\n // Insert a following space if needed\n SlateTransforms.insertText(editor, \" \");\n } else if (isEmptyString(afterCharacter.text)) {\n // Move the selection if it's already followed by a space\n SlateTransforms.move(editor);\n }\n}\n\nexport function insertMentionCharacter(editor: SlateEditor) {\n if (!editor.selection) {\n return;\n }\n\n // Check if the selection is preceded or followed by a non-whitespace character\n const beforeCharacter = getCharacterBefore(editor, editor.selection, {\n filterVoids: true,\n });\n const afterCharacter = getCharacterAfter(editor, editor.selection, {\n filterVoids: true,\n });\n const shouldInsertSpaceBefore =\n beforeCharacter && !isEmptyString(beforeCharacter.text);\n const shouldInsertSpaceAfter =\n afterCharacter && !isEmptyString(afterCharacter.text);\n\n if (!SlateRange.isCollapsed(editor.selection)) {\n const text =\n (shouldInsertSpaceBefore ? \" \" : \"\") +\n MENTION_CHARACTER +\n (shouldInsertSpaceAfter ? \" \" : \"\");\n\n // If the selection is collapsed, insert the mention character at the current selection\n editor.insertText(text);\n\n // If a following space was inserted, move the selection back by one\n if (shouldInsertSpaceAfter) {\n SlateTransforms.move(editor, {\n distance: 1,\n unit: \"character\",\n reverse: true,\n });\n }\n } else {\n const beforeText = (shouldInsertSpaceBefore ? \" \" : \"\") + MENTION_CHARACTER;\n\n // If the selection is not collapsed, insert the mention character before the selection\n editor.insertText(beforeText, { at: SlateRange.start(editor.selection) });\n\n if (shouldInsertSpaceAfter) {\n editor.insertText(\" \", { at: SlateRange.end(editor.selection) });\n }\n\n // Collapse the selection at its end\n SlateTransforms.collapse(editor, { edge: \"end\" });\n }\n}\n\nexport function withMentions<T extends SlateEditor>(editor: T): T {\n const { isInline, isVoid, markableVoid, deleteBackward } = editor;\n\n editor.isInline = (element) => {\n return isComposerBodyMention(element) || isInline(element);\n };\n\n editor.isVoid = (element) => {\n return isComposerBodyMention(element) || isVoid(element);\n };\n\n editor.markableVoid = (element) => {\n return isComposerBodyMention(element) || markableVoid(element);\n };\n\n editor.deleteBackward = (unit) => {\n const { selection } = editor;\n\n if (selection && SlateRange.isCollapsed(selection)) {\n const [mention] = SlateEditor.nodes(editor, {\n at:\n unit === \"character\"\n ? SlateEditor.before(editor, selection, { unit: \"character\" })\n : selection,\n match: isComposerBodyMention,\n });\n\n deleteBackward(unit);\n\n if (mention) {\n SlateTransforms.insertText(editor, MENTION_CHARACTER);\n }\n } else {\n deleteBackward(unit);\n }\n };\n\n return editor;\n}\n"],"names":["SlateRange","getMatchRange","getCharacterBefore","isWhitespaceCharacter","SlateEditor","getCharacterAfter","SlateElement","SlateTransforms","isEmptyString"],"mappings":";;;;;;;;AAcO,MAAM,iBAAoB,GAAA,IAAA;AAO1B,SAAS,2BACd,MAC0B,EAAA;AAC1B,EAAM,MAAA,EAAE,WAAc,GAAA,MAAA,CAAA;AAEtB,EAAA,IAAI,CAAC,SAAa,IAAA,CAACA,WAAW,CAAA,WAAA,CAAY,SAAS,CAAG,EAAA;AACpD,IAAA,OAAA;AAAA,GACF;AAIA,EAAA,MAAM,QAAQC,2BAAc,CAAA,MAAA,EAAQ,SAAW,EAAA,CAAC,GAAG,CAAG,EAAA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
import { getCharacterBefore, getCharacterAfter } from '../utils/get-character.mjs';
|
|
3
3
|
import { getMatchRange } from '../utils/get-match-range.mjs';
|
|
4
4
|
import { isEmptyString } from '../utils/is-empty-string.mjs';
|
|
5
|
+
import { isWhitespaceCharacter } from '../utils/is-whitespace-character.mjs';
|
|
5
6
|
|
|
6
7
|
const MENTION_CHARACTER = "@";
|
|
7
8
|
function getMentionDraftAtSelection(editor) {
|
|
@@ -9,12 +10,29 @@ function getMentionDraftAtSelection(editor) {
|
|
|
9
10
|
if (!selection || !Range.isCollapsed(selection)) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
|
-
const match = getMatchRange(editor, selection
|
|
13
|
+
const match = getMatchRange(editor, selection, ["@"], {
|
|
14
|
+
include: true,
|
|
15
|
+
allowConsecutiveWhitespace: false,
|
|
16
|
+
ignoreTerminator: (_, point) => {
|
|
17
|
+
const characterBefore = getCharacterBefore(editor, point);
|
|
18
|
+
if (characterBefore && !isWhitespaceCharacter(characterBefore.text)) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const after = Editor.after(editor, point, { unit: "character" });
|
|
22
|
+
if (after) {
|
|
23
|
+
const characterAfter = getCharacterAfter(editor, after);
|
|
24
|
+
if (isWhitespaceCharacter(characterAfter?.text)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
13
31
|
if (!match) {
|
|
14
32
|
return;
|
|
15
33
|
}
|
|
16
34
|
const matchText = Editor.string(editor, match);
|
|
17
|
-
if (!matchText.startsWith(MENTION_CHARACTER)) {
|
|
35
|
+
if (!matchText.startsWith(MENTION_CHARACTER) || isWhitespaceCharacter(matchText[1])) {
|
|
18
36
|
return;
|
|
19
37
|
}
|
|
20
38
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mentions.mjs","sources":["../../../src/slate/plugins/mentions.ts"],"sourcesContent":["import type { Node as SlateNode } from \"slate\";\nimport {\n Editor as SlateEditor,\n Element as SlateElement,\n Range as SlateRange,\n Transforms as SlateTransforms,\n} from \"slate\";\n\nimport type { ComposerBodyMention } from \"../../types\";\nimport { getCharacterAfter, getCharacterBefore } from \"../utils/get-character\";\nimport { getMatchRange } from \"../utils/get-match-range\";\nimport { isEmptyString } from \"../utils/is-empty-string\";\n\nexport const MENTION_CHARACTER = \"@\";\n\nexport type MentionDraft = {\n range: SlateRange;\n text: string;\n};\n\nexport function getMentionDraftAtSelection(\n editor: SlateEditor\n): MentionDraft | undefined {\n const { selection } = editor;\n\n if (!selection || !SlateRange.isCollapsed(selection)) {\n return;\n }\n\n // Match the word at the current selection by walking back\n // until a whitespace character is found\n const match = getMatchRange(editor, selection);\n\n if (!match) {\n return;\n }\n\n const matchText = SlateEditor.string(editor, match);\n\n // Check if the match starts with the mention character\n if (!matchText.startsWith(MENTION_CHARACTER)) {\n return;\n }\n\n return {\n range: match,\n // Exclude the mention character from the text\n text: matchText.substring(1),\n };\n}\n\nexport function isComposerBodyMention(\n node: SlateNode\n): node is ComposerBodyMention {\n return SlateElement.isElement(node) && node.type === \"mention\";\n}\n\nexport function insertMention(editor: SlateEditor, userId: string) {\n const mention: ComposerBodyMention = {\n type: \"mention\",\n id: userId,\n children: [{ text: \"\" }],\n };\n\n // Insert the mention\n SlateTransforms.insertNodes(editor, mention);\n SlateTransforms.move(editor);\n\n const afterCharacter = editor.selection\n ? getCharacterAfter(editor, editor.selection)\n : undefined;\n\n if (!afterCharacter || afterCharacter.void) {\n // Insert a following space if needed\n SlateTransforms.insertText(editor, \" \");\n } else if (isEmptyString(afterCharacter.text)) {\n // Move the selection if it's already followed by a space\n SlateTransforms.move(editor);\n }\n}\n\nexport function insertMentionCharacter(editor: SlateEditor) {\n if (!editor.selection) {\n return;\n }\n\n // Check if the selection is preceded or followed by a non-whitespace character\n const beforeCharacter = getCharacterBefore(editor, editor.selection, {\n filterVoids: true,\n });\n const afterCharacter = getCharacterAfter(editor, editor.selection, {\n filterVoids: true,\n });\n const shouldInsertSpaceBefore =\n beforeCharacter && !isEmptyString(beforeCharacter.text);\n const shouldInsertSpaceAfter =\n afterCharacter && !isEmptyString(afterCharacter.text);\n\n if (!SlateRange.isCollapsed(editor.selection)) {\n const text =\n (shouldInsertSpaceBefore ? \" \" : \"\") +\n MENTION_CHARACTER +\n (shouldInsertSpaceAfter ? \" \" : \"\");\n\n // If the selection is collapsed, insert the mention character at the current selection\n editor.insertText(text);\n\n // If a following space was inserted, move the selection back by one\n if (shouldInsertSpaceAfter) {\n SlateTransforms.move(editor, {\n distance: 1,\n unit: \"character\",\n reverse: true,\n });\n }\n } else {\n const beforeText = (shouldInsertSpaceBefore ? \" \" : \"\") + MENTION_CHARACTER;\n\n // If the selection is not collapsed, insert the mention character before the selection\n editor.insertText(beforeText, { at: SlateRange.start(editor.selection) });\n\n if (shouldInsertSpaceAfter) {\n editor.insertText(\" \", { at: SlateRange.end(editor.selection) });\n }\n\n // Collapse the selection at its end\n SlateTransforms.collapse(editor, { edge: \"end\" });\n }\n}\n\nexport function withMentions<T extends SlateEditor>(editor: T): T {\n const { isInline, isVoid, markableVoid, deleteBackward } = editor;\n\n editor.isInline = (element) => {\n return isComposerBodyMention(element) || isInline(element);\n };\n\n editor.isVoid = (element) => {\n return isComposerBodyMention(element) || isVoid(element);\n };\n\n editor.markableVoid = (element) => {\n return isComposerBodyMention(element) || markableVoid(element);\n };\n\n editor.deleteBackward = (unit) => {\n const { selection } = editor;\n\n if (selection && SlateRange.isCollapsed(selection)) {\n const [mention] = SlateEditor.nodes(editor, {\n at:\n unit === \"character\"\n ? SlateEditor.before(editor, selection, { unit: \"character\" })\n : selection,\n match: isComposerBodyMention,\n });\n\n deleteBackward(unit);\n\n if (mention) {\n SlateTransforms.insertText(editor, MENTION_CHARACTER);\n }\n } else {\n deleteBackward(unit);\n }\n };\n\n return editor;\n}\n"],"names":["SlateRange","SlateEditor","SlateElement","SlateTransforms"],"mappings":";;;;;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,IAAM,MAAA,EAAE,WAAc,GAAA,MAAA,CAAA;AAEtB,IAAA,IAAI,SAAa,IAAAH,KAAA,CAAW,WAAY,CAAA,SAAS,CAAG,EAAA;AAClD,MAAA,MAAM,CAAC,OAAO,CAAI,GAAAC,MAAA,CAAY,MAAM,MAAQ,EAAA;AAAA,QAC1C,EAAA,EACE,IAAS,KAAA,WAAA,GACLA,MAAY,CAAA,MAAA,CAAO,MAAQ,EAAA,SAAA,EAAW,EAAE,IAAA,EAAM,WAAY,EAAC,CAC3D,GAAA,SAAA;AAAA,QACN,KAAO,EAAA,qBAAA;AAAA,OACR,CAAA,CAAA;AAED,MAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAEnB,MAAA,IAAI,OAAS,EAAA;AACX,QAAgBE,UAAA,CAAA,UAAA,CAAW,QAAQ,iBAAiB,CAAA,CAAA;AAAA,OACtD;AAAA,KACK,MAAA;AACL,MAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAAA,KACrB;AAAA,GACF,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"mentions.mjs","sources":["../../../src/slate/plugins/mentions.ts"],"sourcesContent":["import type { Node as SlateNode } from \"slate\";\nimport {\n Editor as SlateEditor,\n Element as SlateElement,\n Range as SlateRange,\n Transforms as SlateTransforms,\n} from \"slate\";\n\nimport type { ComposerBodyMention } from \"../../types\";\nimport { getCharacterAfter, getCharacterBefore } from \"../utils/get-character\";\nimport { getMatchRange } from \"../utils/get-match-range\";\nimport { isEmptyString } from \"../utils/is-empty-string\";\nimport { isWhitespaceCharacter } from \"../utils/is-whitespace-character\";\n\nexport const MENTION_CHARACTER = \"@\";\n\nexport type MentionDraft = {\n range: SlateRange;\n text: string;\n};\n\nexport function getMentionDraftAtSelection(\n editor: SlateEditor\n): MentionDraft | undefined {\n const { selection } = editor;\n\n if (!selection || !SlateRange.isCollapsed(selection)) {\n return;\n }\n\n // Walk backwards from the selection until \"@\" is found, unless the character\n // before isn't whitespace (or \"@\" is the block's first character)\n const match = getMatchRange(editor, selection, [\"@\"], {\n include: true,\n allowConsecutiveWhitespace: false,\n ignoreTerminator: (_, point) => {\n const characterBefore = getCharacterBefore(editor, point);\n\n // Ignore \"@\" if it's preceded by a non-whitespace character\n if (characterBefore && !isWhitespaceCharacter(characterBefore.text)) {\n return true;\n }\n\n const after = SlateEditor.after(editor, point, { unit: \"character\" });\n\n if (after) {\n const characterAfter = getCharacterAfter(editor, after);\n\n // Ignore \"@\" if it's followed by a whitespace character\n if (isWhitespaceCharacter(characterAfter?.text)) {\n return true;\n }\n }\n\n return false;\n },\n });\n\n if (!match) {\n return;\n }\n\n const matchText = SlateEditor.string(editor, match);\n\n // Check if the match starts with the mention character (not followed by a whitespace character)\n if (\n !matchText.startsWith(MENTION_CHARACTER) ||\n isWhitespaceCharacter(matchText[1])\n ) {\n return;\n }\n\n return {\n range: match,\n // Exclude the mention character from the text\n text: matchText.substring(1),\n };\n}\n\nexport function isComposerBodyMention(\n node: SlateNode\n): node is ComposerBodyMention {\n return SlateElement.isElement(node) && node.type === \"mention\";\n}\n\nexport function insertMention(editor: SlateEditor, userId: string) {\n const mention: ComposerBodyMention = {\n type: \"mention\",\n id: userId,\n children: [{ text: \"\" }],\n };\n\n // Insert the mention\n SlateTransforms.insertNodes(editor, mention);\n SlateTransforms.move(editor);\n\n const afterCharacter = editor.selection\n ? getCharacterAfter(editor, editor.selection)\n : undefined;\n\n if (!afterCharacter || afterCharacter.void) {\n // Insert a following space if needed\n SlateTransforms.insertText(editor, \" \");\n } else if (isEmptyString(afterCharacter.text)) {\n // Move the selection if it's already followed by a space\n SlateTransforms.move(editor);\n }\n}\n\nexport function insertMentionCharacter(editor: SlateEditor) {\n if (!editor.selection) {\n return;\n }\n\n // Check if the selection is preceded or followed by a non-whitespace character\n const beforeCharacter = getCharacterBefore(editor, editor.selection, {\n filterVoids: true,\n });\n const afterCharacter = getCharacterAfter(editor, editor.selection, {\n filterVoids: true,\n });\n const shouldInsertSpaceBefore =\n beforeCharacter && !isEmptyString(beforeCharacter.text);\n const shouldInsertSpaceAfter =\n afterCharacter && !isEmptyString(afterCharacter.text);\n\n if (!SlateRange.isCollapsed(editor.selection)) {\n const text =\n (shouldInsertSpaceBefore ? \" \" : \"\") +\n MENTION_CHARACTER +\n (shouldInsertSpaceAfter ? \" \" : \"\");\n\n // If the selection is collapsed, insert the mention character at the current selection\n editor.insertText(text);\n\n // If a following space was inserted, move the selection back by one\n if (shouldInsertSpaceAfter) {\n SlateTransforms.move(editor, {\n distance: 1,\n unit: \"character\",\n reverse: true,\n });\n }\n } else {\n const beforeText = (shouldInsertSpaceBefore ? \" \" : \"\") + MENTION_CHARACTER;\n\n // If the selection is not collapsed, insert the mention character before the selection\n editor.insertText(beforeText, { at: SlateRange.start(editor.selection) });\n\n if (shouldInsertSpaceAfter) {\n editor.insertText(\" \", { at: SlateRange.end(editor.selection) });\n }\n\n // Collapse the selection at its end\n SlateTransforms.collapse(editor, { edge: \"end\" });\n }\n}\n\nexport function withMentions<T extends SlateEditor>(editor: T): T {\n const { isInline, isVoid, markableVoid, deleteBackward } = editor;\n\n editor.isInline = (element) => {\n return isComposerBodyMention(element) || isInline(element);\n };\n\n editor.isVoid = (element) => {\n return isComposerBodyMention(element) || isVoid(element);\n };\n\n editor.markableVoid = (element) => {\n return isComposerBodyMention(element) || markableVoid(element);\n };\n\n editor.deleteBackward = (unit) => {\n const { selection } = editor;\n\n if (selection && SlateRange.isCollapsed(selection)) {\n const [mention] = SlateEditor.nodes(editor, {\n at:\n unit === \"character\"\n ? SlateEditor.before(editor, selection, { unit: \"character\" })\n : selection,\n match: isComposerBodyMention,\n });\n\n deleteBackward(unit);\n\n if (mention) {\n SlateTransforms.insertText(editor, MENTION_CHARACTER);\n }\n } else {\n deleteBackward(unit);\n }\n };\n\n return editor;\n}\n"],"names":["SlateRange","SlateEditor","SlateElement","SlateTransforms"],"mappings":";;;;;;AAcO,MAAM,iBAAoB,GAA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QAAQ,iBAAiB,CAAA,CAAA;AAAA,OACtD;AAAA,KACK,MAAA;AACL,MAAA,cAAA,CAAe,IAAI,CAAA,CAAA;AAAA,KACrB;AAAA,GACF,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var slate = require('slate');
|
|
4
|
+
var isWhitespaceCharacter = require('./is-whitespace-character.js');
|
|
4
5
|
|
|
5
6
|
const defaultOptions = {
|
|
6
|
-
direction: "before"
|
|
7
|
+
direction: "before",
|
|
8
|
+
allowConsecutiveWhitespace: true
|
|
7
9
|
};
|
|
8
10
|
function getMatchRange(editor, at, terminators = [" "], options = defaultOptions) {
|
|
9
|
-
const { include, direction } = {
|
|
11
|
+
const { include, direction, ignoreTerminator, allowConsecutiveWhitespace } = {
|
|
12
|
+
...defaultOptions,
|
|
13
|
+
...options
|
|
14
|
+
};
|
|
10
15
|
let [start, end] = slate.Range.edges(at);
|
|
11
16
|
let point = start;
|
|
17
|
+
let previousCharacterWasWhitespace = false;
|
|
12
18
|
function move(direction2) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
const nextPoint = direction2 === "after" ? slate.Editor.after(editor, point, { unit: "character" }) : slate.Editor.before(editor, point, { unit: "character" });
|
|
20
|
+
if (!nextPoint || slate.Path.compare(nextPoint.path, point.path) !== 0) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const nextCharacter = nextPoint && slate.Editor.string(
|
|
17
24
|
editor,
|
|
18
|
-
direction2 === "after" ? { anchor: point, focus:
|
|
25
|
+
direction2 === "after" ? { anchor: point, focus: nextPoint } : { anchor: nextPoint, focus: point }
|
|
19
26
|
);
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
|
|
27
|
+
const lastCharacter = nextCharacter && nextCharacter[direction2 === "after" ? 0 : nextCharacter.length - 1];
|
|
28
|
+
if (!allowConsecutiveWhitespace && previousCharacterWasWhitespace && isWhitespaceCharacter.isWhitespaceCharacter(lastCharacter)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (nextPoint && lastCharacter && (!terminators.includes(lastCharacter) || ignoreTerminator?.(lastCharacter, nextPoint, direction2))) {
|
|
32
|
+
previousCharacterWasWhitespace = isWhitespaceCharacter.isWhitespaceCharacter(lastCharacter);
|
|
33
|
+
point = nextPoint;
|
|
23
34
|
if (point.offset === 0) {
|
|
24
35
|
return false;
|
|
25
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-match-range.js","sources":["../../../src/slate/utils/get-match-range.ts"],"sourcesContent":["import type { Point as SlatePoint } from \"slate\";\nimport {
|
|
1
|
+
{"version":3,"file":"get-match-range.js","sources":["../../../src/slate/utils/get-match-range.ts"],"sourcesContent":["import type { Point as SlatePoint } from \"slate\";\nimport {\n Editor as SlateEditor,\n Path as SlatePath,\n Range as SlateRange,\n} from \"slate\";\n\nimport { isWhitespaceCharacter } from \"./is-whitespace-character\";\n\ninterface Options {\n include?: boolean;\n direction?: \"before\" | \"after\" | \"both\";\n allowConsecutiveWhitespace?: boolean;\n ignoreTerminator?: (\n character: string,\n point: SlatePoint,\n direction: \"before\" | \"after\"\n ) => boolean;\n}\n\nconst defaultOptions: Options = {\n direction: \"before\",\n allowConsecutiveWhitespace: true,\n};\n\nexport function getMatchRange(\n editor: SlateEditor,\n at: SlateRange,\n terminators: string[] = [\" \"],\n options: Options = defaultOptions\n): SlateRange | undefined {\n const { include, direction, ignoreTerminator, allowConsecutiveWhitespace } = {\n ...defaultOptions,\n ...options,\n };\n\n let [start, end] = SlateRange.edges(at);\n let point: SlatePoint = start;\n let previousCharacterWasWhitespace = false;\n\n function move(direction: \"before\" | \"after\"): boolean {\n const nextPoint =\n direction === \"after\"\n ? SlateEditor.after(editor, point, { unit: \"character\" })\n : SlateEditor.before(editor, point, { unit: \"character\" });\n\n // Stop if we reached the end of a block\n if (!nextPoint || SlatePath.compare(nextPoint.path, point.path) !== 0) {\n return false;\n }\n\n const nextCharacter =\n nextPoint &&\n SlateEditor.string(\n editor,\n direction === \"after\"\n ? { anchor: point, focus: nextPoint }\n : { anchor: nextPoint, focus: point }\n );\n const lastCharacter =\n nextCharacter &&\n nextCharacter[direction === \"after\" ? 0 : nextCharacter.length - 1];\n\n if (\n !allowConsecutiveWhitespace &&\n previousCharacterWasWhitespace &&\n isWhitespaceCharacter(lastCharacter)\n ) {\n return false;\n }\n\n if (\n nextPoint &&\n lastCharacter &&\n (!terminators.includes(lastCharacter) ||\n ignoreTerminator?.(lastCharacter, nextPoint, direction))\n ) {\n previousCharacterWasWhitespace = isWhitespaceCharacter(lastCharacter);\n point = nextPoint;\n\n if (point.offset === 0) {\n return false;\n }\n } else {\n return false;\n }\n\n return true;\n }\n\n if (direction !== \"before\") {\n point = end;\n while (move(\"after\"));\n end = point;\n }\n\n if (direction !== \"after\") {\n point = start;\n while (move(\"before\"));\n start = point;\n }\n\n if (include) {\n return {\n anchor: SlateEditor.before(editor, start, { unit: \"offset\" }) ?? start,\n focus: SlateEditor.after(editor, end, { unit: \"offset\" }) ?? end,\n };\n }\n\n return { anchor: start, focus: end };\n}\n"],"names":["SlateRange","direction","SlateEditor","SlatePath","isWhitespaceCharacter"],"mappings":";;;;;AAoBA,MAAM,cAA0B,GAAA;AAAA,EAC9B,SAAW,EAAA,QAAA;AAAA,EACX,0BAA4B,EAAA,IAAA;AAC9B,CAAA,CAAA;AAEgB,SAAA,aAAA,CACd,QACA,EACA,EAAA,WAAA,GAAwB,CAAC,GAAG,CAAA,EAC5B,UAAmB,cACK,EAAA;AACxB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAW,EAAA,gBAAA,EAAkB,4BAA+B,GAAA;AAAA,IAC3E,GAAG,cAAA;AAAA,IACH,GAAG,OAAA;AAAA,GACL,CAAA;AAEA,EAAA,IAAI,CAAC,KAAO,EAAA,GAAG,CAAI,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AAA,CAAA;AAER,MAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACtB,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACK,MAAA;AACL,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAEA,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,IAAI,cAAc,QAAU,EAAA;AAC1B,IAAQ,KAAA,GAAA,GAAA,CAAA;AACR,IAAA,OAAO,KAAK,OAAO,CAAA;AAAE,MAAA,CAAA;AACrB,IAAM,GAAA,GAAA,KAAA,CAAA;AAAA,GACR;AAEA,EAAA,IAAI,cAAc,OAAS,EAAA;AACzB,IAAQ,KAAA,GAAA,KAAA,CAAA;AACR,IAAA,OAAO,KAAK,QAAQ,CAAA;AAAE,MAAA,CAAA;AACtB,IAAQ,KAAA,GAAA,KAAA,CAAA;AAAA,GACV;AAEA,EAAA,IAAI,OAAS,EAAA;AACX,IAAO,OAAA;AAAA,MACL,MAAA,EAAQF,aAAY,MAAO,CAAA,MAAA,EAAQ,OAAO,EAAE,IAAA,EAAM,QAAS,EAAC,CAAK,IAAA,KAAA;AAAA,MACjE,KAAA,EAAOA,aAAY,KAAM,CAAA,MAAA,EAAQ,KAAK,EAAE,IAAA,EAAM,QAAS,EAAC,CAAK,IAAA,GAAA;AAAA,KAC/D,CAAA;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAO,EAAA,KAAA,EAAO,GAAI,EAAA,CAAA;AACrC;;;;"}
|
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
import { Range, Editor } from 'slate';
|
|
1
|
+
import { Range, Editor, Path } from 'slate';
|
|
2
|
+
import { isWhitespaceCharacter } from './is-whitespace-character.mjs';
|
|
2
3
|
|
|
3
4
|
const defaultOptions = {
|
|
4
|
-
direction: "before"
|
|
5
|
+
direction: "before",
|
|
6
|
+
allowConsecutiveWhitespace: true
|
|
5
7
|
};
|
|
6
8
|
function getMatchRange(editor, at, terminators = [" "], options = defaultOptions) {
|
|
7
|
-
const { include, direction } = {
|
|
9
|
+
const { include, direction, ignoreTerminator, allowConsecutiveWhitespace } = {
|
|
10
|
+
...defaultOptions,
|
|
11
|
+
...options
|
|
12
|
+
};
|
|
8
13
|
let [start, end] = Range.edges(at);
|
|
9
14
|
let point = start;
|
|
15
|
+
let previousCharacterWasWhitespace = false;
|
|
10
16
|
function move(direction2) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
const nextPoint = direction2 === "after" ? Editor.after(editor, point, { unit: "character" }) : Editor.before(editor, point, { unit: "character" });
|
|
18
|
+
if (!nextPoint || Path.compare(nextPoint.path, point.path) !== 0) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const nextCharacter = nextPoint && Editor.string(
|
|
15
22
|
editor,
|
|
16
|
-
direction2 === "after" ? { anchor: point, focus:
|
|
23
|
+
direction2 === "after" ? { anchor: point, focus: nextPoint } : { anchor: nextPoint, focus: point }
|
|
17
24
|
);
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
|
|
25
|
+
const lastCharacter = nextCharacter && nextCharacter[direction2 === "after" ? 0 : nextCharacter.length - 1];
|
|
26
|
+
if (!allowConsecutiveWhitespace && previousCharacterWasWhitespace && isWhitespaceCharacter(lastCharacter)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (nextPoint && lastCharacter && (!terminators.includes(lastCharacter) || ignoreTerminator?.(lastCharacter, nextPoint, direction2))) {
|
|
30
|
+
previousCharacterWasWhitespace = isWhitespaceCharacter(lastCharacter);
|
|
31
|
+
point = nextPoint;
|
|
21
32
|
if (point.offset === 0) {
|
|
22
33
|
return false;
|
|
23
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-match-range.mjs","sources":["../../../src/slate/utils/get-match-range.ts"],"sourcesContent":["import type { Point as SlatePoint } from \"slate\";\nimport {
|
|
1
|
+
{"version":3,"file":"get-match-range.mjs","sources":["../../../src/slate/utils/get-match-range.ts"],"sourcesContent":["import type { Point as SlatePoint } from \"slate\";\nimport {\n Editor as SlateEditor,\n Path as SlatePath,\n Range as SlateRange,\n} from \"slate\";\n\nimport { isWhitespaceCharacter } from \"./is-whitespace-character\";\n\ninterface Options {\n include?: boolean;\n direction?: \"before\" | \"after\" | \"both\";\n allowConsecutiveWhitespace?: boolean;\n ignoreTerminator?: (\n character: string,\n point: SlatePoint,\n direction: \"before\" | \"after\"\n ) => boolean;\n}\n\nconst defaultOptions: Options = {\n direction: \"before\",\n allowConsecutiveWhitespace: true,\n};\n\nexport function getMatchRange(\n editor: SlateEditor,\n at: SlateRange,\n terminators: string[] = [\" \"],\n options: Options = defaultOptions\n): SlateRange | undefined {\n const { include, direction, ignoreTerminator, allowConsecutiveWhitespace } = {\n ...defaultOptions,\n ...options,\n };\n\n let [start, end] = SlateRange.edges(at);\n let point: SlatePoint = start;\n let previousCharacterWasWhitespace = false;\n\n function move(direction: \"before\" | \"after\"): boolean {\n const nextPoint =\n direction === \"after\"\n ? SlateEditor.after(editor, point, { unit: \"character\" })\n : SlateEditor.before(editor, point, { unit: \"character\" });\n\n // Stop if we reached the end of a block\n if (!nextPoint || SlatePath.compare(nextPoint.path, point.path) !== 0) {\n return false;\n }\n\n const nextCharacter =\n nextPoint &&\n SlateEditor.string(\n editor,\n direction === \"after\"\n ? { anchor: point, focus: nextPoint }\n : { anchor: nextPoint, focus: point }\n );\n const lastCharacter =\n nextCharacter &&\n nextCharacter[direction === \"after\" ? 0 : nextCharacter.length - 1];\n\n if (\n !allowConsecutiveWhitespace &&\n previousCharacterWasWhitespace &&\n isWhitespaceCharacter(lastCharacter)\n ) {\n return false;\n }\n\n if (\n nextPoint &&\n lastCharacter &&\n (!terminators.includes(lastCharacter) ||\n ignoreTerminator?.(lastCharacter, nextPoint, direction))\n ) {\n previousCharacterWasWhitespace = isWhitespaceCharacter(lastCharacter);\n point = nextPoint;\n\n if (point.offset === 0) {\n return false;\n }\n } else {\n return false;\n }\n\n return true;\n }\n\n if (direction !== \"before\") {\n point = end;\n while (move(\"after\"));\n end = point;\n }\n\n if (direction !== \"after\") {\n point = start;\n while (move(\"before\"));\n start = point;\n }\n\n if (include) {\n return {\n anchor: SlateEditor.before(editor, start, { unit: \"offset\" }) ?? start,\n focus: SlateEditor.after(editor, end, { unit: \"offset\" }) ?? end,\n };\n }\n\n return { anchor: start, focus: end };\n}\n"],"names":["SlateRange","direction","SlateEditor","SlatePath"],"mappings":";;;AAoBA,MAAM,cAA0B,GAAA;AAAA,EAC9B,SAAW,EAAA,QAAA;AAAA,EACX,0BAA4B,EAAA,IAAA;AAC9B,CAAA,CAAA;AAEgB,SAAA,aAAA,CACd,QACA,EACA,EAAA,WAAA,GAAwB,CAAC,GAAG,CAAA,EAC5B,UAAmB,cACK,EAAA;AACxB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAW,EAAA,gBAAA,EAAkB,4BAA+B,GAAA;AAAA,IAC3E,GAAG,cAAA;AAAA,IACH,GAAG,OAAA;AAAA,GACL,CAAA;AAEA,EAAA,IAAI,CAAC,KAAO,EAAA,GAAG,CAAI,GAAAA,KAAA,CAAW,MAAM,EAAE,CAAA,CAAA;AACtC,EAAA,IAAI,KAAoB,GAAA,KAAA,CAAA;AACxB,EAAA,IAAI,8BAAiC,GAAA,KAAA,CAAA;AAErC,EAAA,SAAS,KAAKC,UAAwC,EAAA;AACpD,IAAA,MAAM,YACJA,UAAc,KAAA,OAAA,GACVC,OAAY,KAAM,CAAA,MAAA,EAAQ,OAAO,EAAE,IAAA,EAAM,aAAa,CAAA,GACtDA,OAAY,MAAO,CAAA,MAAA,EAAQ,OAAO,EAAE,IAAA,EAAM,aAAa,CAAA,CAAA;AAG7D,IAAI,IAAA,CAAC,aAAaC,IAAU,CAAA,OAAA,CAAQ,UAAU,IAAM,EAAA,KAAA,CAAM,IAAI,CAAA,KAAM,CAAG,EAAA;AACrE,MAAO,OAAA,KAAA,CA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AAA,GAAA,KAAA,CAAA;AAAA,GACV;AAEA,EAAA,IAAI,OAAS,EAAA;AACX,IAAO,OAAA;AAAA,MACL,MAAA,EAAQC,OAAY,MAAO,CAAA,MAAA,EAAQ,OAAO,EAAE,IAAA,EAAM,QAAS,EAAC,CAAK,IAAA,KAAA;AAAA,MACjE,KAAA,EAAOA,OAAY,KAAM,CAAA,MAAA,EAAQ,KAAK,EAAE,IAAA,EAAM,QAAS,EAAC,CAAK,IAAA,GAAA;AAAA,KAC/D,CAAA;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAO,EAAA,KAAA,EAAO,GAAI,EAAA,CAAA;AACrC;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const WHITESPACE_REGEX = /\s/;
|
|
4
|
+
function isWhitespaceCharacter(character) {
|
|
5
|
+
return character ? WHITESPACE_REGEX.test(character) : false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
exports.isWhitespaceCharacter = isWhitespaceCharacter;
|
|
9
|
+
//# sourceMappingURL=is-whitespace-character.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-whitespace-character.js","sources":["../../../src/slate/utils/is-whitespace-character.ts"],"sourcesContent":["const WHITESPACE_REGEX = /\\s/;\n\nexport function isWhitespaceCharacter(character?: string): boolean {\n return character ? WHITESPACE_REGEX.test(character) : false;\n}\n"],"names":[],"mappings":";;AAAA,MAAM,gBAAmB,GAAA,IAAA,CAAA;AAElB,SAAS,sBAAsB,SAA6B,EAAA;AACjE,EAAA,OAAO,SAAY,GAAA,gBAAA,CAAiB,IAAK,CAAA,SAAS,CAAI,GAAA,KAAA,CAAA;AACxD;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-whitespace-character.mjs","sources":["../../../src/slate/utils/is-whitespace-character.ts"],"sourcesContent":["const WHITESPACE_REGEX = /\\s/;\n\nexport function isWhitespaceCharacter(character?: string): boolean {\n return character ? WHITESPACE_REGEX.test(character) : false;\n}\n"],"names":[],"mappings":"AAAA,MAAM,gBAAmB,GAAA,IAAA,CAAA;AAElB,SAAS,sBAAsB,SAA6B,EAAA;AACjE,EAAA,OAAO,SAAY,GAAA,gBAAA,CAAiB,IAAK,CAAA,SAAS,CAAI,GAAA,KAAA,CAAA;AACxD;;;;"}
|
package/dist/utils/memoize.js
CHANGED
|
@@ -5,7 +5,7 @@ var core = require('@liveblocks/core');
|
|
|
5
5
|
function memoize(fn) {
|
|
6
6
|
const cache = /* @__PURE__ */ new Map();
|
|
7
7
|
return (...args) => {
|
|
8
|
-
const key = JSON.stringify(args.map((arg) => core.
|
|
8
|
+
const key = JSON.stringify(args.map((arg) => core.stableStringify(arg)));
|
|
9
9
|
const cached = cache.get(key);
|
|
10
10
|
if (cached !== void 0) {
|
|
11
11
|
return cached;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.js","sources":["../../src/utils/memoize.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"memoize.js","sources":["../../src/utils/memoize.ts"],"sourcesContent":["import { stableStringify } from \"@liveblocks/core\";\n\nexport function memoize<TArgs extends unknown[], TReturn>(\n fn: (...args: TArgs) => TReturn\n): (...args: TArgs) => TReturn {\n const cache = new Map<string, TReturn>();\n\n return (...args: TArgs): TReturn => {\n const key = JSON.stringify(args.map((arg) => stableStringify(arg)));\n const cached = cache.get(key);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const result = fn(...args);\n cache.set(key, result);\n\n return result;\n };\n}\n"],"names":["stableStringify"],"mappings":";;;;AAEO,SAAS,QACd,EAC6B,EAAA;AAC7B,EAAM,MAAA,KAAA,uBAAY,GAAqB,EAAA,CAAA;AAEvC,EAAA,OAAO,IAAI,IAAyB,KAAA;AAClC,IAAM,MAAA,GAAA,GAAM,IAAK,CAAA,SAAA,CAAU,IAAK,CAAA,GAAA,CAAI,CAAC,GAAQ,KAAAA,oBAAA,CAAgB,GAAG,CAAC,CAAC,CAAA,CAAA;AAClE,IAAM,MAAA,MAAA,GAAS,KAAM,CAAA,GAAA,CAAI,GAAG,CAAA,CAAA;AAE5B,IAAA,IAAI,WAAW,KAAW,CAAA,EAAA;AACxB,MAAO,OAAA,MAAA,CAAA;AAAA,KACT;AAEA,IAAM,MAAA,MAAA,GAAS,EAAG,CAAA,GAAG,IAAI,CAAA,CAAA;AACzB,IAAM,KAAA,CAAA,GAAA,CAAI,KAAK,MAAM,CAAA,CAAA;AAErB,IAAO,OAAA,MAAA,CAAA;AAAA,GACT,CAAA;AACF;;;;"}
|
package/dist/utils/memoize.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stableStringify } from '@liveblocks/core';
|
|
2
2
|
|
|
3
3
|
function memoize(fn) {
|
|
4
4
|
const cache = /* @__PURE__ */ new Map();
|
|
5
5
|
return (...args) => {
|
|
6
|
-
const key = JSON.stringify(args.map((arg) =>
|
|
6
|
+
const key = JSON.stringify(args.map((arg) => stableStringify(arg)));
|
|
7
7
|
const cached = cache.get(key);
|
|
8
8
|
if (cached !== void 0) {
|
|
9
9
|
return cached;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.mjs","sources":["../../src/utils/memoize.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"memoize.mjs","sources":["../../src/utils/memoize.ts"],"sourcesContent":["import { stableStringify } from \"@liveblocks/core\";\n\nexport function memoize<TArgs extends unknown[], TReturn>(\n fn: (...args: TArgs) => TReturn\n): (...args: TArgs) => TReturn {\n const cache = new Map<string, TReturn>();\n\n return (...args: TArgs): TReturn => {\n const key = JSON.stringify(args.map((arg) => stableStringify(arg)));\n const cached = cache.get(key);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const result = fn(...args);\n cache.set(key, result);\n\n return result;\n };\n}\n"],"names":[],"mappings":";;AAEO,SAAS,QACd,EAC6B,EAAA;AAC7B,EAAM,MAAA,KAAA,uBAAY,GAAqB,EAAA,CAAA;AAEvC,EAAA,OAAO,IAAI,IAAyB,KAAA;AAClC,IAAM,MAAA,GAAA,GAAM,IAAK,CAAA,SAAA,CAAU,IAAK,CAAA,GAAA,CAAI,CAAC,GAAQ,KAAA,eAAA,CAAgB,GAAG,CAAC,CAAC,CAAA,CAAA;AAClE,IAAM,MAAA,MAAA,GAAS,KAAM,CAAA,GAAA,CAAI,GAAG,CAAA,CAAA;AAE5B,IAAA,IAAI,WAAW,KAAW,CAAA,EAAA;AACxB,MAAO,OAAA,MAAA,CAAA;AAAA,KACT;AAEA,IAAM,MAAA,MAAA,GAAS,EAAG,CAAA,GAAG,IAAI,CAAA,CAAA;AACzB,IAAM,KAAA,CAAA,GAAA,CAAI,KAAK,MAAM,CAAA,CAAA;AAErB,IAAO,OAAA,MAAA,CAAA;AAAA,GACT,CAAA;AACF;;;;"}
|
package/dist/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const PKG_NAME = "@liveblocks/react-ui";
|
|
4
|
-
const PKG_VERSION = typeof "2.18.
|
|
4
|
+
const PKG_VERSION = typeof "2.18.3" === "string" && "2.18.3";
|
|
5
5
|
const PKG_FORMAT = typeof "cjs" === "string" && "cjs";
|
|
6
6
|
|
|
7
7
|
exports.PKG_FORMAT = PKG_FORMAT;
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-ui\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":";;AAGO,MAAM,QAAW,GAAA,uBAAA;AACX,MAAA,WAAA,GAAc,OAAO,
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-ui\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":";;AAGO,MAAM,QAAW,GAAA,uBAAA;AACX,MAAA,WAAA,GAAc,OAAO,QAAA,KAAgB,QAAY,IAAA,SAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;;;"}
|
package/dist/version.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PKG_NAME = "@liveblocks/react-ui";
|
|
2
|
-
const PKG_VERSION = typeof "2.18.
|
|
2
|
+
const PKG_VERSION = typeof "2.18.3" === "string" && "2.18.3";
|
|
3
3
|
const PKG_FORMAT = typeof "esm" === "string" && "esm";
|
|
4
4
|
|
|
5
5
|
export { PKG_FORMAT, PKG_NAME, PKG_VERSION };
|
package/dist/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-ui\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA,uBAAA;AACX,MAAA,WAAA,GAAc,OAAO,
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../src/version.ts"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const ROLLUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react-ui\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof ROLLUP_FORMAT === \"string\" && ROLLUP_FORMAT;\n"],"names":[],"mappings":"AAGO,MAAM,QAAW,GAAA,uBAAA;AACX,MAAA,WAAA,GAAc,OAAO,QAAA,KAAgB,QAAY,IAAA,SAAA;AACjD,MAAA,UAAA,GAAa,OAAO,KAAA,KAAkB,QAAY,IAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/react-ui",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.3",
|
|
4
4
|
"description": "A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@floating-ui/react-dom": "^2.1.2",
|
|
78
|
-
"@liveblocks/client": "2.18.
|
|
79
|
-
"@liveblocks/core": "2.18.
|
|
80
|
-
"@liveblocks/react": "2.18.
|
|
78
|
+
"@liveblocks/client": "2.18.3",
|
|
79
|
+
"@liveblocks/core": "2.18.3",
|
|
80
|
+
"@liveblocks/react": "2.18.3",
|
|
81
81
|
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
|
82
82
|
"@radix-ui/react-popover": "^1.1.2",
|
|
83
83
|
"@radix-ui/react-slot": "^1.1.0",
|