@crystallize/design-system 1.3.2 → 1.4.1
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/CHANGELOG.md +12 -0
- package/dist/TableComponent-I2YOOYOU.css +281 -0
- package/dist/TableComponent-QINOO453.mjs +1377 -0
- package/dist/arrow-clockwise-Z2G6UEGP.svg +1 -0
- package/dist/arrow-counterclockwise-2O5EYVJT.svg +1 -0
- package/dist/bg-color-HB2WDYGO.svg +1 -0
- package/dist/camera-CR7D2PNH.svg +1 -0
- package/dist/caret-right-fill-FFBNEXVX.svg +1 -0
- package/dist/chat-square-quote-CI6PUJHH.svg +1 -0
- package/dist/chevron-down-3FRWSIKS.svg +1 -0
- package/dist/chunk-VUXQZRSP.mjs +737 -0
- package/dist/clipboard-OSEFDF25.svg +1 -0
- package/dist/close-FH57ZMJF.svg +1 -0
- package/dist/code-SEVR6TIQ.svg +1 -0
- package/dist/copy-DMGDODUL.svg +1 -0
- package/dist/diagram-2-CEJUD2B4.svg +1 -0
- package/dist/download-JXUGIUCX.svg +1 -0
- package/dist/draggable-block-menu-KKHDNKJA.svg +1 -0
- package/dist/dropdown-more-BHZ5COKX.svg +1 -0
- package/dist/file-image-TIQPFJX4.svg +1 -0
- package/dist/filetype-gif-OG2BEYYK.svg +1 -0
- package/dist/font-color-J4GA3ZJO.svg +1 -0
- package/dist/font-family-ZU5N6TTE.svg +1 -0
- package/dist/gear-ICMT4NTP.svg +1 -0
- package/dist/horizontal-rule-N6RD2V7H.svg +1 -0
- package/dist/indent-MJ6JIMCK.svg +1 -0
- package/dist/index.css +2711 -315
- package/dist/index.d.ts +145 -40
- package/dist/index.js +10376 -1481
- package/dist/index.mjs +7609 -746
- package/dist/journal-code-XUT44HDV.svg +1 -0
- package/dist/justify-J7X5JEEX.svg +1 -0
- package/dist/link-W52N4JKZ.svg +1 -0
- package/dist/list-ol-2ZEUN4Z7.svg +1 -0
- package/dist/list-ul-DVKNUP47.svg +1 -0
- package/dist/lock-WCYOZOHW.svg +1 -0
- package/dist/lock-fill-JZSKOSHK.svg +1 -0
- package/dist/markdown-4BGQNLLT.svg +1 -0
- package/dist/mic-H5FNOMM7.svg +1 -0
- package/dist/outdent-2LUMUMIP.svg +1 -0
- package/dist/paint-bucket-VCISMZTH.svg +1 -0
- package/dist/palette-SWGFPRWZ.svg +1 -0
- package/dist/pencil-fill-STFSC26F.svg +1 -0
- package/dist/plug-HGGGEVS3.svg +1 -0
- package/dist/plug-fill-OTG3U4TN.svg +1 -0
- package/dist/plus-CQISIKEC.svg +1 -0
- package/dist/plus-slash-minus-N22JU4TI.svg +1 -0
- package/dist/prettier-WUJ7B5NV.svg +1 -0
- package/dist/prettier-error-DYJSLYDP.svg +1 -0
- package/dist/square-check-UTG6FU6D.svg +1 -0
- package/dist/success-YVXUMPEZ.svg +1 -0
- package/dist/table-BR6DI4ZQ.svg +1 -0
- package/dist/text-center-UQI6PAEF.svg +1 -0
- package/dist/text-left-KT2B6TR3.svg +1 -0
- package/dist/text-paragraph-MFTUIIQG.svg +1 -0
- package/dist/text-right-SKELPISG.svg +1 -0
- package/dist/trash-UOM6D7TD.svg +1 -0
- package/dist/type-bold-PY7COC3N.svg +1 -0
- package/dist/type-h1-6KJP7YOM.svg +1 -0
- package/dist/type-h2-VHI2USC3.svg +1 -0
- package/dist/type-h3-JIU77CHO.svg +1 -0
- package/dist/type-h4-P5EHKDAL.svg +1 -0
- package/dist/type-h5-CS2KYVRG.svg +1 -0
- package/dist/type-h6-J2O74LJZ.svg +1 -0
- package/dist/type-italic-3DSFOSG2.svg +1 -0
- package/dist/type-strikethrough-E2KKQFSX.svg +1 -0
- package/dist/type-subscript-BMPTRIBU.svg +1 -0
- package/dist/type-superscript-EDF6EPAA.svg +1 -0
- package/dist/type-underline-CBFA5VLF.svg +1 -0
- package/dist/upload-Q6KICGZW.svg +1 -0
- package/dist/user-EOI2NEFZ.svg +1 -0
- package/package.json +30 -6
- package/src/dialog/dialog.tsx +1 -0
- package/src/icon-button/icon-button.css +16 -14
- package/src/index.ts +4 -4
- package/src/input/input.css +1 -1
- package/src/input-with-label/input-with-label.css +1 -1
- package/src/rich-text-editor/appSettings.ts +28 -0
- package/src/rich-text-editor/context/SettingsContext.tsx +71 -0
- package/src/rich-text-editor/context/SharedAutocompleteContext.tsx +60 -0
- package/src/rich-text-editor/context/SharedHistoryContext.tsx +25 -0
- package/src/rich-text-editor/hooks/useReport.ts +64 -0
- package/src/rich-text-editor/images/cat-typing.gif +0 -0
- package/src/rich-text-editor/images/emoji/1F600.png +0 -0
- package/src/rich-text-editor/images/emoji/1F641.png +0 -0
- package/src/rich-text-editor/images/emoji/1F642.png +0 -0
- package/src/rich-text-editor/images/emoji/2764.png +0 -0
- package/src/rich-text-editor/images/emoji/LICENSE.md +5 -0
- package/src/rich-text-editor/images/icons/LICENSE.md +5 -0
- package/src/rich-text-editor/images/icons/arrow-clockwise.svg +1 -0
- package/src/rich-text-editor/images/icons/arrow-counterclockwise.svg +1 -0
- package/src/rich-text-editor/images/icons/bg-color.svg +1 -0
- package/src/rich-text-editor/images/icons/camera.svg +1 -0
- package/src/rich-text-editor/images/icons/card-checklist.svg +1 -0
- package/src/rich-text-editor/images/icons/caret-right-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-left-text.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right-dots.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right-text.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-square-quote.svg +1 -0
- package/src/rich-text-editor/images/icons/chevron-down.svg +1 -0
- package/src/rich-text-editor/images/icons/clipboard.svg +1 -0
- package/src/rich-text-editor/images/icons/close.svg +1 -0
- package/src/rich-text-editor/images/icons/code.svg +1 -0
- package/src/rich-text-editor/images/icons/comments.svg +1 -0
- package/src/rich-text-editor/images/icons/copy.svg +1 -0
- package/src/rich-text-editor/images/icons/diagram-2.svg +1 -0
- package/src/rich-text-editor/images/icons/download.svg +1 -0
- package/src/rich-text-editor/images/icons/draggable-block-menu.svg +1 -0
- package/src/rich-text-editor/images/icons/dropdown-more.svg +1 -0
- package/src/rich-text-editor/images/icons/figma.svg +1 -0
- package/src/rich-text-editor/images/icons/file-image.svg +1 -0
- package/src/rich-text-editor/images/icons/filetype-gif.svg +1 -0
- package/src/rich-text-editor/images/icons/font-color.svg +1 -0
- package/src/rich-text-editor/images/icons/font-family.svg +1 -0
- package/src/rich-text-editor/images/icons/gear.svg +1 -0
- package/src/rich-text-editor/images/icons/horizontal-rule.svg +1 -0
- package/src/rich-text-editor/images/icons/indent.svg +1 -0
- package/src/rich-text-editor/images/icons/journal-code.svg +1 -0
- package/src/rich-text-editor/images/icons/journal-text.svg +1 -0
- package/src/rich-text-editor/images/icons/justify.svg +1 -0
- package/src/rich-text-editor/images/icons/link.svg +1 -0
- package/src/rich-text-editor/images/icons/list-ol.svg +1 -0
- package/src/rich-text-editor/images/icons/list-ul.svg +1 -0
- package/src/rich-text-editor/images/icons/lock-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/lock.svg +1 -0
- package/src/rich-text-editor/images/icons/markdown.svg +1 -0
- package/src/rich-text-editor/images/icons/mic.svg +1 -0
- package/src/rich-text-editor/images/icons/outdent.svg +1 -0
- package/src/rich-text-editor/images/icons/paint-bucket.svg +1 -0
- package/src/rich-text-editor/images/icons/palette.svg +1 -0
- package/src/rich-text-editor/images/icons/pencil-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/plug-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/plug.svg +1 -0
- package/src/rich-text-editor/images/icons/plus-slash-minus.svg +1 -0
- package/src/rich-text-editor/images/icons/plus.svg +1 -0
- package/src/rich-text-editor/images/icons/prettier-error.svg +1 -0
- package/src/rich-text-editor/images/icons/prettier.svg +1 -0
- package/src/rich-text-editor/images/icons/send.svg +1 -0
- package/src/rich-text-editor/images/icons/square-check.svg +1 -0
- package/src/rich-text-editor/images/icons/sticky.svg +1 -0
- package/src/rich-text-editor/images/icons/success.svg +1 -0
- package/src/rich-text-editor/images/icons/table.svg +1 -0
- package/src/rich-text-editor/images/icons/text-center.svg +1 -0
- package/src/rich-text-editor/images/icons/text-left.svg +1 -0
- package/src/rich-text-editor/images/icons/text-paragraph.svg +1 -0
- package/src/rich-text-editor/images/icons/text-right.svg +1 -0
- package/src/rich-text-editor/images/icons/trash.svg +1 -0
- package/src/rich-text-editor/images/icons/trash3.svg +1 -0
- package/src/rich-text-editor/images/icons/tweet.svg +1 -0
- package/src/rich-text-editor/images/icons/type-bold.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h1.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h2.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h3.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h4.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h5.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h6.svg +1 -0
- package/src/rich-text-editor/images/icons/type-italic.svg +1 -0
- package/src/rich-text-editor/images/icons/type-strikethrough.svg +1 -0
- package/src/rich-text-editor/images/icons/type-subscript.svg +1 -0
- package/src/rich-text-editor/images/icons/type-superscript.svg +1 -0
- package/src/rich-text-editor/images/icons/type-underline.svg +1 -0
- package/src/rich-text-editor/images/icons/upload.svg +1 -0
- package/src/rich-text-editor/images/icons/user.svg +1 -0
- package/src/rich-text-editor/images/icons/youtube.svg +1 -0
- package/src/rich-text-editor/images/image/LICENSE.md +5 -0
- package/src/rich-text-editor/images/landscape.jpg +0 -0
- package/src/rich-text-editor/images/logo.svg +1 -0
- package/src/rich-text-editor/images/yellow-flower-small.jpg +0 -0
- package/src/rich-text-editor/images/yellow-flower.jpg +0 -0
- package/src/rich-text-editor/index.ts +1 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/code.ts +39 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/headings.ts +12 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/index.ts +69 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/link.ts +9 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/table.ts +16 -0
- package/src/rich-text-editor/model/crystallize-to-lexical.ts +186 -0
- package/src/rich-text-editor/model/lexical-to-crystallize.ts +232 -0
- package/src/rich-text-editor/nodes/AutocompleteNode.tsx +96 -0
- package/src/rich-text-editor/nodes/BaseNodes.ts +45 -0
- package/src/rich-text-editor/nodes/KeywordNode.ts +73 -0
- package/src/rich-text-editor/nodes/TableCellNodes.ts +31 -0
- package/src/rich-text-editor/nodes/TableComponent.tsx +1547 -0
- package/src/rich-text-editor/nodes/TableNode.tsx +398 -0
- package/src/rich-text-editor/plugins/ActionsPlugin/index.tsx +83 -0
- package/src/rich-text-editor/plugins/AutoLinkPlugin/index.tsx +47 -0
- package/src/rich-text-editor/plugins/AutocompletePlugin/index.tsx +2536 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx +60 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.css +14 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx +140 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.css +46 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.tsx +155 -0
- package/src/rich-text-editor/plugins/CodeHighlightPlugin/index.ts +21 -0
- package/src/rich-text-editor/plugins/ComponentPickerPlugin/index.tsx +320 -0
- package/src/rich-text-editor/plugins/DragDropPastePlugin/index.ts +40 -0
- package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.css +36 -0
- package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.tsx +368 -0
- package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.css +40 -0
- package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx +305 -0
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.css +128 -0
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +351 -0
- package/src/rich-text-editor/plugins/LinkPlugin/index.tsx +16 -0
- package/src/rich-text-editor/plugins/ListMaxIndentLevelPlugin/index.ts +86 -0
- package/src/rich-text-editor/plugins/MarkdownShortcutPlugin/index.tsx +16 -0
- package/src/rich-text-editor/plugins/MarkdownTransformers/index.ts +195 -0
- package/src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx +49 -0
- package/src/rich-text-editor/plugins/SpeechToTextPlugin/index.ts +113 -0
- package/src/rich-text-editor/plugins/TabFocusPlugin/index.tsx +65 -0
- package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx +481 -0
- package/src/rich-text-editor/plugins/TableCellResizer/index.css +12 -0
- package/src/rich-text-editor/plugins/TableCellResizer/index.tsx +386 -0
- package/src/rich-text-editor/plugins/TablePlugin.tsx +190 -0
- package/src/rich-text-editor/plugins/ToolbarPlugin/index.tsx +726 -0
- package/src/rich-text-editor/plugins/TreeViewPlugin/index.tsx +25 -0
- package/src/rich-text-editor/plugins/TypingPerfPlugin/index.ts +117 -0
- package/src/rich-text-editor/rich-text-editor.css +1396 -0
- package/src/rich-text-editor/rich-text-editor.stories.tsx +385 -0
- package/src/rich-text-editor/rich-text-editor.tsx +228 -0
- package/src/rich-text-editor/tests/rich-text-editor-basic-rendering.test.tsx +47 -0
- package/src/rich-text-editor/tests/rich-text-editor-code.test.tsx +39 -0
- package/src/rich-text-editor/tests/rich-text-editor-model-basics.test.tsx +56 -0
- package/src/rich-text-editor/tests/rich-text-editor-model-conversions.test.tsx +195 -0
- package/src/rich-text-editor/tests/rich-text-editor-onchange.test.tsx +37 -0
- package/src/rich-text-editor/tests/rich-text-editor-quote.test.tsx +36 -0
- package/src/rich-text-editor/tests/rich-text-editor-text-formats.test.tsx +135 -0
- package/src/rich-text-editor/tests/rich-text-editor-typing.test.tsx +73 -0
- package/src/rich-text-editor/tests/utils.ts +23 -0
- package/src/rich-text-editor/themes/PlaygroundEditorTheme.css +433 -0
- package/src/rich-text-editor/themes/PlaygroundEditorTheme.ts +113 -0
- package/src/rich-text-editor/types.ts +5 -0
- package/src/rich-text-editor/ui/ContentEditable.css +13 -0
- package/src/rich-text-editor/ui/ContentEditable.tsx +15 -0
- package/src/rich-text-editor/ui/LinkPreview.css +57 -0
- package/src/rich-text-editor/ui/LinkPreview.tsx +169 -0
- package/src/rich-text-editor/utils/environment.ts +1 -0
- package/src/rich-text-editor/utils/getDOMRangeRect.ts +42 -0
- package/src/rich-text-editor/utils/getSelectedNode.ts +27 -0
- package/src/rich-text-editor/utils/guard.ts +10 -0
- package/src/rich-text-editor/utils/isMobileWidth.ts +7 -0
- package/src/rich-text-editor/utils/joinClasses.ts +13 -0
- package/src/rich-text-editor/utils/point.ts +55 -0
- package/src/rich-text-editor/utils/rect.ts +158 -0
- package/src/rich-text-editor/utils/setFloatingElemPosition.ts +46 -0
- package/src/rich-text-editor/utils/swipe.ts +127 -0
- package/src/rich-text-editor/utils/url.ts +33 -0
- package/src/Tokens.stories.tsx +0 -18
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$createLineBreakNode,
|
|
3
|
+
$createParagraphNode,
|
|
4
|
+
$createTextNode,
|
|
5
|
+
$getRoot,
|
|
6
|
+
LexicalNode,
|
|
7
|
+
TextFormatType,
|
|
8
|
+
} from 'lexical';
|
|
9
|
+
import { $createCodeHighlightNode, $createCodeNode } from '@lexical/code';
|
|
10
|
+
import { $createLinkNode } from '@lexical/link';
|
|
11
|
+
import { $createListItemNode, $createListNode } from '@lexical/list';
|
|
12
|
+
import { $createHorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
13
|
+
import { $createHeadingNode, $createQuoteNode } from '@lexical/rich-text';
|
|
14
|
+
import { $createTableCellNode, $createTableNode, $createTableRowNode } from '@lexical/table';
|
|
15
|
+
|
|
16
|
+
import type { CrystallizeRichTextNode, CrystallizeRichText } from './crystallize-rich-text-types';
|
|
17
|
+
|
|
18
|
+
export function composeInitialState({ richText }: { richText: CrystallizeRichText }) {
|
|
19
|
+
return function setLexicalState() {
|
|
20
|
+
const root = $getRoot();
|
|
21
|
+
|
|
22
|
+
const richTextArray = Array.isArray(richText) ? richText : [richText];
|
|
23
|
+
|
|
24
|
+
function handleNode({
|
|
25
|
+
crystallizeContentNode,
|
|
26
|
+
lexicalParent,
|
|
27
|
+
}: {
|
|
28
|
+
crystallizeContentNode: CrystallizeRichTextNode;
|
|
29
|
+
lexicalParent: LexicalNode;
|
|
30
|
+
}) {
|
|
31
|
+
const { textContent, kind, type, children, metadata } = crystallizeContentNode;
|
|
32
|
+
let lexicalNode: LexicalNode | null = null;
|
|
33
|
+
|
|
34
|
+
let insertedTextContent = false;
|
|
35
|
+
|
|
36
|
+
const customTextFormat = getLexicalTextFormat(crystallizeContentNode);
|
|
37
|
+
if (customTextFormat) {
|
|
38
|
+
lexicalNode = $createTextNode(textContent).toggleFormat(customTextFormat);
|
|
39
|
+
insertedTextContent = true;
|
|
40
|
+
} else {
|
|
41
|
+
switch (type) {
|
|
42
|
+
case 'heading1': {
|
|
43
|
+
lexicalNode = $createHeadingNode('h1');
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case 'heading2': {
|
|
47
|
+
lexicalNode = $createHeadingNode('h2');
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case 'heading3': {
|
|
51
|
+
lexicalNode = $createHeadingNode('h3');
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case 'heading4': {
|
|
55
|
+
lexicalNode = $createHeadingNode('h4');
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case 'heading5': {
|
|
59
|
+
lexicalNode = $createHeadingNode('h5');
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case 'heading6': {
|
|
63
|
+
lexicalNode = $createHeadingNode('h6');
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case 'paragraph': {
|
|
67
|
+
lexicalNode = $createParagraphNode();
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case 'horizontal-line': {
|
|
71
|
+
lexicalNode = $createHorizontalRuleNode();
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 'code': {
|
|
75
|
+
const language = metadata && typeof metadata.language === 'string' ? metadata.language : null;
|
|
76
|
+
lexicalNode = $createCodeNode(language);
|
|
77
|
+
lexicalNode.append($createCodeHighlightNode(textContent ?? ''));
|
|
78
|
+
insertedTextContent = true;
|
|
79
|
+
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case 'ordered-list': {
|
|
83
|
+
lexicalNode = $createListNode('number');
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case 'unordered-list': {
|
|
87
|
+
lexicalNode = $createListNode('bullet');
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case 'list-item': {
|
|
91
|
+
lexicalNode = $createListItemNode();
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case 'line-break': {
|
|
95
|
+
lexicalNode = $createLineBreakNode();
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'link': {
|
|
99
|
+
const href = metadata && typeof metadata.href === 'string' ? metadata.href : '';
|
|
100
|
+
const target = metadata && typeof metadata.target === 'string' ? metadata.target : null;
|
|
101
|
+
const rel = metadata && typeof metadata.rel === 'string' ? metadata.rel : null;
|
|
102
|
+
|
|
103
|
+
lexicalNode = $createLinkNode(href, {
|
|
104
|
+
target,
|
|
105
|
+
rel,
|
|
106
|
+
});
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'quote': {
|
|
110
|
+
lexicalNode = $createQuoteNode();
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case 'table': {
|
|
114
|
+
lexicalNode = $createTableNode();
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case 'table-row': {
|
|
118
|
+
lexicalNode = $createTableRowNode();
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 'table-cell': {
|
|
122
|
+
// ** colSpan / rowSpan has not yet been implemented **
|
|
123
|
+
// const colSpanFromMeta = metadata?.colSpan;
|
|
124
|
+
// const colSpanParsed =
|
|
125
|
+
// typeof colSpanFromMeta === 'number'
|
|
126
|
+
// ? colSpanFromMeta
|
|
127
|
+
// : parseInt(colSpanFromMeta as unknown as string, 10);
|
|
128
|
+
// const colSpan = !isNaN(colSpanParsed) ? colSpanParsed : undefined;
|
|
129
|
+
const colSpan = undefined;
|
|
130
|
+
|
|
131
|
+
lexicalNode = $createTableCellNode(
|
|
132
|
+
// 2 indicates NO_HEADER_STATUS
|
|
133
|
+
// See TableCellHeaderStates in @lexical/table/LexicalTableCellNode for details
|
|
134
|
+
0,
|
|
135
|
+
colSpan,
|
|
136
|
+
);
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!insertedTextContent && typeof textContent === 'string') {
|
|
142
|
+
const textNode = $createTextNode(textContent);
|
|
143
|
+
if (!lexicalNode && kind === 'inline') {
|
|
144
|
+
lexicalNode = textNode;
|
|
145
|
+
} else if (lexicalNode) {
|
|
146
|
+
lexicalNode.append(textNode);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (lexicalNode) {
|
|
152
|
+
if (Array.isArray(children)) {
|
|
153
|
+
children.forEach(n => handleNode({ crystallizeContentNode: n, lexicalParent: lexicalNode as LexicalNode }));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
lexicalParent.append(lexicalNode);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
richTextArray.forEach(crystallizeContentNode => handleNode({ crystallizeContentNode, lexicalParent: root }));
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function getLexicalTextFormat(node: CrystallizeRichTextNode): null | TextFormatType {
|
|
165
|
+
switch (node.type) {
|
|
166
|
+
case 'strong':
|
|
167
|
+
return 'bold';
|
|
168
|
+
case 'emphasized':
|
|
169
|
+
return 'italic';
|
|
170
|
+
case 'underlined':
|
|
171
|
+
return 'underline';
|
|
172
|
+
case 'subscripted':
|
|
173
|
+
return 'subscript';
|
|
174
|
+
case 'superscripted':
|
|
175
|
+
return 'superscript';
|
|
176
|
+
case 'deleted':
|
|
177
|
+
return 'strikethrough';
|
|
178
|
+
case 'code': {
|
|
179
|
+
if (node.kind === 'inline') {
|
|
180
|
+
return 'code';
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$getRoot,
|
|
3
|
+
$isElementNode,
|
|
4
|
+
$isLineBreakNode,
|
|
5
|
+
$isParagraphNode,
|
|
6
|
+
$isTextNode,
|
|
7
|
+
EditorState,
|
|
8
|
+
ElementNode,
|
|
9
|
+
TextNode,
|
|
10
|
+
} from 'lexical';
|
|
11
|
+
import { $isCodeNode } from '@lexical/code';
|
|
12
|
+
import { $isLinkNode } from '@lexical/link';
|
|
13
|
+
import { $isListItemNode, $isListNode } from '@lexical/list';
|
|
14
|
+
import { $isHorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
15
|
+
import { $isHeadingNode, $isQuoteNode, HeadingTagType } from '@lexical/rich-text';
|
|
16
|
+
import { $isTableCellNode, $isTableNode, $isTableRowNode } from '@lexical/table';
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
CrystallizeRichTextNode,
|
|
20
|
+
CrystallizeRichText,
|
|
21
|
+
CrystallizeRichTextCodeNodes,
|
|
22
|
+
} from './crystallize-rich-text-types';
|
|
23
|
+
import type { CrystallizeRichTextHeadingTypes } from './crystallize-rich-text-types/headings';
|
|
24
|
+
|
|
25
|
+
const headingMapper: Record<HeadingTagType, CrystallizeRichTextHeadingTypes> = {
|
|
26
|
+
h1: 'heading1',
|
|
27
|
+
h2: 'heading2',
|
|
28
|
+
h3: 'heading3',
|
|
29
|
+
h4: 'heading4',
|
|
30
|
+
h5: 'heading5',
|
|
31
|
+
h6: 'heading6',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function lexicalToCrystallizeRichText({ editorState }: { editorState: EditorState }): CrystallizeRichText {
|
|
35
|
+
const crystallizeRichText: CrystallizeRichTextNode['children'] = [];
|
|
36
|
+
|
|
37
|
+
editorState.read(() => {
|
|
38
|
+
handleNode($getRoot(), crystallizeRichText);
|
|
39
|
+
|
|
40
|
+
function handleNode(lexicalNode: ElementNode, parentChildren: CrystallizeRichTextNode[]) {
|
|
41
|
+
let crystallizeNode: CrystallizeRichTextNode | null = null;
|
|
42
|
+
|
|
43
|
+
let innerContentsIsTakenCareOf = false;
|
|
44
|
+
|
|
45
|
+
// Paragraph
|
|
46
|
+
if ($isParagraphNode(lexicalNode)) {
|
|
47
|
+
crystallizeNode = {
|
|
48
|
+
kind: 'block',
|
|
49
|
+
type: 'paragraph',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Headings
|
|
53
|
+
else if ($isHeadingNode(lexicalNode)) {
|
|
54
|
+
const tag = lexicalNode.getTag();
|
|
55
|
+
|
|
56
|
+
crystallizeNode = {
|
|
57
|
+
kind: 'block',
|
|
58
|
+
type: headingMapper[tag],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Link
|
|
62
|
+
else if ($isLinkNode(lexicalNode)) {
|
|
63
|
+
const href = lexicalNode.getURL();
|
|
64
|
+
const target = lexicalNode.getTarget();
|
|
65
|
+
const rel = lexicalNode.getRel();
|
|
66
|
+
|
|
67
|
+
crystallizeNode = {
|
|
68
|
+
kind: 'inline',
|
|
69
|
+
type: 'link',
|
|
70
|
+
metadata: {
|
|
71
|
+
href,
|
|
72
|
+
...(target && { target }),
|
|
73
|
+
...(rel && { rel }),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// List
|
|
78
|
+
else if ($isListNode(lexicalNode)) {
|
|
79
|
+
const listType = lexicalNode.getListType();
|
|
80
|
+
crystallizeNode = {
|
|
81
|
+
kind: 'block',
|
|
82
|
+
type: listType === 'number' ? 'ordered-list' : 'unordered-list',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// List item
|
|
86
|
+
else if ($isListItemNode(lexicalNode)) {
|
|
87
|
+
crystallizeNode = {
|
|
88
|
+
kind: 'block',
|
|
89
|
+
type: 'list-item',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Quote
|
|
93
|
+
else if ($isQuoteNode(lexicalNode)) {
|
|
94
|
+
crystallizeNode = {
|
|
95
|
+
kind: 'block',
|
|
96
|
+
type: 'quote',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// Table
|
|
100
|
+
else if ($isTableNode(lexicalNode)) {
|
|
101
|
+
crystallizeNode = {
|
|
102
|
+
kind: 'block',
|
|
103
|
+
type: 'table',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// Table row
|
|
107
|
+
else if ($isTableRowNode(lexicalNode)) {
|
|
108
|
+
crystallizeNode = {
|
|
109
|
+
kind: 'block',
|
|
110
|
+
type: 'table-row',
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// Table cell
|
|
114
|
+
else if ($isTableCellNode(lexicalNode)) {
|
|
115
|
+
crystallizeNode = {
|
|
116
|
+
kind: 'inline',
|
|
117
|
+
type: 'table-cell',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// Line break
|
|
121
|
+
else if ($isLineBreakNode(lexicalNode)) {
|
|
122
|
+
crystallizeNode = {
|
|
123
|
+
kind: 'inline',
|
|
124
|
+
type: 'line-break',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Code
|
|
128
|
+
else if ($isCodeNode(lexicalNode)) {
|
|
129
|
+
const language = lexicalNode.getLanguage();
|
|
130
|
+
crystallizeNode = {
|
|
131
|
+
kind: 'block',
|
|
132
|
+
type: 'code',
|
|
133
|
+
textContent: lexicalNode.getTextContent(),
|
|
134
|
+
metadata: {
|
|
135
|
+
language,
|
|
136
|
+
},
|
|
137
|
+
} as CrystallizeRichTextCodeNodes;
|
|
138
|
+
|
|
139
|
+
innerContentsIsTakenCareOf = true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (crystallizeNode) {
|
|
143
|
+
parentChildren.push(crystallizeNode);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!innerContentsIsTakenCareOf) {
|
|
147
|
+
/**
|
|
148
|
+
* If there is only a single child, and that
|
|
149
|
+
* child does not have a format set, then we can
|
|
150
|
+
* set the textContent directly on the parent
|
|
151
|
+
*/
|
|
152
|
+
let onlyChildIsPureTextContent = false;
|
|
153
|
+
|
|
154
|
+
const children = lexicalNode.getChildren();
|
|
155
|
+
if (children?.length > 0) {
|
|
156
|
+
let parentChildrenToUse = parentChildren;
|
|
157
|
+
if (crystallizeNode) {
|
|
158
|
+
if (children.length === 1 && parent) {
|
|
159
|
+
const [first] = children;
|
|
160
|
+
if ($isTextNode(first)) {
|
|
161
|
+
const childTextNode = getTextChild(first);
|
|
162
|
+
if (!childTextNode.type) {
|
|
163
|
+
crystallizeNode.textContent = childTextNode.textContent;
|
|
164
|
+
onlyChildIsPureTextContent = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!onlyChildIsPureTextContent) {
|
|
170
|
+
crystallizeNode.children = [];
|
|
171
|
+
parentChildrenToUse = crystallizeNode.children;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!onlyChildIsPureTextContent) {
|
|
176
|
+
children.forEach(childNode => {
|
|
177
|
+
if ($isElementNode(childNode)) {
|
|
178
|
+
handleNode(childNode, parentChildrenToUse);
|
|
179
|
+
}
|
|
180
|
+
if ($isHorizontalRuleNode(childNode)) {
|
|
181
|
+
parentChildrenToUse.push({
|
|
182
|
+
kind: 'block',
|
|
183
|
+
type: 'horizontal-line',
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
if ($isTextNode(childNode)) {
|
|
187
|
+
parentChildrenToUse.push(getTextChild(childNode));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
return crystallizeRichText;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function getTextChild(n: TextNode): CrystallizeRichTextNode {
|
|
201
|
+
const textContent = n.getTextContent();
|
|
202
|
+
|
|
203
|
+
// Deal with code seperately, since it can be both "inline" and "block"
|
|
204
|
+
if (n.hasFormat('code')) {
|
|
205
|
+
return {
|
|
206
|
+
type: 'code',
|
|
207
|
+
kind: 'inline',
|
|
208
|
+
textContent,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const textChild = {
|
|
213
|
+
kind: 'inline',
|
|
214
|
+
textContent,
|
|
215
|
+
} as CrystallizeRichTextNode;
|
|
216
|
+
|
|
217
|
+
if (n.hasFormat('bold')) {
|
|
218
|
+
textChild.type = 'strong';
|
|
219
|
+
} else if (n.hasFormat('italic')) {
|
|
220
|
+
textChild.type = 'emphasized';
|
|
221
|
+
} else if (n.hasFormat('underline')) {
|
|
222
|
+
textChild.type = 'underlined';
|
|
223
|
+
} else if (n.hasFormat('strikethrough')) {
|
|
224
|
+
textChild.type = 'deleted';
|
|
225
|
+
} else if (n.hasFormat('subscript')) {
|
|
226
|
+
textChild.type = 'subscripted';
|
|
227
|
+
} else if (n.hasFormat('superscript')) {
|
|
228
|
+
textChild.type = 'superscripted';
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return textChild;
|
|
232
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Spread } from 'lexical';
|
|
10
|
+
|
|
11
|
+
import { DecoratorNode, EditorConfig, NodeKey, SerializedLexicalNode } from 'lexical';
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
|
|
14
|
+
import { useSharedAutocompleteContext } from '../context/SharedAutocompleteContext';
|
|
15
|
+
import { uuid as UUID } from '../plugins/AutocompletePlugin';
|
|
16
|
+
|
|
17
|
+
declare global {
|
|
18
|
+
interface Navigator {
|
|
19
|
+
userAgentData?: {
|
|
20
|
+
mobile: boolean;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SerializedAutocompleteNode = Spread<
|
|
26
|
+
{
|
|
27
|
+
type: 'autocomplete';
|
|
28
|
+
version: 1;
|
|
29
|
+
uuid: string;
|
|
30
|
+
},
|
|
31
|
+
SerializedLexicalNode
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
export class AutocompleteNode extends DecoratorNode<JSX.Element | null> {
|
|
35
|
+
// TODO add comment
|
|
36
|
+
__uuid: string;
|
|
37
|
+
|
|
38
|
+
static clone(node: AutocompleteNode): AutocompleteNode {
|
|
39
|
+
return new AutocompleteNode(node.__key);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static getType(): 'autocomplete' {
|
|
43
|
+
return 'autocomplete';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static importJSON(serializedNode: SerializedAutocompleteNode): AutocompleteNode {
|
|
47
|
+
const node = $createAutocompleteNode(serializedNode.uuid);
|
|
48
|
+
return node;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
exportJSON(): SerializedAutocompleteNode {
|
|
52
|
+
return {
|
|
53
|
+
...super.exportJSON(),
|
|
54
|
+
type: 'autocomplete',
|
|
55
|
+
uuid: this.__uuid,
|
|
56
|
+
version: 1,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
constructor(uuid: string, key?: NodeKey) {
|
|
61
|
+
super(key);
|
|
62
|
+
this.__uuid = uuid;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
updateDOM(prevNode: unknown, dom: HTMLElement, config: EditorConfig): boolean {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
createDOM(config: EditorConfig): HTMLElement {
|
|
70
|
+
return document.createElement('span');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
decorate(): JSX.Element | null {
|
|
74
|
+
if (this.__uuid !== UUID) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return <AutocompleteComponent />;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function $createAutocompleteNode(uuid: string): AutocompleteNode {
|
|
82
|
+
return new AutocompleteNode(uuid);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function AutocompleteComponent(): JSX.Element {
|
|
86
|
+
const [suggestion] = useSharedAutocompleteContext();
|
|
87
|
+
const userAgentData = window.navigator.userAgentData;
|
|
88
|
+
const isMobile =
|
|
89
|
+
userAgentData !== undefined ? userAgentData.mobile : window.innerWidth <= 800 && window.innerHeight <= 600;
|
|
90
|
+
// TODO Move to theme
|
|
91
|
+
return (
|
|
92
|
+
<span style={{ color: '#ccc' }} spellCheck="false">
|
|
93
|
+
{suggestion} {isMobile ? '(SWIPE \u2B95)' : '(TAB)'}
|
|
94
|
+
</span>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Klass, LexicalNode, LineBreakNode } from 'lexical';
|
|
10
|
+
import { CodeHighlightNode, CodeNode } from '@lexical/code';
|
|
11
|
+
import { HashtagNode } from '@lexical/hashtag';
|
|
12
|
+
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
13
|
+
import { ListItemNode, ListNode } from '@lexical/list';
|
|
14
|
+
import { MarkNode } from '@lexical/mark';
|
|
15
|
+
import { OverflowNode } from '@lexical/overflow';
|
|
16
|
+
import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
17
|
+
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
18
|
+
import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
19
|
+
|
|
20
|
+
// import { AutocompleteNode } from './AutocompleteNode';
|
|
21
|
+
|
|
22
|
+
import { KeywordNode } from './KeywordNode';
|
|
23
|
+
import { TableNode as NewTableNode } from './TableNode';
|
|
24
|
+
|
|
25
|
+
export const BaseNodes: Array<Klass<LexicalNode>> = [
|
|
26
|
+
HeadingNode,
|
|
27
|
+
ListNode,
|
|
28
|
+
ListItemNode,
|
|
29
|
+
QuoteNode,
|
|
30
|
+
CodeNode,
|
|
31
|
+
NewTableNode,
|
|
32
|
+
TableNode,
|
|
33
|
+
TableCellNode,
|
|
34
|
+
TableRowNode,
|
|
35
|
+
HashtagNode,
|
|
36
|
+
CodeHighlightNode,
|
|
37
|
+
AutoLinkNode,
|
|
38
|
+
LinkNode,
|
|
39
|
+
OverflowNode,
|
|
40
|
+
// AutocompleteNode,
|
|
41
|
+
KeywordNode,
|
|
42
|
+
HorizontalRuleNode,
|
|
43
|
+
MarkNode,
|
|
44
|
+
LineBreakNode,
|
|
45
|
+
];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { EditorConfig, LexicalNode, SerializedTextNode, Spread } from 'lexical';
|
|
10
|
+
|
|
11
|
+
import { TextNode } from 'lexical';
|
|
12
|
+
|
|
13
|
+
export type SerializedKeywordNode = Spread<
|
|
14
|
+
{
|
|
15
|
+
type: 'keyword';
|
|
16
|
+
version: 1;
|
|
17
|
+
},
|
|
18
|
+
SerializedTextNode
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export class KeywordNode extends TextNode {
|
|
22
|
+
static getType(): string {
|
|
23
|
+
return 'keyword';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static clone(node: KeywordNode): KeywordNode {
|
|
27
|
+
return new KeywordNode(node.__text, node.__key);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static importJSON(serializedNode: SerializedKeywordNode): KeywordNode {
|
|
31
|
+
const node = $createKeywordNode(serializedNode.text);
|
|
32
|
+
node.setFormat(serializedNode.format);
|
|
33
|
+
node.setDetail(serializedNode.detail);
|
|
34
|
+
node.setMode(serializedNode.mode);
|
|
35
|
+
node.setStyle(serializedNode.style);
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exportJSON(): SerializedKeywordNode {
|
|
40
|
+
return {
|
|
41
|
+
...super.exportJSON(),
|
|
42
|
+
type: 'keyword',
|
|
43
|
+
version: 1,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
createDOM(config: EditorConfig): HTMLElement {
|
|
48
|
+
const dom = super.createDOM(config);
|
|
49
|
+
dom.style.cursor = 'default';
|
|
50
|
+
dom.className = 'keyword';
|
|
51
|
+
return dom;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
canInsertTextBefore(): boolean {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
canInsertTextAfter(): boolean {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
isTextEntity(): true {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function $createKeywordNode(keyword: string): KeywordNode {
|
|
68
|
+
return new KeywordNode(keyword);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function $isKeywordNode(node: LexicalNode | null | undefined | undefined): boolean {
|
|
72
|
+
return node instanceof KeywordNode;
|
|
73
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Klass, LexicalNode } from 'lexical';
|
|
10
|
+
import { CodeHighlightNode, CodeNode } from '@lexical/code';
|
|
11
|
+
import { HashtagNode } from '@lexical/hashtag';
|
|
12
|
+
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
13
|
+
import { ListItemNode, ListNode } from '@lexical/list';
|
|
14
|
+
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
15
|
+
|
|
16
|
+
// import { AutocompleteNode } from './AutocompleteNode';
|
|
17
|
+
import { KeywordNode } from './KeywordNode';
|
|
18
|
+
|
|
19
|
+
export const BaseNodes: Array<Klass<LexicalNode>> = [
|
|
20
|
+
HeadingNode,
|
|
21
|
+
ListNode,
|
|
22
|
+
ListItemNode,
|
|
23
|
+
QuoteNode,
|
|
24
|
+
CodeNode,
|
|
25
|
+
HashtagNode,
|
|
26
|
+
CodeHighlightNode,
|
|
27
|
+
AutoLinkNode,
|
|
28
|
+
LinkNode,
|
|
29
|
+
// AutocompleteNode,
|
|
30
|
+
KeywordNode,
|
|
31
|
+
];
|