@react-fabric/lexical 1.0.0-beta.47 → 1.0.0-beta.49

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 (62) hide show
  1. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +29 -19
  2. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
  3. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +9 -9
  4. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +142 -75
  5. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +1 -1
  6. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +25 -21
  7. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +10 -3
  8. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +1 -1
  9. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  10. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +147 -103
  11. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +1 -1
  12. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +10 -10
  13. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +254 -178
  14. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +1 -1
  15. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +19 -16
  16. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +53 -29
  17. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
  18. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +10 -10
  19. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +176 -194
  20. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +1 -1
  21. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +25 -18
  22. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +1925 -793
  23. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +1 -1
  24. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +48 -40
  25. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +426 -144
  26. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +11 -1
  27. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +46 -32
  28. package/dist/cjs/node_modules/prismjs/prism.js +1 -1
  29. package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +1 -1
  30. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +29 -19
  31. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +1 -1
  32. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +3 -3
  33. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +139 -76
  34. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +1 -1
  35. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +4 -4
  36. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +11 -4
  37. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +1 -1
  38. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +3 -3
  39. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +149 -105
  40. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +1 -1
  41. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +4 -4
  42. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +253 -180
  43. package/dist/esm/node_modules/@lexical/list/LexicalList.js +1 -1
  44. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +4 -4
  45. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +54 -30
  46. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +1 -1
  47. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +3 -3
  48. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +171 -196
  49. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +1 -1
  50. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +4 -4
  51. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +1920 -796
  52. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +1 -1
  53. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +4 -4
  54. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +413 -145
  55. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +7 -2
  56. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +3 -3
  57. package/dist/esm/node_modules/prismjs/prism.js +1 -1
  58. package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +1 -1
  59. package/package.json +7 -8
  60. package/src/components/StickyComponent.tsx +1 -1
  61. package/src/editor/LexicalEditor.tsx +25 -21
  62. package/src/plugins/ToolbarPlugin.tsx +20 -4
@@ -22,17 +22,12 @@ var lexical = require('lexical');
22
22
  *
23
23
  */
24
24
 
25
- const CAN_USE_DOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
25
+ // Do not require this module directly! Use normal `invariant` calls.
26
26
 
27
- /**
28
- * Copyright (c) Meta Platforms, Inc. and affiliates.
29
- *
30
- * This source code is licensed under the MIT license found in the
31
- * LICENSE file in the root directory of this source tree.
32
- *
33
- */
27
+ function formatDevErrorMessage(message) {
28
+ throw new Error(message);
29
+ }
34
30
 
