@lexical/react 0.1.11 → 0.1.12

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.
Files changed (48) hide show
  1. package/DEPRECATED_useLexical.dev.js +3 -7
  2. package/DEPRECATED_useLexical.prod.js +1 -1
  3. package/DEPRECATED_useLexicalAutoFormatter.dev.js +14 -9
  4. package/DEPRECATED_useLexicalAutoFormatter.prod.js +18 -18
  5. package/DEPRECATED_useLexicalPlainText.dev.js +33 -27
  6. package/DEPRECATED_useLexicalPlainText.prod.js +12 -12
  7. package/DEPRECATED_useLexicalRichText.dev.js +43 -388
  8. package/DEPRECATED_useLexicalRichText.prod.js +17 -25
  9. package/LexicalAutoFormatterPlugin.d.ts +9 -0
  10. package/LexicalAutoFormatterPlugin.dev.js +14 -9
  11. package/LexicalAutoFormatterPlugin.prod.js +18 -18
  12. package/LexicalAutoLinkPlugin.d.ts +20 -0
  13. package/LexicalCharacterLimitPlugin.d.ts +11 -0
  14. package/LexicalClearEditorPlugin.d.ts +14 -0
  15. package/LexicalClearEditorPlugin.dev.js +22 -1
  16. package/LexicalClearEditorPlugin.prod.js +2 -1
  17. package/LexicalCollaborationPlugin.d.ts +49 -0
  18. package/LexicalCollaborationPlugin.js.flow +1 -1
  19. package/LexicalComposer.d.ts +22 -0
  20. package/LexicalComposer.dev.js +27 -5
  21. package/LexicalComposer.js.flow +2 -1
  22. package/LexicalComposer.prod.js +3 -3
  23. package/LexicalComposerContext.d.ts +24 -0
  24. package/LexicalComposerContext.js.flow +1 -1
  25. package/LexicalContentEditable.d.ts +32 -0
  26. package/LexicalContentEditable.dev.js +22 -1
  27. package/LexicalContentEditable.prod.js +3 -3
  28. package/LexicalHashtagPlugin.d.ts +9 -0
  29. package/LexicalHashtagPlugin.js.flow +0 -10
  30. package/LexicalHistoryPlugin.d.ts +29 -0
  31. package/LexicalHorizontalRuleNode.d.ts +23 -0
  32. package/LexicalLinkPlugin.d.ts +9 -0
  33. package/LexicalListPlugin.d.ts +9 -0
  34. package/LexicalNestedComposer.d.ts +20 -0
  35. package/LexicalOnChangePlugin.d.ts +12 -0
  36. package/LexicalPlainTextPlugin.d.ts +15 -0
  37. package/LexicalPlainTextPlugin.dev.js +11 -26
  38. package/LexicalPlainTextPlugin.prod.js +8 -8
  39. package/LexicalRichTextPlugin.d.ts +15 -0
  40. package/LexicalRichTextPlugin.dev.js +24 -390
  41. package/LexicalRichTextPlugin.prod.js +13 -21
  42. package/LexicalTablePlugin.d.ts +9 -0
  43. package/LexicalTreeView.d.ts +17 -0
  44. package/package.json +6 -5
  45. package/useLexicalDecoratorMap.d.ts +14 -0
  46. package/useLexicalIsTextContentEmpty.d.ts +13 -0
  47. package/useLexicalNodeSelection.d.ts +12 -0
  48. package/withSubscriptions.d.ts +12 -0
@@ -9,6 +9,7 @@
9
9
  var withSubscriptions = require('@lexical/react/withSubscriptions');
10
10
  var lexical = require('lexical');
11
11
  var react = require('react');
12
+ var clipboard = require('@lexical/clipboard');
12
13
 
13
14
  /**
14
15
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -347,188 +348,6 @@ function useLexicalHistory(editor, externalHistoryState, delay = 1000) {
347
348
  *
348
349
  */
349
350
 
