@lexical/code 0.14.5 → 0.16.0
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/CodeHighlighterPrism.d.ts +6 -0
- package/LexicalCode.dev.js +32 -55
- package/LexicalCode.dev.mjs +33 -56
- package/LexicalCode.js +2 -0
- package/LexicalCode.mjs +2 -0
- package/LexicalCode.node.mjs +2 -0
- package/LexicalCode.prod.js +38 -36
- package/LexicalCode.prod.mjs +3 -1
- package/package.json +3 -3
|
@@ -14,9 +14,15 @@ import 'prismjs/components/prism-c';
|
|
|
14
14
|
import 'prismjs/components/prism-css';
|
|
15
15
|
import 'prismjs/components/prism-objectivec';
|
|
16
16
|
import 'prismjs/components/prism-sql';
|
|
17
|
+
import 'prismjs/components/prism-powershell';
|
|
17
18
|
import 'prismjs/components/prism-python';
|
|
18
19
|
import 'prismjs/components/prism-rust';
|
|
19
20
|
import 'prismjs/components/prism-swift';
|
|
20
21
|
import 'prismjs/components/prism-typescript';
|
|
21
22
|
import 'prismjs/components/prism-java';
|
|
22
23
|
import 'prismjs/components/prism-cpp';
|
|
24
|
+
declare global {
|
|
25
|
+
interface Window {
|
|
26
|
+
Prism: typeof import('prismjs');
|
|
27
|
+
}
|
|
28
|
+
}
|
package/LexicalCode.dev.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
require('prismjs');
|
|
@@ -15,6 +17,7 @@ require('prismjs/components/prism-c');
|
|
|
15
17
|
require('prismjs/components/prism-css');
|
|
16
18
|
require('prismjs/components/prism-objectivec');
|
|
17
19
|
require('prismjs/components/prism-sql');
|
|
20
|
+
require('prismjs/components/prism-powershell');
|
|
18
21
|
require('prismjs/components/prism-python');
|
|
19
22
|
require('prismjs/components/prism-rust');
|
|
20
23
|
require('prismjs/components/prism-swift');
|
|
@@ -57,6 +60,7 @@ function invariant(cond, message, ...args) {
|
|
|
57
60
|
* LICENSE file in the root directory of this source tree.
|
|
58
61
|
*
|
|
59
62
|
*/
|
|
63
|
+
|
|
60
64
|
const mapToPrismLanguage = language => {
|
|
61
65
|
// eslint-disable-next-line no-prototype-builtins
|
|
62
66
|
return language != null && window.Prism.languages.hasOwnProperty(language) ? language : undefined;
|
|
@@ -130,16 +134,16 @@ class CodeNode extends lexical.ElementNode {
|
|
|
130
134
|
code: node => {
|
|
131
135
|
const isMultiLine = node.textContent != null && (/\r?\n/.test(node.textContent) || hasChildDOMNodeTag(node, 'BR'));
|
|
132
136
|
return isMultiLine ? {
|
|
133
|
-
conversion: convertPreElement,
|
|
137
|
+
conversion: $convertPreElement,
|
|
134
138
|
priority: 1
|
|
135
139
|
} : null;
|
|
136
140
|
},
|
|
137
|
-
div:
|
|
138
|
-
conversion: convertDivElement,
|
|
141
|
+
div: () => ({
|
|
142
|
+
conversion: $convertDivElement,
|
|
139
143
|
priority: 1
|
|
140
144
|
}),
|
|
141
|
-
pre:
|
|
142
|
-
conversion: convertPreElement,
|
|
145
|
+
pre: () => ({
|
|
146
|
+
conversion: $convertPreElement,
|
|
143
147
|
priority: 0
|
|
144
148
|
}),
|
|
145
149
|
table: node => {
|
|
@@ -147,7 +151,7 @@ class CodeNode extends lexical.ElementNode {
|
|
|
147
151
|
// domNode is a <table> since we matched it by nodeName
|
|
148
152
|
if (isGitHubCodeTable(table)) {
|
|
149
153
|
return {
|
|
150
|
-
conversion: convertTableElement,
|
|
154
|
+
conversion: $convertTableElement,
|
|
151
155
|
priority: 3
|
|
152
156
|
};
|
|
153
157
|
}
|
|
@@ -157,13 +161,7 @@ class CodeNode extends lexical.ElementNode {
|
|
|
157
161
|
// element is a <td> since we matched it by nodeName
|
|
158
162
|
const td = node;
|
|
159
163
|
const table = td.closest('table');
|
|
160
|
-
if (isGitHubCodeCell(td)) {
|
|
161
|
-
return {
|
|
162
|
-
conversion: convertTableCellElement,
|
|
163
|
-
priority: 3
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
if (table && isGitHubCodeTable(table)) {
|
|
164
|
+
if (isGitHubCodeCell(td) || table && isGitHubCodeTable(table)) {
|
|
167
165
|
// Return a no-op if it's a table cell in a code table, but not a code line.
|
|
168
166
|
// Otherwise it'll fall back to the T
|
|
169
167
|
return {
|
|
@@ -298,16 +296,13 @@ function $createCodeNode(language) {
|
|
|
298
296
|
function $isCodeNode(node) {
|
|
299
297
|
return node instanceof CodeNode;
|
|
300
298
|
}
|
|
301
|
-
function convertPreElement(domNode) {
|
|
302
|
-
|
|
303
|
-
if (utils.isHTMLElement(domNode)) {
|
|
304
|
-
language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE);
|
|
305
|
-
}
|
|
299
|
+
function $convertPreElement(domNode) {
|
|
300
|
+
const language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE);
|
|
306
301
|
return {
|
|
307
302
|
node: $createCodeNode(language)
|
|
308
303
|
};
|
|
309
304
|
}
|
|
310
|
-
function convertDivElement(domNode) {
|
|
305
|
+
function $convertDivElement(domNode) {
|
|
311
306
|
// domNode is a <div> since we matched it by nodeName
|
|
312
307
|
const div = domNode;
|
|
313
308
|
const isCode = isCodeElement(div);
|
|
@@ -317,17 +312,10 @@ function convertDivElement(domNode) {
|
|
|
317
312
|
};
|
|
318
313
|
}
|
|
319
314
|
return {
|
|
320
|
-
after: childLexicalNodes => {
|
|
321
|
-
const domParent = domNode.parentNode;
|
|
322
|
-
if (domParent != null && domNode !== domParent.lastChild) {
|
|
323
|
-
childLexicalNodes.push(lexical.$createLineBreakNode());
|
|
324
|
-
}
|
|
325
|
-
return childLexicalNodes;
|
|
326
|
-
},
|
|
327
315
|
node: isCode ? $createCodeNode() : null
|
|
328
316
|
};
|
|
329
317
|
}
|
|
330
|
-
function convertTableElement() {
|
|
318
|
+
function $convertTableElement() {
|
|
331
319
|
return {
|
|
332
320
|
node: $createCodeNode()
|
|
333
321
|
};
|
|
@@ -337,20 +325,6 @@ function convertCodeNoop() {
|
|
|
337
325
|
node: null
|
|
338
326
|
};
|
|
339
327
|
}
|
|
340
|
-
function convertTableCellElement(domNode) {
|
|
341
|
-
// domNode is a <td> since we matched it by nodeName
|
|
342
|
-
const cell = domNode;
|
|
343
|
-
return {
|
|
344
|
-
after: childLexicalNodes => {
|
|
345
|
-
if (cell.parentNode && cell.parentNode.nextSibling) {
|
|
346
|
-
// Append newline between code lines
|
|
347
|
-
childLexicalNodes.push(lexical.$createLineBreakNode());
|
|
348
|
-
}
|
|
349
|
-
return childLexicalNodes;
|
|
350
|
-
},
|
|
351
|
-
node: null
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
328
|
function isCodeElement(div) {
|
|
355
329
|
return div.style.fontFamily.match('monospace') !== null;
|
|
356
330
|
}
|
|
@@ -378,6 +352,7 @@ function isGitHubCodeTable(table) {
|
|
|
378
352
|
* LICENSE file in the root directory of this source tree.
|
|
379
353
|
*
|
|
380
354
|
*/
|
|
355
|
+
|
|
381
356
|
const DEFAULT_CODE_LANGUAGE = 'javascript';
|
|
382
357
|
const CODE_LANGUAGE_FRIENDLY_NAME_MAP = {
|
|
383
358
|
c: 'C',
|
|
@@ -390,6 +365,7 @@ const CODE_LANGUAGE_FRIENDLY_NAME_MAP = {
|
|
|
390
365
|
markdown: 'Markdown',
|
|
391
366
|
objc: 'Objective-C',
|
|
392
367
|
plain: 'Plain Text',
|
|
368
|
+
powershell: 'PowerShell',
|
|
393
369
|
py: 'Python',
|
|
394
370
|
rust: 'Rust',
|
|
395
371
|
sql: 'SQL',
|
|
@@ -524,6 +500,7 @@ function getLastCodeNodeOfLine(anchor) {
|
|
|
524
500
|
* LICENSE file in the root directory of this source tree.
|
|
525
501
|
*
|
|
526
502
|
*/
|
|
503
|
+
|
|
527
504
|
const PrismTokenizer = {
|
|
528
505
|
defaultLanguage: DEFAULT_CODE_LANGUAGE,
|
|
529
506
|
tokenize(code, language) {
|
|
@@ -630,7 +607,7 @@ function getEndOfCodeInLine(anchor) {
|
|
|
630
607
|
}
|
|
631
608
|
return lastNode;
|
|
632
609
|
}
|
|
633
|
-
function textNodeTransform(node, editor, tokenizer) {
|
|
610
|
+
function $textNodeTransform(node, editor, tokenizer) {
|
|
634
611
|
// Since CodeNode has flat children structure we only need to check
|
|
635
612
|
// if node's parent is a code node and run highlighting if so
|
|
636
613
|
const parentNode = node.getParent();
|
|
@@ -691,14 +668,14 @@ function codeNodeTransform(node, editor, tokenizer) {
|
|
|
691
668
|
// each individual codehighlight node to be transformed again as it's already
|
|
692
669
|
// in its final state
|
|
693
670
|
editor.update(() => {
|
|
694
|
-
updateAndRetainSelection(nodeKey, () => {
|
|
671
|
+
$updateAndRetainSelection(nodeKey, () => {
|
|
695
672
|
const currentNode = lexical.$getNodeByKey(nodeKey);
|
|
696
673
|
if (!$isCodeNode(currentNode) || !currentNode.isAttached()) {
|
|
697
674
|
return false;
|
|
698
675
|
}
|
|
699
676
|
const code = currentNode.getTextContent();
|
|
700
677
|
const tokens = tokenizer.tokenize(code, currentNode.getLanguage() || tokenizer.defaultLanguage);
|
|
701
|
-
const highlightNodes = getHighlightNodes(tokens);
|
|
678
|
+
const highlightNodes = $getHighlightNodes(tokens);
|
|
702
679
|
const diffRange = getDiffRange(currentNode.getChildren(), highlightNodes);
|
|
703
680
|
const {
|
|
704
681
|
from,
|
|
@@ -718,7 +695,7 @@ function codeNodeTransform(node, editor, tokenizer) {
|
|
|
718
695
|
skipTransforms: true
|
|
719
696
|
});
|
|
720
697
|
}
|
|
721
|
-
function getHighlightNodes(tokens, type) {
|
|
698
|
+
function $getHighlightNodes(tokens, type) {
|
|
722
699
|
const nodes = [];
|
|
723
700
|
for (const token of tokens) {
|
|
724
701
|
if (typeof token === 'string') {
|
|
@@ -739,9 +716,9 @@ function getHighlightNodes(tokens, type) {
|
|
|
739
716
|
content
|
|
740
717
|
} = token;
|
|
741
718
|
if (typeof content === 'string') {
|
|
742
|
-
nodes.push(
|
|
719
|
+
nodes.push(...$getHighlightNodes([content], token.type));
|
|
743
720
|
} else if (Array.isArray(content)) {
|
|
744
|
-
nodes.push(
|
|
721
|
+
nodes.push(...$getHighlightNodes(content, token.type));
|
|
745
722
|
}
|
|
746
723
|
}
|
|
747
724
|
}
|
|
@@ -750,7 +727,7 @@ function getHighlightNodes(tokens, type) {
|
|
|
750
727
|
|
|
751
728
|
// Wrapping update function into selection retainer, that tries to keep cursor at the same
|
|
752
729
|
// position as before.
|
|
753
|
-
function updateAndRetainSelection(nodeKey, updateFn) {
|
|
730
|
+
function $updateAndRetainSelection(nodeKey, updateFn) {
|
|
754
731
|
const node = lexical.$getNodeByKey(nodeKey);
|
|
755
732
|
if (!$isCodeNode(node) || !node.isAttached()) {
|
|
756
733
|
return;
|
|
@@ -872,7 +849,7 @@ function $getCodeLines(selection) {
|
|
|
872
849
|
}
|
|
873
850
|
return lines;
|
|
874
851
|
}
|
|
875
|
-
function handleTab(shiftKey) {
|
|
852
|
+
function $handleTab(shiftKey) {
|
|
876
853
|
const selection = lexical.$getSelection();
|
|
877
854
|
if (!lexical.$isRangeSelection(selection) || !$isSelectionInCode(selection)) {
|
|
878
855
|
return null;
|
|
@@ -912,7 +889,7 @@ function handleTab(shiftKey) {
|
|
|
912
889
|
// 3. Else: tab/outdent
|
|
913
890
|
return tabOrOutdent;
|
|
914
891
|
}
|
|
915
|
-
function handleMultilineIndent(type) {
|
|
892
|
+
function $handleMultilineIndent(type) {
|
|
916
893
|
const selection = lexical.$getSelection();
|
|
917
894
|
if (!lexical.$isRangeSelection(selection) || !$isSelectionInCode(selection)) {
|
|
918
895
|
return false;
|
|
@@ -968,7 +945,7 @@ function handleMultilineIndent(type) {
|
|
|
968
945
|
}
|
|
969
946
|
return true;
|
|
970
947
|
}
|
|
971
|
-
function handleShiftLines(type, event) {
|
|
948
|
+
function $handleShiftLines(type, event) {
|
|
972
949
|
// We only care about the alt+arrow keys
|
|
973
950
|
const selection = lexical.$getSelection();
|
|
974
951
|
if (!lexical.$isRangeSelection(selection)) {
|
|
@@ -1066,7 +1043,7 @@ function handleShiftLines(type, event) {
|
|
|
1066
1043
|
selection.setTextNodeRange(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
1067
1044
|
return true;
|
|
1068
1045
|
}
|
|
1069
|
-
function handleMoveTo(type, event) {
|
|
1046
|
+
function $handleMoveTo(type, event) {
|
|
1070
1047
|
const selection = lexical.$getSelection();
|
|
1071
1048
|
if (!lexical.$isRangeSelection(selection)) {
|
|
1072
1049
|
return false;
|
|
@@ -1122,8 +1099,8 @@ function registerCodeHighlighting(editor, tokenizer) {
|
|
|
1122
1099
|
}
|
|
1123
1100
|
}
|
|
1124
1101
|
});
|
|
1125
|
-
}), editor.registerNodeTransform(CodeNode, node => codeNodeTransform(node, editor, tokenizer)), editor.registerNodeTransform(lexical.TextNode, node => textNodeTransform(node, editor, tokenizer)), editor.registerNodeTransform(CodeHighlightNode, node => textNodeTransform(node, editor, tokenizer)), editor.registerCommand(lexical.KEY_TAB_COMMAND, event => {
|
|
1126
|
-
const command = handleTab(event.shiftKey);
|
|
1102
|
+
}), editor.registerNodeTransform(CodeNode, node => codeNodeTransform(node, editor, tokenizer)), editor.registerNodeTransform(lexical.TextNode, node => $textNodeTransform(node, editor, tokenizer)), editor.registerNodeTransform(CodeHighlightNode, node => $textNodeTransform(node, editor, tokenizer)), editor.registerCommand(lexical.KEY_TAB_COMMAND, event => {
|
|
1103
|
+
const command = $handleTab(event.shiftKey);
|
|
1127
1104
|
if (command === null) {
|
|
1128
1105
|
return false;
|
|
1129
1106
|
}
|
|
@@ -1137,7 +1114,7 @@ function registerCodeHighlighting(editor, tokenizer) {
|
|
|
1137
1114
|
}
|
|
1138
1115
|
lexical.$insertNodes([lexical.$createTabNode()]);
|
|
1139
1116
|
return true;
|
|
1140
|
-
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, payload => handleMultilineIndent(lexical.INDENT_CONTENT_COMMAND), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, payload => handleMultilineIndent(lexical.OUTDENT_CONTENT_COMMAND), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, payload => handleShiftLines(lexical.KEY_ARROW_UP_COMMAND, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, payload => handleShiftLines(lexical.KEY_ARROW_DOWN_COMMAND, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.MOVE_TO_END, payload => handleMoveTo(lexical.MOVE_TO_END, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.MOVE_TO_START, payload => handleMoveTo(lexical.MOVE_TO_START, payload), lexical.COMMAND_PRIORITY_LOW));
|
|
1117
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, payload => $handleMultilineIndent(lexical.INDENT_CONTENT_COMMAND), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, payload => $handleMultilineIndent(lexical.OUTDENT_CONTENT_COMMAND), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, payload => $handleShiftLines(lexical.KEY_ARROW_UP_COMMAND, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, payload => $handleShiftLines(lexical.KEY_ARROW_DOWN_COMMAND, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.MOVE_TO_END, payload => $handleMoveTo(lexical.MOVE_TO_END, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.MOVE_TO_START, payload => $handleMoveTo(lexical.MOVE_TO_START, payload), lexical.COMMAND_PRIORITY_LOW));
|
|
1141
1118
|
}
|
|
1142
1119
|
|
|
1143
1120
|
/**
|
package/LexicalCode.dev.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import 'prismjs';
|
|
8
10
|
import 'prismjs/components/prism-clike.js';
|
|
9
11
|
import 'prismjs/components/prism-javascript.js';
|
|
@@ -13,6 +15,7 @@ import 'prismjs/components/prism-c.js';
|
|
|
13
15
|
import 'prismjs/components/prism-css.js';
|
|
14
16
|
import 'prismjs/components/prism-objectivec.js';
|
|
15
17
|
import 'prismjs/components/prism-sql.js';
|
|
18
|
+
import 'prismjs/components/prism-powershell.js';
|
|
16
19
|
import 'prismjs/components/prism-python.js';
|
|
17
20
|
import 'prismjs/components/prism-rust.js';
|
|
18
21
|
import 'prismjs/components/prism-swift.js';
|
|
@@ -20,7 +23,7 @@ import 'prismjs/components/prism-typescript.js';
|
|
|
20
23
|
import 'prismjs/components/prism-java.js';
|
|
21
24
|
import 'prismjs/components/prism-cpp.js';
|
|
22
25
|
import { isHTMLElement, addClassNamesToElement, removeClassNamesFromElement, mergeRegister } from '@lexical/utils';
|
|
23
|
-
import { ElementNode, $
|
|
26
|
+
import { ElementNode, $createParagraphNode, $isTextNode, $isTabNode, $createTabNode, $createLineBreakNode, $applyNodeReplacement, TextNode, $isLineBreakNode, $createTextNode, $getNodeByKey, $getSelection, $isRangeSelection, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, INSERT_TAB_COMMAND, KEY_ARROW_UP_COMMAND, MOVE_TO_START, KEY_TAB_COMMAND, COMMAND_PRIORITY_LOW, $insertNodes, KEY_ARROW_DOWN_COMMAND, MOVE_TO_END } from 'lexical';
|
|
24
27
|
|
|
25
28
|
/**
|
|
26
29
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -55,6 +58,7 @@ function invariant(cond, message, ...args) {
|
|
|
55
58
|
* LICENSE file in the root directory of this source tree.
|
|
56
59
|
*
|
|
57
60
|
*/
|
|
61
|
+
|
|
58
62
|
const mapToPrismLanguage = language => {
|
|
59
63
|
// eslint-disable-next-line no-prototype-builtins
|
|
60
64
|
return language != null && window.Prism.languages.hasOwnProperty(language) ? language : undefined;
|
|
@@ -128,16 +132,16 @@ class CodeNode extends ElementNode {
|
|
|
128
132
|
code: node => {
|
|
129
133
|
const isMultiLine = node.textContent != null && (/\r?\n/.test(node.textContent) || hasChildDOMNodeTag(node, 'BR'));
|
|
130
134
|
return isMultiLine ? {
|
|
131
|
-
conversion: convertPreElement,
|
|
135
|
+
conversion: $convertPreElement,
|
|
132
136
|
priority: 1
|
|
133
137
|
} : null;
|
|
134
138
|
},
|
|
135
|
-
div:
|
|
136
|
-
conversion: convertDivElement,
|
|
139
|
+
div: () => ({
|
|
140
|
+
conversion: $convertDivElement,
|
|
137
141
|
priority: 1
|
|
138
142
|
}),
|
|
139
|
-
pre:
|
|
140
|
-
conversion: convertPreElement,
|
|
143
|
+
pre: () => ({
|
|
144
|
+
conversion: $convertPreElement,
|
|
141
145
|
priority: 0
|
|
142
146
|
}),
|
|
143
147
|
table: node => {
|
|
@@ -145,7 +149,7 @@ class CodeNode extends ElementNode {
|
|
|
145
149
|
// domNode is a <table> since we matched it by nodeName
|
|
146
150
|
if (isGitHubCodeTable(table)) {
|
|
147
151
|
return {
|
|
148
|
-
conversion: convertTableElement,
|
|
152
|
+
conversion: $convertTableElement,
|
|
149
153
|
priority: 3
|
|
150
154
|
};
|
|
151
155
|
}
|
|
@@ -155,13 +159,7 @@ class CodeNode extends ElementNode {
|
|
|
155
159
|
// element is a <td> since we matched it by nodeName
|
|
156
160
|
const td = node;
|
|
157
161
|
const table = td.closest('table');
|
|
158
|
-
if (isGitHubCodeCell(td)) {
|
|
159
|
-
return {
|
|
160
|
-
conversion: convertTableCellElement,
|
|
161
|
-
priority: 3
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
if (table && isGitHubCodeTable(table)) {
|
|
162
|
+
if (isGitHubCodeCell(td) || table && isGitHubCodeTable(table)) {
|
|
165
163
|
// Return a no-op if it's a table cell in a code table, but not a code line.
|
|
166
164
|
// Otherwise it'll fall back to the T
|
|
167
165
|
return {
|
|
@@ -296,16 +294,13 @@ function $createCodeNode(language) {
|
|
|
296
294
|
function $isCodeNode(node) {
|
|
297
295
|
return node instanceof CodeNode;
|
|
298
296
|
}
|
|
299
|
-
function convertPreElement(domNode) {
|
|
300
|
-
|
|
301
|
-
if (isHTMLElement(domNode)) {
|
|
302
|
-
language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE);
|
|
303
|
-
}
|
|
297
|
+
function $convertPreElement(domNode) {
|
|
298
|
+
const language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE);
|
|
304
299
|
return {
|
|
305
300
|
node: $createCodeNode(language)
|
|
306
301
|
};
|
|
307
302
|
}
|
|
308
|
-
function convertDivElement(domNode) {
|
|
303
|
+
function $convertDivElement(domNode) {
|
|
309
304
|
// domNode is a <div> since we matched it by nodeName
|
|
310
305
|
const div = domNode;
|
|
311
306
|
const isCode = isCodeElement(div);
|
|
@@ -315,17 +310,10 @@ function convertDivElement(domNode) {
|
|
|
315
310
|
};
|
|
316
311
|
}
|
|
317
312
|
return {
|
|
318
|
-
after: childLexicalNodes => {
|
|
319
|
-
const domParent = domNode.parentNode;
|
|
320
|
-
if (domParent != null && domNode !== domParent.lastChild) {
|
|
321
|
-
childLexicalNodes.push($createLineBreakNode());
|
|
322
|
-
}
|
|
323
|
-
return childLexicalNodes;
|
|
324
|
-
},
|
|
325
313
|
node: isCode ? $createCodeNode() : null
|
|
326
314
|
};
|
|
327
315
|
}
|
|
328
|
-
function convertTableElement() {
|
|
316
|
+
function $convertTableElement() {
|
|
329
317
|
return {
|
|
330
318
|
node: $createCodeNode()
|
|
331
319
|
};
|
|
@@ -335,20 +323,6 @@ function convertCodeNoop() {
|
|
|
335
323
|
node: null
|
|
336
324
|
};
|
|
337
325
|
}
|
|
338
|
-
function convertTableCellElement(domNode) {
|
|
339
|
-
// domNode is a <td> since we matched it by nodeName
|
|
340
|
-
const cell = domNode;
|
|
341
|
-
return {
|
|
342
|
-
after: childLexicalNodes => {
|
|
343
|
-
if (cell.parentNode && cell.parentNode.nextSibling) {
|
|
344
|
-
// Append newline between code lines
|
|
345
|
-
childLexicalNodes.push($createLineBreakNode());
|
|
346
|
-
}
|
|
347
|
-
return childLexicalNodes;
|
|
348
|
-
},
|
|
349
|
-
node: null
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
326
|
function isCodeElement(div) {
|
|
353
327
|
return div.style.fontFamily.match('monospace') !== null;
|
|
354
328
|
}
|
|
@@ -376,6 +350,7 @@ function isGitHubCodeTable(table) {
|
|
|
376
350
|
* LICENSE file in the root directory of this source tree.
|
|
377
351
|
*
|
|
378
352
|
*/
|
|
353
|
+
|
|
379
354
|
const DEFAULT_CODE_LANGUAGE = 'javascript';
|
|
380
355
|
const CODE_LANGUAGE_FRIENDLY_NAME_MAP = {
|
|
381
356
|
c: 'C',
|
|
@@ -388,6 +363,7 @@ const CODE_LANGUAGE_FRIENDLY_NAME_MAP = {
|
|
|
388
363
|
markdown: 'Markdown',
|
|
389
364
|
objc: 'Objective-C',
|
|
390
365
|
plain: 'Plain Text',
|
|
366
|
+
powershell: 'PowerShell',
|
|
391
367
|
py: 'Python',
|
|
392
368
|
rust: 'Rust',
|
|
393
369
|
sql: 'SQL',
|
|
@@ -522,6 +498,7 @@ function getLastCodeNodeOfLine(anchor) {
|
|
|
522
498
|
* LICENSE file in the root directory of this source tree.
|
|
523
499
|
*
|
|
524
500
|
*/
|
|
501
|
+
|
|
525
502
|
const PrismTokenizer = {
|
|
526
503
|
defaultLanguage: DEFAULT_CODE_LANGUAGE,
|
|
527
504
|
tokenize(code, language) {
|
|
@@ -628,7 +605,7 @@ function getEndOfCodeInLine(anchor) {
|
|
|
628
605
|
}
|
|
629
606
|
return lastNode;
|
|
630
607
|
}
|
|
631
|
-
function textNodeTransform(node, editor, tokenizer) {
|
|
608
|
+
function $textNodeTransform(node, editor, tokenizer) {
|
|
632
609
|
// Since CodeNode has flat children structure we only need to check
|
|
633
610
|
// if node's parent is a code node and run highlighting if so
|
|
634
611
|
const parentNode = node.getParent();
|
|
@@ -689,14 +666,14 @@ function codeNodeTransform(node, editor, tokenizer) {
|
|
|
689
666
|
// each individual codehighlight node to be transformed again as it's already
|
|
690
667
|
// in its final state
|
|
691
668
|
editor.update(() => {
|
|
692
|
-
updateAndRetainSelection(nodeKey, () => {
|
|
669
|
+
$updateAndRetainSelection(nodeKey, () => {
|
|
693
670
|
const currentNode = $getNodeByKey(nodeKey);
|
|
694
671
|
if (!$isCodeNode(currentNode) || !currentNode.isAttached()) {
|
|
695
672
|
return false;
|
|
696
673
|
}
|
|
697
674
|
const code = currentNode.getTextContent();
|
|
698
675
|
const tokens = tokenizer.tokenize(code, currentNode.getLanguage() || tokenizer.defaultLanguage);
|
|
699
|
-
const highlightNodes = getHighlightNodes(tokens);
|
|
676
|
+
const highlightNodes = $getHighlightNodes(tokens);
|
|
700
677
|
const diffRange = getDiffRange(currentNode.getChildren(), highlightNodes);
|
|
701
678
|
const {
|
|
702
679
|
from,
|
|
@@ -716,7 +693,7 @@ function codeNodeTransform(node, editor, tokenizer) {
|
|
|
716
693
|
skipTransforms: true
|
|
717
694
|
});
|
|
718
695
|
}
|
|
719
|
-
function getHighlightNodes(tokens, type) {
|
|
696
|
+
function $getHighlightNodes(tokens, type) {
|
|
720
697
|
const nodes = [];
|
|
721
698
|
for (const token of tokens) {
|
|
722
699
|
if (typeof token === 'string') {
|
|
@@ -737,9 +714,9 @@ function getHighlightNodes(tokens, type) {
|
|
|
737
714
|
content
|
|
738
715
|
} = token;
|
|
739
716
|
if (typeof content === 'string') {
|
|
740
|
-
nodes.push(
|
|
717
|
+
nodes.push(...$getHighlightNodes([content], token.type));
|
|
741
718
|
} else if (Array.isArray(content)) {
|
|
742
|
-
nodes.push(
|
|
719
|
+
nodes.push(...$getHighlightNodes(content, token.type));
|
|
743
720
|
}
|
|
744
721
|
}
|
|
745
722
|
}
|
|
@@ -748,7 +725,7 @@ function getHighlightNodes(tokens, type) {
|
|
|
748
725
|
|
|
749
726
|
// Wrapping update function into selection retainer, that tries to keep cursor at the same
|
|
750
727
|
// position as before.
|
|
751
|
-
function updateAndRetainSelection(nodeKey, updateFn) {
|
|
728
|
+
function $updateAndRetainSelection(nodeKey, updateFn) {
|
|
752
729
|
const node = $getNodeByKey(nodeKey);
|
|
753
730
|
if (!$isCodeNode(node) || !node.isAttached()) {
|
|
754
731
|
return;
|
|
@@ -870,7 +847,7 @@ function $getCodeLines(selection) {
|
|
|
870
847
|
}
|
|
871
848
|
return lines;
|
|
872
849
|
}
|
|
873
|
-
function handleTab(shiftKey) {
|
|
850
|
+
function $handleTab(shiftKey) {
|
|
874
851
|
const selection = $getSelection();
|
|
875
852
|
if (!$isRangeSelection(selection) || !$isSelectionInCode(selection)) {
|
|
876
853
|
return null;
|
|
@@ -910,7 +887,7 @@ function handleTab(shiftKey) {
|
|
|
910
887
|
// 3. Else: tab/outdent
|
|
911
888
|
return tabOrOutdent;
|
|
912
889
|
}
|
|
913
|
-
function handleMultilineIndent(type) {
|
|
890
|
+
function $handleMultilineIndent(type) {
|
|
914
891
|
const selection = $getSelection();
|
|
915
892
|
if (!$isRangeSelection(selection) || !$isSelectionInCode(selection)) {
|
|
916
893
|
return false;
|
|
@@ -966,7 +943,7 @@ function handleMultilineIndent(type) {
|
|
|
966
943
|
}
|
|
967
944
|
return true;
|
|
968
945
|
}
|
|
969
|
-
function handleShiftLines(type, event) {
|
|
946
|
+
function $handleShiftLines(type, event) {
|
|
970
947
|
// We only care about the alt+arrow keys
|
|
971
948
|
const selection = $getSelection();
|
|
972
949
|
if (!$isRangeSelection(selection)) {
|
|
@@ -1064,7 +1041,7 @@ function handleShiftLines(type, event) {
|
|
|
1064
1041
|
selection.setTextNodeRange(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
1065
1042
|
return true;
|
|
1066
1043
|
}
|
|
1067
|
-
function handleMoveTo(type, event) {
|
|
1044
|
+
function $handleMoveTo(type, event) {
|
|
1068
1045
|
const selection = $getSelection();
|
|
1069
1046
|
if (!$isRangeSelection(selection)) {
|
|
1070
1047
|
return false;
|
|
@@ -1120,8 +1097,8 @@ function registerCodeHighlighting(editor, tokenizer) {
|
|
|
1120
1097
|
}
|
|
1121
1098
|
}
|
|
1122
1099
|
});
|
|
1123
|
-
}), editor.registerNodeTransform(CodeNode, node => codeNodeTransform(node, editor, tokenizer)), editor.registerNodeTransform(TextNode, node => textNodeTransform(node, editor, tokenizer)), editor.registerNodeTransform(CodeHighlightNode, node => textNodeTransform(node, editor, tokenizer)), editor.registerCommand(KEY_TAB_COMMAND, event => {
|
|
1124
|
-
const command = handleTab(event.shiftKey);
|
|
1100
|
+
}), editor.registerNodeTransform(CodeNode, node => codeNodeTransform(node, editor, tokenizer)), editor.registerNodeTransform(TextNode, node => $textNodeTransform(node, editor, tokenizer)), editor.registerNodeTransform(CodeHighlightNode, node => $textNodeTransform(node, editor, tokenizer)), editor.registerCommand(KEY_TAB_COMMAND, event => {
|
|
1101
|
+
const command = $handleTab(event.shiftKey);
|
|
1125
1102
|
if (command === null) {
|
|
1126
1103
|
return false;
|
|
1127
1104
|
}
|
|
@@ -1135,7 +1112,7 @@ function registerCodeHighlighting(editor, tokenizer) {
|
|
|
1135
1112
|
}
|
|
1136
1113
|
$insertNodes([$createTabNode()]);
|
|
1137
1114
|
return true;
|
|
1138
|
-
}, COMMAND_PRIORITY_LOW), editor.registerCommand(INDENT_CONTENT_COMMAND, payload => handleMultilineIndent(INDENT_CONTENT_COMMAND), COMMAND_PRIORITY_LOW), editor.registerCommand(OUTDENT_CONTENT_COMMAND, payload => handleMultilineIndent(OUTDENT_CONTENT_COMMAND), COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_UP_COMMAND, payload => handleShiftLines(KEY_ARROW_UP_COMMAND, payload), COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_DOWN_COMMAND, payload => handleShiftLines(KEY_ARROW_DOWN_COMMAND, payload), COMMAND_PRIORITY_LOW), editor.registerCommand(MOVE_TO_END, payload => handleMoveTo(MOVE_TO_END, payload), COMMAND_PRIORITY_LOW), editor.registerCommand(MOVE_TO_START, payload => handleMoveTo(MOVE_TO_START, payload), COMMAND_PRIORITY_LOW));
|
|
1115
|
+
}, COMMAND_PRIORITY_LOW), editor.registerCommand(INDENT_CONTENT_COMMAND, payload => $handleMultilineIndent(INDENT_CONTENT_COMMAND), COMMAND_PRIORITY_LOW), editor.registerCommand(OUTDENT_CONTENT_COMMAND, payload => $handleMultilineIndent(OUTDENT_CONTENT_COMMAND), COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_UP_COMMAND, payload => $handleShiftLines(KEY_ARROW_UP_COMMAND, payload), COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_ARROW_DOWN_COMMAND, payload => $handleShiftLines(KEY_ARROW_DOWN_COMMAND, payload), COMMAND_PRIORITY_LOW), editor.registerCommand(MOVE_TO_END, payload => $handleMoveTo(MOVE_TO_END, payload), COMMAND_PRIORITY_LOW), editor.registerCommand(MOVE_TO_START, payload => $handleMoveTo(MOVE_TO_START, payload), COMMAND_PRIORITY_LOW));
|
|
1139
1116
|
}
|
|
1140
1117
|
|
|
1141
1118
|
/**
|
package/LexicalCode.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalCode = process.env.NODE_ENV === 'development' ? require('./LexicalCode.dev.js') : require('./LexicalCode.prod.js');
|
|
9
11
|
module.exports = LexicalCode;
|
package/LexicalCode.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalCode.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalCode.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
package/LexicalCode.node.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalCode.dev.mjs') : import('./LexicalCode.prod.mjs'));
|
|
8
10
|
export const $createCodeHighlightNode = mod.$createCodeHighlightNode;
|
|
9
11
|
export const $createCodeNode = mod.$createCodeNode;
|
package/LexicalCode.prod.js
CHANGED
|
@@ -3,40 +3,42 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
require("prismjs/components/prism-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(
|
|
22
|
-
function Q(a,b
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
function
|
|
28
|
-
function W(a){
|
|
29
|
-
function
|
|
30
|
-
f.getKey()&&0===b.offset&&g.key===e.getKey()&&g.offset===e.getTextContentSize()?
|
|
31
|
-
|
|
32
|
-
b
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
a.registerCommand(m.
|
|
8
|
+
|
|
9
|
+
'use strict';require("prismjs");require("prismjs/components/prism-clike");require("prismjs/components/prism-javascript");require("prismjs/components/prism-markup");require("prismjs/components/prism-markdown");require("prismjs/components/prism-c");require("prismjs/components/prism-css");require("prismjs/components/prism-objectivec");require("prismjs/components/prism-sql");require("prismjs/components/prism-powershell");require("prismjs/components/prism-python");require("prismjs/components/prism-rust");
|
|
10
|
+
require("prismjs/components/prism-swift");require("prismjs/components/prism-typescript");require("prismjs/components/prism-java");require("prismjs/components/prism-cpp");var d=require("@lexical/utils"),m=require("lexical");"use strict";var q;
|
|
11
|
+
function v(a){let b=new URLSearchParams;b.append("code",a);for(let c=1;c<arguments.length;c++)b.append("v",arguments[c]);throw Error(`Minified Lexical error #${a}; visit https://lexical.dev/docs/error?${b} for the full message or `+"use the non-minified dev environment for full errors and additional helpful warnings.");}q=v&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v["default"]:v;let x=a=>null!=a&&window.Prism.languages.hasOwnProperty(a)?a:void 0;
|
|
12
|
+
function y(a,b){for(let c of a.childNodes){if(d.isHTMLElement(c)&&c.tagName===b)return!0;y(c,b)}return!1}
|
|
13
|
+
class z extends m.ElementNode{static getType(){return"code"}static clone(a){return new z(a.__language,a.__key)}constructor(a,b){super(b);this.__language=x(a)}createDOM(a){let b=document.createElement("code");d.addClassNamesToElement(b,a.theme.code);b.setAttribute("spellcheck","false");(a=this.getLanguage())&&b.setAttribute("data-highlight-language",a);return b}updateDOM(a,b){let c=this.__language;a=a.__language;c?c!==a&&b.setAttribute("data-highlight-language",c):a&&b.removeAttribute("data-highlight-language");
|
|
14
|
+
return!1}exportDOM(a){let b=document.createElement("pre");d.addClassNamesToElement(b,a._config.theme.code);b.setAttribute("spellcheck","false");(a=this.getLanguage())&&b.setAttribute("data-highlight-language",a);return{element:b}}static importDOM(){return{code:a=>null!=a.textContent&&(/\r?\n/.test(a.textContent)||y(a,"BR"))?{conversion:A,priority:1}:null,div:()=>({conversion:aa,priority:1}),pre:()=>({conversion:A,priority:0}),table:a=>B(a)?{conversion:ba,priority:3}:null,td:a=>{let b=a.closest("table");
|
|
15
|
+
return a.classList.contains("js-file-line")||b&&B(b)?{conversion:C,priority:3}:null},tr:a=>(a=a.closest("table"))&&B(a)?{conversion:C,priority:3}:null}}static importJSON(a){let b=D(a.language);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),type:"code",version:1}}insertNewAfter(a,b=!0){var c=this.getChildren(),e=c.length;if(2<=e&&"\n"===c[e-1].getTextContent()&&"\n"===c[e-2].getTextContent()&&a.isCollapsed()&&
|
|
16
|
+
a.anchor.key===this.__key&&a.anchor.offset===e)return c[e-1].remove(),c[e-2].remove(),a=m.$createParagraphNode(),this.insertAfter(a,b),a;let {anchor:f,focus:g}=a;b=(f.isBefore(g)?f:g).getNode();if(m.$isTextNode(b)){e=E(b);for(c=[];;)if(m.$isTabNode(e))c.push(m.$createTabNode()),e=e.getNextSibling();else if(F(e)){for(var h=0,k=e.getTextContent(),l=e.getTextContentSize();h<l&&" "===k[h];)h++;0!==h&&c.push(G(" ".repeat(h)));if(h!==l)break;e=e.getNextSibling()}else break;e=b.splitText(f.offset)[0];h=
|
|
17
|
+
0===f.offset?0:1;h=e.getIndexWithinParent()+h;k=b.getParentOrThrow();l=[m.$createLineBreakNode(),...c];k.splice(h,0,l);(c=c[c.length-1])?c.select():0===f.offset?e.selectPrevious():e.getNextSibling().selectNext(0,0)}H(b)&&({offset:a}=a.anchor,b.splice(a,0,[m.$createLineBreakNode()]),b.select(a+1,a+1));return null}canIndent(){return!1}collapseAtStart(){let a=m.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}setLanguage(a){this.getWritable().__language=x(a)}getLanguage(){return this.getLatest().__language}}
|
|
18
|
+
function D(a){return m.$applyNodeReplacement(new z(a))}function H(a){return a instanceof z}function A(a){a=a.getAttribute("data-highlight-language");return{node:D(a)}}function aa(a){let b=null!==a.style.fontFamily.match("monospace");var c;if(c=!b){a:{for(a=a.parentElement;null!==a;){if(null!==a.style.fontFamily.match("monospace")){a=!0;break a}a=a.parentElement}a=!1}c=!a}return c?{node:null}:{node:b?D():null}}function ba(){return{node:D()}}function C(){return{node:null}}
|
|
19
|
+
function B(a){return a.classList.contains("js-file-line-container")}let I={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},J={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function L(a){return J[a]||a}
|
|
20
|
+
class M extends m.TextNode{constructor(a,b,c){super(a,c);this.__highlightType=b}static getType(){return"code-highlight"}static clone(a){return new M(a.__text,a.__highlightType||void 0,a.__key)}getHighlightType(){return this.getLatest().__highlightType}canHaveFormat(){return!1}createDOM(a){let b=super.createDOM(a);a=N(a.theme,this.__highlightType);d.addClassNamesToElement(b,a);return b}updateDOM(a,b,c){let e=super.updateDOM(a,b,c);a=N(c.theme,a.__highlightType);c=N(c.theme,this.__highlightType);a!==
|
|
21
|
+
c&&(a&&d.removeClassNamesFromElement(b,a),c&&d.addClassNamesToElement(b,c));return e}static importJSON(a){let b=G(a.text,a.highlightType);b.setFormat(a.format);b.setDetail(a.detail);b.setMode(a.mode);b.setStyle(a.style);return b}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(){return this}isParentRequired(){return!0}createParentElementNode(){return D()}}function N(a,b){return b&&a&&a.codeHighlight&&a.codeHighlight[b]}
|
|
22
|
+
function G(a,b){return m.$applyNodeReplacement(new M(a,b))}function F(a){return a instanceof M}function E(a){let b=a;for(;F(a)||m.$isTabNode(a);)b=a,a=a.getPreviousSibling();return b}function O(a){let b=a;for(;F(a)||m.$isTabNode(a);)b=a,a=a.getNextSibling();return b}let P={defaultLanguage:"javascript",tokenize(a,b){return window.Prism.tokenize(a,window.Prism.languages[b||""]||window.Prism.languages[this.defaultLanguage])}};
|
|
23
|
+
function Q(a,b){let c=null;var e=null,f=a;let g=b,h=a.getTextContent();for(;;){if(0===g){f=f.getPreviousSibling();if(null===f)break;F(f)||m.$isTabNode(f)||m.$isLineBreakNode(f)||q(167);if(m.$isLineBreakNode(f)){c={node:f,offset:1};break}g=Math.max(0,f.getTextContentSize()-1);h=f.getTextContent()}else g--;let k=h[g];F(f)&&" "!==k&&(e={node:f,offset:g})}if(null!==e)return e;e=null;b<a.getTextContentSize()?F(a)&&(e=a.getTextContent()[b]):(f=a.getNextSibling(),F(f)&&(e=f.getTextContent()[0]));if(null!==
|
|
24
|
+
e&&" "!==e)return c;a:for(e=a,f=a.getTextContent(),a=a.getTextContentSize();;){if(!F(e)||b===a){e=e.getNextSibling();if(null===e||m.$isLineBreakNode(e)){a=null;break a}F(e)&&(b=0,f=e.getTextContent(),a=e.getTextContentSize())}if(F(e)){if(" "!==f[b]){a={node:e,offset:b};break a}b++}}return null!==a?a:c}function R(a){a=O(a);m.$isLineBreakNode(a)&&q(168);return a}function S(a,b,c){let e=a.getParent();H(e)?T(e,b,c):F(a)&&a.replace(m.$createTextNode(a.__text))}let U=new Set;
|
|
25
|
+
function T(a,b,c){let e=a.getKey();U.has(e)||(U.add(e),void 0===a.getLanguage()&&a.setLanguage(c.defaultLanguage),b.update(()=>{ca(e,()=>{var f=m.$getNodeByKey(e);if(!H(f)||!f.isAttached())return!1;var g=f.getTextContent();g=c.tokenize(g,f.getLanguage()||c.defaultLanguage);g=V(g);var h=f.getChildren();for(f=0;f<h.length&&W(h[f],g[f]);)f++;var k=h.length;let l=g.length,r=Math.min(k,l)-f,n=0;for(;n<r;)if(n++,!W(h[k-n],g[l-n])){n--;break}h=f;k-=n;g=g.slice(f,l-n);let {from:p,to:w,nodesForReplacement:u}=
|
|
26
|
+
{from:h,nodesForReplacement:g,to:k};return p!==w||u.length?(a.splice(p,w-p,u),!0):!1})},{onUpdate:()=>{U.delete(e)},skipTransforms:!0}))}
|
|
27
|
+
function V(a,b){let c=[];for(let e of a)if("string"===typeof e){a=e.split(/(\n|\t)/);let f=a.length;for(let g=0;g<f;g++){let h=a[g];"\n"===h||"\r\n"===h?c.push(m.$createLineBreakNode()):"\t"===h?c.push(m.$createTabNode()):0<h.length&&c.push(G(h,b))}}else({content:a}=e),"string"===typeof a?c.push(...V([a],e.type)):Array.isArray(a)&&c.push(...V(a,e.type));return c}
|
|
28
|
+
function ca(a,b){a=m.$getNodeByKey(a);if(H(a)&&a.isAttached()){var c=m.$getSelection();if(m.$isRangeSelection(c)){c=c.anchor;var e=c.offset,f="element"===c.type&&m.$isLineBreakNode(a.getChildAtIndex(c.offset-1)),g=0;if(!f){let h=c.getNode();g=e+h.getPreviousSiblings().reduce((k,l)=>k+l.getTextContentSize(),0)}b()&&(f?c.getNode().select(e,e):a.getChildren().some(h=>{let k=m.$isTextNode(h);if(k||m.$isLineBreakNode(h)){let l=h.getTextContentSize();if(k&&l>=g)return h.select(g,g),!0;g-=l}return!1}))}else b()}}
|
|
29
|
+
function W(a,b){return F(a)&&F(b)&&a.__text===b.__text&&a.__highlightType===b.__highlightType||m.$isTabNode(a)&&m.$isTabNode(b)||m.$isLineBreakNode(a)&&m.$isLineBreakNode(b)}function X(a){if(!m.$isRangeSelection(a))return!1;var b=a.anchor.getNode();a=a.focus.getNode();if(b.is(a)&&H(b))return!0;b=b.getParent();return H(b)&&b.is(a.getParent())}
|
|
30
|
+
function Y(a){a=a.getNodes();let b=[[]];if(1===a.length&&H(a[0]))return b;let c=b[0];for(let e=0;e<a.length;e++){let f=a[e];F(f)||m.$isTabNode(f)||m.$isLineBreakNode(f)||q(169);m.$isLineBreakNode(f)?0!==e&&0<c.length&&(c=[],b.push(c)):c.push(f)}return b}
|
|
31
|
+
function da(a){var b=m.$getSelection();if(!m.$isRangeSelection(b)||!X(b))return null;let c=a?m.OUTDENT_CONTENT_COMMAND:m.INDENT_CONTENT_COMMAND;a=a?m.OUTDENT_CONTENT_COMMAND:m.INSERT_TAB_COMMAND;if(1<Y(b).length)return c;var e=b.getNodes()[0];H(e)||F(e)||m.$isTabNode(e)||m.$isLineBreakNode(e)||q(170);if(H(e))return c;let f=E(e);e=O(e);var g=b.anchor;let h=b.focus;h.isBefore(g)?b=h:(b=g,g=h);return null!==f&&null!==e&&b.key===f.getKey()&&0===b.offset&&g.key===e.getKey()&&g.offset===e.getTextContentSize()?
|
|
32
|
+
c:a}
|
|
33
|
+
function Z(a){var b=m.$getSelection();if(!m.$isRangeSelection(b)||!X(b))return!1;var c=Y(b);let e=c.length;if(1<c.length){for(b=0;b<e;b++){var f=c[b];0<f.length&&(f=f[0],0===b&&(f=E(f)),null!==f&&(a===m.INDENT_CONTENT_COMMAND?f.insertBefore(m.$createTabNode()):m.$isTabNode(f)&&f.remove()))}return!0}c=b.getNodes()[0];H(c)||F(c)||m.$isTabNode(c)||m.$isLineBreakNode(c)||q(171);if(H(c))return a===m.INDENT_CONTENT_COMMAND&&b.insertNodes([m.$createTabNode()]),!0;c=E(c);null===c&&q(172);a===m.INDENT_CONTENT_COMMAND?m.$isLineBreakNode(c)?
|
|
34
|
+
c.insertAfter(m.$createTabNode()):c.insertBefore(m.$createTabNode()):m.$isTabNode(c)&&c.remove();return!0}
|
|
35
|
+
function ea(a,b){let c=m.$getSelection();if(!m.$isRangeSelection(c))return!1;let {anchor:e,focus:f}=c,g=e.offset,h=f.offset,k=e.getNode(),l=f.getNode();var r=a===m.KEY_ARROW_UP_COMMAND;if(!X(c)||!F(k)&&!m.$isTabNode(k)||!F(l)&&!m.$isTabNode(l))return!1;if(!b.altKey){if(c.isCollapsed())if(a=k.getParentOrThrow(),r&&0===g&&null===k.getPreviousSibling()){if(null===a.getPreviousSibling())return a.selectPrevious(),b.preventDefault(),!0}else if(!r&&g===k.getTextContentSize()&&null===k.getNextSibling()&&
|
|
36
|
+
null===a.getNextSibling())return a.selectNext(),b.preventDefault(),!0;return!1}let n;if(k.isBefore(l)){var p=E(k);n=O(l)}else p=E(l),n=O(k);if(null==p||null==n)return!1;let w=p.getNodesBetween(n);for(let t=0;t<w.length;t++){let K=w[t];if(!F(K)&&!m.$isTabNode(K)&&!m.$isLineBreakNode(K))return!1}b.preventDefault();b.stopPropagation();b=r?p.getPreviousSibling():n.getNextSibling();if(!m.$isLineBreakNode(b))return!0;p=r?b.getPreviousSibling():b.getNextSibling();if(null==p)return!0;r=F(p)||m.$isTabNode(p)||
|
|
37
|
+
m.$isLineBreakNode(p)?r?E(p):O(p):null;let u=null!=r?r:p;b.remove();w.forEach(t=>t.remove());a===m.KEY_ARROW_UP_COMMAND?(w.forEach(t=>u.insertBefore(t)),u.insertBefore(b)):(u.insertAfter(b),u=b,w.forEach(t=>{u.insertAfter(t);u=t}));c.setTextNodeRange(k,g,l,h);return!0}
|
|
38
|
+
function fa(a,b){let c=m.$getSelection();if(!m.$isRangeSelection(c))return!1;let {anchor:e,focus:f}=c;var g=e.getNode();let h=f.getNode();a=a===m.MOVE_TO_START;if(!F(g)&&!m.$isTabNode(g)||!F(h)&&!m.$isTabNode(h))return!1;if(a)if(g=Q(h,f.offset),null!==g){let {node:k,offset:l}=g;m.$isLineBreakNode(k)?k.selectNext(0,0):c.setTextNodeRange(k,l,k,l)}else h.getParentOrThrow().selectStart();else R(h).select();b.preventDefault();b.stopPropagation();return!0}exports.$createCodeHighlightNode=G;
|
|
39
|
+
exports.$createCodeNode=D;exports.$isCodeHighlightNode=F;exports.$isCodeNode=H;exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP=I;exports.CODE_LANGUAGE_MAP=J;exports.CodeHighlightNode=M;exports.CodeNode=z;exports.DEFAULT_CODE_LANGUAGE="javascript";exports.PrismTokenizer=P;exports.getCodeLanguages=()=>Object.keys(window.Prism.languages).filter(a=>"function"!==typeof window.Prism.languages[a]).sort();exports.getDefaultCodeLanguage=()=>"javascript";exports.getEndOfCodeInLine=R;
|
|
40
|
+
exports.getFirstCodeNodeOfLine=E;exports.getLanguageFriendlyName=function(a){a=L(a);return I[a]||a};exports.getLastCodeNodeOfLine=O;exports.getStartOfCodeInLine=Q;exports.normalizeCodeLang=L;
|
|
41
|
+
exports.registerCodeHighlighting=function(a,b){if(!a.hasNodes([z,M]))throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==b&&(b=P);return d.mergeRegister(a.registerMutationListener(z,c=>{a.update(()=>{for(let [g,h]of c)if("destroyed"!==h){var e=m.$getNodeByKey(g);if(null!==e)a:{var f=e;e=a.getElementByKey(f.getKey());if(null===e)break a;f=f.getChildren();let k=f.length;if(k===e.__cachedChildrenLength)break a;e.__cachedChildrenLength=k;let l="1",r=1;for(let n=
|
|
42
|
+
0;n<k;n++)m.$isLineBreakNode(f[n])&&(l+="\n"+ ++r);e.setAttribute("data-gutter",l)}}})}),a.registerNodeTransform(z,c=>T(c,a,b)),a.registerNodeTransform(m.TextNode,c=>S(c,a,b)),a.registerNodeTransform(M,c=>S(c,a,b)),a.registerCommand(m.KEY_TAB_COMMAND,c=>{let e=da(c.shiftKey);if(null===e)return!1;c.preventDefault();a.dispatchCommand(e,void 0);return!0},m.COMMAND_PRIORITY_LOW),a.registerCommand(m.INSERT_TAB_COMMAND,()=>{let c=m.$getSelection();if(!X(c))return!1;m.$insertNodes([m.$createTabNode()]);
|
|
43
|
+
return!0},m.COMMAND_PRIORITY_LOW),a.registerCommand(m.INDENT_CONTENT_COMMAND,()=>Z(m.INDENT_CONTENT_COMMAND),m.COMMAND_PRIORITY_LOW),a.registerCommand(m.OUTDENT_CONTENT_COMMAND,()=>Z(m.OUTDENT_CONTENT_COMMAND),m.COMMAND_PRIORITY_LOW),a.registerCommand(m.KEY_ARROW_UP_COMMAND,c=>ea(m.KEY_ARROW_UP_COMMAND,c),m.COMMAND_PRIORITY_LOW),a.registerCommand(m.KEY_ARROW_DOWN_COMMAND,c=>ea(m.KEY_ARROW_DOWN_COMMAND,c),m.COMMAND_PRIORITY_LOW),a.registerCommand(m.MOVE_TO_END,c=>fa(m.MOVE_TO_END,c),m.COMMAND_PRIORITY_LOW),
|
|
44
|
+
a.registerCommand(m.MOVE_TO_START,c=>fa(m.MOVE_TO_START,c),m.COMMAND_PRIORITY_LOW))}
|
package/LexicalCode.prod.mjs
CHANGED
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
6
7
|
*/
|
|
7
|
-
import"prismjs";import"prismjs/components/prism-clike.js";import"prismjs/components/prism-javascript.js";import"prismjs/components/prism-markup.js";import"prismjs/components/prism-markdown.js";import"prismjs/components/prism-c.js";import"prismjs/components/prism-css.js";import"prismjs/components/prism-objectivec.js";import"prismjs/components/prism-sql.js";import"prismjs/components/prism-python.js";import"prismjs/components/prism-rust.js";import"prismjs/components/prism-swift.js";import"prismjs/components/prism-typescript.js";import"prismjs/components/prism-java.js";import"prismjs/components/prism-cpp.js";import{isHTMLElement as e,addClassNamesToElement as t,removeClassNamesFromElement as n,mergeRegister as r}from"@lexical/utils";import{ElementNode as o,$applyNodeReplacement as i,$createParagraphNode as s,$isTextNode as l,$isTabNode as c,$createTabNode as u,$createLineBreakNode as g,TextNode as a,$isLineBreakNode as f,$createTextNode as p,$getNodeByKey as d,$getSelection as h,$isRangeSelection as m,INDENT_CONTENT_COMMAND as x,OUTDENT_CONTENT_COMMAND as N,INSERT_TAB_COMMAND as y,KEY_ARROW_UP_COMMAND as C,MOVE_TO_START as v,KEY_TAB_COMMAND as T,COMMAND_PRIORITY_LOW as _,$insertNodes as b,KEY_ARROW_DOWN_COMMAND as j,MOVE_TO_END as S}from"lexical";const w=e=>null!=e&&window.Prism.languages.hasOwnProperty(e)?e:void 0;function k(t,n){for(const r of t.childNodes){if(e(r)&&r.tagName===n)return!0;k(r,n)}return!1}const P="data-highlight-language";class L extends o{static getType(){return"code"}static clone(e){return new L(e.__language,e.__key)}constructor(e,t){super(t),this.__language=w(e)}createDOM(e){const n=document.createElement("code");t(n,e.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&n.setAttribute(P,r),n}updateDOM(e,t,n){const r=this.__language,o=e.__language;return r?r!==o&&t.setAttribute(P,r):o&&t.removeAttribute(P),!1}exportDOM(e){const n=document.createElement("pre");t(n,e._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&n.setAttribute(P,r),{element:n}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||k(e,"BR"))?{conversion:A,priority:1}:null,div:e=>({conversion:D,priority:1}),pre:e=>({conversion:A,priority:0}),table:e=>F(e)?{conversion:M,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")?{conversion:z,priority:3}:n&&F(n)?{conversion:B,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&F(t)?{conversion:B,priority:3}:null}}}static importJSON(e){const t=E(e.language);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),type:"code",version:1}}insertNewAfter(e,t=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const e=s();return this.insertAfter(e,t),e}const{anchor:o,focus:i}=e,a=(o.isBefore(i)?o:i).getNode();if(l(a)){let e=Y(a);const t=[];for(;;)if(c(e))t.push(u()),e=e.getNextSibling();else{if(!V(e))break;{let n=0;const r=e.getTextContent(),o=e.getTextContentSize();for(;n<o&&" "===r[n];)n++;if(0!==n&&t.push(G(" ".repeat(n))),n!==o)break;e=e.getNextSibling()}}const n=a.splitText(o.offset)[0],r=0===o.offset?0:1,i=n.getIndexWithinParent()+r,s=a.getParentOrThrow(),l=[g(),...t];s.splice(i,0,l);const f=t[t.length-1];f?f.select():0===o.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0)}if(O(a)){const{offset:t}=e.anchor;a.splice(t,0,[g()]),a.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const e=s();return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}setLanguage(e){this.getWritable().__language=w(e)}getLanguage(){return this.getLatest().__language}}function E(e){return i(new L(e))}function O(e){return e instanceof L}function A(t){let n;return e(t)&&(n=t.getAttribute(P)),{node:E(n)}}function D(e){const t=e,n=H(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(H(t))return!0;t=t.parentElement}return!1}(t)?{after:t=>{const n=e.parentNode;return null!=n&&e!==n.lastChild&&t.push(g()),t},node:n?E():null}:{node:null}}function M(){return{node:E()}}function B(){return{node:null}}function z(e){const t=e;return{after:e=>(t.parentNode&&t.parentNode.nextSibling&&e.push(g()),e),node:null}}function H(e){return null!==e.style.fontFamily.match("monospace")}function F(e){return e.classList.contains("js-file-line-container")}const J="javascript",K={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},R={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function I(e){return R[e]||e}function q(e){const t=I(e);return K[t]||t}const U=()=>J,W=()=>Object.keys(window.Prism.languages).filter((e=>"function"!=typeof window.Prism.languages[e])).sort();class Q extends a{constructor(e,t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new Q(e.__text,e.__highlightType||void 0,e.__key)}getHighlightType(){return this.getLatest().__highlightType}canHaveFormat(){return!1}createDOM(e){const n=super.createDOM(e),r=X(e.theme,this.__highlightType);return t(n,r),n}updateDOM(e,r,o){const i=super.updateDOM(e,r,o),s=X(o.theme,e.__highlightType),l=X(o.theme,this.__highlightType);return s!==l&&(s&&n(r,s),l&&t(r,l)),i}static importJSON(e){const t=G(e.text,e.highlightType);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return E()}}function X(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function G(e,t){return i(new Q(e,t))}function V(e){return e instanceof Q}function Y(e){let t=e,n=e;for(;V(n)||c(n);)t=n,n=n.getPreviousSibling();return t}function Z(e){let t=e,n=e;for(;V(n)||c(n);)t=n,n=n.getNextSibling();return t}const $={defaultLanguage:J,tokenize(e,t){return window.Prism.tokenize(e,window.Prism.languages[t||""]||window.Prism.languages[this.defaultLanguage])}};function ee(e,t){let n=null,r=null,o=e,i=t,s=e.getTextContent();for(;;){if(0===i){if(o=o.getPreviousSibling(),null===o)break;if(!(V(o)||c(o)||f(o)))throw Error("Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode");if(f(o)){n={node:o,offset:1};break}i=Math.max(0,o.getTextContentSize()-1),s=o.getTextContent()}else i--;const e=s[i];V(o)&&" "!==e&&(r={node:o,offset:i})}if(null!==r)return r;let l=null;if(t<e.getTextContentSize())V(e)&&(l=e.getTextContent()[t]);else{const t=e.getNextSibling();V(t)&&(l=t.getTextContent()[0])}if(null!==l&&" "!==l)return n;{const r=function(e,t){let n=e,r=t,o=e.getTextContent(),i=e.getTextContentSize();for(;;){if(!V(n)||r===i){if(n=n.getNextSibling(),null===n||f(n))return null;V(n)&&(r=0,o=n.getTextContent(),i=n.getTextContentSize())}if(V(n)){if(" "!==o[r])return{node:n,offset:r};r++}}}(e,t);return null!==r?r:n}}function te(e){const t=Z(e);if(f(t))throw Error("Unexpected lineBreakNode in getEndOfCodeInLine");return t}function ne(e,t,n){const r=e.getParent();O(r)?ie(r,t,n):V(e)&&e.replace(p(e.__text))}function re(e,t){const n=t.getElementByKey(e.getKey());if(null===n)return;const r=e.getChildren(),o=r.length;if(o===n.__cachedChildrenLength)return;n.__cachedChildrenLength=o;let i="1",s=1;for(let e=0;e<o;e++)f(r[e])&&(i+="\n"+ ++s);n.setAttribute("data-gutter",i)}const oe=new Set;function ie(e,t,n){const r=e.getKey();oe.has(r)||(oe.add(r),void 0===e.getLanguage()&&e.setLanguage(n.defaultLanguage),t.update((()=>{!function(e,t){const n=d(e);if(!O(n)||!n.isAttached())return;const r=h();if(!m(r))return void t();const o=r.anchor,i=o.offset,s="element"===o.type&&f(n.getChildAtIndex(o.offset-1));let c=0;if(!s){const e=o.getNode();c=i+e.getPreviousSiblings().reduce(((e,t)=>e+t.getTextContentSize()),0)}if(!t())return;if(s)return void o.getNode().select(i,i);n.getChildren().some((e=>{const t=l(e);if(t||f(e)){const n=e.getTextContentSize();if(t&&n>=c)return e.select(c,c),!0;c-=n}return!1}))}(r,(()=>{const t=d(r);if(!O(t)||!t.isAttached())return!1;const o=t.getTextContent(),i=se(n.tokenize(o,t.getLanguage()||n.defaultLanguage)),s=function(e,t){let n=0;for(;n<e.length&&le(e[n],t[n]);)n++;const r=e.length,o=t.length,i=Math.min(r,o)-n;let s=0;for(;s<i;)if(s++,!le(e[r-s],t[o-s])){s--;break}const l=n,c=r-s,u=t.slice(n,o-s);return{from:l,nodesForReplacement:u,to:c}}(t.getChildren(),i),{from:l,to:c,nodesForReplacement:u}=s;return!(l===c&&!u.length)&&(e.splice(l,c-l,u),!0)}))}),{onUpdate:()=>{oe.delete(r)},skipTransforms:!0}))}function se(e,t){const n=[];for(const r of e)if("string"==typeof r){const e=r.split(/(\n|\t)/),o=e.length;for(let r=0;r<o;r++){const o=e[r];"\n"===o||"\r\n"===o?n.push(g()):"\t"===o?n.push(u()):o.length>0&&n.push(G(o,t))}}else{const{content:e}=r;"string"==typeof e?n.push(...se([e],r.type)):Array.isArray(e)&&n.push(...se(e,r.type))}return n}function le(e,t){return V(e)&&V(t)&&e.__text===t.__text&&e.__highlightType===t.__highlightType||c(e)&&c(t)||f(e)&&f(t)}function ce(e){if(!m(e))return!1;const t=e.anchor.getNode(),n=e.focus.getNode();if(t.is(n)&&O(t))return!0;const r=t.getParent();return O(r)&&r.is(n.getParent())}function ue(e){const t=e.getNodes(),n=[[]];if(1===t.length&&O(t[0]))return n;let r=n[0];for(let e=0;e<t.length;e++){const o=t[e];if(!(V(o)||c(o)||f(o)))throw Error("Expected selection to be inside CodeBlock and consisting of CodeHighlightNode, TabNode and LineBreakNode");f(o)?0!==e&&r.length>0&&(r=[],n.push(r)):r.push(o)}return n}function ge(e){const t=h();if(!m(t)||!ce(t))return!1;const n=ue(t),r=n.length;if(n.length>1){for(let t=0;t<r;t++){const r=n[t];if(r.length>0){let n=r[0];0===t&&(n=Y(n)),null!==n&&(e===x?n.insertBefore(u()):c(n)&&n.remove())}}return!0}const o=t.getNodes()[0];if(!(O(o)||V(o)||c(o)||f(o)))throw Error("Expected selection firstNode to be CodeHighlightNode or CodeTabNode");if(O(o))return e===x&&t.insertNodes([u()]),!0;const i=Y(o);if(null===i)throw Error("Expected getFirstCodeNodeOfLine to return a valid Code Node");return e===x?f(i)?i.insertAfter(u()):i.insertBefore(u()):c(i)&&i.remove(),!0}function ae(e,t){const n=h();if(!m(n))return!1;const{anchor:r,focus:o}=n,i=r.offset,s=o.offset,l=r.getNode(),u=o.getNode(),g=e===C;if(!ce(n)||!V(l)&&!c(l)||!V(u)&&!c(u))return!1;if(!t.altKey){if(n.isCollapsed()){const e=l.getParentOrThrow();if(g&&0===i&&null===l.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!0}else if(!g&&i===l.getTextContentSize()&&null===l.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!0}}return!1}let a,p;if(l.isBefore(u)?(a=Y(l),p=Z(u)):(a=Y(u),p=Z(l)),null==a||null==p)return!1;const d=a.getNodesBetween(p);for(let e=0;e<d.length;e++){const t=d[e];if(!V(t)&&!c(t)&&!f(t))return!1}t.preventDefault(),t.stopPropagation();const x=g?a.getPreviousSibling():p.getNextSibling();if(!f(x))return!0;const N=g?x.getPreviousSibling():x.getNextSibling();if(null==N)return!0;const y=V(N)||c(N)||f(N)?g?Y(N):Z(N):null;let v=null!=y?y:N;return x.remove(),d.forEach((e=>e.remove())),e===C?(d.forEach((e=>v.insertBefore(e))),v.insertBefore(x)):(v.insertAfter(x),v=x,d.forEach((e=>{v.insertAfter(e),v=e}))),n.setTextNodeRange(l,i,u,s),!0}function fe(e,t){const n=h();if(!m(n))return!1;const{anchor:r,focus:o}=n,i=r.getNode(),s=o.getNode(),l=e===v;if(!V(i)&&!c(i)||!V(s)&&!c(s))return!1;if(l){const e=ee(s,o.offset);if(null!==e){const{node:t,offset:r}=e;f(t)?t.selectNext(0,0):n.setTextNodeRange(t,r,t,r)}else s.getParentOrThrow().selectStart()}else{te(s).select()}return t.preventDefault(),t.stopPropagation(),!0}function pe(e,t){if(!e.hasNodes([L,Q]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return null==t&&(t=$),r(e.registerMutationListener(L,(t=>{e.update((()=>{for(const[n,r]of t)if("destroyed"!==r){const t=d(n);null!==t&&re(t,e)}}))})),e.registerNodeTransform(L,(n=>ie(n,e,t))),e.registerNodeTransform(a,(n=>ne(n,e,t))),e.registerNodeTransform(Q,(n=>ne(n,e,t))),e.registerCommand(T,(t=>{const n=function(e){const t=h();if(!m(t)||!ce(t))return null;const n=e?N:x,r=e?N:y;if(ue(t).length>1)return n;const o=t.getNodes()[0];if(!(O(o)||V(o)||c(o)||f(o)))throw Error("Expected selection firstNode to be CodeHighlightNode or TabNode");if(O(o))return n;const i=Y(o),s=Z(o),l=t.anchor,u=t.focus;let g,a;return u.isBefore(l)?(g=u,a=l):(g=l,a=u),null!==i&&null!==s&&g.key===i.getKey()&&0===g.offset&&a.key===s.getKey()&&a.offset===s.getTextContentSize()?n:r}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)}),_),e.registerCommand(y,(()=>!!ce(h())&&(b([u()]),!0)),_),e.registerCommand(x,(e=>ge(x)),_),e.registerCommand(N,(e=>ge(N)),_),e.registerCommand(C,(e=>ae(C,e)),_),e.registerCommand(j,(e=>ae(j,e)),_),e.registerCommand(S,(e=>fe(S,e)),_),e.registerCommand(v,(e=>fe(v,e)),_))}export{G as $createCodeHighlightNode,E as $createCodeNode,V as $isCodeHighlightNode,O as $isCodeNode,K as CODE_LANGUAGE_FRIENDLY_NAME_MAP,R as CODE_LANGUAGE_MAP,Q as CodeHighlightNode,L as CodeNode,J as DEFAULT_CODE_LANGUAGE,$ as PrismTokenizer,W as getCodeLanguages,U as getDefaultCodeLanguage,te as getEndOfCodeInLine,Y as getFirstCodeNodeOfLine,q as getLanguageFriendlyName,Z as getLastCodeNodeOfLine,ee as getStartOfCodeInLine,I as normalizeCodeLang,pe as registerCodeHighlighting};
|
|
8
|
+
|
|
9
|
+
import"prismjs";import"prismjs/components/prism-clike.js";import"prismjs/components/prism-javascript.js";import"prismjs/components/prism-markup.js";import"prismjs/components/prism-markdown.js";import"prismjs/components/prism-c.js";import"prismjs/components/prism-css.js";import"prismjs/components/prism-objectivec.js";import"prismjs/components/prism-sql.js";import"prismjs/components/prism-powershell.js";import"prismjs/components/prism-python.js";import"prismjs/components/prism-rust.js";import"prismjs/components/prism-swift.js";import"prismjs/components/prism-typescript.js";import"prismjs/components/prism-java.js";import"prismjs/components/prism-cpp.js";import{isHTMLElement as e,addClassNamesToElement as t,removeClassNamesFromElement as n,mergeRegister as r}from"@lexical/utils";import{ElementNode as o,$createParagraphNode as i,$isTextNode as s,$isTabNode as l,$createTabNode as u,$createLineBreakNode as c,$applyNodeReplacement as a,TextNode as g,$isLineBreakNode as f,$createTextNode as p,$getNodeByKey as h,$getSelection as d,$isRangeSelection as m,INDENT_CONTENT_COMMAND as y,OUTDENT_CONTENT_COMMAND as x,INSERT_TAB_COMMAND as v,KEY_ARROW_UP_COMMAND as _,MOVE_TO_START as C,KEY_TAB_COMMAND as T,COMMAND_PRIORITY_LOW as j,$insertNodes as N,KEY_ARROW_DOWN_COMMAND as S,MOVE_TO_END as b}from"lexical";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function w(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var P=w((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const k=e=>null!=e&&window.Prism.languages.hasOwnProperty(e)?e:void 0;function L(t,n){for(const r of t.childNodes){if(e(r)&&r.tagName===n)return!0;L(r,n)}return!1}const O="data-highlight-language";class A extends o{static getType(){return"code"}static clone(e){return new A(e.__language,e.__key)}constructor(e,t){super(t),this.__language=k(e)}createDOM(e){const n=document.createElement("code");t(n,e.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&n.setAttribute(O,r),n}updateDOM(e,t,n){const r=this.__language,o=e.__language;return r?r!==o&&t.setAttribute(O,r):o&&t.removeAttribute(O),!1}exportDOM(e){const n=document.createElement("pre");t(n,e._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&n.setAttribute(O,r),{element:n}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||L(e,"BR"))?{conversion:z,priority:1}:null,div:()=>({conversion:E,priority:1}),pre:()=>({conversion:z,priority:0}),table:e=>R(e)?{conversion:B,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&R(n)?{conversion:H,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&R(t)?{conversion:H,priority:3}:null}}}static importJSON(e){const t=M(e.language);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),type:"code",version:1}}insertNewAfter(e,t=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const e=i();return this.insertAfter(e,t),e}const{anchor:o,focus:a}=e,g=(o.isBefore(a)?o:a).getNode();if(s(g)){let e=Y(g);const t=[];for(;;)if(l(e))t.push(u()),e=e.getNextSibling();else{if(!V(e))break;{let n=0;const r=e.getTextContent(),o=e.getTextContentSize();for(;n<o&&" "===r[n];)n++;if(0!==n&&t.push(G(" ".repeat(n))),n!==o)break;e=e.getNextSibling()}}const n=g.splitText(o.offset)[0],r=0===o.offset?0:1,i=n.getIndexWithinParent()+r,s=g.getParentOrThrow(),a=[c(),...t];s.splice(i,0,a);const f=t[t.length-1];f?f.select():0===o.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0)}if(D(g)){const{offset:t}=e.anchor;g.splice(t,0,[c()]),g.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){const e=i();return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}setLanguage(e){this.getWritable().__language=k(e)}getLanguage(){return this.getLatest().__language}}function M(e){return a(new A(e))}function D(e){return e instanceof A}function z(e){return{node:M(e.getAttribute(O))}}function E(e){const t=e,n=J(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if(J(t))return!0;t=t.parentElement}return!1}(t)?{node:n?M():null}:{node:null}}function B(){return{node:M()}}function H(){return{node:null}}function J(e){return null!==e.style.fontFamily.match("monospace")}function R(e){return e.classList.contains("js-file-line-container")}const F="javascript",K={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},I={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function q(e){return I[e]||e}function U(e){const t=q(e);return K[t]||t}const W=()=>F,$=()=>Object.keys(window.Prism.languages).filter((e=>"function"!=typeof window.Prism.languages[e])).sort();class Q extends g{constructor(e,t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(e){return new Q(e.__text,e.__highlightType||void 0,e.__key)}getHighlightType(){return this.getLatest().__highlightType}canHaveFormat(){return!1}createDOM(e){const n=super.createDOM(e),r=X(e.theme,this.__highlightType);return t(n,r),n}updateDOM(e,r,o){const i=super.updateDOM(e,r,o),s=X(o.theme,e.__highlightType),l=X(o.theme,this.__highlightType);return s!==l&&(s&&n(r,s),l&&t(r,l)),i}static importJSON(e){const t=G(e.text,e.highlightType);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"code-highlight",version:1}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return M()}}function X(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function G(e,t){return a(new Q(e,t))}function V(e){return e instanceof Q}function Y(e){let t=e,n=e;for(;V(n)||l(n);)t=n,n=n.getPreviousSibling();return t}function Z(e){let t=e,n=e;for(;V(n)||l(n);)t=n,n=n.getNextSibling();return t}const ee={defaultLanguage:F,tokenize(e,t){return window.Prism.tokenize(e,window.Prism.languages[t||""]||window.Prism.languages[this.defaultLanguage])}};function te(e,t){let n=null,r=null,o=e,i=t,s=e.getTextContent();for(;;){if(0===i){if(o=o.getPreviousSibling(),null===o)break;if(V(o)||l(o)||f(o)||P(167),f(o)){n={node:o,offset:1};break}i=Math.max(0,o.getTextContentSize()-1),s=o.getTextContent()}else i--;const e=s[i];V(o)&&" "!==e&&(r={node:o,offset:i})}if(null!==r)return r;let u=null;if(t<e.getTextContentSize())V(e)&&(u=e.getTextContent()[t]);else{const t=e.getNextSibling();V(t)&&(u=t.getTextContent()[0])}if(null!==u&&" "!==u)return n;{const r=function(e,t){let n=e,r=t,o=e.getTextContent(),i=e.getTextContentSize();for(;;){if(!V(n)||r===i){if(n=n.getNextSibling(),null===n||f(n))return null;V(n)&&(r=0,o=n.getTextContent(),i=n.getTextContentSize())}if(V(n)){if(" "!==o[r])return{node:n,offset:r};r++}}}(e,t);return null!==r?r:n}}function ne(e){const t=Z(e);return f(t)&&P(168),t}function re(e,t,n){const r=e.getParent();D(r)?se(r,t,n):V(e)&&e.replace(p(e.__text))}function oe(e,t){const n=t.getElementByKey(e.getKey());if(null===n)return;const r=e.getChildren(),o=r.length;if(o===n.__cachedChildrenLength)return;n.__cachedChildrenLength=o;let i="1",s=1;for(let e=0;e<o;e++)f(r[e])&&(i+="\n"+ ++s);n.setAttribute("data-gutter",i)}const ie=new Set;function se(e,t,n){const r=e.getKey();ie.has(r)||(ie.add(r),void 0===e.getLanguage()&&e.setLanguage(n.defaultLanguage),t.update((()=>{!function(e,t){const n=h(e);if(!D(n)||!n.isAttached())return;const r=d();if(!m(r))return void t();const o=r.anchor,i=o.offset,l="element"===o.type&&f(n.getChildAtIndex(o.offset-1));let u=0;if(!l){const e=o.getNode();u=i+e.getPreviousSiblings().reduce(((e,t)=>e+t.getTextContentSize()),0)}if(!t())return;if(l)return void o.getNode().select(i,i);n.getChildren().some((e=>{const t=s(e);if(t||f(e)){const n=e.getTextContentSize();if(t&&n>=u)return e.select(u,u),!0;u-=n}return!1}))}(r,(()=>{const t=h(r);if(!D(t)||!t.isAttached())return!1;const o=t.getTextContent(),i=le(n.tokenize(o,t.getLanguage()||n.defaultLanguage)),s=function(e,t){let n=0;for(;n<e.length&&ue(e[n],t[n]);)n++;const r=e.length,o=t.length,i=Math.min(r,o)-n;let s=0;for(;s<i;)if(s++,!ue(e[r-s],t[o-s])){s--;break}const l=n,u=r-s,c=t.slice(n,o-s);return{from:l,nodesForReplacement:c,to:u}}(t.getChildren(),i),{from:l,to:u,nodesForReplacement:c}=s;return!(l===u&&!c.length)&&(e.splice(l,u-l,c),!0)}))}),{onUpdate:()=>{ie.delete(r)},skipTransforms:!0}))}function le(e,t){const n=[];for(const r of e)if("string"==typeof r){const e=r.split(/(\n|\t)/),o=e.length;for(let r=0;r<o;r++){const o=e[r];"\n"===o||"\r\n"===o?n.push(c()):"\t"===o?n.push(u()):o.length>0&&n.push(G(o,t))}}else{const{content:e}=r;"string"==typeof e?n.push(...le([e],r.type)):Array.isArray(e)&&n.push(...le(e,r.type))}return n}function ue(e,t){return V(e)&&V(t)&&e.__text===t.__text&&e.__highlightType===t.__highlightType||l(e)&&l(t)||f(e)&&f(t)}function ce(e){if(!m(e))return!1;const t=e.anchor.getNode(),n=e.focus.getNode();if(t.is(n)&&D(t))return!0;const r=t.getParent();return D(r)&&r.is(n.getParent())}function ae(e){const t=e.getNodes(),n=[[]];if(1===t.length&&D(t[0]))return n;let r=n[0];for(let e=0;e<t.length;e++){const o=t[e];V(o)||l(o)||f(o)||P(169),f(o)?0!==e&&r.length>0&&(r=[],n.push(r)):r.push(o)}return n}function ge(e){const t=d();if(!m(t)||!ce(t))return!1;const n=ae(t),r=n.length;if(n.length>1){for(let t=0;t<r;t++){const r=n[t];if(r.length>0){let n=r[0];0===t&&(n=Y(n)),null!==n&&(e===y?n.insertBefore(u()):l(n)&&n.remove())}}return!0}const o=t.getNodes()[0];if(D(o)||V(o)||l(o)||f(o)||P(171),D(o))return e===y&&t.insertNodes([u()]),!0;const i=Y(o);return null===i&&P(172),e===y?f(i)?i.insertAfter(u()):i.insertBefore(u()):l(i)&&i.remove(),!0}function fe(e,t){const n=d();if(!m(n))return!1;const{anchor:r,focus:o}=n,i=r.offset,s=o.offset,u=r.getNode(),c=o.getNode(),a=e===_;if(!ce(n)||!V(u)&&!l(u)||!V(c)&&!l(c))return!1;if(!t.altKey){if(n.isCollapsed()){const e=u.getParentOrThrow();if(a&&0===i&&null===u.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!0}else if(!a&&i===u.getTextContentSize()&&null===u.getNextSibling()){if(null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!0}}return!1}let g,p;if(u.isBefore(c)?(g=Y(u),p=Z(c)):(g=Y(c),p=Z(u)),null==g||null==p)return!1;const h=g.getNodesBetween(p);for(let e=0;e<h.length;e++){const t=h[e];if(!V(t)&&!l(t)&&!f(t))return!1}t.preventDefault(),t.stopPropagation();const y=a?g.getPreviousSibling():p.getNextSibling();if(!f(y))return!0;const x=a?y.getPreviousSibling():y.getNextSibling();if(null==x)return!0;const v=V(x)||l(x)||f(x)?a?Y(x):Z(x):null;let C=null!=v?v:x;return y.remove(),h.forEach((e=>e.remove())),e===_?(h.forEach((e=>C.insertBefore(e))),C.insertBefore(y)):(C.insertAfter(y),C=y,h.forEach((e=>{C.insertAfter(e),C=e}))),n.setTextNodeRange(u,i,c,s),!0}function pe(e,t){const n=d();if(!m(n))return!1;const{anchor:r,focus:o}=n,i=r.getNode(),s=o.getNode(),u=e===C;if(!V(i)&&!l(i)||!V(s)&&!l(s))return!1;if(u){const e=te(s,o.offset);if(null!==e){const{node:t,offset:r}=e;f(t)?t.selectNext(0,0):n.setTextNodeRange(t,r,t,r)}else s.getParentOrThrow().selectStart()}else{ne(s).select()}return t.preventDefault(),t.stopPropagation(),!0}function he(e,t){if(!e.hasNodes([A,Q]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return null==t&&(t=ee),r(e.registerMutationListener(A,(t=>{e.update((()=>{for(const[n,r]of t)if("destroyed"!==r){const t=h(n);null!==t&&oe(t,e)}}))})),e.registerNodeTransform(A,(n=>se(n,e,t))),e.registerNodeTransform(g,(n=>re(n,e,t))),e.registerNodeTransform(Q,(n=>re(n,e,t))),e.registerCommand(T,(t=>{const n=function(e){const t=d();if(!m(t)||!ce(t))return null;const n=e?x:y,r=e?x:v;if(ae(t).length>1)return n;const o=t.getNodes()[0];if(D(o)||V(o)||l(o)||f(o)||P(170),D(o))return n;const i=Y(o),s=Z(o),u=t.anchor,c=t.focus;let a,g;return c.isBefore(u)?(a=c,g=u):(a=u,g=c),null!==i&&null!==s&&a.key===i.getKey()&&0===a.offset&&g.key===s.getKey()&&g.offset===s.getTextContentSize()?n:r}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)}),j),e.registerCommand(v,(()=>!!ce(d())&&(N([u()]),!0)),j),e.registerCommand(y,(e=>ge(y)),j),e.registerCommand(x,(e=>ge(x)),j),e.registerCommand(_,(e=>fe(_,e)),j),e.registerCommand(S,(e=>fe(S,e)),j),e.registerCommand(b,(e=>pe(b,e)),j),e.registerCommand(C,(e=>pe(C,e)),j))}export{G as $createCodeHighlightNode,M as $createCodeNode,V as $isCodeHighlightNode,D as $isCodeNode,K as CODE_LANGUAGE_FRIENDLY_NAME_MAP,I as CODE_LANGUAGE_MAP,Q as CodeHighlightNode,A as CodeNode,F as DEFAULT_CODE_LANGUAGE,ee as PrismTokenizer,$ as getCodeLanguages,W as getDefaultCodeLanguage,ne as getEndOfCodeInLine,Y as getFirstCodeNodeOfLine,U as getLanguageFriendlyName,Z as getLastCodeNodeOfLine,te as getStartOfCodeInLine,q as normalizeCodeLang,he as registerCodeHighlighting};
|
package/package.json
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"code"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.16.0",
|
|
12
12
|
"main": "LexicalCode.js",
|
|
13
13
|
"types": "index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@lexical/utils": "0.
|
|
16
|
-
"lexical": "0.
|
|
15
|
+
"@lexical/utils": "0.16.0",
|
|
16
|
+
"lexical": "0.16.0",
|
|
17
17
|
"prismjs": "^1.27.0"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|