@blocklet/editor 2.2.47 → 2.3.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/lib/ext/PostLinkEmbedPlugin/PostLinkNode.d.ts +2 -2
- package/lib/ext/PostLinkEmbedPlugin/PostLinkNode.js +3 -3
- package/lib/main/editor.js +3 -7
- package/lib/main/index.css +16 -18
- package/lib/main/markdown-editor/editor.js +1 -1
- package/lib/main/markdown-editor/transformers.js +7 -6
- package/lib/main/nodes/EmojiNode.d.ts +1 -2
- package/lib/main/nodes/EmojiNode.js +4 -9
- package/lib/main/nodes/EquationNode.js +14 -7
- package/lib/main/nodes/ImageComponent.js +2 -2
- package/lib/main/nodes/PlaygroundNodes.js +0 -2
- package/lib/main/nodes/StickyComponent.js +1 -1
- package/lib/main/plugins/CodeActionMenuPlugin/index.js +24 -28
- package/lib/main/plugins/MarkdownTransformers/index.d.ts +1 -4
- package/lib/main/plugins/MarkdownTransformers/index.js +48 -79
- package/lib/main/plugins/TableActionMenuPlugin/index.js +229 -171
- package/lib/main/plugins/TableCellResizer/index.css +8 -2
- package/lib/main/plugins/TableCellResizer/index.js +168 -120
- package/lib/main/plugins/TableOfContentsPlugin/index.js +2 -2
- package/lib/main/plugins/TablePlugin.d.ts +3 -4
- package/lib/main/plugins/TablePlugin.js +7 -24
- package/lib/main/plugins/ToolbarPlugin/index.js +0 -1
- package/lib/main/themes/defaultTheme.js +3 -1
- package/lib/main/ui/ContentEditable.d.ts +1 -4
- package/lib/main/ui/Modal.css +1 -1
- package/lib/main/ui/TextInput.d.ts +4 -3
- package/lib/main/ui/TextInput.js +3 -19
- package/package.json +23 -24
- package/lib/main/nodes/AutocompleteNode.d.ts +0 -34
- package/lib/main/nodes/AutocompleteNode.js +0 -52
- package/lib/main/nodes/EquationComponent.d.ts +0 -16
- package/lib/main/nodes/EquationComponent.js +0 -64
- package/lib/main/plugins/ActionsPlugin/index.d.ts +0 -11
- package/lib/main/plugins/ActionsPlugin/index.js +0 -129
- package/lib/main/plugins/AutocompletePlugin/index.d.ts +0 -10
- package/lib/main/plugins/AutocompletePlugin/index.js +0 -2461
- package/lib/main/plugins/CodeActionMenuPlugin/components/PrettierButton/index.css +0 -14
- package/lib/main/plugins/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +0 -17
- package/lib/main/plugins/CodeActionMenuPlugin/components/PrettierButton/index.js +0 -95
- package/lib/main/plugins/EquationsPlugin/index.d.ts +0 -21
- package/lib/main/plugins/EquationsPlugin/index.js +0 -42
- package/lib/main/plugins/SpeechToTextPlugin/index.d.ts +0 -12
- package/lib/main/plugins/SpeechToTextPlugin/index.js +0 -87
- package/lib/main/ui/EquationEditor.css +0 -38
- package/lib/main/ui/EquationEditor.d.ts +0 -19
- package/lib/main/ui/EquationEditor.js +0 -26
- package/lib/main/ui/KatexEquationAlterer.css +0 -41
- package/lib/main/ui/KatexEquationAlterer.d.ts +0 -15
- package/lib/main/ui/KatexEquationAlterer.js +0 -34
- package/lib/main/ui/KatexRenderer.d.ts +0 -13
- package/lib/main/ui/KatexRenderer.js +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';
|
|
2
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
|
|
3
3
|
import { DecoratorNode } from 'lexical';
|
|
4
4
|
export interface PostInfo {
|
|
5
5
|
id: string;
|
|
@@ -21,7 +21,7 @@ export declare class PostLinkNode extends DecoratorNode<JSX.Element> {
|
|
|
21
21
|
static importJSON(serializedNode: SerializedPostLinkNode): PostLinkNode;
|
|
22
22
|
exportDOM(): DOMExportOutput;
|
|
23
23
|
static importDOM(): DOMConversionMap | null;
|
|
24
|
-
constructor(postInfo: PostInfo);
|
|
24
|
+
constructor(postInfo: PostInfo, key?: NodeKey);
|
|
25
25
|
exportJSON(): SerializedPostLinkNode;
|
|
26
26
|
createDOM(config: EditorConfig): HTMLElement;
|
|
27
27
|
updateDOM(): false;
|
|
@@ -77,7 +77,7 @@ export class PostLinkNode extends DecoratorNode {
|
|
|
77
77
|
return 'post-link';
|
|
78
78
|
}
|
|
79
79
|
static clone(node) {
|
|
80
|
-
return new PostLinkNode({ ...node.__postInfo });
|
|
80
|
+
return new PostLinkNode({ ...node.__postInfo }, node.__key);
|
|
81
81
|
}
|
|
82
82
|
static importJSON(serializedNode) {
|
|
83
83
|
const { postInfo } = serializedNode;
|
|
@@ -100,8 +100,8 @@ export class PostLinkNode extends DecoratorNode {
|
|
|
100
100
|
}),
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
constructor(postInfo) {
|
|
104
|
-
super();
|
|
103
|
+
constructor(postInfo, key) {
|
|
104
|
+
super(key);
|
|
105
105
|
this.__postInfo = postInfo;
|
|
106
106
|
}
|
|
107
107
|
exportJSON() {
|
package/lib/main/editor.js
CHANGED
|
@@ -12,7 +12,7 @@ import { CharacterLimitPlugin } from '@lexical/react/LexicalCharacterLimitPlugin
|
|
|
12
12
|
import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
|
|
13
13
|
import { ClearEditorPlugin } from '@lexical/react/LexicalClearEditorPlugin';
|
|
14
14
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
15
|
-
import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
|
|
15
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
16
16
|
import { HashtagPlugin } from '@lexical/react/LexicalHashtagPlugin';
|
|
17
17
|
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
18
18
|
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
@@ -27,7 +27,6 @@ import { Box, styled, alpha } from '@mui/material';
|
|
|
27
27
|
import { useSettings } from './context/SettingsContext';
|
|
28
28
|
import { useSharedHistoryContext } from './context/SharedHistoryContext';
|
|
29
29
|
import useHasNodes from './hooks/useHasNodes';
|
|
30
|
-
import AutocompletePlugin from './plugins/AutocompletePlugin';
|
|
31
30
|
import AutoEmbedPlugin from './plugins/AutoEmbedPlugin';
|
|
32
31
|
import AutoLinkPlugin from './plugins/AutoLinkPlugin';
|
|
33
32
|
import ClickableLinkPlugin from './plugins/ClickableLinkPlugin';
|
|
@@ -49,7 +48,6 @@ import ListMaxIndentLevelPlugin from './plugins/ListMaxIndentLevelPlugin';
|
|
|
49
48
|
import MarkdownShortcutPlugin from './plugins/MarkdownShortcutPlugin';
|
|
50
49
|
import { MaxLengthPlugin } from './plugins/MaxLengthPlugin';
|
|
51
50
|
import MentionsPlugin from './plugins/MentionsPlugin';
|
|
52
|
-
import SpeechToTextPlugin from './plugins/SpeechToTextPlugin';
|
|
53
51
|
import TabFocusPlugin from './plugins/TabFocusPlugin';
|
|
54
52
|
import TableCellActionMenuPlugin from './plugins/TableActionMenuPlugin';
|
|
55
53
|
import TableCellResizer from './plugins/TableCellResizer';
|
|
@@ -66,8 +64,6 @@ import BookmarkPlugin from '../ext/BookmarkPlugin';
|
|
|
66
64
|
import Placeholder from './ui/Placeholder';
|
|
67
65
|
import { useEditorConfig } from '../config';
|
|
68
66
|
import AidePlugin from '../ext/AIPlugin';
|
|
69
|
-
import SelectBlockPlugin from '../ext/SelectBlockPlugin';
|
|
70
|
-
import RemoveListPlugin from '../ext/RemoveListPlugin';
|
|
71
67
|
import MarkdownHeadTextPlugin from '../ext/HeadTextPlugin';
|
|
72
68
|
import { AiImagePlugin } from '../ext/AiImage';
|
|
73
69
|
import { EditorRefPlugin } from '../ext/LexicalEditorRefPlugin';
|
|
@@ -100,7 +96,7 @@ export default function Editor({ children, prepend, placeholder, onChange, autoF
|
|
|
100
96
|
useTranslationListener();
|
|
101
97
|
const hasNodes = useHasNodes();
|
|
102
98
|
const { historyState } = useSharedHistoryContext();
|
|
103
|
-
const { settings: {
|
|
99
|
+
const { settings: { isMaxLength, isCharLimit, isCharLimitUtf8, isRichText, showTableOfContents }, } = useSettings();
|
|
104
100
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
105
101
|
const onRef = (_floatingAnchorElem) => {
|
|
106
102
|
if (_floatingAnchorElem !== null) {
|
|
@@ -115,7 +111,7 @@ export default function Editor({ children, prepend, placeholder, onChange, autoF
|
|
|
115
111
|
if (minimalMode) {
|
|
116
112
|
return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), _jsx(PasteSlackImagePlugin, {}), _jsx(EditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [hasNodes('code') && _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem })] })), _jsx(AiImagePlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), children] }));
|
|
117
113
|
}
|
|
118
|
-
return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), isMaxLength && _jsx(MaxLengthPlugin, { maxLength: 30 }), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(EmojiPickerPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('emoji') && _jsx(EmojisPlugin, {}), hasNodes('hashtag') && _jsx(HashtagPlugin, {}),
|
|
114
|
+
return (_jsxs(_Fragment, { children: [prepend, isRichText && editable && showToolbar && _jsx(ToolbarPlugin, {}), isMaxLength && _jsx(MaxLengthPlugin, { maxLength: 30 }), hasNodes('image') && hasUploader && _jsx(DragDropPaste, {}), autoFocus && _jsx(AutoFocusPlugin, { defaultSelection: "rootEnd" }), _jsx(ClearEditorPlugin, {}), !!editable && _jsx(ComponentPickerPlugin, {}), !!editable && _jsx(EmojiPickerPlugin, {}), hasNodes('link') && _jsx(AutoEmbedPlugin, {}), !!editable && _jsx(MentionsPlugin, {}), hasNodes('emoji') && _jsx(EmojisPlugin, {}), hasNodes('hashtag') && _jsx(HashtagPlugin, {}), hasNodes('autolink') && _jsx(AutoLinkPlugin, {}), isRichText ? (_jsxs(_Fragment, { children: [_jsx(PasteSlackImagePlugin, {}), _jsx(HistoryPlugin, { externalHistoryState: historyState }), _jsx(EditorContent, { ref: onRef, className: cx('be-content', editable && 'editable'), children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: cx('be-editable', 'notranslate') }), placeholder: _jsx(Placeholder, { className: "be-placeholder", children: placeholder }), ErrorBoundary: LexicalErrorBoundary }) }), _jsx(MarkdownShortcutPlugin, {}), _jsx(TabIndentationPlugin, {}), hasNodes('code', 'code-highlight') && _jsx(CodeHighlightPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListPlugin, {}), hasNodes('list', 'listitem') && _jsx(CheckListPlugin, {}), hasNodes('list', 'listitem') && _jsx(ListMaxIndentLevelPlugin, { maxDepth: 7 }), hasNodes('table', 'tablerow', 'tablecell') && editable && (_jsx(TablePlugin, { hasCellMerge: true, hasCellBackgroundColor: true, hasHorizontalScroll: true })), hasNodes('table', 'tablerow', 'tablecell') && _jsx(TableCellResizer, {}), hasNodes('image') && hasUploader && _jsx(ImagesPlugin, {}), hasNodes('video') && _jsx(VideoPlugin, {}), hasNodes('link') && _jsx(LinkPlugin, {}), hasNodes('tweet') && _jsx(TwitterPlugin, {}), hasNodes('youtube') && _jsx(YouTubePlugin, {}), hasNodes('figma') && _jsx(FigmaPlugin, {}), _jsx(BilibiliPlugin, {}), _jsx(BlockletEmbedPlugin, {}), _jsx(PostLinkEmbedPlugin, {}), _jsx(BookmarkPlugin, {}), _jsx(AidePlugin, {}), editable && _jsx(CustomOnChangePlugin, { placeholder: placeholder }), editable && _jsx(TemplatePlugin, {}), !editable && _jsx(BlurTextPlugin, {}), hasNodes('pdf') && _jsx(PdfPlugin, {}), hasNodes('file') && _jsx(FilePlugin, {}), hasNodes('link') && _jsx(ClickableLinkPlugin, {}), hasNodes('horizontalrule') && _jsx(HorizontalRulePlugin, {}), hasNodes('excalidraw') && _jsx(ExcalidrawPlugin, {}), hasNodes('alert') && _jsx(AlertPlugin, {}), hasNodes('pages-kit-component') && _jsx(PagesKitComponentPlugin, {}), _jsx(TabFocusPlugin, {}), hasNodes('collapsible-container', 'collapsible-content', 'collapsible-title') && _jsx(CollapsiblePlugin, {}), onChange && _jsx(OnChangePlugin, { onChange: onChange }), floatingAnchorElem && editable && (_jsxs(_Fragment, { children: [_jsx(DraggableBlockPlugin, { anchorElem: floatingAnchorElem }), hasNodes('code') && _jsx(CodeActionMenuPlugin, { anchorElem: floatingAnchorElem }), hasNodes('link') && _jsx(FloatingLinkEditorPlugin, { anchorElem: floatingAnchorElem }), hasNodes('table') && _jsx(TableCellActionMenuPlugin, { anchorElem: floatingAnchorElem, cellMerge: true }), _jsx(FloatingTextFormatToolbarPlugin, { anchorElem: floatingAnchorElem })] })), enableHeadingsIdPlugin && _jsx(HeadingsIdPlugin, {})] })) : (_jsxs(_Fragment, { children: [_jsx(PlainTextPlugin, { contentEditable: _jsx(ContentEditable, {}), placeholder: _jsx(Placeholder, { children: "placeholder" }), ErrorBoundary: LexicalErrorBoundary }), _jsx(HistoryPlugin, { externalHistoryState: historyState })] })), (isCharLimit || isCharLimitUtf8) && (_jsx(CharacterLimitPlugin, { charset: isCharLimit ? 'UTF-16' : 'UTF-8', maxLength: 5 })), _jsx("div", { children: showTableOfContents && _jsx(TableOfContentsPlugin, {}) }), _jsx(MarkdownHeadTextPlugin, {}), _jsx(AiImagePlugin, {}), _jsx(EditorHolderPlugin, {}), editorRef && _jsx(EditorRefPlugin, { editorRef: editorRef }), onReady && _jsx(EditorReadyPlugin, { onReady: onReady }), children] }));
|
|
119
115
|
}
|
|
120
116
|
const EditorContent = styled(Box) `
|
|
121
117
|
position: relative;
|
package/lib/main/index.css
CHANGED
|
@@ -738,35 +738,33 @@ button.action-button:disabled {
|
|
|
738
738
|
|
|
739
739
|
.table-cell-action-button-container {
|
|
740
740
|
position: absolute;
|
|
741
|
-
|
|
742
|
-
|
|
741
|
+
z-index: 3;
|
|
742
|
+
top: 0;
|
|
743
|
+
left: 0;
|
|
743
744
|
will-change: transform;
|
|
744
745
|
}
|
|
746
|
+
.table-cell-action-button-container.table-cell-action-button-container--active {
|
|
747
|
+
pointer-events: auto;
|
|
748
|
+
opacity: 1;
|
|
749
|
+
}
|
|
750
|
+
.table-cell-action-button-container.table-cell-action-button-container--inactive {
|
|
751
|
+
pointer-events: none;
|
|
752
|
+
opacity: 0;
|
|
753
|
+
}
|
|
745
754
|
|
|
746
755
|
.table-cell-action-button {
|
|
747
|
-
|
|
748
|
-
display: flex !important;
|
|
756
|
+
display: flex;
|
|
749
757
|
justify-content: center;
|
|
750
758
|
align-items: center;
|
|
751
759
|
border: 0;
|
|
752
|
-
position:
|
|
760
|
+
position: absolute;
|
|
761
|
+
top: 10px;
|
|
762
|
+
right: 10px;
|
|
753
763
|
border-radius: 15px;
|
|
754
764
|
color: #222;
|
|
755
765
|
display: inline-block;
|
|
756
766
|
cursor: pointer;
|
|
757
|
-
|
|
758
|
-
height: 24px;
|
|
759
|
-
padding: 0;
|
|
760
|
-
opacity: 0.75 !important;
|
|
761
|
-
transition: all 0.2s;
|
|
762
|
-
&:hover {
|
|
763
|
-
opacity: 1 !important;
|
|
764
|
-
background: #222;
|
|
765
|
-
color: #eee;
|
|
766
|
-
}
|
|
767
|
-
.iconify {
|
|
768
|
-
font-size: 16px;
|
|
769
|
-
}
|
|
767
|
+
opacity: 0.75;
|
|
770
768
|
}
|
|
771
769
|
|
|
772
770
|
@keyframes mic-pulsate-color {
|
|
@@ -5,7 +5,7 @@ import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
|
5
5
|
import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
|
|
6
6
|
import { ClearEditorPlugin } from '@lexical/react/LexicalClearEditorPlugin';
|
|
7
7
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
8
|
-
import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
|
|
8
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
9
9
|
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
10
10
|
import { ListPlugin } from '@lexical/react/LexicalListPlugin';
|
|
11
11
|
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { $convertFromMarkdownString, $convertToMarkdownString, CHECK_LIST, ELEMENT_TRANSFORMERS, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, } from '@lexical/markdown';
|
|
8
|
+
import { $convertFromMarkdownString, $convertToMarkdownString, CHECK_LIST, ELEMENT_TRANSFORMERS, MULTILINE_ELEMENT_TRANSFORMERS, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, } from '@lexical/markdown';
|
|
9
9
|
import { $createHorizontalRuleNode, $isHorizontalRuleNode, HorizontalRuleNode, } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
10
10
|
import { $createTableCellNode, $createTableNode, $createTableRowNode, $isTableCellNode, $isTableNode, $isTableRowNode, TableCellHeaderStates, TableCellNode, TableNode, TableRowNode, } from '@lexical/table';
|
|
11
11
|
import { $isParagraphNode, $isTextNode } from 'lexical';
|
|
@@ -71,7 +71,7 @@ export const TABLE = {
|
|
|
71
71
|
for (const cell of row.getChildren()) {
|
|
72
72
|
// It's TableCellNode so it's just to make flow happy
|
|
73
73
|
if ($isTableCellNode(cell)) {
|
|
74
|
-
rowOutput.push($convertToMarkdownString(TRANSFORMERS, cell).replace(/\n/g, '\\n'));
|
|
74
|
+
rowOutput.push($convertToMarkdownString(TRANSFORMERS, cell).replace(/\n/g, '\\n').trim());
|
|
75
75
|
if (cell.__headerState === TableCellHeaderStates.ROW) {
|
|
76
76
|
isHeaderRow = true;
|
|
77
77
|
}
|
|
@@ -102,7 +102,7 @@ export const TABLE = {
|
|
|
102
102
|
if (!$isTableCellNode(cell)) {
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
cell.
|
|
105
|
+
cell.setHeaderStyles(TableCellHeaderStates.ROW, TableCellHeaderStates.ROW);
|
|
106
106
|
});
|
|
107
107
|
// Remove line
|
|
108
108
|
parentNode.remove();
|
|
@@ -141,7 +141,7 @@ export const TABLE = {
|
|
|
141
141
|
const tableRow = $createTableRowNode();
|
|
142
142
|
table.append(tableRow);
|
|
143
143
|
for (let i = 0; i < maxCells; i++) {
|
|
144
|
-
tableRow.append(i < cells.length ? cells[i] : createTableCell(''));
|
|
144
|
+
tableRow.append(i < cells.length ? cells[i] : $createTableCell(''));
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
const previousSibling = parentNode.getPreviousSibling();
|
|
@@ -160,7 +160,7 @@ function getTableColumnsSize(table) {
|
|
|
160
160
|
const row = table.getFirstChild();
|
|
161
161
|
return $isTableRowNode(row) ? row.getChildrenSize() : 0;
|
|
162
162
|
}
|
|
163
|
-
const createTableCell = (textContent) => {
|
|
163
|
+
const $createTableCell = (textContent) => {
|
|
164
164
|
textContent = textContent.replace(/\\n/g, '\n');
|
|
165
165
|
const cell = $createTableCellNode(TableCellHeaderStates.NO_STATUS);
|
|
166
166
|
$convertFromMarkdownString(textContent, TRANSFORMERS, cell);
|
|
@@ -171,7 +171,7 @@ const mapToTableCells = (textContent) => {
|
|
|
171
171
|
if (!match || !match[1]) {
|
|
172
172
|
return null;
|
|
173
173
|
}
|
|
174
|
-
return match[1].split('|').map((text) => createTableCell(text));
|
|
174
|
+
return match[1].split('|').map((text) => $createTableCell(text));
|
|
175
175
|
};
|
|
176
176
|
export const TRANSFORMERS = [
|
|
177
177
|
TABLE,
|
|
@@ -179,6 +179,7 @@ export const TRANSFORMERS = [
|
|
|
179
179
|
IMAGE,
|
|
180
180
|
CHECK_LIST,
|
|
181
181
|
...ELEMENT_TRANSFORMERS,
|
|
182
|
+
...MULTILINE_ELEMENT_TRANSFORMERS,
|
|
182
183
|
...TEXT_FORMAT_TRANSFORMERS,
|
|
183
184
|
...TEXT_MATCH_TRANSFORMERS,
|
|
184
185
|
];
|
|
@@ -9,7 +9,6 @@ import type { EditorConfig, LexicalNode, NodeKey, SerializedTextNode, Spread } f
|
|
|
9
9
|
import { TextNode } from 'lexical';
|
|
10
10
|
export type SerializedEmojiNode = Spread<{
|
|
11
11
|
className: string;
|
|
12
|
-
type: 'emoji';
|
|
13
12
|
}, SerializedTextNode>;
|
|
14
13
|
export declare class EmojiNode extends TextNode {
|
|
15
14
|
__className: string;
|
|
@@ -17,7 +16,7 @@ export declare class EmojiNode extends TextNode {
|
|
|
17
16
|
static clone(node: EmojiNode): EmojiNode;
|
|
18
17
|
constructor(className: string, text: string, key?: NodeKey);
|
|
19
18
|
createDOM(config: EditorConfig): HTMLElement;
|
|
20
|
-
updateDOM(prevNode:
|
|
19
|
+
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean;
|
|
21
20
|
static importJSON(serializedNode: SerializedEmojiNode): EmojiNode;
|
|
22
21
|
exportJSON(): SerializedEmojiNode;
|
|
23
22
|
getClassName(): string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { TextNode } from 'lexical';
|
|
8
|
+
import { $applyNodeReplacement, TextNode } from 'lexical';
|
|
9
9
|
export class EmojiNode extends TextNode {
|
|
10
10
|
__className;
|
|
11
11
|
static getType() {
|
|
@@ -35,18 +35,12 @@ export class EmojiNode extends TextNode {
|
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
static importJSON(serializedNode) {
|
|
38
|
-
|
|
39
|
-
node.setFormat(serializedNode.format);
|
|
40
|
-
node.setDetail(serializedNode.detail);
|
|
41
|
-
node.setMode(serializedNode.mode);
|
|
42
|
-
node.setStyle(serializedNode.style);
|
|
43
|
-
return node;
|
|
38
|
+
return $createEmojiNode(serializedNode.className, serializedNode.text).updateFromJSON(serializedNode);
|
|
44
39
|
}
|
|
45
40
|
exportJSON() {
|
|
46
41
|
return {
|
|
47
42
|
...super.exportJSON(),
|
|
48
43
|
className: this.getClassName(),
|
|
49
|
-
type: 'emoji',
|
|
50
44
|
};
|
|
51
45
|
}
|
|
52
46
|
getClassName() {
|
|
@@ -58,5 +52,6 @@ export function $isEmojiNode(node) {
|
|
|
58
52
|
return node instanceof EmojiNode;
|
|
59
53
|
}
|
|
60
54
|
export function $createEmojiNode(className, emojiText) {
|
|
61
|
-
|
|
55
|
+
const node = new EmojiNode(className, emojiText).setMode('token');
|
|
56
|
+
return $applyNodeReplacement(node);
|
|
62
57
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
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
|
+
*/
|
|
2
8
|
import { DecoratorNode } from 'lexical';
|
|
3
|
-
import { lazyRetry as lazy } from '@arcblock/ux/lib/Util';
|
|
4
|
-
import { Suspense } from 'react';
|
|
5
|
-
const EquationComponent = lazy(
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
() => import('./EquationComponent'));
|
|
8
9
|
export class EquationNode extends DecoratorNode {
|
|
9
10
|
__equation;
|
|
10
11
|
__inline;
|
|
@@ -46,7 +47,13 @@ export class EquationNode extends DecoratorNode {
|
|
|
46
47
|
writable.__equation = equation;
|
|
47
48
|
}
|
|
48
49
|
decorate() {
|
|
49
|
-
|
|
50
|
+
console.warn('dummy equation node');
|
|
51
|
+
return null;
|
|
52
|
+
// return (
|
|
53
|
+
// <Suspense fallback={null}>
|
|
54
|
+
// <EquationComponent equation={this.__equation} inline={this.__inline} nodeKey={this.__key} />
|
|
55
|
+
// </Suspense>
|
|
56
|
+
// );
|
|
50
57
|
}
|
|
51
58
|
}
|
|
52
59
|
export function $createEquationNode(equation = '', inline = false) {
|
|
@@ -9,7 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
9
9
|
import styled from '@emotion/styled';
|
|
10
10
|
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
11
11
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
12
|
-
import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
|
|
12
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
13
13
|
import { HashtagPlugin } from '@lexical/react/LexicalHashtagPlugin';
|
|
14
14
|
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
15
15
|
import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
@@ -135,7 +135,7 @@ export default function ImageComponent({ file, src, altText, nodeKey, width, hei
|
|
|
135
135
|
return false;
|
|
136
136
|
}, COMMAND_PRIORITY_LOW), editor.registerCommand(CLICK_COMMAND, (payload) => {
|
|
137
137
|
const event = payload;
|
|
138
|
-
if (isResizing) {
|
|
138
|
+
if (isResizing || !editor.isEditable()) {
|
|
139
139
|
return true;
|
|
140
140
|
}
|
|
141
141
|
if (event.target === imageRef.current) {
|
|
@@ -17,7 +17,6 @@ import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
|
17
17
|
import { CollapsibleContainerNode } from '../plugins/CollapsiblePlugin/CollapsibleContainerNode';
|
|
18
18
|
import { CollapsibleContentNode } from '../plugins/CollapsiblePlugin/CollapsibleContentNode';
|
|
19
19
|
import { CollapsibleTitleNode } from '../plugins/CollapsiblePlugin/CollapsibleTitleNode';
|
|
20
|
-
import { AutocompleteNode } from './AutocompleteNode';
|
|
21
20
|
import { EmojiNode } from './EmojiNode';
|
|
22
21
|
import { EquationNode } from './EquationNode';
|
|
23
22
|
import { ExcalidrawNode } from './ExcalidrawNode';
|
|
@@ -61,7 +60,6 @@ const PlaygroundNodes = [
|
|
|
61
60
|
EmojiNode,
|
|
62
61
|
ExcalidrawNode,
|
|
63
62
|
EquationNode,
|
|
64
|
-
AutocompleteNode,
|
|
65
63
|
KeywordNode,
|
|
66
64
|
HorizontalRuleNode,
|
|
67
65
|
TweetNode,
|
|
@@ -7,7 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
|
-
import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
|
|
10
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
11
11
|
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
12
12
|
import { LexicalNestedComposer } from '@lexical/react/LexicalNestedComposer';
|
|
13
13
|
import { PlainTextPlugin } from '@lexical/react/LexicalPlainTextPlugin';
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
2
|
import './index.css';
|
|
10
3
|
import { $isCodeNode, CodeNode, getLanguageFriendlyName } from '@lexical/code';
|
|
11
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
12
|
-
import { $getNearestNodeFromDOMNode } from 'lexical';
|
|
5
|
+
import { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical';
|
|
13
6
|
import { useEffect, useRef, useState } from 'react';
|
|
14
7
|
import { createPortal } from 'react-dom';
|
|
15
8
|
import { CopyButton } from './components/CopyButton';
|
|
@@ -70,30 +63,33 @@ function CodeActionMenuContainer({ anchorElem }) {
|
|
|
70
63
|
document.removeEventListener('mousemove', debouncedOnMouseMove);
|
|
71
64
|
};
|
|
72
65
|
}, [shouldListenMouseMove, debouncedOnMouseMove]);
|
|
73
|
-
|
|
74
|
-
editor.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
return editor.registerMutationListener(CodeNode, (mutations) => {
|
|
68
|
+
editor.getEditorState().read(() => {
|
|
69
|
+
for (const [key, type] of mutations) {
|
|
70
|
+
switch (type) {
|
|
71
|
+
case 'created':
|
|
72
|
+
codeSetRef.current.add(key);
|
|
73
|
+
break;
|
|
74
|
+
case 'destroyed':
|
|
75
|
+
codeSetRef.current.delete(key);
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
87
80
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
});
|
|
82
|
+
setShouldListenMouseMove(codeSetRef.current.size > 0);
|
|
83
|
+
}, { skipInitialization: false });
|
|
84
|
+
}, [editor]);
|
|
91
85
|
const codeFriendlyName = getLanguageFriendlyName(lang);
|
|
92
|
-
return
|
|
86
|
+
return (
|
|
87
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
88
|
+
_jsx(_Fragment, { children: isShown ? (_jsxs("div", { className: "code-action-menu-container", style: { ...position }, children: [_jsx("div", { className: "code-highlight-language", children: codeFriendlyName }), _jsx(CopyButton, { editor: editor, getCodeDOMNode: getCodeDOMNode })] })) : null }));
|
|
93
89
|
}
|
|
94
90
|
function getMouseInfo(event) {
|
|
95
91
|
const { target } = event;
|
|
96
|
-
if (target
|
|
92
|
+
if (isHTMLElement(target)) {
|
|
97
93
|
const codeDOMNode = target.closest('code.PlaygroundEditorTheme__code');
|
|
98
94
|
const isOutside = !(codeDOMNode || target.closest('div.code-action-menu-container'));
|
|
99
95
|
return { codeDOMNode, isOutside };
|
|
@@ -5,11 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
8
|
+
import { ElementTransformer, TextMatchTransformer, Transformer } from '@lexical/markdown';
|
|
9
9
|
export declare const HR: ElementTransformer;
|
|
10
10
|
export declare const IMAGE: TextMatchTransformer;
|
|
11
|
-
export declare const EQUATION: TextMatchTransformer;
|
|
12
|
-
export declare const TWEET: ElementTransformer;
|
|
13
11
|
export declare const TABLE: ElementTransformer;
|
|
14
|
-
export declare const BOOKMARK: TextMatchTransformer;
|
|
15
12
|
export declare const PLAYGROUND_TRANSFORMERS: Array<Transformer>;
|
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { CHECK_LIST, ELEMENT_TRANSFORMERS, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS } from '@lexical/markdown';
|
|
8
|
+
import { $convertFromMarkdownString, $convertToMarkdownString, CHECK_LIST, ELEMENT_TRANSFORMERS, MULTILINE_ELEMENT_TRANSFORMERS, TEXT_FORMAT_TRANSFORMERS, TEXT_MATCH_TRANSFORMERS, } from '@lexical/markdown';
|
|
9
9
|
import { $createHorizontalRuleNode, $isHorizontalRuleNode, HorizontalRuleNode, } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
10
|
-
import { $createTableCellNode, $createTableNode, $createTableRowNode, $isTableNode, $isTableRowNode, TableCellHeaderStates, TableCellNode, TableNode, TableRowNode, } from '@lexical/table';
|
|
11
|
-
import { $
|
|
12
|
-
import { $createEquationNode, $isEquationNode, EquationNode } from '../../nodes/EquationNode';
|
|
10
|
+
import { $createTableCellNode, $createTableNode, $createTableRowNode, $isTableCellNode, $isTableNode, $isTableRowNode, TableCellHeaderStates, TableCellNode, TableNode, TableRowNode, } from '@lexical/table';
|
|
11
|
+
import { $isParagraphNode, $isTextNode } from 'lexical';
|
|
13
12
|
import { $createImageNode, $isImageNode, ImageNode } from '../../nodes/ImageNode';
|
|
14
|
-
import { $createTweetNode, $isTweetNode, TweetNode } from '../../nodes/TweetNode';
|
|
15
|
-
import { $createBookmarkNode, $isBookmarkNode, BookmarkNode } from '../../../ext/BookmarkPlugin/BookmarkNode';
|
|
16
13
|
export const HR = {
|
|
17
14
|
dependencies: [HorizontalRuleNode],
|
|
18
15
|
export: (node) => {
|
|
@@ -34,7 +31,7 @@ export const HR = {
|
|
|
34
31
|
};
|
|
35
32
|
export const IMAGE = {
|
|
36
33
|
dependencies: [ImageNode],
|
|
37
|
-
export: (node
|
|
34
|
+
export: (node) => {
|
|
38
35
|
if (!$isImageNode(node)) {
|
|
39
36
|
return null;
|
|
40
37
|
}
|
|
@@ -54,66 +51,63 @@ export const IMAGE = {
|
|
|
54
51
|
trigger: ')',
|
|
55
52
|
type: 'text-match',
|
|
56
53
|
};
|
|
57
|
-
export const EQUATION = {
|
|
58
|
-
dependencies: [EquationNode],
|
|
59
|
-
export: (node, exportChildren, exportFormat) => {
|
|
60
|
-
if (!$isEquationNode(node)) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
return `$${node.getEquation()}$`;
|
|
64
|
-
},
|
|
65
|
-
importRegExp: /\$([^$].+?)\$/,
|
|
66
|
-
regExp: /\$([^$].+?)\$$/,
|
|
67
|
-
replace: (textNode, match) => {
|
|
68
|
-
const [, equation] = match;
|
|
69
|
-
const equationNode = $createEquationNode(equation, true);
|
|
70
|
-
textNode.replace(equationNode);
|
|
71
|
-
},
|
|
72
|
-
trigger: '$',
|
|
73
|
-
type: 'text-match',
|
|
74
|
-
};
|
|
75
|
-
export const TWEET = {
|
|
76
|
-
dependencies: [TweetNode],
|
|
77
|
-
export: (node) => {
|
|
78
|
-
if (!$isTweetNode(node)) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
return `<tweet id="${node.getId()}" />`;
|
|
82
|
-
},
|
|
83
|
-
regExp: /<tweet id="([^"]+?)"\s?\/>\s?$/,
|
|
84
|
-
replace: (textNode, _1, match) => {
|
|
85
|
-
const [, id] = match;
|
|
86
|
-
const tweetNode = $createTweetNode(id);
|
|
87
|
-
textNode.replace(tweetNode);
|
|
88
|
-
},
|
|
89
|
-
type: 'element',
|
|
90
|
-
};
|
|
91
54
|
// Very primitive table setup
|
|
92
55
|
const TABLE_ROW_REG_EXP = /^(?:\|)(.+)(?:\|)\s?$/;
|
|
56
|
+
const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
|
|
93
57
|
export const TABLE = {
|
|
94
|
-
// TODO: refactor transformer for new TableNode
|
|
95
58
|
dependencies: [TableNode, TableRowNode, TableCellNode],
|
|
96
|
-
export: (node
|
|
59
|
+
export: (node) => {
|
|
97
60
|
if (!$isTableNode(node)) {
|
|
98
61
|
return null;
|
|
99
62
|
}
|
|
100
63
|
const output = [];
|
|
101
64
|
for (const row of node.getChildren()) {
|
|
102
65
|
const rowOutput = [];
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
66
|
+
if (!$isTableRowNode(row)) {
|
|
67
|
+
// eslint-disable-next-line no-continue
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
let isHeaderRow = false;
|
|
71
|
+
for (const cell of row.getChildren()) {
|
|
72
|
+
// It's TableCellNode so it's just to make flow happy
|
|
73
|
+
if ($isTableCellNode(cell)) {
|
|
74
|
+
rowOutput.push($convertToMarkdownString(PLAYGROUND_TRANSFORMERS, cell).replace(/\n/g, '\\n').trim());
|
|
75
|
+
if (cell.__headerState === TableCellHeaderStates.ROW) {
|
|
76
|
+
isHeaderRow = true;
|
|
108
77
|
}
|
|
109
78
|
}
|
|
110
79
|
}
|
|
111
80
|
output.push(`| ${rowOutput.join(' | ')} |`);
|
|
81
|
+
if (isHeaderRow) {
|
|
82
|
+
output.push(`| ${rowOutput.map((_) => '---').join(' | ')} |`);
|
|
83
|
+
}
|
|
112
84
|
}
|
|
113
85
|
return output.join('\n');
|
|
114
86
|
},
|
|
115
87
|
regExp: TABLE_ROW_REG_EXP,
|
|
116
88
|
replace: (parentNode, _1, match) => {
|
|
89
|
+
// Header row
|
|
90
|
+
if (TABLE_ROW_DIVIDER_REG_EXP.test(match[0])) {
|
|
91
|
+
const table = parentNode.getPreviousSibling();
|
|
92
|
+
if (!table || !$isTableNode(table)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const rows = table.getChildren();
|
|
96
|
+
const lastRow = rows[rows.length - 1];
|
|
97
|
+
if (!lastRow || !$isTableRowNode(lastRow)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Add header state to row cells
|
|
101
|
+
lastRow.getChildren().forEach((cell) => {
|
|
102
|
+
if (!$isTableCellNode(cell)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
cell.setHeaderStyles(TableCellHeaderStates.ROW, TableCellHeaderStates.ROW);
|
|
106
|
+
});
|
|
107
|
+
// Remove line
|
|
108
|
+
parentNode.remove();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
117
111
|
const matchCells = mapToTableCells(match[0]);
|
|
118
112
|
if (matchCells == null) {
|
|
119
113
|
return;
|
|
@@ -147,7 +141,7 @@ export const TABLE = {
|
|
|
147
141
|
const tableRow = $createTableRowNode();
|
|
148
142
|
table.append(tableRow);
|
|
149
143
|
for (let i = 0; i < maxCells; i++) {
|
|
150
|
-
tableRow.append(i < cells.length ? cells[i] : createTableCell(
|
|
144
|
+
tableRow.append(i < cells.length ? cells[i] : $createTableCell(''));
|
|
151
145
|
}
|
|
152
146
|
}
|
|
153
147
|
const previousSibling = parentNode.getPreviousSibling();
|
|
@@ -166,51 +160,26 @@ function getTableColumnsSize(table) {
|
|
|
166
160
|
const row = table.getFirstChild();
|
|
167
161
|
return $isTableRowNode(row) ? row.getChildrenSize() : 0;
|
|
168
162
|
}
|
|
169
|
-
const createTableCell = (textContent) => {
|
|
163
|
+
const $createTableCell = (textContent) => {
|
|
164
|
+
textContent = textContent.replace(/\\n/g, '\n');
|
|
170
165
|
const cell = $createTableCellNode(TableCellHeaderStates.NO_STATUS);
|
|
171
|
-
|
|
172
|
-
if (textContent != null) {
|
|
173
|
-
paragraph.append($createTextNode(textContent.trim()));
|
|
174
|
-
}
|
|
175
|
-
cell.append(paragraph);
|
|
166
|
+
$convertFromMarkdownString(textContent, PLAYGROUND_TRANSFORMERS, cell);
|
|
176
167
|
return cell;
|
|
177
168
|
};
|
|
178
169
|
const mapToTableCells = (textContent) => {
|
|
179
|
-
// TODO:
|
|
180
|
-
// For now plain text, single node. Can be expanded to more complex content
|
|
181
|
-
// including formatted text
|
|
182
170
|
const match = textContent.match(TABLE_ROW_REG_EXP);
|
|
183
171
|
if (!match || !match[1]) {
|
|
184
172
|
return null;
|
|
185
173
|
}
|
|
186
|
-
return match[1].split('|').map((text) => createTableCell(text));
|
|
187
|
-
};
|
|
188
|
-
export const BOOKMARK = {
|
|
189
|
-
dependencies: [BookmarkNode],
|
|
190
|
-
export: (node, exportChildren, exportFormat) => {
|
|
191
|
-
if (!$isBookmarkNode(node)) {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
return `[[]](${node.getId()})`;
|
|
195
|
-
},
|
|
196
|
-
importRegExp: /(?:\[\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,
|
|
197
|
-
regExp: /(?:\[\[([^[]+)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,
|
|
198
|
-
replace: (textNode, match) => {
|
|
199
|
-
const [, , linkUrl] = match;
|
|
200
|
-
const bookmarkNode = $createBookmarkNode(linkUrl);
|
|
201
|
-
textNode.replace(bookmarkNode);
|
|
202
|
-
},
|
|
203
|
-
trigger: ')',
|
|
204
|
-
type: 'text-match',
|
|
174
|
+
return match[1].split('|').map((text) => $createTableCell(text));
|
|
205
175
|
};
|
|
206
176
|
export const PLAYGROUND_TRANSFORMERS = [
|
|
207
|
-
BOOKMARK,
|
|
208
177
|
TABLE,
|
|
209
178
|
HR,
|
|
210
179
|
IMAGE,
|
|
211
|
-
TWEET,
|
|
212
180
|
CHECK_LIST,
|
|
213
181
|
...ELEMENT_TRANSFORMERS,
|
|
182
|
+
...MULTILINE_ELEMENT_TRANSFORMERS,
|
|
214
183
|
...TEXT_FORMAT_TRANSFORMERS,
|
|
215
184
|
...TEXT_MATCH_TRANSFORMERS,
|
|
216
185
|
];
|