350
- function $cloneWithProperties(node) {
351
- const latest = node.getLatest();
352
- const constructor = latest.constructor;
353
- const clone = constructor.clone(latest);
354
- clone.__parent = latest.__parent;
355
-
356
- if (lexical.$isElementNode(latest) && lexical.$isElementNode(clone)) {
357
- clone.__children = Array.from(latest.__children);
358
- clone.__format = latest.__format;
359
- clone.__indent = latest.__indent;
360
- clone.__dir = latest.__dir;
361
- } else if (lexical.$isTextNode(latest) && lexical.$isTextNode(clone)) {
362
- clone.__format = latest.__format;
363
- clone.__style = latest.__style;
364
- clone.__mode = latest.__mode;
365
- clone.__detail = latest.__detail;
366
- } else if (lexical.$isDecoratorNode(latest) && lexical.$isDecoratorNode(clone)) {
367
- clone.__state = latest.__state;
368
- } // $FlowFixMe
369
-
370
-
371
- return clone;
372
- }
373
-
374
- function $getIndexFromPossibleClone(node, parent, nodeMap) {
375
- const parentClone = nodeMap.get(parent.getKey());
376
-
377
- if (lexical.$isElementNode(parentClone)) {
378
- return parentClone.__children.indexOf(node.getKey());
379
- }
380
-
381
- return node.getIndexWithinParent();
382
- }
383
-
384
- function $getParentAvoidingExcludedElements(node) {
385
- let parent = node.getParent();
386
-
387
- while (parent !== null && parent.excludeFromCopy()) {
388
- parent = parent.getParent();
389
- }
390
-
391
- return parent;
392
- }
393
-
394
- function $copyLeafNodeBranchToRoot(leaf, startingOffset, isLeftSide, range, nodeMap) {
395
- let node = leaf;
396
- let offset = startingOffset;
397
-
398
- while (node !== null) {
399
- const parent = $getParentAvoidingExcludedElements(node);
400
-
401
- if (parent === null) {
402
- break;
403
- }
404
-
405
- if (!lexical.$isElementNode(node) || !node.excludeFromCopy()) {
406
- const key = node.getKey();
407
- let clone = nodeMap.get(key);
408
- const needsClone = clone === undefined;
409
-
410
- if (needsClone) {
411
- clone = $cloneWithProperties(node);
412
- nodeMap.set(key, clone);
413
- }
414
-
415
- if (lexical.$isTextNode(clone) && !clone.isSegmented() && !clone.isToken()) {
416
- clone.__text = clone.__text.slice(isLeftSide ? offset : 0, isLeftSide ? undefined : offset);
417
- } else if (lexical.$isElementNode(clone)) {
418
- clone.__children = clone.__children.slice(isLeftSide ? offset : 0, isLeftSide ? undefined : offset + 1);
419
- }
420
-
421
- if (lexical.$isRootNode(parent)) {
422
- if (needsClone) {
423
- // We only want to collect a range of top level nodes.
424
- // So if the parent is the root, we know this is a top level.
425
- range.push(key);
426
- }
427
-
428
- break;
429
- }
430
- }
431
-
432
- offset = $getIndexFromPossibleClone(node, parent, nodeMap);
433
- node = parent;
434
- }
435
- }
436
-
437
- function $cloneContents(selection) {
438
- if (!lexical.$isRangeSelection(selection)) {
439
- {
440
- throw Error(`TODO`);
441
- }
442
- }
443
-
444
- const anchor = selection.anchor;
445
- const focus = selection.focus;
446
- const anchorOffset = anchor.getCharacterOffset();
447
- const focusOffset = focus.getCharacterOffset();
448
- const anchorNode = anchor.getNode();
449
- const focusNode = focus.getNode();
450
- const anchorNodeParent = anchorNode.getParentOrThrow(); // Handle a single text node extraction
451
-
452
- if (anchorNode === focusNode && lexical.$isTextNode(anchorNode) && (anchorNodeParent.canBeEmpty() || anchorNodeParent.getChildrenSize() > 1)) {
453
- const clonedFirstNode = $cloneWithProperties(anchorNode);
454
- const isBefore = focusOffset > anchorOffset;
455
- const startOffset = isBefore ? anchorOffset : focusOffset;
456
- const endOffset = isBefore ? focusOffset : anchorOffset;
457
- clonedFirstNode.__text = clonedFirstNode.__text.slice(startOffset, endOffset);
458
- const key = clonedFirstNode.getKey();
459
- return {
460
- nodeMap: [[key, clonedFirstNode]],
461
- range: [key]
462
- };
463
- }
464
-
465
- const nodes = selection.getNodes();
466
-
467
- if (nodes.length === 0) {
468
- return {
469
- nodeMap: [],
470
- range: []
471
- };
472
- } // Check if we can use the parent of the nodes, if the
473
- // parent can't be empty, then it's important that we
474
- // also copy that element node along with its children.
475
-
476
-
477
- let nodesLength = nodes.length;
478
- const firstNode = nodes[0];
479
- const firstNodeParent = firstNode.getParent();
480
-
481
- if (firstNodeParent !== null && (!firstNodeParent.canBeEmpty() || lexical.$isRootNode(firstNodeParent))) {
482
- const parentChildren = firstNodeParent.__children;
483
- const parentChildrenLength = parentChildren.length;
484
-
485
- if (parentChildrenLength === nodesLength) {
486
- let areTheSame = true;
487
-
488
- for (let i = 0; i < parentChildren.length; i++) {
489
- if (parentChildren[i] !== nodes[i].__key) {
490
- areTheSame = false;
491
- break;
492
- }
493
- }
494
-
495
- if (areTheSame) {
496
- nodesLength++;
497
- nodes.push(firstNodeParent);
498
- }
499
- }
500
- }
501
-
502
- const lastNode = nodes[nodesLength - 1];
503
- const isBefore = anchor.isBefore(focus);
504
- const nodeMap = new Map();
505
- const range = []; // Do first node to root
506
-
507
- $copyLeafNodeBranchToRoot(firstNode, isBefore ? anchorOffset : focusOffset, true, range, nodeMap); // Copy all nodes between
508
-
509
- for (let i = 0; i < nodesLength; i++) {
510
- const node = nodes[i];
511
- const key = node.getKey();
512
-
513
- if (!nodeMap.has(key) && (!lexical.$isElementNode(node) || !node.excludeFromCopy())) {
514
- const clone = $cloneWithProperties(node);
515
-
516
- if (lexical.$isRootNode(node.getParent())) {
517
- range.push(node.getKey());
518
- }
519
-
520
- nodeMap.set(key, clone);
521
- }
522
- } // Do last node to root
523
-
524
-
525
- $copyLeafNodeBranchToRoot(lastNode, isBefore ? focusOffset : anchorOffset, false, range, nodeMap);
526
- return {
527
- nodeMap: Array.from(nodeMap.entries()),
528
- range
529
- };
530
- }
531
-
532
351
  function $moveCaretSelection(selection, isHoldingShift, isBackward, granularity) {
533
352
  selection.modify(isHoldingShift ? 'extend' : 'move', isBackward, granularity);
534
353
  }
@@ -541,6 +360,10 @@ function $moveCharacter(selection, isHoldingShift, isBackward) {
541
360
  const isRTL = $isParentElementRTL(selection);
542
361
  $moveCaretSelection(selection, isHoldingShift, isBackward ? !isRTL : isRTL, 'character');
543
362
  }
363
+ function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
364
+ const possibleNode = lexical.$getDecoratorNode(selection.focus, isBackward);
365
+ return lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated();
366
+ }
544
367
 
545
368
  /**
546
369
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -550,197 +373,27 @@ function $moveCharacter(selection, isHoldingShift, isBackward) {
550
373
  *
551
374
  *
552
375
  */
376
+ const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
553
377
 