35
- const getDOMSelection = targetWindow => CAN_USE_DOM ? (targetWindow || window).getSelection() : null;
36
31
  /**
37
32
  * Returns the *currently selected* Lexical content as an HTML string, relying on the
38
33
  * logic defined in the exportDOM methods on the LexicalNode classes. Note that
@@ -46,7 +41,7 @@ const getDOMSelection = targetWindow => CAN_USE_DOM ? (targetWindow || window).g
46
41
  function $getHtmlContent(editor, selection = lexical.$getSelection()) {
47
42
  if (selection == null) {
48
43
  {
49
- throw Error(`Expected valid LexicalSelection`);
44
+ formatDevErrorMessage(`Expected valid LexicalSelection`);
50
45
  }
51
46
  }
52
47
 
@@ -70,7 +65,7 @@ function $getHtmlContent(editor, selection = lexical.$getSelection()) {
70
65
  function $getLexicalContent(editor, selection = lexical.$getSelection()) {
71
66
  if (selection == null) {
72
67
  {
73
- throw Error(`Expected valid LexicalSelection`);
68
+ formatDevErrorMessage(`Expected valid LexicalSelection`);
74
69
  }
75
70
  }
76
71
 
@@ -119,10 +114,15 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) {
119
114
  }
120
115
  }
121
116
  const htmlString = dataTransfer.getData('text/html');
122
- if (htmlString) {
117
+ const plainString = dataTransfer.getData('text/plain');
118
+
119
+ // Skip HTML handling if it matches the plain text representation.
120
+ // This avoids unnecessary processing for plain text strings created by
121
+ // iOS Safari autocorrect, which incorrectly includes a `text/html` type.
122
+ if (htmlString && plainString !== htmlString) {
123
123
  try {
124
124
  const parser = new DOMParser();
125
- const dom = parser.parseFromString(htmlString, 'text/html');
125
+ const dom = parser.parseFromString(trustHTML(htmlString), 'text/html');
126
126
  const nodes = LexicalHtml.$generateNodesFromDOM(editor, dom);
127
127
  return $insertGeneratedNodes(editor, nodes, selection);
128
128
  } catch (_unused2) {
@@ -133,7 +133,7 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) {
133
133
  // Multi-line plain text in rich text mode pasted as separate paragraphs
134
134
  // instead of single paragraph with linebreaks.
135
135
  // Webkit-specific: Supports read 'text/uri-list' in clipboard.
136
- const text = dataTransfer.getData('text/plain') || dataTransfer.getData('text/uri-list');
136
+ const text = plainString || dataTransfer.getData('text/uri-list');
137
137
  if (text != null) {
138
138
  if (lexical.$isRangeSelection(selection)) {
139
139
  const parts = text.split(/(\r?\n|\t)/);
@@ -158,6 +158,15 @@ function $insertDataTransferForRichText(dataTransfer, selection, editor) {
158
158
  }
159
159
  }
160
160
  }
161
+ function trustHTML(html) {
162
+ if (window.trustedTypes && window.trustedTypes.createPolicy) {
163
+ const policy = window.trustedTypes.createPolicy('lexical', {
164
+ createHTML: input => input
165
+ });
166
+ return policy.createHTML(html);
167
+ }
168
+ return html;
169
+ }
161
170
 
162
171
  /**
163
172
  * Inserts Lexical nodes into the editor using different strategies depending on
@@ -183,14 +192,14 @@ function exportNodeToJSON(node) {
183
192
  const nodeClass = node.constructor;
184
193
  if (serializedNode.type !== nodeClass.getType()) {
185
194
  {
186
- throw Error(`LexicalNode: Node ${nodeClass.name} does not implement .exportJSON().`);
195
+ formatDevErrorMessage(`LexicalNode: Node ${nodeClass.name} does not implement .exportJSON().`);
187
196
  }
188
197
  }
189
198
  if (lexical.$isElementNode(node)) {
190
199
  const serializedChildren = serializedNode.children;
191
200
  if (!Array.isArray(serializedChildren)) {
192
201
  {
193
- throw Error(`LexicalNode: Node ${nodeClass.name} is an element but .exportJSON() does not have a children array.`);
202
+ formatDevErrorMessage(`LexicalNode: Node ${nodeClass.name} is an element but .exportJSON() does not have a children array.`);
194
203
  }
195
204
  }
196
205
  }
@@ -313,8 +322,9 @@ async function copyToClipboard(editor, event, data) {
313
322
  });
314
323
  }
315
324
  const rootElement = editor.getRootElement();
316
- const windowDocument = editor._window == null ? window.document : editor._window.document;
317
- const domSelection = getDOMSelection(editor._window);
325
+ const editorWindow = editor._window || window;
326
+ const windowDocument = window.document;
327
+ const domSelection = lexical.getDOMSelection(editorWindow);
318
328
  if (rootElement === null || domSelection === null) {
319
329
  return false;
320
330
  }
@@ -355,7 +365,7 @@ async function copyToClipboard(editor, event, data) {
355
365
  // TODO shouldn't pass editor (pass namespace directly)
356
366
  function $copyToClipboardEvent(editor, event, data) {
357
367
  if (data === undefined) {
358
- const domSelection = getDOMSelection(editor._window);
368
+ const domSelection = lexical.getDOMSelection(editor._window);
359
369
  if (!domSelection) {
360
370
  return false;
361
371
  }
@@ -11,7 +11,7 @@ var LexicalClipboard_prod = require('./LexicalClipboard.prod.js');
11
11
  *
12
12
  */
13
13
 
14
- const mod = process.env.NODE_ENV === 'development' ? LexicalClipboard_dev : LexicalClipboard_prod;
14
+ const mod = process.env.NODE_ENV !== 'production' ? LexicalClipboard_dev : LexicalClipboard_prod;
15
15
  const $getClipboardDataFromSelection = mod.$getClipboardDataFromSelection;
16
16
  const $insertDataTransferForRichText = mod.$insertDataTransferForRichText;
17
17
  const copyToClipboard = mod.copyToClipboard;
@@ -13,15 +13,15 @@ var lexical = require('lexical');
13
13
  *
14
14
  */
15
15
 
