@lexical/code
Advanced tools
Comparing version 0.12.2 to 0.12.3
@@ -34,3 +34,2 @@ /** | ||
*/ | ||
const mapToPrismLanguage = language => { | ||
@@ -40,3 +39,2 @@ // eslint-disable-next-line no-prototype-builtins | ||
}; | ||
function hasChildDOMNodeTag(node, tagName) { | ||
@@ -47,28 +45,24 @@ for (const child of node.childNodes) { | ||
} | ||
hasChildDOMNodeTag(child, tagName); | ||
} | ||
return false; | ||
} | ||
const LANGUAGE_DATA_ATTRIBUTE = 'data-highlight-language'; | ||
const LANGUAGE_DATA_ATTRIBUTE = 'data-highlight-language'; | ||
/** @noInheritDoc */ | ||
class CodeNode extends lexical.ElementNode { | ||
/** @internal */ | ||
static getType() { | ||
return 'code'; | ||
} | ||
static clone(node) { | ||
return new CodeNode(node.__language, node.__key); | ||
} | ||
constructor(language, key) { | ||
super(key); | ||
this.__language = mapToPrismLanguage(language); | ||
} // View | ||
} | ||
// View | ||
createDOM(config) { | ||
@@ -79,14 +73,10 @@ const element = document.createElement('code'); | ||
const language = this.getLanguage(); | ||
if (language) { | ||
element.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language); | ||
} | ||
return element; | ||
} | ||
updateDOM(prevNode, dom, config) { | ||
const language = this.__language; | ||
const prevLanguage = prevNode.__language; | ||
if (language) { | ||
@@ -99,6 +89,4 @@ if (language !== prevLanguage) { | ||
} | ||
return false; | ||
} | ||
exportDOM() { | ||
@@ -108,7 +96,5 @@ const element = document.createElement('pre'); | ||
const language = this.getLanguage(); | ||
if (language) { | ||
element.setAttribute(LANGUAGE_DATA_ATTRIBUTE, language); | ||
} | ||
return { | ||
@@ -118,3 +104,2 @@ element | ||
} | ||
static importDOM() { | ||
@@ -141,4 +126,4 @@ return { | ||
table: node => { | ||
const table = node; // domNode is a <table> since we matched it by nodeName | ||
const table = node; | ||
// domNode is a <table> since we matched it by nodeName | ||
if (isGitHubCodeTable(table)) { | ||
@@ -150,3 +135,2 @@ return { | ||
} | ||
return null; | ||
@@ -158,3 +142,2 @@ }, | ||
const table = td.closest('table'); | ||
if (isGitHubCodeCell(td)) { | ||
@@ -166,3 +149,2 @@ return { | ||
} | ||
if (table && isGitHubCodeTable(table)) { | ||
@@ -176,3 +158,2 @@ // Return a no-op if it's a table cell in a code table, but not a code line. | ||
} | ||
return null; | ||
@@ -184,3 +165,2 @@ }, | ||
const table = tr.closest('table'); | ||
if (table && isGitHubCodeTable(table)) { | ||
@@ -192,3 +172,2 @@ return { | ||
} | ||
return null; | ||
@@ -198,3 +177,2 @@ } | ||
} | ||
static importJSON(serializedNode) { | ||
@@ -207,5 +185,5 @@ const node = $createCodeNode(serializedNode.language); | ||
} | ||
exportJSON() { | ||
return { ...super.exportJSON(), | ||
return { | ||
...super.exportJSON(), | ||
language: this.getLanguage(), | ||
@@ -215,9 +193,8 @@ type: 'code', | ||
}; | ||
} // Mutation | ||
} | ||
// Mutation | ||
insertNewAfter(selection, restoreSelection = true) { | ||
const children = this.getChildren(); | ||
const childrenLength = children.length; | ||
if (childrenLength >= 2 && children[childrenLength - 1].getTextContent() === '\n' && children[childrenLength - 2].getTextContent() === '\n' && selection.isCollapsed() && selection.anchor.key === this.__key && selection.anchor.offset === childrenLength) { | ||
@@ -229,16 +206,17 @@ children[childrenLength - 1].remove(); | ||
return newElement; | ||
} // If the selection is within the codeblock, find all leading tabs and | ||
} | ||
// If the selection is within the codeblock, find all leading tabs and | ||
// spaces of the current line. Create a new line that has all those | ||
// tabs and spaces, such that leading indentation is preserved. | ||
const anchor = selection.anchor; | ||
const focus = selection.focus; | ||
const { | ||
anchor, | ||
focus | ||
} = selection; | ||
const firstPoint = anchor.isBefore(focus) ? anchor : focus; | ||
const firstSelectionNode = firstPoint.getNode(); | ||
if ($isCodeHighlightNode(firstSelectionNode) || lexical.$isTabNode(firstSelectionNode)) { | ||
if (lexical.$isTextNode(firstSelectionNode)) { | ||
let node = getFirstCodeNodeOfLine(firstSelectionNode); | ||
const insertNodes = []; // eslint-disable-next-line no-constant-condition | ||
const insertNodes = []; | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
@@ -252,13 +230,9 @@ if (lexical.$isTabNode(node)) { | ||
const textSize = node.getTextContentSize(); | ||
for (; spaces < textSize && text[spaces] === ' '; spaces++); | ||
if (spaces !== 0) { | ||
insertNodes.push($createCodeHighlightNode(' '.repeat(spaces))); | ||
} | ||
if (spaces !== textSize) { | ||
break; | ||
} | ||
node = node.getNextSibling(); | ||
@@ -269,16 +243,29 @@ } else { | ||
} | ||
if (insertNodes.length > 0) { | ||
selection.insertNodes([lexical.$createLineBreakNode(), ...insertNodes]); | ||
return insertNodes[insertNodes.length - 1]; | ||
const split = firstSelectionNode.splitText(anchor.offset)[0]; | ||
const x = anchor.offset === 0 ? 0 : 1; | ||
const index = split.getIndexWithinParent() + x; | ||
const codeNode = firstSelectionNode.getParentOrThrow(); | ||
const nodesToInsert = [lexical.$createLineBreakNode(), ...insertNodes]; | ||
codeNode.splice(index, 0, nodesToInsert); | ||
const last = insertNodes[insertNodes.length - 1]; | ||
if (last) { | ||
last.select(); | ||
} else if (anchor.offset === 0) { | ||
split.selectPrevious(); | ||
} else { | ||
split.getNextSibling().selectNext(0, 0); | ||
} | ||
} | ||
if ($isCodeNode(firstSelectionNode)) { | ||
const { | ||
offset | ||
} = selection.anchor; | ||
firstSelectionNode.splice(offset, 0, [lexical.$createLineBreakNode()]); | ||
firstSelectionNode.select(offset + 1, offset + 1); | ||
} | ||
return null; | ||
} | ||
canIndent() { | ||
return false; | ||
} | ||
collapseAtStart() { | ||
@@ -291,3 +278,2 @@ const paragraph = lexical.$createParagraphNode(); | ||
} | ||
setLanguage(language) { | ||
@@ -297,7 +283,5 @@ const writable = this.getWritable(); | ||
} | ||
getLanguage() { | ||
return this.getLatest().__language; | ||
} | ||
} | ||
@@ -310,10 +294,7 @@ function $createCodeNode(language) { | ||
} | ||
function convertPreElement(domNode) { | ||
let language; | ||
if (utils.isHTMLElement(domNode)) { | ||
language = domNode.getAttribute(LANGUAGE_DATA_ATTRIBUTE); | ||
} | ||
return { | ||
@@ -323,3 +304,2 @@ node: $createCodeNode(language) | ||
} | ||
function convertDivElement(domNode) { | ||
@@ -329,3 +309,2 @@ // domNode is a <div> since we matched it by nodeName | ||
const isCode = isCodeElement(div); | ||
if (!isCode && !isCodeChildElement(div)) { | ||
@@ -336,11 +315,8 @@ return { | ||
} | ||
return { | ||
after: childLexicalNodes => { | ||
const domParent = domNode.parentNode; | ||
if (domParent != null && domNode !== domParent.lastChild) { | ||
childLexicalNodes.push(lexical.$createLineBreakNode()); | ||
} | ||
return childLexicalNodes; | ||
@@ -351,3 +327,2 @@ }, | ||
} | ||
function convertTableElement() { | ||
@@ -358,3 +333,2 @@ return { | ||
} | ||
function convertCodeNoop() { | ||
@@ -365,3 +339,2 @@ return { | ||
} | ||
function convertTableCellElement(domNode) { | ||
@@ -376,3 +349,2 @@ // domNode is a <td> since we matched it by nodeName | ||
} | ||
return childLexicalNodes; | ||
@@ -383,10 +355,7 @@ }, | ||
} | ||
function isCodeElement(div) { | ||
return div.style.fontFamily.match('monospace') !== null; | ||
} | ||
function isCodeChildElement(node) { | ||
let parent = node.parentElement; | ||
while (parent !== null) { | ||
@@ -396,13 +365,9 @@ if (isCodeElement(parent)) { | ||
} | ||
parent = parent.parentElement; | ||
} | ||
return false; | ||
} | ||
function isGitHubCodeCell(cell) { | ||
return cell.classList.contains('js-file-line'); | ||
} | ||
function isGitHubCodeTable(table) { | ||
@@ -453,13 +418,14 @@ return table.classList.contains('js-file-line-container'); | ||
const _lang = normalizeCodeLang(lang); | ||
return CODE_LANGUAGE_FRIENDLY_NAME_MAP[_lang] || _lang; | ||
} | ||
const getDefaultCodeLanguage = () => DEFAULT_CODE_LANGUAGE; | ||
const getCodeLanguages = () => Object.keys(Prism.languages).filter( // Prism has several language helpers mixed into languages object | ||
const getCodeLanguages = () => Object.keys(Prism.languages).filter( | ||
// Prism has several language helpers mixed into languages object | ||
// so filtering them out here to get langs list | ||
language => typeof Prism.languages[language] !== 'function').sort(); | ||
/** @noInheritDoc */ | ||
class CodeHighlightNode extends lexical.TextNode { | ||
/** @internal */ | ||
constructor(text, highlightType, key) { | ||
@@ -469,11 +435,8 @@ super(text, key); | ||
} | ||
static getType() { | ||
return 'code-highlight'; | ||
} | ||
static clone(node) { | ||
return new CodeHighlightNode(node.__text, node.__highlightType || undefined, node.__key); | ||
} | ||
getHighlightType() { | ||
@@ -483,3 +446,2 @@ const self = this.getLatest(); | ||
} | ||
createDOM(config) { | ||
@@ -491,3 +453,2 @@ const element = super.createDOM(config); | ||
} | ||
updateDOM(prevNode, dom, config) { | ||
@@ -497,3 +458,2 @@ const update = super.updateDOM(prevNode, dom, config); | ||
const nextClassName = getHighlightThemeClass(config.theme, this.__highlightType); | ||
if (prevClassName !== nextClassName) { | ||
@@ -503,3 +463,2 @@ if (prevClassName) { | ||
} | ||
if (nextClassName) { | ||
@@ -509,6 +468,4 @@ utils.addClassNamesToElement(dom, nextClassName); | ||
} | ||
return update; | ||
} | ||
static importJSON(serializedNode) { | ||
@@ -522,5 +479,5 @@ const node = $createCodeHighlightNode(serializedNode.text, serializedNode.highlightType); | ||
} | ||
exportJSON() { | ||
return { ...super.exportJSON(), | ||
return { | ||
...super.exportJSON(), | ||
highlightType: this.getHighlightType(), | ||
@@ -530,23 +487,18 @@ type: 'code-highlight', | ||
}; | ||
} // Prevent formatting (bold, underline, etc) | ||
} | ||
// Prevent formatting (bold, underline, etc) | ||
setFormat(format) { | ||
return this; | ||
} | ||
isParentRequired() { | ||
return true; | ||
} | ||
createParentElementNode() { | ||
return $createCodeNode(); | ||
} | ||
} | ||
function getHighlightThemeClass(theme, highlightType) { | ||
return highlightType && theme && theme.codeHighlight && theme.codeHighlight[highlightType]; | ||
} | ||
function $createCodeHighlightNode(text, highlightType) { | ||
@@ -561,3 +513,2 @@ return lexical.$applyNodeReplacement(new CodeHighlightNode(text, highlightType)); | ||
let node = anchor; | ||
while ($isCodeHighlightNode(node) || lexical.$isTabNode(node)) { | ||
@@ -567,3 +518,2 @@ previousNode = node; | ||
} | ||
return previousNode; | ||
@@ -574,3 +524,2 @@ } | ||
let node = anchor; | ||
while ($isCodeHighlightNode(node) || lexical.$isTabNode(node)) { | ||
@@ -580,3 +529,2 @@ nextNode = node; | ||
} | ||
return nextNode; | ||
@@ -594,7 +542,5 @@ } | ||
defaultLanguage: DEFAULT_CODE_LANGUAGE, | ||
tokenize(code, language) { | ||
return Prism.tokenize(code, Prism.languages[language || ''] || Prism.languages[this.defaultLanguage]); | ||
} | ||
}; | ||
@@ -606,16 +552,13 @@ function getStartOfCodeInLine(anchor, offset) { | ||
let nodeOffset = offset; | ||
let nodeTextContent = anchor.getTextContent(); // eslint-disable-next-line no-constant-condition | ||
let nodeTextContent = anchor.getTextContent(); | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
if (nodeOffset === 0) { | ||
node = node.getPreviousSibling(); | ||
if (node === null) { | ||
break; | ||
} | ||
if (!($isCodeHighlightNode(node) || lexical.$isTabNode(node) || lexical.$isLineBreakNode(node))) { | ||
throw Error(`Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode`); | ||
} | ||
if (lexical.$isLineBreakNode(node)) { | ||
@@ -628,3 +571,2 @@ last = { | ||
} | ||
nodeOffset = Math.max(0, node.getTextContentSize() - 1); | ||
@@ -635,5 +577,3 @@ nodeTextContent = node.getTextContent(); | ||
} | ||
const character = nodeTextContent[nodeOffset]; | ||
if ($isCodeHighlightNode(node) && character !== ' ') { | ||
@@ -645,12 +585,9 @@ lastNonBlank = { | ||
} | ||
} // lastNonBlank !== null: anchor in the middle of code; move to line beginning | ||
} | ||
// lastNonBlank !== null: anchor in the middle of code; move to line beginning | ||
if (lastNonBlank !== null) { | ||
return lastNonBlank; | ||
} // Spaces, tabs or nothing ahead of anchor | ||
} | ||
// Spaces, tabs or nothing ahead of anchor | ||
let codeCharacterAtAnchorOffset = null; | ||
if (offset < anchor.getTextContentSize()) { | ||
@@ -662,3 +599,2 @@ if ($isCodeHighlightNode(anchor)) { | ||
const nextSibling = anchor.getNextSibling(); | ||
if ($isCodeHighlightNode(nextSibling)) { | ||
@@ -668,3 +604,2 @@ codeCharacterAtAnchorOffset = nextSibling.getTextContent()[0]; | ||
} | ||
if (codeCharacterAtAnchorOffset !== null && codeCharacterAtAnchorOffset !== ' ') { | ||
@@ -675,3 +610,2 @@ // Borderline whitespace and code, move to line beginning | ||
const nextNonBlank = findNextNonBlankInLine(anchor, offset); | ||
if (nextNonBlank !== null) { | ||
@@ -684,3 +618,2 @@ return nextNonBlank; | ||
} | ||
function findNextNonBlankInLine(anchor, offset) { | ||
@@ -690,12 +623,10 @@ let node = anchor; | ||
let nodeTextContent = anchor.getTextContent(); | ||
let nodeTextContentSize = anchor.getTextContentSize(); // eslint-disable-next-line no-constant-condition | ||
let nodeTextContentSize = anchor.getTextContentSize(); | ||
// eslint-disable-next-line no-constant-condition | ||
while (true) { | ||
if (!$isCodeHighlightNode(node) || nodeOffset === nodeTextContentSize) { | ||
node = node.getNextSibling(); | ||
if (node === null || lexical.$isLineBreakNode(node)) { | ||
return null; | ||
} | ||
if ($isCodeHighlightNode(node)) { | ||
@@ -707,3 +638,2 @@ nodeOffset = 0; | ||
} | ||
if ($isCodeHighlightNode(node)) { | ||
@@ -716,3 +646,2 @@ if (nodeTextContent[nodeOffset] !== ' ') { | ||
} | ||
nodeOffset++; | ||
@@ -722,13 +651,9 @@ } | ||
} | ||
function getEndOfCodeInLine(anchor) { | ||
const lastNode = getLastCodeNodeOfLine(anchor); | ||
if (!!lexical.$isLineBreakNode(lastNode)) { | ||
throw Error(`Unexpected lineBreakNode in getEndOfCodeInLine`); | ||
} | ||
return lastNode; | ||
} | ||
function textNodeTransform(node, editor, tokenizer) { | ||
@@ -738,3 +663,2 @@ // Since CodeNode has flat children structure we only need to check | ||
const parentNode = node.getParent(); | ||
if ($isCodeNode(parentNode)) { | ||
@@ -748,23 +672,18 @@ codeNodeTransform(parentNode, editor, tokenizer); | ||
} | ||
function updateCodeGutter(node, editor) { | ||
const codeElement = editor.getElementByKey(node.getKey()); | ||
if (codeElement === null) { | ||
return; | ||
} | ||
const children = node.getChildren(); | ||
const childrenLength = children.length; // @ts-ignore: internal field | ||
const childrenLength = children.length; | ||
// @ts-ignore: internal field | ||
if (childrenLength === codeElement.__cachedChildrenLength) { | ||
// Avoid updating the attribute if the children length hasn't changed. | ||
return; | ||
} // @ts-ignore:: internal field | ||
} | ||
// @ts-ignore:: internal field | ||
codeElement.__cachedChildrenLength = childrenLength; | ||
let gutter = '1'; | ||
let count = 1; | ||
for (let i = 0; i < childrenLength; i++) { | ||
@@ -775,5 +694,6 @@ if (lexical.$isLineBreakNode(children[i])) { | ||
} | ||
codeElement.setAttribute('data-gutter', gutter); | ||
} | ||
codeElement.setAttribute('data-gutter', gutter); | ||
} // Using `skipTransforms` to prevent extra transforms since reformatting the code | ||
// Using `skipTransforms` to prevent extra transforms since reformatting the code | ||
// will not affect code block content itself. | ||
@@ -786,29 +706,24 @@ // | ||
const nodesCurrentlyHighlighting = new Set(); | ||
function codeNodeTransform(node, editor, tokenizer) { | ||
const nodeKey = node.getKey(); | ||
if (nodesCurrentlyHighlighting.has(nodeKey)) { | ||
return; | ||
} | ||
nodesCurrentlyHighlighting.add(nodeKey); | ||
nodesCurrentlyHighlighting.add(nodeKey); // When new code block inserted it might not have language selected | ||
// When new code block inserted it might not have language selected | ||
if (node.getLanguage() === undefined) { | ||
node.setLanguage(tokenizer.defaultLanguage); | ||
} // Using nested update call to pass `skipTransforms` since we don't want | ||
} | ||
// Using nested update call to pass `skipTransforms` since we don't want | ||
// each individual codehighlight node to be transformed again as it's already | ||
// in its final state | ||
editor.update(() => { | ||
updateAndRetainSelection(nodeKey, () => { | ||
const currentNode = lexical.$getNodeByKey(nodeKey); | ||
if (!$isCodeNode(currentNode) || !currentNode.isAttached()) { | ||
return false; | ||
} | ||
const code = currentNode.getTextContent(); | ||
@@ -823,3 +738,2 @@ const tokens = tokenizer.tokenize(code, currentNode.getLanguage() || tokenizer.defaultLanguage); | ||
} = diffRange; | ||
if (from !== to || nodesForReplacement.length) { | ||
@@ -829,3 +743,2 @@ node.splice(from, to - from, nodesForReplacement); | ||
} | ||
return false; | ||
@@ -840,6 +753,4 @@ }); | ||
} | ||
function getHighlightNodes(tokens, type) { | ||
const nodes = []; | ||
for (const token of tokens) { | ||
@@ -849,6 +760,4 @@ if (typeof token === 'string') { | ||
const partialsLength = partials.length; | ||
for (let i = 0; i < partialsLength; i++) { | ||
const part = partials[i]; | ||
if (part === '\n' || part === '\r\n') { | ||
@@ -866,3 +775,2 @@ nodes.push(lexical.$createLineBreakNode()); | ||
} = token; | ||
if (typeof content === 'string') { | ||
@@ -875,18 +783,15 @@ nodes.push(...getHighlightNodes([content], token.type)); | ||
} | ||
return nodes; | ||
} | ||
return nodes; | ||
} // Wrapping update function into selection retainer, that tries to keep cursor at the same | ||
// Wrapping update function into selection retainer, that tries to keep cursor at the same | ||
// position as before. | ||
function updateAndRetainSelection(nodeKey, updateFn) { | ||
const node = lexical.$getNodeByKey(nodeKey); | ||
if (!$isCodeNode(node) || !node.isAttached()) { | ||
return; | ||
} | ||
const selection = lexical.$getSelection(); // If it's not range selection (or null selection) there's no need to change it, | ||
const selection = lexical.$getSelection(); | ||
// If it's not range selection (or null selection) there's no need to change it, | ||
// but we can still run highlighting logic | ||
if (!lexical.$isRangeSelection(selection)) { | ||
@@ -896,8 +801,8 @@ updateFn(); | ||
} | ||
const anchor = selection.anchor; | ||
const anchorOffset = anchor.offset; | ||
const isNewLineAnchor = anchor.type === 'element' && lexical.$isLineBreakNode(node.getChildAtIndex(anchor.offset - 1)); | ||
let textOffset = 0; // Calculating previous text offset (all text node prior to anchor + anchor own text offset) | ||
let textOffset = 0; | ||
// Calculating previous text offset (all text node prior to anchor + anchor own text offset) | ||
if (!isNewLineAnchor) { | ||
@@ -909,42 +814,34 @@ const anchorNode = anchor.getNode(); | ||
} | ||
const hasChanges = updateFn(); | ||
if (!hasChanges) { | ||
return; | ||
} // Non-text anchors only happen for line breaks, otherwise | ||
} | ||
// Non-text anchors only happen for line breaks, otherwise | ||
// selection will be within text node (code highlight node) | ||
if (isNewLineAnchor) { | ||
anchor.getNode().select(anchorOffset, anchorOffset); | ||
return; | ||
} // If it was non-element anchor then we walk through child nodes | ||
} | ||
// If it was non-element anchor then we walk through child nodes | ||
// and looking for a position of original text offset | ||
node.getChildren().some(_node => { | ||
const isText = lexical.$isTextNode(_node); | ||
if (isText || lexical.$isLineBreakNode(_node)) { | ||
const textContentSize = _node.getTextContentSize(); | ||
if (isText && textContentSize >= textOffset) { | ||
_node.select(textOffset, textOffset); | ||
return true; | ||
} | ||
textOffset -= textContentSize; | ||
} | ||
return false; | ||
}); | ||
} // Finds minimal diff range between two nodes lists. It returns from/to range boundaries of prevNodes | ||
} | ||
// Finds minimal diff range between two nodes lists. It returns from/to range boundaries of prevNodes | ||
// that needs to be replaced with `nodes` (subset of nextNodes) to make prevNodes equal to nextNodes. | ||
function getDiffRange(prevNodes, nextNodes) { | ||
let leadingMatch = 0; | ||
while (leadingMatch < prevNodes.length) { | ||
@@ -954,6 +851,4 @@ if (!isEqual(prevNodes[leadingMatch], nextNodes[leadingMatch])) { | ||
} | ||
leadingMatch++; | ||
} | ||
const prevNodesLength = prevNodes.length; | ||
@@ -963,6 +858,4 @@ const nextNodesLength = nextNodes.length; | ||
let trailingMatch = 0; | ||
while (trailingMatch < maxTrailingMatch) { | ||
trailingMatch++; | ||
if (!isEqual(prevNodes[prevNodesLength - trailingMatch], nextNodes[nextNodesLength - trailingMatch])) { | ||
@@ -973,3 +866,2 @@ trailingMatch--; | ||
} | ||
const from = leadingMatch; | ||
@@ -984,3 +876,2 @@ const to = prevNodesLength - trailingMatch; | ||
} | ||
function isEqual(nodeA, nodeB) { | ||
@@ -991,3 +882,2 @@ // Only checking for code higlight nodes, tabs and linebreaks. If it's regular text node | ||
} | ||
function $isSelectionInCode(selection) { | ||
@@ -997,31 +887,22 @@ if (!lexical.$isRangeSelection(selection)) { | ||
} | ||
const anchorNode = selection.anchor.getNode(); | ||
const focusNode = selection.focus.getNode(); | ||
if (anchorNode.is(focusNode) && $isCodeNode(anchorNode)) { | ||
return true; | ||
} | ||
const anchorParent = anchorNode.getParent(); | ||
return $isCodeNode(anchorParent) && anchorParent.is(focusNode.getParent()); | ||
} | ||
function $getCodeLines(selection) { | ||
const nodes = selection.getNodes(); | ||
const lines = [[]]; | ||
if (nodes.length === 1 && $isCodeNode(nodes[0])) { | ||
return lines; | ||
} | ||
let lastLine = lines[0]; | ||
for (let i = 0; i < nodes.length; i++) { | ||
const node = nodes[i]; | ||
if (!($isCodeHighlightNode(node) || lexical.$isTabNode(node) || lexical.$isLineBreakNode(node))) { | ||
throw Error(`Expected selection to be inside CodeBlock and consisting of CodeHighlightNode, TabNode and LineBreakNode`); | ||
} | ||
if (lexical.$isLineBreakNode(node)) { | ||
@@ -1036,34 +917,25 @@ if (i !== 0 && lastLine.length > 0) { | ||
} | ||
return lines; | ||
} | ||
function handleTab(shiftKey) { | ||
const selection = lexical.$getSelection(); | ||
if (!lexical.$isRangeSelection(selection) || !$isSelectionInCode(selection)) { | ||
return null; | ||
} | ||
const indentOrOutdent = !shiftKey ? lexical.INDENT_CONTENT_COMMAND : lexical.OUTDENT_CONTENT_COMMAND; | ||
const tabOrOutdent = !shiftKey ? lexical.INSERT_TAB_COMMAND : lexical.OUTDENT_CONTENT_COMMAND; // 1. If multiple lines selected: indent/outdent | ||
const tabOrOutdent = !shiftKey ? lexical.INSERT_TAB_COMMAND : lexical.OUTDENT_CONTENT_COMMAND; | ||
// 1. If multiple lines selected: indent/outdent | ||
const codeLines = $getCodeLines(selection); | ||
if (codeLines.length > 1) { | ||
return indentOrOutdent; | ||
} // 2. If entire line selected: indent/outdent | ||
} | ||
// 2. If entire line selected: indent/outdent | ||
const selectionNodes = selection.getNodes(); | ||
const firstNode = selectionNodes[0]; | ||
if (!($isCodeNode(firstNode) || $isCodeHighlightNode(firstNode) || lexical.$isTabNode(firstNode) || lexical.$isLineBreakNode(firstNode))) { | ||
throw Error(`Expected selection firstNode to be CodeHighlightNode or TabNode`); | ||
} | ||
if ($isCodeNode(firstNode)) { | ||
return indentOrOutdent; | ||
} | ||
const firstOfLine = getFirstCodeNodeOfLine(firstNode); | ||
@@ -1075,3 +947,2 @@ const lastOfLine = getLastCodeNodeOfLine(firstNode); | ||
let selectionLast; | ||
if (focus.isBefore(anchor)) { | ||
@@ -1084,32 +955,25 @@ selectionFirst = focus; | ||
} | ||
if (firstOfLine !== null && lastOfLine !== null && selectionFirst.key === firstOfLine.getKey() && selectionFirst.offset === 0 && selectionLast.key === lastOfLine.getKey() && selectionLast.offset === lastOfLine.getTextContentSize()) { | ||
return indentOrOutdent; | ||
} // 3. Else: tab/outdent | ||
} | ||
// 3. Else: tab/outdent | ||
return tabOrOutdent; | ||
} | ||
function handleMultilineIndent(type) { | ||
const selection = lexical.$getSelection(); | ||
if (!lexical.$isRangeSelection(selection) || !$isSelectionInCode(selection)) { | ||
return false; | ||
} | ||
const codeLines = $getCodeLines(selection); | ||
const codeLinesLength = codeLines.length; // Multiple lines selection | ||
const codeLinesLength = codeLines.length; | ||
// Multiple lines selection | ||
if (codeLines.length > 1) { | ||
for (let i = 0; i < codeLinesLength; i++) { | ||
const line = codeLines[i]; | ||
if (line.length > 0) { | ||
let firstOfLine = line[0]; // First and last lines might not be complete | ||
let firstOfLine = line[0]; | ||
// First and last lines might not be complete | ||
if (i === 0) { | ||
firstOfLine = getFirstCodeNodeOfLine(firstOfLine); | ||
} | ||
if (firstOfLine !== null) { | ||
@@ -1124,14 +988,10 @@ if (type === lexical.INDENT_CONTENT_COMMAND) { | ||
} | ||
return true; | ||
} // Just one line | ||
} | ||
// Just one line | ||
const selectionNodes = selection.getNodes(); | ||
const firstNode = selectionNodes[0]; | ||
if (!($isCodeNode(firstNode) || $isCodeHighlightNode(firstNode) || lexical.$isTabNode(firstNode) || lexical.$isLineBreakNode(firstNode))) { | ||
throw Error(`Expected selection firstNode to be CodeHighlightNode or CodeTabNode`); | ||
} | ||
if ($isCodeNode(firstNode)) { | ||
@@ -1142,12 +1002,8 @@ // CodeNode is empty | ||
} | ||
return true; | ||
} | ||
const firstOfLine = getFirstCodeNodeOfLine(firstNode); | ||
if (!(firstOfLine !== null)) { | ||
throw Error(`Expected getFirstCodeNodeOfLine to return a valid Code Node`); | ||
} | ||
if (type === lexical.INDENT_CONTENT_COMMAND) { | ||
@@ -1162,16 +1018,13 @@ if (lexical.$isLineBreakNode(firstOfLine)) { | ||
} | ||
return true; | ||
} | ||
function handleShiftLines(type, event) { | ||
// We only care about the alt+arrow keys | ||
const selection = lexical.$getSelection(); | ||
if (!lexical.$isRangeSelection(selection)) { | ||
return false; | ||
} // I'm not quite sure why, but it seems like calling anchor.getNode() collapses the selection here | ||
} | ||
// I'm not quite sure why, but it seems like calling anchor.getNode() collapses the selection here | ||
// So first, get the anchor and the focus, then get their nodes | ||
const { | ||
@@ -1185,8 +1038,8 @@ anchor, | ||
const focusNode = focus.getNode(); | ||
const arrowIsUp = type === lexical.KEY_ARROW_UP_COMMAND; // Ensure the selection is within the codeblock | ||
const arrowIsUp = type === lexical.KEY_ARROW_UP_COMMAND; | ||
// Ensure the selection is within the codeblock | ||
if (!$isSelectionInCode(selection) || !($isCodeHighlightNode(anchorNode) || lexical.$isTabNode(anchorNode)) || !($isCodeHighlightNode(focusNode) || lexical.$isTabNode(focusNode))) { | ||
return false; | ||
} | ||
if (!event.altKey) { | ||
@@ -1197,6 +1050,4 @@ // Handle moving selection out of the code block, given there are no | ||
const codeNode = anchorNode.getParentOrThrow(); | ||
if (arrowIsUp && anchorOffset === 0 && anchorNode.getPreviousSibling() === null) { | ||
const codeNodeSibling = codeNode.getPreviousSibling(); | ||
if (codeNodeSibling === null) { | ||
@@ -1209,3 +1060,2 @@ codeNode.selectPrevious(); | ||
const codeNodeSibling = codeNode.getNextSibling(); | ||
if (codeNodeSibling === null) { | ||
@@ -1218,9 +1068,6 @@ codeNode.selectNext(); | ||
} | ||
return false; | ||
} | ||
let start; | ||
let end; | ||
if (anchorNode.isBefore(focusNode)) { | ||
@@ -1233,20 +1080,16 @@ start = getFirstCodeNodeOfLine(anchorNode); | ||
} | ||
if (start == null || end == null) { | ||
return false; | ||
} | ||
const range = start.getNodesBetween(end); | ||
for (let i = 0; i < range.length; i++) { | ||
const node = range[i]; | ||
if (!$isCodeHighlightNode(node) && !lexical.$isTabNode(node) && !lexical.$isLineBreakNode(node)) { | ||
return false; | ||
} | ||
} // After this point, we know the selection is within the codeblock. We may not be able to | ||
} | ||
// After this point, we know the selection is within the codeblock. We may not be able to | ||
// actually move the lines around, but we want to return true either way to prevent | ||
// the event's default behavior | ||
event.preventDefault(); | ||
@@ -1256,13 +1099,9 @@ event.stopPropagation(); // required to stop cursor movement under Firefox | ||
const linebreak = arrowIsUp ? start.getPreviousSibling() : end.getNextSibling(); | ||
if (!lexical.$isLineBreakNode(linebreak)) { | ||
return true; | ||
} | ||
const sibling = arrowIsUp ? linebreak.getPreviousSibling() : linebreak.getNextSibling(); | ||
if (sibling == null) { | ||
return true; | ||
} | ||
const maybeInsertionPoint = $isCodeHighlightNode(sibling) || lexical.$isTabNode(sibling) || lexical.$isLineBreakNode(sibling) ? arrowIsUp ? getFirstCodeNodeOfLine(sibling) : getLastCodeNodeOfLine(sibling) : null; | ||
@@ -1272,3 +1111,2 @@ let insertionPoint = maybeInsertionPoint != null ? maybeInsertionPoint : sibling; | ||
range.forEach(node => node.remove()); | ||
if (type === lexical.KEY_ARROW_UP_COMMAND) { | ||
@@ -1285,14 +1123,10 @@ range.forEach(node => insertionPoint.insertBefore(node)); | ||
} | ||
selection.setTextNodeRange(anchorNode, anchorOffset, focusNode, focusOffset); | ||
return true; | ||
} | ||
function handleMoveTo(type, event) { | ||
const selection = lexical.$getSelection(); | ||
if (!lexical.$isRangeSelection(selection)) { | ||
return false; | ||
} | ||
const { | ||
@@ -1305,10 +1139,7 @@ anchor, | ||
const isMoveToStart = type === lexical.MOVE_TO_START; | ||
if (!($isCodeHighlightNode(anchorNode) || lexical.$isTabNode(anchorNode)) || !($isCodeHighlightNode(focusNode) || lexical.$isTabNode(focusNode))) { | ||
return false; | ||
} | ||
if (isMoveToStart) { | ||
const start = getStartOfCodeInLine(focusNode, focus.offset); | ||
if (start !== null) { | ||
@@ -1319,3 +1150,2 @@ const { | ||
} = start; | ||
if (lexical.$isLineBreakNode(node)) { | ||
@@ -1333,3 +1163,2 @@ node.selectNext(0, 0); | ||
} | ||
event.preventDefault(); | ||
@@ -1339,3 +1168,2 @@ event.stopPropagation(); | ||
} | ||
function registerCodeHighlighting(editor, tokenizer) { | ||
@@ -1345,7 +1173,5 @@ if (!editor.hasNodes([CodeNode, CodeHighlightNode])) { | ||
} | ||
if (tokenizer == null) { | ||
tokenizer = PrismTokenizer; | ||
} | ||
return utils.mergeRegister(editor.registerMutationListener(CodeNode, mutations => { | ||
@@ -1356,3 +1182,2 @@ editor.update(() => { | ||
const node = lexical.$getNodeByKey(key); | ||
if (node !== null) { | ||
@@ -1366,7 +1191,5 @@ updateCodeGutter(node, editor); | ||
const command = handleTab(event.shiftKey); | ||
if (command === null) { | ||
return false; | ||
} | ||
event.preventDefault(); | ||
@@ -1377,7 +1200,5 @@ editor.dispatchCommand(command, undefined); | ||
const selection = lexical.$getSelection(); | ||
if (!$isSelectionInCode(selection)) { | ||
return false; | ||
} | ||
lexical.$insertNodes([lexical.$createTabNode()]); | ||
@@ -1384,0 +1205,0 @@ return true; |
@@ -8,36 +8,36 @@ /** | ||
'use strict';var d=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-python");require("prismjs/components/prism-rust");require("prismjs/components/prism-swift"); | ||
require("prismjs/components/prism-typescript");require("prismjs/components/prism-java");require("prismjs/components/prism-cpp");var l=require("@lexical/utils"),r=require("lexical");let v=a=>null!=a&&d.languages.hasOwnProperty(a)?a:void 0;function x(a,b){for(let c of a.childNodes){if(l.isHTMLElement(c)&&c.tagName===b)return!0;x(c,b)}return!1} | ||
class y extends r.ElementNode{static getType(){return"code"}static clone(a){return new y(a.__language,a.__key)}constructor(a,b){super(b);this.__language=v(a)}createDOM(a){let b=document.createElement("code");l.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"); | ||
require("prismjs/components/prism-typescript");require("prismjs/components/prism-java");require("prismjs/components/prism-cpp");var m=require("@lexical/utils"),q=require("lexical");let v=a=>null!=a&&d.languages.hasOwnProperty(a)?a:void 0;function x(a,b){for(let c of a.childNodes){if(m.isHTMLElement(c)&&c.tagName===b)return!0;x(c,b)}return!1} | ||
class y extends q.ElementNode{static getType(){return"code"}static clone(a){return new y(a.__language,a.__key)}constructor(a,b){super(b);this.__language=v(a)}createDOM(a){let b=document.createElement("code");m.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"); | ||
return!1}exportDOM(){let a=document.createElement("pre");a.setAttribute("spellcheck","false");let b=this.getLanguage();b&&a.setAttribute("data-highlight-language",b);return{element:a}}static importDOM(){return{code:a=>null!=a.textContent&&(/\r?\n/.test(a.textContent)||x(a,"BR"))?{conversion:z,priority:1}:null,div:()=>({conversion:aa,priority:1}),pre:()=>({conversion:z,priority:0}),table:a=>A(a)?{conversion:ba,priority:3}:null,td:a=>{let b=a.closest("table");return a.classList.contains("js-file-line")? | ||
{conversion:ca,priority:3}:b&&A(b)?{conversion:B,priority:3}:null},tr:a=>(a=a.closest("table"))&&A(a)?{conversion:B,priority:3}:null}}static importJSON(a){let b=C(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()&&a.anchor.key=== | ||
this.__key&&a.anchor.offset===e)return c[e-1].remove(),c[e-2].remove(),a=r.$createParagraphNode(),this.insertAfter(a,b),a;b=a.anchor;c=a.focus;b=(b.isBefore(c)?b:c).getNode();if(D(b)||r.$isTabNode(b)){b=E(b);for(c=[];;)if(r.$isTabNode(b))c.push(r.$createTabNode()),b=b.getNextSibling();else if(D(b)){e=0;let f=b.getTextContent(),g=b.getTextContentSize();for(;e<g&&" "===f[e];e++);0!==e&&c.push(F(" ".repeat(e)));if(e!==g)break;b=b.getNextSibling()}else break;if(0<c.length)return a.insertNodes([r.$createLineBreakNode(), | ||
...c]),c[c.length-1]}return null}canIndent(){return!1}collapseAtStart(){let a=r.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}setLanguage(a){this.getWritable().__language=v(a)}getLanguage(){return this.getLatest().__language}}function C(a){return r.$applyNodeReplacement(new y(a))}function G(a){return a instanceof y}function z(a){let b;l.isHTMLElement(a)&&(b=a.getAttribute("data-highlight-language"));return{node:C(b)}} | ||
function aa(a){let b=null!==a.style.fontFamily.match("monospace");return b||da(a)?{after:c=>{let e=a.parentNode;null!=e&&a!==e.lastChild&&c.push(r.$createLineBreakNode());return c},node:b?C():null}:{node:null}}function ba(){return{node:C()}}function B(){return{node:null}}function ca(a){return{after:b=>{a.parentNode&&a.parentNode.nextSibling&&b.push(r.$createLineBreakNode());return b},node:null}} | ||
function da(a){for(a=a.parentElement;null!==a;){if(null!==a.style.fontFamily.match("monospace"))return!0;a=a.parentElement}return!1}function A(a){return a.classList.contains("js-file-line-container")} | ||
this.__key&&a.anchor.offset===e)return c[e-1].remove(),c[e-2].remove(),a=q.$createParagraphNode(),this.insertAfter(a,b),a;let {anchor:f,focus:g}=a;b=(f.isBefore(g)?f:g).getNode();if(q.$isTextNode(b)){e=D(b);for(c=[];;)if(q.$isTabNode(e))c.push(q.$createTabNode()),e=e.getNextSibling();else if(E(e)){for(var h=0,k=e.getTextContent(),l=e.getTextContentSize();h<l&&" "===k[h];h++);0!==h&&c.push(F(" ".repeat(h)));if(h!==l)break;e=e.getNextSibling()}else break;e=b.splitText(f.offset)[0];h=0===f.offset?0: | ||
1;h=e.getIndexWithinParent()+h;k=b.getParentOrThrow();l=[q.$createLineBreakNode(),...c];k.splice(h,0,l);(c=c[c.length-1])?c.select():0===f.offset?e.selectPrevious():e.getNextSibling().selectNext(0,0)}G(b)&&({offset:a}=a.anchor,b.splice(a,0,[q.$createLineBreakNode()]),b.select(a+1,a+1));return null}canIndent(){return!1}collapseAtStart(){let a=q.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}setLanguage(a){this.getWritable().__language=v(a)}getLanguage(){return this.getLatest().__language}} | ||
function C(a){return q.$applyNodeReplacement(new y(a))}function G(a){return a instanceof y}function z(a){let b;m.isHTMLElement(a)&&(b=a.getAttribute("data-highlight-language"));return{node:C(b)}}function aa(a){let b=null!==a.style.fontFamily.match("monospace");return b||da(a)?{after:c=>{let e=a.parentNode;null!=e&&a!==e.lastChild&&c.push(q.$createLineBreakNode());return c},node:b?C():null}:{node:null}}function ba(){return{node:C()}}function B(){return{node:null}} | ||
function ca(a){return{after:b=>{a.parentNode&&a.parentNode.nextSibling&&b.push(q.$createLineBreakNode());return b},node:null}}function da(a){for(a=a.parentElement;null!==a;){if(null!==a.style.fontFamily.match("monospace"))return!0;a=a.parentElement}return!1}function A(a){return a.classList.contains("js-file-line-container")} | ||
let H={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"},I={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function K(a){return I[a]||a} | ||
class L extends r.TextNode{constructor(a,b,c){super(a,c);this.__highlightType=b}static getType(){return"code-highlight"}static clone(a){return new L(a.__text,a.__highlightType||void 0,a.__key)}getHighlightType(){return this.getLatest().__highlightType}createDOM(a){let b=super.createDOM(a);a=M(a.theme,this.__highlightType);l.addClassNamesToElement(b,a);return b}updateDOM(a,b,c){let e=super.updateDOM(a,b,c);a=M(c.theme,a.__highlightType);c=M(c.theme,this.__highlightType);a!==c&&(a&&l.removeClassNamesFromElement(b, | ||
a),c&&l.addClassNamesToElement(b,c));return e}static importJSON(a){let b=F(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 C()}}function M(a,b){return b&&a&&a.codeHighlight&&a.codeHighlight[b]} | ||
function F(a,b){return r.$applyNodeReplacement(new L(a,b))}function D(a){return a instanceof L}function E(a){let b=a;for(;D(a)||r.$isTabNode(a);)b=a,a=a.getPreviousSibling();return b}function N(a){let b=a;for(;D(a)||r.$isTabNode(a);)b=a,a=a.getNextSibling();return b}let O={defaultLanguage:"javascript",tokenize(a,b){return d.tokenize(a,d.languages[b||""]||d.languages[this.defaultLanguage])}}; | ||
function P(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;if(!(D(f)||r.$isTabNode(f)||r.$isLineBreakNode(f)))throw Error("Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode");if(r.$isLineBreakNode(f)){c={node:f,offset:1};break}g=Math.max(0,f.getTextContentSize()-1);h=f.getTextContent()}else g--;let k=h[g];D(f)&&" "!==k&&(e={node:f,offset:g})}if(null!==e)return e;e=null;b<a.getTextContentSize()?D(a)&&(e=a.getTextContent()[b]): | ||
(f=a.getNextSibling(),D(f)&&(e=f.getTextContent()[0]));if(null!==e&&" "!==e)return c;a:for(e=a,f=a.getTextContent(),a=a.getTextContentSize();;){if(!D(e)||b===a){e=e.getNextSibling();if(null===e||r.$isLineBreakNode(e)){a=null;break a}D(e)&&(b=0,f=e.getTextContent(),a=e.getTextContentSize())}if(D(e)){if(" "!==f[b]){a={node:e,offset:b};break a}b++}}return null!==a?a:c}function Q(a){a=N(a);if(r.$isLineBreakNode(a))throw Error("Unexpected lineBreakNode in getEndOfCodeInLine");return a} | ||
function R(a,b,c){let e=a.getParent();G(e)?S(e,b,c):D(a)&&a.replace(r.$createTextNode(a.__text))}let T=new Set; | ||
function S(a,b,c){let e=a.getKey();T.has(e)||(T.add(e),void 0===a.getLanguage()&&a.setLanguage(c.defaultLanguage),b.update(()=>{ea(e,()=>{var f=r.$getNodeByKey(e);if(!G(f)||!f.isAttached())return!1;var g=f.getTextContent();g=c.tokenize(g,f.getLanguage()||c.defaultLanguage);g=U(g);var h=f.getChildren();for(f=0;f<h.length&&V(h[f],g[f]);)f++;var k=h.length;let m=g.length,q=Math.min(k,m)-f,n=0;for(;n<q;)if(n++,!V(h[k-n],g[m-n])){n--;break}h=f;k-=n;g=g.slice(f,m-n);let {from:p,to:w,nodesForReplacement:u}= | ||
class L extends q.TextNode{constructor(a,b,c){super(a,c);this.__highlightType=b}static getType(){return"code-highlight"}static clone(a){return new L(a.__text,a.__highlightType||void 0,a.__key)}getHighlightType(){return this.getLatest().__highlightType}createDOM(a){let b=super.createDOM(a);a=M(a.theme,this.__highlightType);m.addClassNamesToElement(b,a);return b}updateDOM(a,b,c){let e=super.updateDOM(a,b,c);a=M(c.theme,a.__highlightType);c=M(c.theme,this.__highlightType);a!==c&&(a&&m.removeClassNamesFromElement(b, | ||
a),c&&m.addClassNamesToElement(b,c));return e}static importJSON(a){let b=F(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 C()}}function M(a,b){return b&&a&&a.codeHighlight&&a.codeHighlight[b]} | ||
function F(a,b){return q.$applyNodeReplacement(new L(a,b))}function E(a){return a instanceof L}function D(a){let b=a;for(;E(a)||q.$isTabNode(a);)b=a,a=a.getPreviousSibling();return b}function N(a){let b=a;for(;E(a)||q.$isTabNode(a);)b=a,a=a.getNextSibling();return b}let O={defaultLanguage:"javascript",tokenize(a,b){return d.tokenize(a,d.languages[b||""]||d.languages[this.defaultLanguage])}}; | ||
function P(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;if(!(E(f)||q.$isTabNode(f)||q.$isLineBreakNode(f)))throw Error("Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode");if(q.$isLineBreakNode(f)){c={node:f,offset:1};break}g=Math.max(0,f.getTextContentSize()-1);h=f.getTextContent()}else g--;let k=h[g];E(f)&&" "!==k&&(e={node:f,offset:g})}if(null!==e)return e;e=null;b<a.getTextContentSize()?E(a)&&(e=a.getTextContent()[b]): | ||
(f=a.getNextSibling(),E(f)&&(e=f.getTextContent()[0]));if(null!==e&&" "!==e)return c;a:for(e=a,f=a.getTextContent(),a=a.getTextContentSize();;){if(!E(e)||b===a){e=e.getNextSibling();if(null===e||q.$isLineBreakNode(e)){a=null;break a}E(e)&&(b=0,f=e.getTextContent(),a=e.getTextContentSize())}if(E(e)){if(" "!==f[b]){a={node:e,offset:b};break a}b++}}return null!==a?a:c}function Q(a){a=N(a);if(q.$isLineBreakNode(a))throw Error("Unexpected lineBreakNode in getEndOfCodeInLine");return a} | ||
function R(a,b,c){let e=a.getParent();G(e)?S(e,b,c):E(a)&&a.replace(q.$createTextNode(a.__text))}let T=new Set; | ||
function S(a,b,c){let e=a.getKey();T.has(e)||(T.add(e),void 0===a.getLanguage()&&a.setLanguage(c.defaultLanguage),b.update(()=>{ea(e,()=>{var f=q.$getNodeByKey(e);if(!G(f)||!f.isAttached())return!1;var g=f.getTextContent();g=c.tokenize(g,f.getLanguage()||c.defaultLanguage);g=U(g);var h=f.getChildren();for(f=0;f<h.length&&V(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++,!V(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}= | ||
{from:h,nodesForReplacement:g,to:k};return p!==w||u.length?(a.splice(p,w-p,u),!0):!1})},{onUpdate:()=>{T.delete(e)},skipTransforms:!0}))} | ||
function U(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(r.$createLineBreakNode()):"\t"===h?c.push(r.$createTabNode()):0<h.length&&c.push(F(h,b))}}else({content:a}=e),"string"===typeof a?c.push(...U([a],e.type)):Array.isArray(a)&&c.push(...U(a,e.type));return c} | ||
function ea(a,b){a=r.$getNodeByKey(a);if(G(a)&&a.isAttached()){var c=r.$getSelection();if(r.$isRangeSelection(c)){c=c.anchor;var e=c.offset,f="element"===c.type&&r.$isLineBreakNode(a.getChildAtIndex(c.offset-1)),g=0;if(!f){let h=c.getNode();g=e+h.getPreviousSiblings().reduce((k,m)=>k+m.getTextContentSize(),0)}b()&&(f?c.getNode().select(e,e):a.getChildren().some(h=>{let k=r.$isTextNode(h);if(k||r.$isLineBreakNode(h)){let m=h.getTextContentSize();if(k&&m>=g)return h.select(g,g),!0;g-=m}return!1}))}else b()}} | ||
function V(a,b){return D(a)&&D(b)&&a.__text===b.__text&&a.__highlightType===b.__highlightType||r.$isTabNode(a)&&r.$isTabNode(b)||r.$isLineBreakNode(a)&&r.$isLineBreakNode(b)}function W(a){if(!r.$isRangeSelection(a))return!1;var b=a.anchor.getNode();a=a.focus.getNode();if(b.is(a)&&G(b))return!0;b=b.getParent();return G(b)&&b.is(a.getParent())} | ||
function X(a){a=a.getNodes();let b=[[]];if(1===a.length&&G(a[0]))return b;let c=b[0];for(let e=0;e<a.length;e++){let f=a[e];if(!(D(f)||r.$isTabNode(f)||r.$isLineBreakNode(f)))throw Error("Expected selection to be inside CodeBlock and consisting of CodeHighlightNode, TabNode and LineBreakNode");r.$isLineBreakNode(f)?0!==e&&0<c.length&&(c=[],b.push(c)):c.push(f)}return b} | ||
function fa(a){var b=r.$getSelection();if(!r.$isRangeSelection(b)||!W(b))return null;let c=a?r.OUTDENT_CONTENT_COMMAND:r.INDENT_CONTENT_COMMAND;a=a?r.OUTDENT_CONTENT_COMMAND:r.INSERT_TAB_COMMAND;if(1<X(b).length)return c;var e=b.getNodes()[0];if(!(G(e)||D(e)||r.$isTabNode(e)||r.$isLineBreakNode(e)))throw Error("Expected selection firstNode to be CodeHighlightNode or TabNode");if(G(e))return c;let f=E(e);e=N(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=== | ||
function U(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(q.$createLineBreakNode()):"\t"===h?c.push(q.$createTabNode()):0<h.length&&c.push(F(h,b))}}else({content:a}=e),"string"===typeof a?c.push(...U([a],e.type)):Array.isArray(a)&&c.push(...U(a,e.type));return c} | ||
function ea(a,b){a=q.$getNodeByKey(a);if(G(a)&&a.isAttached()){var c=q.$getSelection();if(q.$isRangeSelection(c)){c=c.anchor;var e=c.offset,f="element"===c.type&&q.$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=q.$isTextNode(h);if(k||q.$isLineBreakNode(h)){let l=h.getTextContentSize();if(k&&l>=g)return h.select(g,g),!0;g-=l}return!1}))}else b()}} | ||
function V(a,b){return E(a)&&E(b)&&a.__text===b.__text&&a.__highlightType===b.__highlightType||q.$isTabNode(a)&&q.$isTabNode(b)||q.$isLineBreakNode(a)&&q.$isLineBreakNode(b)}function W(a){if(!q.$isRangeSelection(a))return!1;var b=a.anchor.getNode();a=a.focus.getNode();if(b.is(a)&&G(b))return!0;b=b.getParent();return G(b)&&b.is(a.getParent())} | ||
function X(a){a=a.getNodes();let b=[[]];if(1===a.length&&G(a[0]))return b;let c=b[0];for(let e=0;e<a.length;e++){let f=a[e];if(!(E(f)||q.$isTabNode(f)||q.$isLineBreakNode(f)))throw Error("Expected selection to be inside CodeBlock and consisting of CodeHighlightNode, TabNode and LineBreakNode");q.$isLineBreakNode(f)?0!==e&&0<c.length&&(c=[],b.push(c)):c.push(f)}return b} | ||
function fa(a){var b=q.$getSelection();if(!q.$isRangeSelection(b)||!W(b))return null;let c=a?q.OUTDENT_CONTENT_COMMAND:q.INDENT_CONTENT_COMMAND;a=a?q.OUTDENT_CONTENT_COMMAND:q.INSERT_TAB_COMMAND;if(1<X(b).length)return c;var e=b.getNodes()[0];if(!(G(e)||E(e)||q.$isTabNode(e)||q.$isLineBreakNode(e)))throw Error("Expected selection firstNode to be CodeHighlightNode or TabNode");if(G(e))return c;let f=D(e);e=N(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()?c:a} | ||
function Y(a){var b=r.$getSelection();if(!r.$isRangeSelection(b)||!W(b))return!1;var c=X(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===r.INDENT_CONTENT_COMMAND?f.insertBefore(r.$createTabNode()):r.$isTabNode(f)&&f.remove()))}return!0}c=b.getNodes()[0];if(!(G(c)||D(c)||r.$isTabNode(c)||r.$isLineBreakNode(c)))throw Error("Expected selection firstNode to be CodeHighlightNode or CodeTabNode");if(G(c))return a===r.INDENT_CONTENT_COMMAND&& | ||
b.insertNodes([r.$createTabNode()]),!0;c=E(c);if(null===c)throw Error("Expected getFirstCodeNodeOfLine to return a valid Code Node");a===r.INDENT_CONTENT_COMMAND?r.$isLineBreakNode(c)?c.insertAfter(r.$createTabNode()):c.insertBefore(r.$createTabNode()):r.$isTabNode(c)&&c.remove();return!0} | ||
function Z(a,b){let c=r.$getSelection();if(!r.$isRangeSelection(c))return!1;let {anchor:e,focus:f}=c,g=e.offset,h=f.offset,k=e.getNode(),m=f.getNode();var q=a===r.KEY_ARROW_UP_COMMAND;if(!W(c)||!D(k)&&!r.$isTabNode(k)||!D(m)&&!r.$isTabNode(m))return!1;if(!b.altKey){if(c.isCollapsed())if(a=k.getParentOrThrow(),q&&0===g&&null===k.getPreviousSibling()){if(null===a.getPreviousSibling())return a.selectPrevious(),b.preventDefault(),!0}else if(!q&&g===k.getTextContentSize()&&null===k.getNextSibling()&&null=== | ||
a.getNextSibling())return a.selectNext(),b.preventDefault(),!0;return!1}let n;if(k.isBefore(m)){var p=E(k);n=N(m)}else p=E(m),n=N(k);if(null==p||null==n)return!1;let w=p.getNodesBetween(n);for(let t=0;t<w.length;t++){let J=w[t];if(!D(J)&&!r.$isTabNode(J)&&!r.$isLineBreakNode(J))return!1}b.preventDefault();b.stopPropagation();b=q?p.getPreviousSibling():n.getNextSibling();if(!r.$isLineBreakNode(b))return!0;p=q?b.getPreviousSibling():b.getNextSibling();if(null==p)return!0;q=D(p)||r.$isTabNode(p)||r.$isLineBreakNode(p)? | ||
q?E(p):N(p):null;let u=null!=q?q:p;b.remove();w.forEach(t=>t.remove());a===r.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,m,h);return!0} | ||
function ha(a,b){let c=r.$getSelection();if(!r.$isRangeSelection(c))return!1;let {anchor:e,focus:f}=c;var g=e.getNode();let h=f.getNode();a=a===r.MOVE_TO_START;if(!D(g)&&!r.$isTabNode(g)||!D(h)&&!r.$isTabNode(h))return!1;if(a)if(g=P(h,f.offset),null!==g){let {node:k,offset:m}=g;r.$isLineBreakNode(k)?k.selectNext(0,0):c.setTextNodeRange(k,m,k,m)}else h.getParentOrThrow().selectStart();else Q(h).select();b.preventDefault();b.stopPropagation();return!0}exports.$createCodeHighlightNode=F; | ||
exports.$createCodeNode=C;exports.$isCodeHighlightNode=D;exports.$isCodeNode=G;exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP=H;exports.CODE_LANGUAGE_MAP=I;exports.CodeHighlightNode=L;exports.CodeNode=y;exports.DEFAULT_CODE_LANGUAGE="javascript";exports.PrismTokenizer=O;exports.getCodeLanguages=()=>Object.keys(d.languages).filter(a=>"function"!==typeof d.languages[a]).sort();exports.getDefaultCodeLanguage=()=>"javascript";exports.getEndOfCodeInLine=Q;exports.getFirstCodeNodeOfLine=E; | ||
function Y(a){var b=q.$getSelection();if(!q.$isRangeSelection(b)||!W(b))return!1;var c=X(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=D(f)),null!==f&&(a===q.INDENT_CONTENT_COMMAND?f.insertBefore(q.$createTabNode()):q.$isTabNode(f)&&f.remove()))}return!0}c=b.getNodes()[0];if(!(G(c)||E(c)||q.$isTabNode(c)||q.$isLineBreakNode(c)))throw Error("Expected selection firstNode to be CodeHighlightNode or CodeTabNode");if(G(c))return a===q.INDENT_CONTENT_COMMAND&& | ||
b.insertNodes([q.$createTabNode()]),!0;c=D(c);if(null===c)throw Error("Expected getFirstCodeNodeOfLine to return a valid Code Node");a===q.INDENT_CONTENT_COMMAND?q.$isLineBreakNode(c)?c.insertAfter(q.$createTabNode()):c.insertBefore(q.$createTabNode()):q.$isTabNode(c)&&c.remove();return!0} | ||
function Z(a,b){let c=q.$getSelection();if(!q.$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===q.KEY_ARROW_UP_COMMAND;if(!W(c)||!E(k)&&!q.$isTabNode(k)||!E(l)&&!q.$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()&&null=== | ||
a.getNextSibling())return a.selectNext(),b.preventDefault(),!0;return!1}let n;if(k.isBefore(l)){var p=D(k);n=N(l)}else p=D(l),n=N(k);if(null==p||null==n)return!1;let w=p.getNodesBetween(n);for(let t=0;t<w.length;t++){let J=w[t];if(!E(J)&&!q.$isTabNode(J)&&!q.$isLineBreakNode(J))return!1}b.preventDefault();b.stopPropagation();b=r?p.getPreviousSibling():n.getNextSibling();if(!q.$isLineBreakNode(b))return!0;p=r?b.getPreviousSibling():b.getNextSibling();if(null==p)return!0;r=E(p)||q.$isTabNode(p)||q.$isLineBreakNode(p)? | ||
r?D(p):N(p):null;let u=null!=r?r:p;b.remove();w.forEach(t=>t.remove());a===q.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} | ||
function ha(a,b){let c=q.$getSelection();if(!q.$isRangeSelection(c))return!1;let {anchor:e,focus:f}=c;var g=e.getNode();let h=f.getNode();a=a===q.MOVE_TO_START;if(!E(g)&&!q.$isTabNode(g)||!E(h)&&!q.$isTabNode(h))return!1;if(a)if(g=P(h,f.offset),null!==g){let {node:k,offset:l}=g;q.$isLineBreakNode(k)?k.selectNext(0,0):c.setTextNodeRange(k,l,k,l)}else h.getParentOrThrow().selectStart();else Q(h).select();b.preventDefault();b.stopPropagation();return!0}exports.$createCodeHighlightNode=F; | ||
exports.$createCodeNode=C;exports.$isCodeHighlightNode=E;exports.$isCodeNode=G;exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP=H;exports.CODE_LANGUAGE_MAP=I;exports.CodeHighlightNode=L;exports.CodeNode=y;exports.DEFAULT_CODE_LANGUAGE="javascript";exports.PrismTokenizer=O;exports.getCodeLanguages=()=>Object.keys(d.languages).filter(a=>"function"!==typeof d.languages[a]).sort();exports.getDefaultCodeLanguage=()=>"javascript";exports.getEndOfCodeInLine=Q;exports.getFirstCodeNodeOfLine=D; | ||
exports.getLanguageFriendlyName=function(a){a=K(a);return H[a]||a};exports.getLastCodeNodeOfLine=N;exports.getStartOfCodeInLine=P;exports.normalizeCodeLang=K; | ||
exports.registerCodeHighlighting=function(a,b){if(!a.hasNodes([y,L]))throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==b&&(b=O);return l.mergeRegister(a.registerMutationListener(y,c=>{a.update(()=>{for(let [g,h]of c)if("destroyed"!==h){var e=r.$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 m="1",q=1;for(let n= | ||
0;n<k;n++)r.$isLineBreakNode(f[n])&&(m+="\n"+ ++q);e.setAttribute("data-gutter",m)}}})}),a.registerNodeTransform(y,c=>S(c,a,b)),a.registerNodeTransform(r.TextNode,c=>R(c,a,b)),a.registerNodeTransform(L,c=>R(c,a,b)),a.registerCommand(r.KEY_TAB_COMMAND,c=>{let e=fa(c.shiftKey);if(null===e)return!1;c.preventDefault();a.dispatchCommand(e,void 0);return!0},r.COMMAND_PRIORITY_LOW),a.registerCommand(r.INSERT_TAB_COMMAND,()=>{let c=r.$getSelection();if(!W(c))return!1;r.$insertNodes([r.$createTabNode()]); | ||
return!0},r.COMMAND_PRIORITY_LOW),a.registerCommand(r.INDENT_CONTENT_COMMAND,()=>Y(r.INDENT_CONTENT_COMMAND),r.COMMAND_PRIORITY_LOW),a.registerCommand(r.OUTDENT_CONTENT_COMMAND,()=>Y(r.OUTDENT_CONTENT_COMMAND),r.COMMAND_PRIORITY_LOW),a.registerCommand(r.KEY_ARROW_UP_COMMAND,c=>Z(r.KEY_ARROW_UP_COMMAND,c),r.COMMAND_PRIORITY_LOW),a.registerCommand(r.KEY_ARROW_DOWN_COMMAND,c=>Z(r.KEY_ARROW_DOWN_COMMAND,c),r.COMMAND_PRIORITY_LOW),a.registerCommand(r.MOVE_TO_END,c=>ha(r.MOVE_TO_END,c),r.COMMAND_PRIORITY_LOW), | ||
a.registerCommand(r.MOVE_TO_START,c=>ha(r.MOVE_TO_START,c),r.COMMAND_PRIORITY_LOW))} | ||
exports.registerCodeHighlighting=function(a,b){if(!a.hasNodes([y,L]))throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==b&&(b=O);return m.mergeRegister(a.registerMutationListener(y,c=>{a.update(()=>{for(let [g,h]of c)if("destroyed"!==h){var e=q.$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= | ||
0;n<k;n++)q.$isLineBreakNode(f[n])&&(l+="\n"+ ++r);e.setAttribute("data-gutter",l)}}})}),a.registerNodeTransform(y,c=>S(c,a,b)),a.registerNodeTransform(q.TextNode,c=>R(c,a,b)),a.registerNodeTransform(L,c=>R(c,a,b)),a.registerCommand(q.KEY_TAB_COMMAND,c=>{let e=fa(c.shiftKey);if(null===e)return!1;c.preventDefault();a.dispatchCommand(e,void 0);return!0},q.COMMAND_PRIORITY_LOW),a.registerCommand(q.INSERT_TAB_COMMAND,()=>{let c=q.$getSelection();if(!W(c))return!1;q.$insertNodes([q.$createTabNode()]); | ||
return!0},q.COMMAND_PRIORITY_LOW),a.registerCommand(q.INDENT_CONTENT_COMMAND,()=>Y(q.INDENT_CONTENT_COMMAND),q.COMMAND_PRIORITY_LOW),a.registerCommand(q.OUTDENT_CONTENT_COMMAND,()=>Y(q.OUTDENT_CONTENT_COMMAND),q.COMMAND_PRIORITY_LOW),a.registerCommand(q.KEY_ARROW_UP_COMMAND,c=>Z(q.KEY_ARROW_UP_COMMAND,c),q.COMMAND_PRIORITY_LOW),a.registerCommand(q.KEY_ARROW_DOWN_COMMAND,c=>Z(q.KEY_ARROW_DOWN_COMMAND,c),q.COMMAND_PRIORITY_LOW),a.registerCommand(q.MOVE_TO_END,c=>ha(q.MOVE_TO_END,c),q.COMMAND_PRIORITY_LOW), | ||
a.registerCommand(q.MOVE_TO_START,c=>ha(q.MOVE_TO_START,c),q.COMMAND_PRIORITY_LOW))} |
@@ -11,9 +11,9 @@ { | ||
"license": "MIT", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"main": "LexicalCode.js", | ||
"peerDependencies": { | ||
"lexical": "0.12.2" | ||
"lexical": "0.12.3" | ||
}, | ||
"dependencies": { | ||
"@lexical/utils": "0.12.2", | ||
"@lexical/utils": "0.12.3", | ||
"prismjs": "^1.27.0" | ||
@@ -20,0 +20,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66680
1347
+ Added@lexical/list@0.12.3(transitive)
+ Added@lexical/selection@0.12.3(transitive)
+ Added@lexical/table@0.12.3(transitive)
+ Added@lexical/utils@0.12.3(transitive)
+ Addedlexical@0.12.3(transitive)
- Removed@lexical/list@0.12.2(transitive)
- Removed@lexical/selection@0.12.2(transitive)
- Removed@lexical/table@0.12.2(transitive)
- Removed@lexical/utils@0.12.2(transitive)
- Removedlexical@0.12.2(transitive)
Updated@lexical/utils@0.12.3