554
- function $generateNodes(nodeRange) {
555
- const {
556
- range,
557
- nodeMap
558
- } = nodeRange;
559
- const parsedNodeMap = new Map(nodeMap);
560
- const nodes = [];
561
-
562
- for (let i = 0; i < range.length; i++) {
563
- const key = range[i];
564
- const parsedNode = parsedNodeMap.get(key);
565
-
566
- if (parsedNode !== undefined) {
567
- const node = lexical.$createNodeFromParse(parsedNode, parsedNodeMap);
568
- nodes.push(node);
569
- }
570
- }
571
-
572
- return nodes;
573
- }
574
-
575
- function getConversionFunction(domNode, editor) {
576
- const {
577
- nodeName
578
- } = domNode;
579
-
580
- const cachedConversions = editor._htmlConversions.get(nodeName.toLowerCase());
581
-
582
- let currentConversion = null;
583
-
584
- if (cachedConversions !== undefined) {
585
- cachedConversions.forEach(cachedConversion => {
586
- const domConversion = cachedConversion(domNode);
587
-
588
- if (domConversion !== null) {
589
- if (currentConversion === null || currentConversion.priority < domConversion.priority) {
590
- currentConversion = domConversion;
591
- }
592
- }
593
- });
594
- }
595
-
596
- return currentConversion !== null ? currentConversion.conversion : null;
597
- }
598
-
599
- function $createNodesFromDOM(node, editor, forChildMap = new Map()) {
600
- let lexicalNodes = [];
601
- let currentLexicalNode = null;
602
- const transformFunction = getConversionFunction(node, editor);
603
- const transformOutput = transformFunction ? transformFunction(node) : null;
604
- let postTransform = null;
605
-
606
- if (transformOutput !== null) {
607
- postTransform = transformOutput.after;
608
- currentLexicalNode = transformOutput.node;
609
-
610
- if (currentLexicalNode !== null) {
611
- lexicalNodes.push(currentLexicalNode);
612
- const forChildFunctions = Array.from(forChildMap.values());
613
-
614
- for (let i = 0; i < forChildFunctions.length; i++) {
615
- forChildFunctions[i](currentLexicalNode);
616
- }
617
- }
618
-
619
- if (transformOutput.forChild != null) {
620
- forChildMap.set(node.nodeName, transformOutput.forChild);
621
- }
622
- } // If the DOM node doesn't have a transformer, we don't know what
623
- // to do with it but we still need to process any childNodes.
624
-
625
-
626
- const children = node.childNodes;
627
- let childLexicalNodes = [];
628
-
629
- for (let i = 0; i < children.length; i++) {
630
- childLexicalNodes.push(...$createNodesFromDOM(children[i], editor, forChildMap));
631
- }
632
-
633
- if (postTransform != null) {
634
- childLexicalNodes = postTransform(childLexicalNodes);
635
- }
636
-
637
- if (currentLexicalNode == null) {
638
- // If it hasn't been converted to a LexicalNode, we hoist its children
639
- // up to the same level as it.
640
- lexicalNodes = lexicalNodes.concat(childLexicalNodes);
641
- } else {
642
- if (lexical.$isElementNode(currentLexicalNode)) {
643
- // If the current node is a ElementNode after conversion,
644
- // we can append all the children to it.
645
- currentLexicalNode.append(...childLexicalNodes);
646
- }
647
- }
648
-
649
- return lexicalNodes;
650
- }
651
-
652
- function $generateNodesFromDOM(dom, editor) {
653
- let lexicalNodes = [];
654
- const elements = dom.body ? Array.from(dom.body.childNodes) : [];
655
- const elementsLength = elements.length;
656
-
657
- for (let i = 0; i < elementsLength; i++) {
658
- const lexicalNode = $createNodesFromDOM(elements[i], editor);
659
-
660
- if (lexicalNode !== null) {
661
- lexicalNodes = lexicalNodes.concat(lexicalNode);
662
- }
663
- }
664
-
665
- return lexicalNodes;
666
- }
667
-
668
- function $insertDataTransferForRichText(dataTransfer, selection, editor) {
669
- const lexicalNodesString = dataTransfer.getData('application/x-lexical-editor');
670
-
671
- if (lexicalNodesString) {
672
- const namespace = editor._config.namespace;
673
-
674
- try {
675
- const lexicalClipboardData = JSON.parse(lexicalNodesString);
676
-
677
- if (lexicalClipboardData.namespace === namespace) {
678
- const nodeRange = lexicalClipboardData.state;
679
- const nodes = $generateNodes(nodeRange);
680
- selection.insertNodes(nodes);
681
- return;
682
- }
683
- } catch (e) {// Malformed, missing nodes..
684
- }
685
- }
686
-
687
- const textHtmlMimeType = 'text/html';
688
- const htmlString = dataTransfer.getData(textHtmlMimeType);
689
-
690
- if (htmlString) {
691
- const parser = new DOMParser();
692
- const dom = parser.parseFromString(htmlString, textHtmlMimeType);
693
- const nodes = $generateNodesFromDOM(dom, editor); // Wrap text and inline nodes in paragraph nodes so we have all blocks at the top-level
694
-
695
- const topLevelBlocks = [];
696
- let currentBlock = null;
697
-
698
- for (let i = 0; i < nodes.length; i++) {
699
- const node = nodes[i];
700
-
701
- if (!lexical.$isElementNode(node) || node.isInline()) {
702
- if (currentBlock === null) {
703
- currentBlock = lexical.$createParagraphNode();
704
- topLevelBlocks.push(currentBlock);
705
- }
706
-
707
- if (currentBlock !== null) {
708
- currentBlock.append(node);
709
- }
710
- } else {
711
- topLevelBlocks.push(node);
712
- currentBlock = null;
713
- }
714
- }
715
-
716
- selection.insertNodes(topLevelBlocks);
717
- return;
718
- }
719
-
720
- $insertDataTransferForPlainText(dataTransfer, selection);
721
- }
722
- function $insertDataTransferForPlainText(dataTransfer, selection) {
723
- const text = dataTransfer.getData('text/plain');
724
-
725
- if (text != null) {
726
- selection.insertRawText(text);
727
- }
728
- }
729
- function $shouldOverrideDefaultCharacterSelection(selection, isBackward) {
730
- const possibleNode = lexical.$getDecoratorNode(selection.focus, isBackward);
731
- return lexical.$isDecoratorNode(possibleNode) && !possibleNode.isIsolated();
732
- }
733
- function onPasteForRichText(event, editor) {
734
- event.preventDefault();
735
- editor.update(() => {
736
- const selection = lexical.$getSelection();
737
- const clipboardData = event.clipboardData;
378
+ /**
379
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
380
+ *
381
+ * This source code is licensed under the MIT license found in the
382
+ * LICENSE file in the root directory of this source tree.
383
+ *
384
+ *
385
+ */
386
+ const useLayoutEffectImpl = CAN_USE_DOM ? react.useLayoutEffect : react.useEffect;
387
+ var useLayoutEffect = useLayoutEffectImpl;
738
388
 
739
- if (clipboardData != null && lexical.$isRangeSelection(selection)) {
740
- $insertDataTransferForRichText(clipboardData, selection, editor);
741
- }
742
- });
743
- }
389
+ /**
390
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
391
+ *
392
+ * This source code is licensed under the MIT license found in the
393
+ * LICENSE file in the root directory of this source tree.
394
+ *
395
+ *
396
+ */
744
397
  function onCutForRichText(event, editor) {
745
398
  onCopyForRichText(event, editor);
746
399
  editor.update(() => {
@@ -759,31 +412,33 @@ function onCopyForRichText(event, editor) {
759
412
 
760
413
  if (selection !== null) {
761
414
  if (clipboardData != null) {
762
- const domSelection = window.getSelection(); // If we haven't selected a range, then don't copy anything
415
+ const htmlString = clipboard.getHtmlContent(editor);
416
+ const lexicalString = clipboard.$getLexicalContent(editor);
763
417
 
764
- if (domSelection.isCollapsed) {
765
- return;
418
+ if (htmlString !== null) {
419
+ clipboardData.setData('text/html', htmlString);
766
420
  }
767
421
 
768
- const range = domSelection.getRangeAt(0);
769
-
770
- if (range) {
771
- const container = document.createElement('div');
772
- const frag = range.cloneContents();
773
- container.appendChild(frag);
774
- clipboardData.setData('text/html', container.innerHTML);
422
+ if (lexicalString !== null) {
423
+ clipboardData.setData('application/x-lexical-editor', lexicalString);
775
424
  }
776
425
 
777
426
  clipboardData.setData('text/plain', selection.getTextContent());
778
- const namespace = editor._config.namespace;
779
- clipboardData.setData('application/x-lexical-editor', JSON.stringify({
780
- namespace,
781
- state: $cloneContents(selection)
782
- }));
783
427
  }
784
428
  }
785
429
  });
786
430
  }
431
+ function onPasteForRichText(event, editor) {
432
+ event.preventDefault();
433
+ editor.update(() => {
434
+ const selection = lexical.$getSelection();
435
+ const clipboardData = event.clipboardData;
436
+
437
+ if (clipboardData != null && lexical.$isRangeSelection(selection)) {
438
+ clipboard.$insertDataTransferForRichText(clipboardData, selection, editor);
439
+ }
440
+ });
441
+ }
787
442
 
788
443
  /**
789
444
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -938,7 +593,7 @@ function useLexicalDragonSupport(editor) {
938
593
  *
939
594
  */
940
595
  function useRichTextSetup(editor, initialEditorState) {
941
- react.useLayoutEffect(() => {
596
+ useLayoutEffect(() => {
942
597
  const removeListener = editor.addListener('command', (type, payload) => {
943
598
  const selection = lexical.$getSelection();
944
599
 
@@ -983,7 +638,7 @@ function useRichTextSetup(editor, initialEditorState) {
983
638
  const dataTransfer = eventOrText.dataTransfer;
984
639
 
985
640
  if (dataTransfer != null) {
986
- $insertDataTransferForRichText(dataTransfer, selection, editor);
641
+ clipboard.$insertDataTransferForRichText(dataTransfer, selection, editor);
987
642
  } else {
988
643
  const data = eventOrText.data;
989
644
 
@@ -4,28 +4,20 @@
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
- var k=require("@lexical/react/withSubscriptions"),w=require("lexical"),y=require("react");
8
- function z(a,e,f,c,d){if(null===a||0===f.size&&0===c.size)return 0;var b=e._selection,g=a._selection;if(d)return 1;if(!(w.$isRangeSelection(b)&&w.$isRangeSelection(g)&&g.isCollapsed()&&b.isCollapsed()))return 0;var h=Array.from(f);c=Array.from(c);f=e._nodeMap;d=[];for(var l=0;l<h.length;l++){const n=f.get(h[l]);void 0!==n&&d.push(n)}for(h=0;h<c.length;h++)c[h][1]&&(l=f.get(c[h][0]),void 0===l||w.$isRootNode(l)||d.push(l));if(0===d.length)return 0;if(1<d.length)return c=e._nodeMap,e=c.get(b.anchor.key),
9
- g=c.get(g.anchor.key),e&&g&&!a._nodeMap.has(e.__key)&&w.$isTextNode(e)&&1===e.__text.length&&1===b.anchor.offset?2:0;e=d[0];a=a._nodeMap.get(e.__key);if(!w.$isTextNode(a)||!w.$isTextNode(e)||a.__mode!==e.__mode)return 0;a=a.__text;e=e.__text;if(a===e)return 0;b=b.anchor;g=g.anchor;if(b.key!==g.key||"text"!==b.type)return 0;b=b.offset;g=g.offset;a=e.length-a.length;return 1===a&&g===b-1?2:-1===a&&g===b+1?3:-1===a&&g===b?4:0}
10
- function A(a,e){let f=Date.now(),c=0;return(d,b,g,h,l,n)=>{const p=Date.now();if(n.has("historic"))return c=0,f=p,2;const m=z(d,b,h,l,a.isComposing()),t=(()=>{const q=n.has("history-push");if(!q&&n.has("history-merge"))return 0;if(null===d)return 1;var r=b._selection;const u=d._selection;if(!(0<h.size||0<l.size))return null===u&&null!==r?0:2;r=null===g||g.editor===a;return!1===q&&0!==m&&m===c&&p<f+e&&r?0:1})();f=p;c=m;return t}}
11
- function B(a,e,f=1E3){const c=y.useMemo(()=>e||{current:null,redoStack:[],undoStack:[]},[e]),d=y.useCallback(()=>{c.undoStack=[];c.redoStack=[];c.current=null},[c]);y.useEffect(()=>{const b=A(a,f);return k(a.addListener("command",g=>{switch(g){case "undo":g=c.redoStack;var h=c.undoStack;if(0!==h.length){var l=c.current;const n=h.pop();null!==l&&(g.push(l),a.execCommand("canRedo",!0));0===h.length&&a.execCommand("canUndo",!1);c.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection),
12
- {tag:"historic"})}return!0;case "redo":return g=c.redoStack,h=c.undoStack,0!==g.length&&(l=c.current,null!==l&&(h.push(l),a.execCommand("canUndo",!0)),h=g.pop(),0===g.length&&a.execCommand("canRedo",!1),c.current=h,h.editor.setEditorState(h.editorState,{tag:"historic"})),!0;case "clearEditor":return d(),!1;case "clearHistory":return d(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:h,dirtyLeaves:l,dirtyElements:n,tags:p})=>{const m=c.current,t=c.redoStack,q=c.undoStack,
13
- r=null===m?null:m.editorState;if(null===m||g!==r){l=b(h,g,m,l,n,p);if(1===l)0!==t.length&&(c.redoStack=[]),null!==m&&(q.push({...m,undoSelection:h.read(w.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;c.current={editor:a,editorState:g}}}))},[d,f,a,c])}function C(a,e,f=1E3){return B(a,e,f)}
14
- function D(a){a=a.getLatest();const e=a.constructor.clone(a);e.__parent=a.__parent;w.$isElementNode(a)&&w.$isElementNode(e)?(e.__children=Array.from(a.__children),e.__format=a.__format,e.__indent=a.__indent,e.__dir=a.__dir):w.$isTextNode(a)&&w.$isTextNode(e)?(e.__format=a.__format,e.__style=a.__style,e.__mode=a.__mode,e.__detail=a.__detail):w.$isDecoratorNode(a)&&w.$isDecoratorNode(e)&&(e.__state=a.__state);return e}
15
- function E(a,e,f,c,d){for(var b=e;null!==a;){for(e=a.getParent();null!==e&&e.excludeFromCopy();)e=e.getParent();if(null===e)break;if(!w.$isElementNode(a)||!a.excludeFromCopy()){const g=a.getKey();let h=d.get(g);const l=void 0===h;l&&(h=D(a),d.set(g,h));!w.$isTextNode(h)||h.isSegmented()||h.isToken()?w.$isElementNode(h)&&(h.__children=h.__children.slice(f?b:0,f?void 0:b+1)):h.__text=h.__text.slice(f?b:0,f?void 0:b);if(w.$isRootNode(e)){l&&c.push(g);break}}b=d.get(e.getKey());b=w.$isElementNode(b)?
16
- b.__children.indexOf(a.getKey()):a.getIndexWithinParent();a=e}}function F(a){a=a.anchor.getNode();return"rtl"===(w.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}function G(a,e){const {nodeName:f}=a;e=e._htmlConversions.get(f.toLowerCase());let c=null;void 0!==e&&e.forEach(d=>{d=d(a);null!==d&&(null===c||c.priority<d.priority)&&(c=d)});return null!==c?c.conversion:null}
17
- function H(a,e,f=new Map){let c=[],d=null;var b=G(a,e),g=b?b(a):null;b=null;if(null!==g){b=g.after;d=g.node;if(null!==d){c.push(d);var h=Array.from(f.values());for(let l=0;l<h.length;l++)h[l](d)}null!=g.forChild&&f.set(a.nodeName,g.forChild)}a=a.childNodes;g=[];for(h=0;h<a.length;h++)g.push(...H(a[h],e,f));null!=b&&(g=b(g));null==d?c=c.concat(g):w.$isElementNode(d)&&d.append(...g);return c}
18
- function I(a,e,f){var c=a.getData("application/x-lexical-editor");if(c){var d=f._config.namespace;try{const l=JSON.parse(c);if(l.namespace===d){const {range:n,nodeMap:p}=l.state;var b=new Map(p);c=[];for(d=0;d<n.length;d++){var g=b.get(n[d]);if(void 0!==g){var h=w.$createNodeFromParse(g,b);c.push(h)}}e.insertNodes(c);return}}catch(l){}}if(b=a.getData("text/html")){b=(new DOMParser).parseFromString(b,"text/html");a=[];b=b.body?Array.from(b.body.childNodes):[];g=b.length;for(h=0;h<g;h++)c=H(b[h],f),
19
- null!==c&&(a=a.concat(c));f=a;a=[];b=null;for(g=0;g<f.length;g++)h=f[g],!w.$isElementNode(h)||h.isInline()?(null===b&&(b=w.$createParagraphNode(),a.push(b)),null!==b&&b.append(h)):(a.push(h),b=null);e.insertNodes(a)}else f=a.getData("text/plain"),null!=f&&e.insertRawText(f)}function J(a,e){a=w.$getDecoratorNode(a.focus,e);return w.$isDecoratorNode(a)&&!a.isIsolated()}
20
- function K(a,e){a.preventDefault();e.update(()=>{const f=w.$getSelection(),c=a.clipboardData;null!=c&&w.$isRangeSelection(f)&&I(c,f,e)})}function L(a,e){M(a,e);e.update(()=>{const f=w.$getSelection();w.$isRangeSelection(f)&&f.removeText()})}
21
- function M(a,e){a.preventDefault();e.update(()=>{const f=a.clipboardData;var c=w.$getSelection();if(null!==c&&null!=f){var d=window.getSelection();if(!d.isCollapsed){var b=d.getRangeAt(0);b&&(d=document.createElement("div"),b=b.cloneContents(),d.appendChild(b),f.setData("text/html",d.innerHTML));f.setData("text/plain",c.getTextContent());d=e._config.namespace;b=f.setData;var g=JSON,h=g.stringify;{if(!w.$isRangeSelection(c))throw Error("Minified Lexical error #68; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");
22
- var l=c.anchor,n=c.focus;var p=l.getCharacterOffset();const x=n.getCharacterOffset();var m=l.getNode(),t=n.getNode(),q=m.getParentOrThrow();if(m===t&&w.$isTextNode(m)&&(q.canBeEmpty()||1<q.getChildrenSize()))c=D(m),m=x>p,c.__text=c.__text.slice(m?p:x,m?x:p),p=c.getKey(),p={nodeMap:[[p,c]],range:[p]};else if(c=c.getNodes(),0===c.length)p={nodeMap:[],range:[]};else{m=c.length;t=c[0];q=t.getParent();if(null!==q&&(!q.canBeEmpty()||w.$isRootNode(q))){var r=q.__children;if(r.length===m){var u=!0;for(var v=
23
- 0;v<r.length;v++)if(r[v]!==c[v].__key){u=!1;break}u&&(m++,c.push(q))}}q=c[m-1];l=l.isBefore(n);n=new Map;r=[];E(t,l?p:x,!0,r,n);for(t=0;t<m;t++)if(u=c[t],v=u.getKey(),!(n.has(v)||w.$isElementNode(u)&&u.excludeFromCopy())){const O=D(u);w.$isRootNode(u.getParent())&&r.push(u.getKey());n.set(v,O)}E(q,l?x:p,!1,r,n);p={nodeMap:Array.from(n.entries()),range:r}}}b.call(f,"application/x-lexical-editor",h.call(g,{namespace:d,state:p}))}}})}const N={tag:"history-merge"};
24
- function P(a,e){if(null!==e)if(void 0===e)a.update(()=>{var f=w.$getRoot();if(null===f.getFirstChild()){const c=w.$createParagraphNode();f.append(c);f=document.activeElement;(null!==w.$getSelection()||null!==f&&f===a.getRootElement())&&c.select()}},N);else if(null!==e)switch(typeof e){case "string":e=a.parseEditorState(e);a.setEditorState(e,N);break;case "object":a.setEditorState(e,N);break;case "function":a.update(e,N)}}
25
- function Q(a){y.useEffect(()=>{const e=f=>{var c=a.getRootElement();if(document.activeElement===c&&(c=f.data,"string"===typeof c)){try{var d=JSON.parse(c)}catch(b){return}if(d&&"nuanria_messaging"===d.protocol&&"request"===d.type&&(d=d.payload)&&"makeChanges"===d.functionId&&(d=d.args)){const [b,g,h,l,n]=d;a.update(()=>{const p=w.$getSelection();if(w.$isRangeSelection(p)){var m=p.anchor;let t=m.getNode(),q=0,r=0;w.$isTextNode(t)&&0<=b&&0<=g&&(q=b,r=b+g,p.setTextNodeRange(t,q,t,r));if(q!==r||""!==
26
- h)p.insertRawText(h),t=m.getNode();w.$isTextNode(t)&&(q=l,r=l+n,m=t.getTextContentSize(),q=q>m?m:q,r=r>m?m:r,p.setTextNodeRange(t,q,t,r));f.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
27
- function R(a,e){y.useLayoutEffect(()=>{const f=a.addListener("command",(c,d)=>{var b=w.$getSelection();if("click"===c&&w.$isNodeSelection(b))return b.clear(),!0;if(!w.$isRangeSelection(b))return!1;switch(c){case "deleteCharacter":return b.deleteCharacter(d),!0;case "deleteWord":return b.deleteWord(d),!0;case "deleteLine":return b.deleteLine(d),!0;case "insertText":return"string"===typeof d?b.insertText(d):(c=d.dataTransfer,null!=c?I(c,b,a):(d=d.data)&&b.insertText(d)),!0;case "removeText":return b.removeText(),
28
- !0;case "formatText":return b.formatText(d),!0;case "formatElement":return b=b.anchor.getNode(),(w.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(d),!0;case "insertLineBreak":return b.insertLineBreak(d),!0;case "insertParagraph":return b.insertParagraph(),!0;case "indentContent":return b=b.anchor,b="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),b.canInsertTab()?a.execCommand("insertText","\t"):10!==b.getIndent()&&b.setIndent(b.getIndent()+1),!0;case "outdentContent":return b=b.anchor,
29
- d=b.getNode(),c="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),c.canInsertTab()?"\t"===d.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==c.getIndent()&&c.setIndent(c.getIndent()-1),!0;case "keyArrowLeft":c=d.shiftKey;if(J(b,!0))return d.preventDefault(),d=c,c=F(b),b.modify(d?"extend":"move",!c,"character"),!0;break;case "keyArrowRight":c=d.shiftKey;if(J(b,!1))return d.preventDefault(),d=c,c=F(b),b.modify(d?"extend":"move",c,"character"),!0;break;case "keyBackspace":return d.preventDefault(),
30
- {anchor:d}=b,b.isCollapsed()&&0===d.offset&&0<("element"===d.type?d.getNode():d.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return d.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return d.preventDefault(),d.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return d.preventDefault(),a.execCommand(d.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),
31
- !0;case "copy":return M(d,a),!0;case "cut":return L(d,a),!0;case "paste":return K(d,a),!0;case "drop":case "dragstart":return d.preventDefault(),!0}return!1},0);P(a,e);return f},[a]);Q(a)}module.exports=function(a,e,f){R(a,f);C(a,e)};
7
+ var h=require("@lexical/react/withSubscriptions"),u=require("lexical"),v=require("react"),w=require("@lexical/clipboard");
8
+ function x(a,e,f,d,c){if(null===a||0===f.size&&0===d.size)return 0;var b=e._selection,g=a._selection;if(c)return 1;if(!(u.$isRangeSelection(b)&&u.$isRangeSelection(g)&&g.isCollapsed()&&b.isCollapsed()))return 0;var k=Array.from(f);d=Array.from(d);f=e._nodeMap;c=[];for(var l=0;l<k.length;l++){const n=f.get(k[l]);void 0!==n&&c.push(n)}for(k=0;k<d.length;k++)d[k][1]&&(l=f.get(d[k][0]),void 0===l||u.$isRootNode(l)||c.push(l));if(0===c.length)return 0;if(1<c.length)return d=e._nodeMap,e=d.get(b.anchor.key),
9
+ g=d.get(g.anchor.key),e&&g&&!a._nodeMap.has(e.__key)&&u.$isTextNode(e)&&1===e.__text.length&&1===b.anchor.offset?2:0;e=c[0];a=a._nodeMap.get(e.__key);if(!u.$isTextNode(a)||!u.$isTextNode(e)||a.__mode!==e.__mode)return 0;a=a.__text;e=e.__text;if(a===e)return 0;b=b.anchor;g=g.anchor;if(b.key!==g.key||"text"!==b.type)return 0;b=b.offset;g=g.offset;a=e.length-a.length;return 1===a&&g===b-1?2:-1===a&&g===b+1?3:-1===a&&g===b?4:0}
10
+ function y(a,e){let f=Date.now(),d=0;return(c,b,g,k,l,n)=>{const t=Date.now();if(n.has("historic"))return d=0,f=t,2;const m=x(c,b,k,l,a.isComposing()),r=(()=>{const q=n.has("history-push");if(!q&&n.has("history-merge"))return 0;if(null===c)return 1;var p=b._selection;const D=c._selection;if(!(0<k.size||0<l.size))return null===D&&null!==p?0:2;p=null===g||g.editor===a;return!1===q&&0!==m&&m===d&&t<f+e&&p?0:1})();f=t;d=m;return r}}
11
+ function z(a,e,f=1E3){const d=v.useMemo(()=>e||{current:null,redoStack:[],undoStack:[]},[e]),c=v.useCallback(()=>{d.undoStack=[];d.redoStack=[];d.current=null},[d]);v.useEffect(()=>{const b=y(a,f);return h(a.addListener("command",g=>{switch(g){case "undo":g=d.redoStack;var k=d.undoStack;if(0!==k.length){var l=d.current;const n=k.pop();null!==l&&(g.push(l),a.execCommand("canRedo",!0));0===k.length&&a.execCommand("canUndo",!1);d.current=n;n.editor.setEditorState(n.editorState.clone(n.undoSelection),
12
+ {tag:"historic"})}return!0;case "redo":return g=d.redoStack,k=d.undoStack,0!==g.length&&(l=d.current,null!==l&&(k.push(l),a.execCommand("canUndo",!0)),k=g.pop(),0===g.length&&a.execCommand("canRedo",!1),d.current=k,k.editor.setEditorState(k.editorState,{tag:"historic"})),!0;case "clearEditor":return c(),!1;case "clearHistory":return c(),!0;default:return!1}},0),a.addListener("update",({editorState:g,prevEditorState:k,dirtyLeaves:l,dirtyElements:n,tags:t})=>{const m=d.current,r=d.redoStack,q=d.undoStack,
13
+ p=null===m?null:m.editorState;if(null===m||g!==p){l=b(k,g,m,l,n,t);if(1===l)0!==r.length&&(d.redoStack=[]),null!==m&&(q.push({...m,undoSelection:k.read(u.$getSelection)}),a.execCommand("canUndo",!0));else if(2===l)return;d.current={editor:a,editorState:g}}}))},[c,f,a,d])}function A(a,e,f=1E3){return z(a,e,f)}function B(a){a=a.anchor.getNode();return"rtl"===(u.$isRootNode(a)?a:a.getParentOrThrow()).getDirection()}
14
+ function C(a,e){a=u.$getDecoratorNode(a.focus,e);return u.$isDecoratorNode(a)&&!a.isIsolated()}var E="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?v.useLayoutEffect:v.useEffect;function F(a,e){G(a,e);e.update(()=>{const f=u.$getSelection();u.$isRangeSelection(f)&&f.removeText()})}
15
+ function G(a,e){a.preventDefault();e.update(()=>{const f=a.clipboardData,d=u.$getSelection();if(null!==d&&null!=f){const c=w.getHtmlContent(e),b=w.$getLexicalContent(e);null!==c&&f.setData("text/html",c);null!==b&&f.setData("application/x-lexical-editor",b);f.setData("text/plain",d.getTextContent())}})}function H(a,e){a.preventDefault();e.update(()=>{const f=u.$getSelection(),d=a.clipboardData;null!=d&&u.$isRangeSelection(f)&&w.$insertDataTransferForRichText(d,f,e)})}const I={tag:"history-merge"};
16
+ function J(a,e){if(null!==e)if(void 0===e)a.update(()=>{var f=u.$getRoot();if(null===f.getFirstChild()){const d=u.$createParagraphNode();f.append(d);f=document.activeElement;(null!==u.$getSelection()||null!==f&&f===a.getRootElement())&&d.select()}},I);else if(null!==e)switch(typeof e){case "string":e=a.parseEditorState(e);a.setEditorState(e,I);break;case "object":a.setEditorState(e,I);break;case "function":a.update(e,I)}}
17
+ function K(a){v.useEffect(()=>{const e=f=>{var d=a.getRootElement();if(document.activeElement===d&&(d=f.data,"string"===typeof d)){try{var c=JSON.parse(d)}catch(b){return}if(c&&"nuanria_messaging"===c.protocol&&"request"===c.type&&(c=c.payload)&&"makeChanges"===c.functionId&&(c=c.args)){const [b,g,k,l,n]=c;a.update(()=>{const t=u.$getSelection();if(u.$isRangeSelection(t)){var m=t.anchor;let r=m.getNode(),q=0,p=0;u.$isTextNode(r)&&0<=b&&0<=g&&(q=b,p=b+g,t.setTextNodeRange(r,q,r,p));if(q!==p||""!==
18
+ k)t.insertRawText(k),r=m.getNode();u.$isTextNode(r)&&(q=l,p=l+n,m=r.getTextContentSize(),q=q>m?m:q,p=p>m?m:p,t.setTextNodeRange(r,q,r,p));f.stopImmediatePropagation()}})}}};window.addEventListener("message",e,!0);return()=>{window.removeEventListener("message",e,!0)}},[a])}
19
+ function L(a,e){E(()=>{const f=a.addListener("command",(d,c)=>{var b=u.$getSelection();if("click"===d&&u.$isNodeSelection(b))return b.clear(),!0;if(!u.$isRangeSelection(b))return!1;switch(d){case "deleteCharacter":return b.deleteCharacter(c),!0;case "deleteWord":return b.deleteWord(c),!0;case "deleteLine":return b.deleteLine(c),!0;case "insertText":return"string"===typeof c?b.insertText(c):(d=c.dataTransfer,null!=d?w.$insertDataTransferForRichText(d,b,a):(c=c.data)&&b.insertText(c)),!0;case "removeText":return b.removeText(),
20
+ !0;case "formatText":return b.formatText(c),!0;case "formatElement":return b=b.anchor.getNode(),(u.$isElementNode(b)?b:b.getParentOrThrow()).setFormat(c),!0;case "insertLineBreak":return b.insertLineBreak(c),!0;case "insertParagraph":return b.insertParagraph(),!0;case "indentContent":return b=b.anchor,b="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),b.canInsertTab()?a.execCommand("insertText","\t"):10!==b.getIndent()&&b.setIndent(b.getIndent()+1),!0;case "outdentContent":return b=b.anchor,
21
+ c=b.getNode(),d="element"===b.type?b.getNode():b.getNode().getParentOrThrow(),d.canInsertTab()?"\t"===c.getTextContent()[b.offset-1]&&a.execCommand("deleteCharacter",!0):0!==d.getIndent()&&d.setIndent(d.getIndent()-1),!0;case "keyArrowLeft":d=c.shiftKey;if(C(b,!0))return c.preventDefault(),c=d,d=B(b),b.modify(c?"extend":"move",!d,"character"),!0;break;case "keyArrowRight":d=c.shiftKey;if(C(b,!1))return c.preventDefault(),c=d,d=B(b),b.modify(c?"extend":"move",d,"character"),!0;break;case "keyBackspace":return c.preventDefault(),
22
+ {anchor:c}=b,b.isCollapsed()&&0===c.offset&&0<("element"===c.type?c.getNode():c.getNode().getParentOrThrow()).getIndent()?a.execCommand("outdentContent"):a.execCommand("deleteCharacter",!0);case "keyDelete":return c.preventDefault(),a.execCommand("deleteCharacter",!1);case "keyEnter":return c.preventDefault(),c.shiftKey?a.execCommand("insertLineBreak"):a.execCommand("insertParagraph");case "keyTab":return c.preventDefault(),a.execCommand(c.shiftKey?"outdentContent":"indentContent");case "keyEscape":return a.blur(),
23
+ !0;case "copy":return G(c,a),!0;case "cut":return F(c,a),!0;case "paste":return H(c,a),!0;case "drop":case "dragstart":return c.preventDefault(),!0}return!1},0);J(a,e);return f},[a]);K(a)}module.exports=function(a,e,f){L(a,f);A(a,e)};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ export default function LexicalAutoFormatterPlugin(): React.ReactNode;
@@ -133,31 +133,31 @@ const paragraphStartBase = { ...autoFormatBase,
133
133
  };
134
134
  const markdownHeader1 = { ...paragraphStartBase,
135
135
  nodeTransformationKind: 'paragraphH1',
136
- regEx: /(?:# )/
136
+ regEx: /^(?:# )/
137
137
  };
138
138
  const markdownHeader2 = { ...paragraphStartBase,
139
139
  nodeTransformationKind: 'paragraphH2',
140
- regEx: /(?:## )/
140
+ regEx: /^(?:## )/
141
141
  };
142
142
  const markdownHeader3 = { ...paragraphStartBase,
143
143
  nodeTransformationKind: 'paragraphH2',
144
- regEx: /(?:### )/
144
+ regEx: /^(?:### )/
145
145
  };
146
146
  const markdownBlockQuote = { ...paragraphStartBase,
147
147
  nodeTransformationKind: 'paragraphBlockQuote',
148
- regEx: /(?:> )/
148
+ regEx: /^(?:> )/
149
149
  };
150
150
  const markdownUnorderedListDash = { ...paragraphStartBase,
151
151
  nodeTransformationKind: 'paragraphUnorderedList',
152
- regEx: /(?:- )/
152
+ regEx: /^(?:- )/
153
153
  };
154
154
  const markdownUnorderedListAsterisk = { ...paragraphStartBase,
155
155
  nodeTransformationKind: 'paragraphUnorderedList',
156
- regEx: /(?:\* )/
156
+ regEx: /^(?:\* )/
157
157
  };
158
158
  const markdownCodeBlock = { ...paragraphStartBase,
159
159
  nodeTransformationKind: 'paragraphCodeBlock',
160
- regEx: /(?:``` )/
160
+ regEx: /^(```)([a-z]*)( )/
161
161
  };
162
162
  const markdownOrderedList = { ...paragraphStartBase,
163
163
  nodeTransformationKind: 'paragraphOrderedList',
@@ -165,11 +165,11 @@ const markdownOrderedList = { ...paragraphStartBase,
165
165
  };
166
166
  const markdownHorizontalRule = { ...paragraphStartBase,
167
167
  nodeTransformationKind: 'horizontalRule',
168
- regEx: /(?:\*\*\* )/
168
+ regEx: /^(?:\*\*\* )/
169
169
  };
170
170
  const markdownHorizontalRuleUsingDashes = { ...paragraphStartBase,
171
171
  nodeTransformationKind: 'horizontalRule',
172
- regEx: /(?:--- )/
172
+ regEx: /^(?:--- )/
173
173
  };
174
174
  const markdownItalic = { ...autoFormatBase,
175
175
  nodeTransformationKind: 'italic',
@@ -359,6 +359,11 @@ function getNewNodeForCriteria(scanningContext, element) {
359
359
  newNode = lexical.$createParagraphNode();
360
360
  } else {
361
361
  newNode = CodeNode.$createCodeNode();
362
+ const codingLanguage = matchResultContext.regExCaptureGroups.length >= 3 ? matchResultContext.regExCaptureGroups[2].text : null;
363
+
364
+ if (codingLanguage != null && codingLanguage.length > 0) {
365
+ newNode.setLanguage(codingLanguage);
366
+ }
362
367
  }
363
368
 
364
369
  newNode.append(...children);