16
- function w(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var y=w((function(t){const e=new URLSearchParams;e.append("code",t);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${t}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));const v="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,C=t=>v?(t||window).getSelection():null;function D(e,n=lexical.$getSelection()){return null==n&&y(166),lexical.$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":LexicalHtml.$generateHtmlFromNodes(e,n)}function N(t,e=lexical.$getSelection()){return null==e&&y(166),lexical.$isRangeSelection(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(R(t,e))}function _(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n);}function T(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return S(o,E(t.nodes),n)}}catch(t){}const s=t.getData("text/html");if(s)try{const t=(new DOMParser).parseFromString(s,"text/html");return S(o,LexicalHtml.$generateNodesFromDOM(o,t),n)}catch(t){}const a=t.getData("text/plain")||t.getData("text/uri-list");if(null!=a)if(lexical.$isRangeSelection(n)){const t=a.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=lexical.$getSelection();if(lexical.$isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([lexical.$createTabNode()]):n.insertText(o);}}}else n.insertRawText(a);}function S(t,e,n){t.dispatchCommand(lexical.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||n.insertNodes(e);}function A(t,e,n,r=[]){let l=null===e||n.isSelected(e);const i=lexical.$isElementNode(n)&&n.excludeFromCopy("html");let c=n;if(null!==e){let t=lexical.$cloneWithProperties(n);t=lexical.$isTextNode(t)&&null!==e?LexicalSelection.$sliceSelectedTextNodeContent(e,t):t,c=t;}const s=lexical.$isElementNode(c)?c.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&y(58,n.name),lexical.$isElementNode(t)){const t=e.children;Array.isArray(t)||y(59,n.name);}return e}(c);if(lexical.$isTextNode(c)){const t=c.__text;t.length>0?a.text=t:l=!1;}for(let o=0;o<s.length;o++){const r=s[o],i=A(t,e,r,a.children);!l&&lexical.$isElementNode(n)&&i&&n.extractWithChild(r,e,"clone")&&(l=!0);}if(l&&!i)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return l}function R(t,e){const n=[],o=lexical.$getRoot().getChildren();for(let r=0;r<o.length;r++){A(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function E(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],l=lexical.$parseSerializedNode(r);lexical.$isTextNode(l)&&LexicalSelection.$addNodeStyle(l),e.push(l);}return e}let O=null;async function P(t,e,n){if(null!==O)return !1;if(null!==e)return new Promise(((o,r)=>{t.update((()=>{o(b(t,e,n));}));}));const o=t.getRootElement(),l=null==t._window?window.document:t._window.document,i=C(t._window);if(null===o||null===i)return !1;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const s=new Range;return s.setStart(c,0),s.setEnd(c,1),i.removeAllRanges(),i.addRange(s),new Promise(((e,o)=>{const i=t.registerCommand(lexical.COPY_COMMAND,(o=>(LexicalUtils.objectKlassEquals(o,ClipboardEvent)&&(i(),null!==O&&(window.clearTimeout(O),O=null),e(b(t,o,n))),!0)),lexical.COMMAND_PRIORITY_CRITICAL);O=window.setTimeout((()=>{i(),O=null,e(!1);}),50),l.execCommand("copy"),c.remove();}))}function b(t,e,n){if(void 0===n){const e=C(t._window);if(!e)return !1;const o=e.anchorNode,r=e.focusNode;if(null!==o&&null!==r&&!lexical.isSelectionWithinEditor(t,o,r))return !1;const l=lexical.$getSelection();if(null===l)return !1;n=M(l);}e.preventDefault();const o=e.clipboardData;return null!==o&&(F(o,n),!0)}const J=[["text/html",D],["application/x-lexical-editor",N]];function M(t=lexical.$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=lexical.$getEditor();for(const[o,r]of J){const l=r(n,t);null!==l&&(e[o]=l);}}return e}function F(t,e){for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}}
16
+ function y(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function T(e,n=lexical.$getSelection()){return null==n&&y(166),lexical.$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":LexicalHtml.$generateHtmlFromNodes(e,n)}function v(t,e=lexical.$getSelection()){return null==e&&y(166),lexical.$isRangeSelection(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(R(t,e))}function C(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n);}function D(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return N(o,A(t.nodes),n)}}catch(t){}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return N(o,LexicalHtml.$generateNodesFromDOM(o,t),n)}catch(t){}const u=a||t.getData("text/uri-list");if(null!=u)if(lexical.$isRangeSelection(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=lexical.$getSelection();if(lexical.$isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([lexical.$createTabNode()]):n.insertText(o);}}}else n.insertRawText(u);}function N(t,e,n){t.dispatchCommand(lexical.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||n.insertNodes(e);}function S(t,e,n,r=[]){let i=null===e||n.isSelected(e);const l=lexical.$isElementNode(n)&&n.excludeFromCopy("html");let s=n;if(null!==e){let t=lexical.$cloneWithProperties(n);t=lexical.$isTextNode(t)&&null!==e?LexicalSelection.$sliceSelectedTextNodeContent(e,t):t,s=t;}const c=lexical.$isElementNode(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&y(58,n.name),lexical.$isElementNode(t)){const t=e.children;Array.isArray(t)||y(59,n.name);}return e}(s);if(lexical.$isTextNode(s)){const t=s.__text;t.length>0?a.text=t:i=!1;}for(let o=0;o<c.length;o++){const r=c[o],l=S(t,e,r,a.children);!i&&lexical.$isElementNode(n)&&l&&n.extractWithChild(r,e,"clone")&&(i=!0);}if(i&&!l)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return i}function R(t,e){const n=[],o=lexical.$getRoot().getChildren();for(let r=0;r<o.length;r++){S(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function A(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],i=lexical.$parseSerializedNode(r);lexical.$isTextNode(i)&&LexicalSelection.$addNodeStyle(i),e.push(i);}return e}let P=null;async function _(t,e,n){if(null!==P)return !1;if(null!==e)return new Promise(((o,r)=>{t.update((()=>{o(E(t,e,n));}));}));const o=t.getRootElement(),i=t._window||window,l=window.document,s=lexical.getDOMSelection(i);if(null===o||null===s)return !1;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise(((e,o)=>{const i=t.registerCommand(lexical.COPY_COMMAND,(o=>(LexicalUtils.objectKlassEquals(o,ClipboardEvent)&&(i(),null!==P&&(window.clearTimeout(P),P=null),e(E(t,o,n))),!0)),lexical.COMMAND_PRIORITY_CRITICAL);P=window.setTimeout((()=>{i(),P=null,e(!1);}),50),l.execCommand("copy"),c.remove();}))}function E(t,e,n){if(void 0===n){const e=lexical.getDOMSelection(t._window);if(!e)return !1;const o=e.anchorNode,r=e.focusNode;if(null!==o&&null!==r&&!lexical.isSelectionWithinEditor(t,o,r))return !1;const i=lexical.$getSelection();if(null===i)return !1;n=M(i);}e.preventDefault();const o=e.clipboardData;return null!==o&&(O(o,n),!0)}const L=[["text/html",T],["application/x-lexical-editor",v]];function M(t=lexical.$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=lexical.$getEditor();for(const[o,r]of L){const i=r(n,t);null!==i&&(e[o]=i);}}return e}function O(t,e){for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}}
17
17
 
18
18
  exports.$generateJSONFromSelectedNodes = R;
19
- exports.$generateNodesFromSerializedNodes = E;
19
+ exports.$generateNodesFromSerializedNodes = A;
20
20
  exports.$getClipboardDataFromSelection = M;
21
- exports.$getHtmlContent = D;
22
- exports.$getLexicalContent = N;
23
- exports.$insertDataTransferForPlainText = _;
24
- exports.$insertDataTransferForRichText = T;
25
- exports.$insertGeneratedNodes = S;
26
- exports.copyToClipboard = P;
27
- exports.setLexicalClipboardDataTransfer = F;
21
+ exports.$getHtmlContent = T;
22
+ exports.$getLexicalContent = v;
23
+ exports.$insertDataTransferForPlainText = C;
24
+ exports.$insertDataTransferForRichText = D;
25
+ exports.$insertGeneratedNodes = N;
26
+ exports.copyToClipboard = _;
27
+ exports.setLexicalClipboardDataTransfer = O;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var LexicalUtils = require('../utils/LexicalUtils.js');
4
+ var lexical = require('lexical');
3
5
  require('../../prismjs/prism.js');
4
6
  require('../../prismjs/components/prism-clike.js');
5
7
  require('../../prismjs/components/prism-javascript.js');
@@ -16,8 +18,6 @@ require('../../prismjs/components/prism-swift.js');
16
18
  require('../../prismjs/components/prism-typescript.js');
17
19
  require('../../prismjs/components/prism-java.js');
18
20
  require('../../prismjs/components/prism-cpp.js');
19
- var LexicalUtils = require('../utils/LexicalUtils.js');
20
- var lexical = require('lexical');
21
21
 
22
22
  /**
23
23
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -28,6 +28,30 @@ var lexical = require('lexical');
28
28
  */
29
29
 
30
30
 
31
+ /**
32
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
33
+ *
34
+ * This source code is licensed under the MIT license found in the
35
+ * LICENSE file in the root directory of this source tree.
36
+ *
37
+ */
38
+
39
+ // Do not require this module directly! Use normal `invariant` calls.
40
+
41
+ function formatDevErrorMessage(message) {
42
+ throw new Error(message);
43
+ }
44
+
45
+ /**
46
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
47
+ *
48
+ * This source code is licensed under the MIT license found in the
49
+ * LICENSE file in the root directory of this source tree.
50
+ *
51
+ */
52
+
53
+ const Prism = globalThis.Prism || window.Prism;
54
+
31
55
  /**
32
56
  * Copyright (c) Meta Platforms, Inc. and affiliates.
33
57
  *
@@ -39,7 +63,7 @@ var lexical = require('lexical');
39
63
  const isLanguageSupportedByPrism = language => {
40
64
  try {
41
65
  // eslint-disable-next-line no-prototype-builtins
42
- return language ? window.Prism.languages.hasOwnProperty(language) : false;
66
+ return language ? Prism.languages.hasOwnProperty(language) : false;
43
67
  } catch (_unused) {
44
68
  return false;
45
69
  }
@@ -70,7 +94,7 @@ class CodeNode extends lexical.ElementNode {
70
94
  }
71
95
  constructor(language, key) {
72
96
  super(key);
73
- this.__language = language;
97
+ this.__language = language || undefined;
74
98
  this.__isSyntaxHighlightSupported = isLanguageSupportedByPrism(language);
75
99
  }
76
100
 
@@ -181,18 +205,15 @@ class CodeNode extends lexical.ElementNode {
181
205
  };
182
206
  }
183
207
  static importJSON(serializedNode) {
184
- const node = $createCodeNode(serializedNode.language);
185
- node.setFormat(serializedNode.format);
186
- node.setIndent(serializedNode.indent);
187
- node.setDirection(serializedNode.direction);
188
- return node;
208
+ return $createCodeNode().updateFromJSON(serializedNode);
209
+ }
210
+ updateFromJSON(serializedNode) {
211
+ return super.updateFromJSON(serializedNode).setLanguage(serializedNode.language);
189
212
  }
190
213
  exportJSON() {
191
214
  return {
192
215
  ...super.exportJSON(),
193
- language: this.getLanguage(),
194
- type: 'code',
195
- version: 1
216
+ language: this.getLanguage()
196
217
  };
197
218
  }
198
219
 
@@ -218,7 +239,7 @@ class CodeNode extends lexical.ElementNode {
218
239
  const firstPoint = anchor.isBefore(focus) ? anchor : focus;
219
240
  const firstSelectionNode = firstPoint.getNode();
220
241
  if (lexical.$isTextNode(firstSelectionNode)) {
221
- let node = getFirstCodeNodeOfLine(firstSelectionNode);
242
+ let node = $getFirstCodeNodeOfLine(firstSelectionNode);
222
243
  const insertNodes = [];
223
244
  // eslint-disable-next-line no-constant-condition
224
245
  while (true) {
@@ -279,8 +300,9 @@ class CodeNode extends lexical.ElementNode {
279
300
  }
280
301
  setLanguage(language) {
281
302
  const writable = this.getWritable();
282
- writable.__language = language;
303
+ writable.__language = language || undefined;
283
304
  writable.__isSyntaxHighlightSupported = isLanguageSupportedByPrism(language);
305
+ return writable;
284
306
  }
285
307
  getLanguage() {
286
308
  return this.getLatest().__language;
@@ -390,16 +412,16 @@ function getLanguageFriendlyName(lang) {
390
412
  return CODE_LANGUAGE_FRIENDLY_NAME_MAP[_lang] || _lang;
391
413
  }
392
414
  const getDefaultCodeLanguage = () => DEFAULT_CODE_LANGUAGE;
393
- const getCodeLanguages = () => Object.keys(window.Prism.languages).filter(
415
+ const getCodeLanguages = () => Object.keys(Prism.languages).filter(
394
416
  // Prism has several language helpers mixed into languages object
395
417
  // so filtering them out here to get langs list
396
- language => typeof window.Prism.languages[language] !== 'function').sort();
418
+ language => typeof Prism.languages[language] !== 'function').sort();
397
419
 
398
420
  /** @noInheritDoc */
399
421
  class CodeHighlightNode extends lexical.TextNode {
400
422
  /** @internal */
401
423
 
402
- constructor(text, highlightType, key) {
424
+ constructor(text = '', highlightType, key) {
403
425
  super(text, key);
404
426
  this.__highlightType = highlightType;
405
427
  }
@@ -413,6 +435,11 @@ class CodeHighlightNode extends lexical.TextNode {
413
435
  const self = this.getLatest();
414
436
  return self.__highlightType;
415
437
  }
438
+ setHighlightType(highlightType) {
439
+ const self = this.getWritable();
440
+ self.__highlightType = highlightType || undefined;
441
+ return self;
442
+ }
416
443
  canHaveFormat() {
417
444
  return false;
418
445
  }
@@ -437,19 +464,15 @@ class CodeHighlightNode extends lexical.TextNode {
437
464
  return update;
438
465
  }
439
466
  static importJSON(serializedNode) {
440
- const node = $createCodeHighlightNode(serializedNode.text, serializedNode.highlightType);
441
- node.setFormat(serializedNode.format);
442
- node.setDetail(serializedNode.detail);
443
- node.setMode(serializedNode.mode);
444
- node.setStyle(serializedNode.style);
445
- return node;
467
+ return $createCodeHighlightNode().updateFromJSON(serializedNode);
468
+ }
469
+ updateFromJSON(serializedNode) {
470
+ return super.updateFromJSON(serializedNode).setHighlightType(serializedNode.highlightType);
446
471
  }
447
472
  exportJSON() {
448
473
  return {
449
474
  ...super.exportJSON(),
450
- highlightType: this.getHighlightType(),
451
- type: 'code-highlight',
452
- version: 1
475
+ highlightType: this.getHighlightType()
453
476
  };
454
477
  }
455
478
 
@@ -467,46 +490,33 @@ class CodeHighlightNode extends lexical.TextNode {
467
490
  function getHighlightThemeClass(theme, highlightType) {
468
491
  return highlightType && theme && theme.codeHighlight && theme.codeHighlight[highlightType];
469
492
  }
470
- function $createCodeHighlightNode(text, highlightType) {
493
+ function $createCodeHighlightNode(text = '', highlightType) {
471
494
  return lexical.$applyNodeReplacement(new CodeHighlightNode(text, highlightType));
472
495
  }
473
496
  function $isCodeHighlightNode(node) {
474
497
  return node instanceof CodeHighlightNode;
475
498
  }
476
- function getFirstCodeNodeOfLine(anchor) {
477
- let previousNode = anchor;
478
- let node = anchor;
479
- while ($isCodeHighlightNode(node) || lexical.$isTabNode(node)) {
480
- previousNode = node;
481
- node = node.getPreviousSibling();
499
+ function $getLastMatchingCodeNode(anchor, direction) {
500
+ let matchingNode = anchor;
501
+ for (let caret = lexical.$getSiblingCaret(anchor, direction); caret && ($isCodeHighlightNode(caret.origin) || lexical.$isTabNode(caret.origin)); caret = LexicalUtils.$getAdjacentCaret(caret)) {
502
+ matchingNode = caret.origin;
482
503
  }
483
- return previousNode;
504
+ return matchingNode;
484
505
  }
485
- function getLastCodeNodeOfLine(anchor) {
486
- let nextNode = anchor;
487
- let node = anchor;
488
- while ($isCodeHighlightNode(node) || lexical.$isTabNode(node)) {
489
- nextNode = node;
490
- node = node.getNextSibling();
491
- }
492
- return nextNode;
506
+ function $getFirstCodeNodeOfLine(anchor) {
507
+ return $getLastMatchingCodeNode(anchor, 'previous');
508
+ }
509
+ function $getLastCodeNodeOfLine(anchor) {
510
+ return $getLastMatchingCodeNode(anchor, 'next');
493
511
  }
494
-
495
- /**
496
- * Copyright (c) Meta Platforms, Inc. and affiliates.
497
- *
498
- * This source code is licensed under the MIT license found in the
499
- * LICENSE file in the root directory of this source tree.
500
- *
501
- */
502
512
 
503
513
  const PrismTokenizer = {
504
514
  defaultLanguage: DEFAULT_CODE_LANGUAGE,
505
515
  tokenize(code, language) {
506
- return window.Prism.tokenize(code, window.Prism.languages[language || ''] || window.Prism.languages[this.defaultLanguage]);
516
+ return Prism.tokenize(code, Prism.languages[language || ''] || Prism.languages[this.defaultLanguage]);
507
517
  }
508
518
  };
509
- function getStartOfCodeInLine(anchor, offset) {
519
+ function $getStartOfCodeInLine(anchor, offset) {
510
520
  let last = null;
511
521
  let lastNonBlank = null;
512
522
  let node = anchor;
@@ -520,7 +530,7 @@ function getStartOfCodeInLine(anchor, offset) {
520
530
  break;
521
531
  }
522
532
  if (!($isCodeHighlightNode(node) || lexical.$isTabNode(node) || lexical.$isLineBreakNode(node))) {
523
- throw Error(`Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode`);
533
+ formatDevErrorMessage(`Expected a valid Code Node: CodeHighlightNode, TabNode, LineBreakNode`);
524
534
  }
525
535
  if (lexical.$isLineBreakNode(node)) {
526
536
  last = {
@@ -599,10 +609,10 @@ function findNextNonBlankInLine(anchor, offset) {
599
609
  }
600
610
  }
601
611
  }
602
- function getEndOfCodeInLine(anchor) {
603
- const lastNode = getLastCodeNodeOfLine(anchor);
612
+ function $getEndOfCodeInLine(anchor) {
613
+ const lastNode = $getLastCodeNodeOfLine(anchor);
604
614
  if (!!lexical.$isLineBreakNode(lastNode)) {
605
- throw Error(`Unexpected lineBreakNode in getEndOfCodeInLine`);
615
+ formatDevErrorMessage(`Unexpected lineBreakNode in getEndOfCodeInLine`);
606
616
  }
607
617
  return lastNode;
608
618
  }
@@ -835,7 +845,7 @@ function $getCodeLines(selection) {
835
845
  for (let i = 0; i < nodes.length; i++) {
836
846
  const node = nodes[i];
837
847
  if (!($isCodeHighlightNode(node) || lexical.$isTabNode(node) || lexical.$isLineBreakNode(node))) {
838
- throw Error(`Expected selection to be inside CodeBlock and consisting of CodeHighlightNode, TabNode and LineBreakNode`);
848
+ formatDevErrorMessage(`Expected selection to be inside CodeBlock and consisting of CodeHighlightNode, TabNode and LineBreakNode`);
839
849
  }
840
850
  if (lexical.$isLineBreakNode(node)) {
841
851
  if (i !== 0 && lastLine.length > 0) {
@@ -864,13 +874,13 @@ function $handleTab(shiftKey) {
864
874
  const selectionNodes = selection.getNodes();
865
875
  const firstNode = selectionNodes[0];
866
876
  if (!($isCodeNode(firstNode) || $isCodeHighlightNode(firstNode) || lexical.$isTabNode(firstNode) || lexical.$isLineBreakNode(firstNode))) {
867
- throw Error(`Expected selection firstNode to be CodeHighlightNode or TabNode`);
877
+ formatDevErrorMessage(`Expected selection firstNode to be CodeHighlightNode or TabNode`);
868
878
  }
869
879
  if ($isCodeNode(firstNode)) {
870
880
  return indentOrOutdent;
871
881
  }
872
- const firstOfLine = getFirstCodeNodeOfLine(firstNode);
873
- const lastOfLine = getLastCodeNodeOfLine(firstNode);
882
+ const firstOfLine = $getFirstCodeNodeOfLine(firstNode);
883
+ const lastOfLine = $getLastCodeNodeOfLine(firstNode);
874
884
  const anchor = selection.anchor;
875
885
  const focus = selection.focus;
876
886
  let selectionFirst;
@@ -903,7 +913,7 @@ function $handleMultilineIndent(type) {
903
913
  let firstOfLine = line[0];
904
914
  // First and last lines might not be complete
905
915
  if (i === 0) {
906
- firstOfLine = getFirstCodeNodeOfLine(firstOfLine);
916
+ firstOfLine = $getFirstCodeNodeOfLine(firstOfLine);
907
917
  }
908
918
  if (firstOfLine !== null) {
909
919
  if (type === lexical.INDENT_CONTENT_COMMAND) {
@@ -920,7 +930,7 @@ function $handleMultilineIndent(type) {
920
930
  const selectionNodes = selection.getNodes();
921
931
  const firstNode = selectionNodes[0];
922
932
  if (!($isCodeNode(firstNode) || $isCodeHighlightNode(firstNode) || lexical.$isTabNode(firstNode) || lexical.$isLineBreakNode(firstNode))) {
923
- throw Error(`Expected selection firstNode to be CodeHighlightNode or CodeTabNode`);
933
+ formatDevErrorMessage(`Expected selection firstNode to be CodeHighlightNode or CodeTabNode`);
924
934
  }
925
935
  if ($isCodeNode(firstNode)) {
926
936
  // CodeNode is empty
@@ -929,10 +939,7 @@ function $handleMultilineIndent(type) {
929
939
  }
930
940
  return true;
931
941
  }
932
- const firstOfLine = getFirstCodeNodeOfLine(firstNode);
933
- if (!(firstOfLine !== null)) {
934
- throw Error(`Expected getFirstCodeNodeOfLine to return a valid Code Node`);
935
- }
942
+ const firstOfLine = $getFirstCodeNodeOfLine(firstNode);
936
943
  if (type === lexical.INDENT_CONTENT_COMMAND) {
937
944
  if (lexical.$isLineBreakNode(firstOfLine)) {
938
945
  firstOfLine.insertAfter(lexical.$createTabNode());
@@ -993,11 +1000,11 @@ function $handleShiftLines(type, event) {
993
1000
  let start;
994
1001
  let end;
995
1002
  if (anchorNode.isBefore(focusNode)) {
996
- start = getFirstCodeNodeOfLine(anchorNode);
997
- end = getLastCodeNodeOfLine(focusNode);
1003
+ start = $getFirstCodeNodeOfLine(anchorNode);
1004
+ end = $getLastCodeNodeOfLine(focusNode);
998
1005
  } else {
999
- start = getFirstCodeNodeOfLine(focusNode);
1000
- end = getLastCodeNodeOfLine(anchorNode);
1006
+ start = $getFirstCodeNodeOfLine(focusNode);
1007
+ end = $getLastCodeNodeOfLine(anchorNode);
1001
1008
  }
1002
1009
  if (start == null || end == null) {
1003
1010
  return false;
@@ -1024,7 +1031,7 @@ function $handleShiftLines(type, event) {
1024
1031
  if (sibling == null) {
1025
1032
  return true;
1026
1033
  }
1027
- const maybeInsertionPoint = $isCodeHighlightNode(sibling) || lexical.$isTabNode(sibling) || lexical.$isLineBreakNode(sibling) ? arrowIsUp ? getFirstCodeNodeOfLine(sibling) : getLastCodeNodeOfLine(sibling) : null;
1034
+ const maybeInsertionPoint = $isCodeHighlightNode(sibling) || lexical.$isTabNode(sibling) || lexical.$isLineBreakNode(sibling) ? arrowIsUp ? $getFirstCodeNodeOfLine(sibling) : $getLastCodeNodeOfLine(sibling) : null;
1028
1035
  let insertionPoint = maybeInsertionPoint != null ? maybeInsertionPoint : sibling;
1029
1036
  linebreak.remove();
1030
1037
  range.forEach(node => node.remove());
@@ -1054,11 +1061,13 @@ function $handleMoveTo(type, event) {
1054
1061
  const anchorNode = anchor.getNode();
1055
1062
  const focusNode = focus.getNode();
1056
1063
  const isMoveToStart = type === lexical.MOVE_TO_START;
1057
- if (!($isCodeHighlightNode(anchorNode) || lexical.$isTabNode(anchorNode)) || !($isCodeHighlightNode(focusNode) || lexical.$isTabNode(focusNode))) {
1064
+
1065
+ // Ensure the selection is within the codeblock
1066
+ if (!$isSelectionInCode(selection) || !($isCodeHighlightNode(anchorNode) || lexical.$isTabNode(anchorNode)) || !($isCodeHighlightNode(focusNode) || lexical.$isTabNode(focusNode))) {
1058
1067
  return false;
1059
1068
  }
1060
1069
  if (isMoveToStart) {
1061
- const start = getStartOfCodeInLine(focusNode, focus.offset);
1070
+ const start = $getStartOfCodeInLine(focusNode, focus.offset);
1062
1071
  if (start !== null) {
1063
1072
  const {
1064
1073
  node,
@@ -1073,7 +1082,7 @@ function $handleMoveTo(type, event) {
1073
1082
  focusNode.getParentOrThrow().selectStart();
1074
1083
  }
1075
1084
  } else {
1076
- const node = getEndOfCodeInLine(focusNode);
1085
+ const node = $getEndOfCodeInLine(focusNode);
1077
1086
  node.select();
1078
1087
  }
1079
1088
  event.preventDefault();
@@ -1115,11 +1124,69 @@ function registerCodeHighlighting(editor, tokenizer) {
1115
1124
  }
1116
1125
  lexical.$insertNodes([lexical.$createTabNode()]);
1117
1126
  return true;
1118
- }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, payload => $handleMultilineIndent(lexical.INDENT_CONTENT_COMMAND), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, payload => $handleMultilineIndent(lexical.OUTDENT_CONTENT_COMMAND), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, payload => $handleShiftLines(lexical.KEY_ARROW_UP_COMMAND, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, payload => $handleShiftLines(lexical.KEY_ARROW_DOWN_COMMAND, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.MOVE_TO_END, payload => $handleMoveTo(lexical.MOVE_TO_END, payload), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.MOVE_TO_START, payload => $handleMoveTo(lexical.MOVE_TO_START, payload), lexical.COMMAND_PRIORITY_LOW));
1127
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, payload => $handleMultilineIndent(lexical.INDENT_CONTENT_COMMAND), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, payload => $handleMultilineIndent(lexical.OUTDENT_CONTENT_COMMAND), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_UP_COMMAND, event => {
1128
+ const selection = lexical.$getSelection();
1129
+ if (!lexical.$isRangeSelection(selection)) {
1130
+ return false;
1131
+ }
1132
+ const {
1133
+ anchor
1134
+ } = selection;
1135
+ const anchorNode = anchor.getNode();
1136
+ if (!$isSelectionInCode(selection)) {
1137
+ return false;
1138
+ }
1139
+ // If at the start of a code block, prevent selection from moving out
1140
+ if (selection.isCollapsed() && anchor.offset === 0 && anchorNode.getPreviousSibling() === null && $isCodeNode(anchorNode.getParentOrThrow())) {
1141
+ event.preventDefault();
1142
+ return true;
1143
+ }
1144
+ return $handleShiftLines(lexical.KEY_ARROW_UP_COMMAND, event);
1145
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.KEY_ARROW_DOWN_COMMAND, event => {
1146
+ const selection = lexical.$getSelection();
1147
+ if (!lexical.$isRangeSelection(selection)) {
1148
+ return false;
1149
+ }
1150
+ const {
1151
+ anchor
1152
+ } = selection;
1153
+ const anchorNode = anchor.getNode();
1154
+ if (!$isSelectionInCode(selection)) {
1155
+ return false;
1156
+ }
1157
+ // If at the end of a code block, prevent selection from moving out
1158
+ if (selection.isCollapsed() && anchor.offset === anchorNode.getTextContentSize() && anchorNode.getNextSibling() === null && $isCodeNode(anchorNode.getParentOrThrow())) {
1159
+ event.preventDefault();
1160
+ return true;
1161
+ }
1162
+ return $handleShiftLines(lexical.KEY_ARROW_DOWN_COMMAND, event);
1163
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.MOVE_TO_START, event => $handleMoveTo(lexical.MOVE_TO_START, event), lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.MOVE_TO_END, event => $handleMoveTo(lexical.MOVE_TO_END, event), lexical.COMMAND_PRIORITY_LOW));
1119
1164
  }
1120
1165
 
1166
+ /**
1167
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1168
+ *
1169
+ * This source code is licensed under the MIT license found in the
1170
+ * LICENSE file in the root directory of this source tree.
1171
+ *
1172
+ */
1173
+
1174
+
1175
+ /** @deprecated renamed to {@link $getFirstCodeNodeOfLine} by @lexical/eslint-plugin rules-of-lexical */
1176
+ const getFirstCodeNodeOfLine = $getFirstCodeNodeOfLine;
1177
+ /** @deprecated renamed to {@link $getLastCodeNodeOfLine} by @lexical/eslint-plugin rules-of-lexical */
1178
+ const getLastCodeNodeOfLine = $getLastCodeNodeOfLine;
1179
+ /** @deprecated renamed to {@link $getEndOfCodeInLine} by @lexical/eslint-plugin rules-of-lexical */
1180
+ const getEndOfCodeInLine = $getEndOfCodeInLine;
1181
+ /** @deprecated renamed to {@link $getStartOfCodeInLine} by @lexical/eslint-plugin rules-of-lexical */
1182
+ const getStartOfCodeInLine = $getStartOfCodeInLine;
1183
+
1121
1184
  exports.$createCodeHighlightNode = $createCodeHighlightNode;
1122
1185
  exports.$createCodeNode = $createCodeNode;
1186
+ exports.$getEndOfCodeInLine = $getEndOfCodeInLine;
1187
+ exports.$getFirstCodeNodeOfLine = $getFirstCodeNodeOfLine;
1188
+ exports.$getLastCodeNodeOfLine = $getLastCodeNodeOfLine;
1189
+ exports.$getStartOfCodeInLine = $getStartOfCodeInLine;
1123
1190
  exports.$isCodeHighlightNode = $isCodeHighlightNode;
1124
1191
  exports.$isCodeNode = $isCodeNode;
1125
1192
  exports.CODE_LANGUAGE_FRIENDLY_NAME_MAP = CODE_LANGUAGE_FRIENDLY_NAME_MAP;
@@ -11,7 +11,7 @@ var LexicalCode_prod = require('./LexicalCode.prod.js');
11
11
  *
12
12
  */
13
13
 
14
- const mod = process.env.NODE_ENV === 'development' ? LexicalCode_dev : LexicalCode_prod;
14
+ const mod = process.env.NODE_ENV !== 'production' ? LexicalCode_dev : LexicalCode_prod;
15
15
  const $createCodeNode = mod.$createCodeNode;
16
16
  const $isCodeNode = mod.$isCodeNode;
17
17
  const CODE_LANGUAGE_MAP = mod.CODE_LANGUAGE_MAP;