@lexical/code 0.2.5 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LexicalCode.d.ts CHANGED
@@ -4,7 +4,6 @@
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
- * @flow strict
8
7
  */
9
8
 
10
9
  import type {
@@ -23,7 +22,7 @@ declare class CodeNode extends ElementNode {
23
22
  static getType(): string;
24
23
  static clone(node: CodeNode): CodeNode;
25
24
  constructor(key?: NodeKey);
26
- createDOM<EditorContext>(config: EditorConfig<EditorContext>): HTMLElement;
25
+ createDOM(config: EditorConfig): HTMLElement;
27
26
  updateDOM(prevNode: CodeNode, dom: HTMLElement): boolean;
28
27
  insertNewAfter(
29
28
  selection: RangeSelection,
@@ -33,7 +32,7 @@ declare class CodeNode extends ElementNode {
33
32
  setLanguage(language: string): void;
34
33
  getLanguage(): string | void;
35
34
  }
36
- declare function $createCodeNode(): CodeNode;
35
+ declare function $createCodeNode(language?: string): CodeNode;
37
36
  declare function $isCodeNode(
38
37
  node: null | undefined | LexicalNode,
39
38
  ): node is CodeNode;
@@ -54,12 +53,11 @@ declare class CodeHighlightNode extends TextNode {
54
53
  constructor(text: string, highlightType?: string, key?: NodeKey);
55
54
  static getType(): string;
56
55
  static clone(node: CodeHighlightNode): CodeHighlightNode;
57
- createDOM<EditorContext>(config: EditorConfig<EditorContext>): HTMLElement;
58
- updateDOM<EditorContext>(
59
- // $FlowFixMe
56
+ createDOM(config: EditorConfig): HTMLElement;
57
+ updateDOM(
60
58
  prevNode: CodeHighlightNode,
61
59
  dom: HTMLElement,
62
- config: EditorConfig<EditorContext>,
60
+ config: EditorConfig,
63
61
  ): boolean;
64
62
  setFormat(format: number): this;
65
63
  }
@@ -72,7 +70,7 @@ declare function $createCodeHighlightNode(
72
70
  highlightType?: string,
73
71
  ): CodeHighlightNode;
74
72
  declare function $isCodeHighlightNode(
75
- node: ?LexicalNode,
73
+ node: LexicalNode | null | undefined,
76
74
  ): node is CodeHighlightNode;
77
75
 
78
76
  declare function registerCodeHighlighting(editor: LexicalEditor): () => void;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  'use strict';
8
8
 
9
- var Prism = require('prismjs/components/prism-core');
9
+ var Prism = require('prismjs');
10
10
  require('prismjs/components/prism-clike');
11
11
  require('prismjs/components/prism-javascript');
12
12
  require('prismjs/components/prism-markup');
@@ -27,11 +27,11 @@ var lexical = require('lexical');
27
27
  * This source code is licensed under the MIT license found in the
28
28
  * LICENSE file in the root directory of this source tree.
29
29
  *
30
- *
31
30
  */
32
31
  const DEFAULT_CODE_LANGUAGE = 'javascript';
33
32
 
34
33
  const mapToPrismLanguage = language => {
34
+ // eslint-disable-next-line no-prototype-builtins
35
35
  return language != null && Prism.languages.hasOwnProperty(language) ? language : undefined;
36
36
  };
37
37
 
@@ -60,8 +60,7 @@ class CodeHighlightNode extends lexical.TextNode {
60
60
  return element;
61
61
  }
62
62
 
63
- updateDOM( // $FlowFixMe
64
- prevNode, dom, config) {
63
+ updateDOM(prevNode, dom, config) {
65
64
  const update = super.updateDOM(prevNode, dom, config);
66
65
  const prevClassName = getHighlightThemeClass(config.theme, prevNode.__highlightType);
67
66
  const nextClassName = getHighlightThemeClass(config.theme, this.__highlightType);
@@ -151,8 +150,7 @@ class CodeNode extends lexical.ElementNode {
151
150
  priority: 0
152
151
  }),
153
152
  table: node => {
154
- // $FlowFixMe[incompatible-type] domNode is a <table> since we matched it by nodeName
155
- const table = node;
153
+ const table = node; // domNode is a <table> since we matched it by nodeName
156
154
 
157
155
  if (isGitHubCodeTable(table)) {
158
156
  return {
@@ -164,9 +162,8 @@ class CodeNode extends lexical.ElementNode {
164
162
  return null;
165
163
  },
166
164
  td: node => {
167
- // $FlowFixMe[incompatible-type] element is a <td> since we matched it by nodeName
168
- const td = node; // $FlowFixMe[incompatible-type] we know this will be a table, or null.
169
-
165
+ // element is a <td> since we matched it by nodeName
166
+ const td = node;
170
167
  const table = td.closest('table');
171
168
 
172
169
  if (isGitHubCodeCell(td)) {
@@ -188,9 +185,8 @@ class CodeNode extends lexical.ElementNode {
188
185
  return null;
189
186
  },
190
187
  tr: node => {
191
- // $FlowFixMe[incompatible-type] element is a <tr> since we matched it by nodeName
192
- const tr = node; // $FlowFixMe[incompatible-type] we know this will be a table, or null.
193
-
188
+ // element is a <tr> since we matched it by nodeName
189
+ const tr = node;
194
190
  const table = tr.closest('table');
195
191
 
196
192
  if (table && isGitHubCodeTable(table)) {
@@ -329,7 +325,7 @@ function convertPreElement(domNode) {
329
325
  }
330
326
 
331
327
  function convertDivElement(domNode) {
332
- // $FlowFixMe[incompatible-type] domNode is a <div> since we matched it by nodeName
328
+ // domNode is a <div> since we matched it by nodeName
333
329
  const div = domNode;
334
330
  return {
335
331
  after: childLexicalNodes => {
@@ -358,7 +354,7 @@ function convertCodeNoop() {
358
354
  }
359
355
 
360
356
  function convertTableCellElement(domNode) {
361
- // $FlowFixMe[incompatible-type] domNode is a <td> since we matched it by nodeName
357
+ // domNode is a <td> since we matched it by nodeName
362
358
  const cell = domNode;
363
359
  return {
364
360
  after: childLexicalNodes => {
@@ -407,12 +403,12 @@ function updateCodeGutter(node, editor) {
407
403
  }
408
404
 
409
405
  const children = node.getChildren();
410
- const childrenLength = children.length; // $FlowFixMe: internal field
406
+ const childrenLength = children.length; // @ts-ignore: internal field
411
407
 
412
408
  if (childrenLength === codeElement.__cachedChildrenLength) {
413
409
  // Avoid updating the attribute if the children length hasn't changed.
414
410
  return;
415
- } // $FlowFixMe: internal field
411
+ } // @ts-ignore:: internal field
416
412
 
417
413
 
418
414
  codeElement.__cachedChildrenLength = childrenLength;
@@ -502,9 +498,9 @@ function getHighlightNodes(tokens) {
502
498
 
503
499
  if (typeof content === 'string') {
504
500
  nodes.push($createCodeHighlightNode(content, token.type));
505
- } else if (content.length === 1 && typeof content[0] === 'string') {
501
+ } else if (Array.isArray(content) && content.length === 1 && typeof content[0] === 'string') {
506
502
  nodes.push($createCodeHighlightNode(content[0], token.type));
507
- } else {
503
+ } else if (Array.isArray(content)) {
508
504
  nodes.push(...getHighlightNodes(content));
509
505
  }
510
506
  }
@@ -33,7 +33,7 @@ declare export class CodeNode extends ElementNode {
33
33
  setLanguage(language: string): void;
34
34
  getLanguage(): string | void;
35
35
  }
36
- declare export function $createCodeNode(): CodeNode;
36
+ declare export function $createCodeNode(language?: string): CodeNode;
37
37
  declare export function $isCodeNode(
38
38
  node: ?LexicalNode,
39
39
  ): boolean %checks(node instanceof CodeNode);
@@ -4,25 +4,25 @@
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 d=require("prismjs/components/prism-core");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");
8
- var n=require("@lexical/utils"),r=require("lexical");const t=a=>null!=a&&d.languages.hasOwnProperty(a)?a:void 0;
9
- class u extends r.TextNode{constructor(a,c,b){super(a,b);this.__highlightType=c}static getType(){return"code-highlight"}static clone(a){return new u(a.__text,a.__highlightType||void 0,a.__key)}createDOM(a){const c=super.createDOM(a);a=v(a.theme,this.__highlightType);n.addClassNamesToElement(c,a);return c}updateDOM(a,c,b){const e=super.updateDOM(a,c,b);a=v(b.theme,a.__highlightType);b=v(b.theme,this.__highlightType);a!==b&&(a&&n.removeClassNamesFromElement(c,a),b&&n.addClassNamesToElement(c,b));return e}setFormat(){return this}}
7
+ var e=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");
8
+ var n=require("@lexical/utils"),r=require("lexical");const t=a=>null!=a&&e.languages.hasOwnProperty(a)?a:void 0;
9
+ class u extends r.TextNode{constructor(a,c,b){super(a,b);this.__highlightType=c}static getType(){return"code-highlight"}static clone(a){return new u(a.__text,a.__highlightType||void 0,a.__key)}createDOM(a){const c=super.createDOM(a);a=v(a.theme,this.__highlightType);n.addClassNamesToElement(c,a);return c}updateDOM(a,c,b){const d=super.updateDOM(a,c,b);a=v(b.theme,a.__highlightType);b=v(b.theme,this.__highlightType);a!==b&&(a&&n.removeClassNamesFromElement(c,a),b&&n.addClassNamesToElement(c,b));return d}setFormat(){return this}}
10
10
  function v(a,c){return c&&a&&a.codeHighlight&&a.codeHighlight[c]}function y(a,c){return new u(a,c)}function z(a){return a instanceof u}
11
11
  class B extends r.ElementNode{static getType(){return"code"}static clone(a){return new B(a.__language,a.__key)}constructor(a,c){super(c);this.__language=t(a)}createDOM(a){const c=document.createElement("code");n.addClassNamesToElement(c,a.theme.code);c.setAttribute("spellcheck","false");(a=this.getLanguage())&&c.setAttribute("data-highlight-language",a);return c}updateDOM(a,c){const b=this.__language;a=a.__language;b?b!==a&&c.setAttribute("data-highlight-language",b):a&&c.removeAttribute("data-highlight-language");
12
12
  return!1}static importDOM(){return{div:()=>({conversion:C,priority:1}),pre:()=>({conversion:D,priority:0}),table:a=>E(a)?{conversion:F,priority:4}:null,td:a=>{const c=a.closest("table");return a.classList.contains("js-file-line")?{conversion:G,priority:4}:c&&E(c)?{conversion:H,priority:4}:null},tr:a=>(a=a.closest("table"))&&E(a)?{conversion:H,priority:4}:null}}insertNewAfter(a){var c=this.getChildren(),b=c.length;if(2<=b&&"\n"===c[b-1].getTextContent()&&"\n"===c[b-2].getTextContent()&&a.isCollapsed()&&
13
- a.anchor.key===this.__key&&a.anchor.offset===b)return c[b-1].remove(),c[b-2].remove(),a=r.$createParagraphNode(),this.insertAfter(a),a;c=a.anchor.getNode();var e=I(c);if(null!=e){b=0;for(e=e.getTextContent();b<e.length&&/[\t ]/.test(e[b]);)b+=1;if(0<b)return b=e.substring(0,b),b=y(b),c.insertAfter(b),a.insertNodes([r.$createLineBreakNode()]),b.select(),b}return null}canInsertTab(){const a=r.$getSelection();return r.$isRangeSelection(a)&&a.isCollapsed()?!0:!1}canIndent(){return!1}collapseAtStart(){const a=
13
+ a.anchor.key===this.__key&&a.anchor.offset===b)return c[b-1].remove(),c[b-2].remove(),a=r.$createParagraphNode(),this.insertAfter(a),a;c=a.anchor.getNode();var d=I(c);if(null!=d){b=0;for(d=d.getTextContent();b<d.length&&/[\t ]/.test(d[b]);)b+=1;if(0<b)return b=d.substring(0,b),b=y(b),c.insertAfter(b),a.insertNodes([r.$createLineBreakNode()]),b.select(),b}return null}canInsertTab(){const a=r.$getSelection();return r.$isRangeSelection(a)&&a.isCollapsed()?!0:!1}canIndent(){return!1}collapseAtStart(){const a=
14
14
  r.$createParagraphNode();this.getChildren().forEach(c=>a.append(c));this.replace(a);return!0}setLanguage(a){this.getWritable().__language=t(a)}getLanguage(){return this.getLatest().__language}}function J(a){return new B(a)}function K(a){return a instanceof B}function I(a){let c=null;const b=a.getPreviousSiblings();for(b.push(a);0<b.length&&(a=b.pop(),z(a)&&(c=a),!r.$isLineBreakNode(a)););return c}
15
15
  function L(a){let c=null;const b=a.getNextSiblings();for(b.unshift(a);0<b.length&&(a=b.shift(),z(a)&&(c=a),!r.$isLineBreakNode(a)););return c}function D(){return{node:J()}}function C(a){return{after:c=>{const b=a.parentNode;null!=b&&a!==b.lastChild&&c.push(r.$createLineBreakNode());return c},node:null!==a.style.fontFamily.match("monospace")?J():null}}function F(){return{node:J()}}function H(){return{node:null}}
16
16
  function G(a){return{after:c=>{a.parentNode&&a.parentNode.nextSibling&&c.push(r.$createLineBreakNode());return c},node:null}}function E(a){return a.classList.contains("js-file-line-container")}function M(a,c){const b=a.getParent();K(b)?N(b,c):z(a)&&a.replace(r.$createTextNode(a.__text))}let O=!1;
17
- function N(a,c){O||(O=!0,void 0===a.getLanguage()&&a.setLanguage("javascript"),c.update(()=>{P(a,()=>{var b=a.getTextContent();b=d.tokenize(b,d.languages[a.getLanguage()||""]||d.languages.javascript);b=R(b);var e=a.getChildren();let f=0;for(;f<e.length&&S(e[f],b[f]);)f++;var h=e.length;const m=b.length,g=Math.min(h,m)-f;let k=0;for(;k<g;)if(k++,!S(e[h-k],b[m-k])){k--;break}e=f;h-=k;b=b.slice(f,m-k);const {from:l,to:p,nodesForReplacement:w}={from:e,nodesForReplacement:b,to:h};return l!==p||w.length?
18
- (a.splice(l,p-l,w),!0):!1})},{onUpdate:()=>{O=!1},skipTransforms:!0}))}function R(a){const c=[];a.forEach(b=>{if("string"===typeof b){b=b.split("\n");for(var e=0;e<b.length;e++){const f=b[e];f.length&&c.push(y(f));e<b.length-1&&c.push(r.$createLineBreakNode())}}else({content:e}=b),"string"===typeof e?c.push(y(e,b.type)):1===e.length&&"string"===typeof e[0]?c.push(y(e[0],b.type)):c.push(...R(e))});return c}
19
- function P(a,c){var b=r.$getSelection();if(r.$isRangeSelection(b)&&b.anchor){b=b.anchor;var e=b.offset,f="element"===b.type&&r.$isLineBreakNode(a.getChildAtIndex(b.offset-1)),h=0;if(!f){const m=b.getNode();h=e+m.getPreviousSiblings().reduce((g,k)=>g+(r.$isLineBreakNode(k)?0:k.getTextContentSize()),0)}c()&&(f?b.getNode().select(e,e):a.getChildren().some(m=>{if(r.$isTextNode(m)){const g=m.getTextContentSize();if(g>=h)return m.select(h,h),!0;h-=g}return!1}))}}
20
- function S(a,c){return z(a)&&z(c)?a.__text===c.__text&&a.__highlightType===c.__highlightType:r.$isLineBreakNode(a)&&r.$isLineBreakNode(c)?!0:!1}function T(a){var c=r.$getSelection();if(!r.$isRangeSelection(c)||c.isCollapsed())return!1;c=c.getNodes();for(var b=0;b<c.length;b++){var e=c[b];if(!z(e)&&!r.$isLineBreakNode(e))return!1}b=I(c[0]);null!=b&&U(b,a);for(b=1;b<c.length;b++)e=c[b],r.$isLineBreakNode(c[b-1])&&z(e)&&U(e,a);return!0}
17
+ function N(a,c){O||(O=!0,void 0===a.getLanguage()&&a.setLanguage("javascript"),c.update(()=>{P(a,()=>{var b=a.getTextContent();b=e.tokenize(b,e.languages[a.getLanguage()||""]||e.languages.javascript);b=R(b);var d=a.getChildren();let f=0;for(;f<d.length&&S(d[f],b[f]);)f++;var h=d.length;const m=b.length,g=Math.min(h,m)-f;let k=0;for(;k<g;)if(k++,!S(d[h-k],b[m-k])){k--;break}d=f;h-=k;b=b.slice(f,m-k);const {from:l,to:p,nodesForReplacement:w}={from:d,nodesForReplacement:b,to:h};return l!==p||w.length?
18
+ (a.splice(l,p-l,w),!0):!1})},{onUpdate:()=>{O=!1},skipTransforms:!0}))}function R(a){const c=[];a.forEach(b=>{if("string"===typeof b){b=b.split("\n");for(var d=0;d<b.length;d++){const f=b[d];f.length&&c.push(y(f));d<b.length-1&&c.push(r.$createLineBreakNode())}}else({content:d}=b),"string"===typeof d?c.push(y(d,b.type)):Array.isArray(d)&&1===d.length&&"string"===typeof d[0]?c.push(y(d[0],b.type)):Array.isArray(d)&&c.push(...R(d))});return c}
19
+ function P(a,c){var b=r.$getSelection();if(r.$isRangeSelection(b)&&b.anchor){b=b.anchor;var d=b.offset,f="element"===b.type&&r.$isLineBreakNode(a.getChildAtIndex(b.offset-1)),h=0;if(!f){const m=b.getNode();h=d+m.getPreviousSiblings().reduce((g,k)=>g+(r.$isLineBreakNode(k)?0:k.getTextContentSize()),0)}c()&&(f?b.getNode().select(d,d):a.getChildren().some(m=>{if(r.$isTextNode(m)){const g=m.getTextContentSize();if(g>=h)return m.select(h,h),!0;h-=g}return!1}))}}
20
+ function S(a,c){return z(a)&&z(c)?a.__text===c.__text&&a.__highlightType===c.__highlightType:r.$isLineBreakNode(a)&&r.$isLineBreakNode(c)?!0:!1}function T(a){var c=r.$getSelection();if(!r.$isRangeSelection(c)||c.isCollapsed())return!1;c=c.getNodes();for(var b=0;b<c.length;b++){var d=c[b];if(!z(d)&&!r.$isLineBreakNode(d))return!1}b=I(c[0]);null!=b&&U(b,a);for(b=1;b<c.length;b++)d=c[b],r.$isLineBreakNode(c[b-1])&&z(d)&&U(d,a);return!0}
21
21
  function U(a,c){const b=a.getTextContent();c===r.INDENT_CONTENT_COMMAND?0<b.length&&/\s/.test(b[0])?a.setTextContent("\t"+b):(c=y("\t"),a.insertBefore(c)):0===b.indexOf("\t")&&(1===b.length?a.remove():a.setTextContent(b.substring(1)))}
22
- function V(a,c){const b=r.$getSelection();if(!r.$isRangeSelection(b))return!1;const {anchor:e,focus:f}=b,h=e.offset,m=f.offset,g=e.getNode(),k=f.getNode();var l=a===r.KEY_ARROW_UP_COMMAND;if(!z(g)||!z(k))return!1;if(!c.altKey){if(b.isCollapsed())if(a=g.getParentOrThrow(),l&&0===h&&null===g.getPreviousSibling()){if(null===a.getPreviousSibling())return a.selectPrevious(),c.preventDefault(),!0}else if(!l&&h===g.getTextContentSize()&&null===g.getNextSibling()&&null===a.getNextSibling())return a.selectNext(),
22
+ function V(a,c){const b=r.$getSelection();if(!r.$isRangeSelection(b))return!1;const {anchor:d,focus:f}=b,h=d.offset,m=f.offset,g=d.getNode(),k=f.getNode();var l=a===r.KEY_ARROW_UP_COMMAND;if(!z(g)||!z(k))return!1;if(!c.altKey){if(b.isCollapsed())if(a=g.getParentOrThrow(),l&&0===h&&null===g.getPreviousSibling()){if(null===a.getPreviousSibling())return a.selectPrevious(),c.preventDefault(),!0}else if(!l&&h===g.getTextContentSize()&&null===g.getNextSibling()&&null===a.getNextSibling())return a.selectNext(),
23
23
  c.preventDefault(),!0;return!1}var p=I(g);const w=L(k);if(null==p||null==w)return!1;const A=p.getNodesBetween(w);for(let q=0;q<A.length;q++){const Q=A[q];if(!z(Q)&&!r.$isLineBreakNode(Q))return!1}c.preventDefault();c.stopPropagation();c=l?p.getPreviousSibling():w.getNextSibling();if(!r.$isLineBreakNode(c))return!0;p=l?c.getPreviousSibling():c.getNextSibling();if(null==p)return!0;l=l?I(p):L(p);let x=null!=l?l:p;c.remove();A.forEach(q=>q.remove());a===r.KEY_ARROW_UP_COMMAND?(A.forEach(q=>x.insertBefore(q)),
24
- x.insertBefore(c)):(x.insertAfter(c),x=c,A.forEach(q=>{x.insertAfter(q);x=q}));b.setTextNodeRange(g,h,k,m);return!0}exports.$createCodeHighlightNode=y;exports.$createCodeNode=J;exports.$isCodeHighlightNode=z;exports.$isCodeNode=K;exports.CodeHighlightNode=u;exports.CodeNode=B;exports.getCodeLanguages=()=>Object.keys(d.languages).filter(a=>"function"!==typeof d.languages[a]).sort();exports.getDefaultCodeLanguage=()=>"javascript";exports.getFirstCodeHighlightNodeOfLine=I;
24
+ x.insertBefore(c)):(x.insertAfter(c),x=c,A.forEach(q=>{x.insertAfter(q);x=q}));b.setTextNodeRange(g,h,k,m);return!0}exports.$createCodeHighlightNode=y;exports.$createCodeNode=J;exports.$isCodeHighlightNode=z;exports.$isCodeNode=K;exports.CodeHighlightNode=u;exports.CodeNode=B;exports.getCodeLanguages=()=>Object.keys(e.languages).filter(a=>"function"!==typeof e.languages[a]).sort();exports.getDefaultCodeLanguage=()=>"javascript";exports.getFirstCodeHighlightNodeOfLine=I;
25
25
  exports.getLastCodeHighlightNodeOfLine=L;
26
- exports.registerCodeHighlighting=function(a){if(!a.hasNodes([B,u]))throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return n.mergeRegister(a.registerMutationListener(B,c=>{a.update(()=>{for(const [f,h]of c)if("destroyed"!==h){var b=r.$getNodeByKey(f);if(null!==b)a:{var e=b;b=a.getElementByKey(e.getKey());if(null===b)break a;e=e.getChildren();const m=e.length;if(m===b.__cachedChildrenLength)break a;b.__cachedChildrenLength=m;let g="1",k=1;for(let l=0;l<m;l++)r.$isLineBreakNode(e[l])&&
26
+ exports.registerCodeHighlighting=function(a){if(!a.hasNodes([B,u]))throw Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return n.mergeRegister(a.registerMutationListener(B,c=>{a.update(()=>{for(const [f,h]of c)if("destroyed"!==h){var b=r.$getNodeByKey(f);if(null!==b)a:{var d=b;b=a.getElementByKey(d.getKey());if(null===b)break a;d=d.getChildren();const m=d.length;if(m===b.__cachedChildrenLength)break a;b.__cachedChildrenLength=m;let g="1",k=1;for(let l=0;l<m;l++)r.$isLineBreakNode(d[l])&&
27
27
  (g+="\n"+ ++k);b.setAttribute("data-gutter",g)}}})}),a.registerNodeTransform(B,c=>N(c,a)),a.registerNodeTransform(r.TextNode,c=>M(c,a)),a.registerNodeTransform(u,c=>M(c,a)),a.registerCommand(r.INDENT_CONTENT_COMMAND,()=>T(r.INDENT_CONTENT_COMMAND),r.COMMAND_PRIORITY_LOW),a.registerCommand(r.OUTDENT_CONTENT_COMMAND,()=>T(r.OUTDENT_CONTENT_COMMAND),r.COMMAND_PRIORITY_LOW),a.registerCommand(r.KEY_ARROW_UP_COMMAND,c=>V(r.KEY_ARROW_UP_COMMAND,c),r.COMMAND_PRIORITY_LOW),a.registerCommand(r.KEY_ARROW_DOWN_COMMAND,
28
28
  c=>V(r.KEY_ARROW_DOWN_COMMAND,c),r.COMMAND_PRIORITY_LOW))};
package/package.json CHANGED
@@ -8,18 +8,21 @@
8
8
  "code"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.2.5",
12
- "main": "LexicalCode.js",
11
+ "version": "0.2.8",
12
+ "main": "LexicalCode.ts",
13
13
  "peerDependencies": {
14
- "lexical": "0.2.5"
14
+ "lexical": "0.2.8"
15
15
  },
16
16
  "dependencies": {
17
- "@lexical/utils": "0.2.5",
17
+ "@lexical/utils": "0.2.8",
18
18
  "prismjs": "^1.27.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
22
22
  "url": "https://github.com/facebook/lexical",
23
23
  "directory": "packages/lexical-code"
24
+ },
25
+ "devDependencies": {
26
+ "@types/prismjs": "^1.26.0"
24
27
  }
25
28
  }