@lexical/code
Advanced tools
Comparing version 0.3.11 to 0.4.0
@@ -32,3 +32,5 @@ /** | ||
export declare const getCodeLanguages: () => Array<string>; | ||
/** @noInheritDoc */ | ||
export declare class CodeHighlightNode extends TextNode { | ||
/** @internal */ | ||
__highlightType: string | null | undefined; | ||
@@ -35,0 +37,0 @@ constructor(text: string, highlightType?: string | null | undefined, key?: NodeKey); |
@@ -27,3 +27,5 @@ /** | ||
}, SerializedElementNode>; | ||
/** @noInheritDoc */ | ||
export declare class CodeNode extends ElementNode { | ||
/** @internal */ | ||
__language: string | null | undefined; | ||
@@ -30,0 +32,0 @@ static getType(): string; |
@@ -0,1 +1,2 @@ | ||
/** @module @lexical/code */ | ||
/** | ||
@@ -7,2 +8,3 @@ * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* | ||
*/ | ||
@@ -9,0 +11,0 @@ export { getEndOfCodeInLine, getStartOfCodeInLine, registerCodeHighlighting, } from './CodeHighlighter'; |
@@ -66,3 +66,6 @@ /** | ||
language => typeof Prism.languages[language] !== 'function').sort(); | ||
/** @noInheritDoc */ | ||
class CodeHighlightNode extends lexical.TextNode { | ||
/** @internal */ | ||
constructor(text, highlightType, key) { | ||
@@ -198,3 +201,6 @@ super(text, key); | ||
const LANGUAGE_DATA_ATTRIBUTE = 'data-highlight-language'; | ||
/** @noInheritDoc */ | ||
class CodeNode extends lexical.ElementNode { | ||
/** @internal */ | ||
static getType() { | ||
@@ -746,5 +752,7 @@ return 'code'; | ||
function updateAndRetainSelection(node, updateFn) { | ||
const selection = lexical.$getSelection(); | ||
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) || !selection.anchor) { | ||
if (!lexical.$isRangeSelection(selection)) { | ||
updateFn(); | ||
return; | ||
@@ -751,0 +759,0 @@ } |
@@ -22,3 +22,3 @@ /** | ||
p-n,w),!0):!1})},{onUpdate:()=>{S=!1},skipTransforms:!0}))}function T(a){let b=[];a.forEach(c=>{if("string"===typeof c){c=c.split("\n");for(var d=0;d<c.length;d++){let f=c[d];f.length&&b.push(A(f));d<c.length-1&&b.push(r.$createLineBreakNode())}}else({content:d}=c),"string"===typeof d?b.push(A(d,c.type)):Array.isArray(d)&&1===d.length&&"string"===typeof d[0]?b.push(A(d[0],c.type)):Array.isArray(d)&&b.push(...T(d))});return b} | ||
function ca(a,b){var c=r.$getSelection();if(r.$isRangeSelection(c)&&c.anchor){c=c.anchor;var d=c.offset,f="element"===c.type&&r.$isLineBreakNode(a.getChildAtIndex(c.offset-1)),g=0;if(!f){let l=c.getNode();g=d+l.getPreviousSiblings().reduce((h,k)=>h+(r.$isLineBreakNode(k)?0:k.getTextContentSize()),0)}b()&&(f?c.getNode().select(d,d):a.getChildren().some(l=>{if(r.$isTextNode(l)){let h=l.getTextContentSize();if(h>=g)return l.select(g,g),!0;g-=h}return!1}))}} | ||
function ca(a,b){var c=r.$getSelection();if(r.$isRangeSelection(c)){c=c.anchor;var d=c.offset,f="element"===c.type&&r.$isLineBreakNode(a.getChildAtIndex(c.offset-1)),g=0;if(!f){let l=c.getNode();g=d+l.getPreviousSiblings().reduce((h,k)=>h+(r.$isLineBreakNode(k)?0:k.getTextContentSize()),0)}b()&&(f?c.getNode().select(d,d):a.getChildren().some(l=>{if(r.$isTextNode(l)){let h=l.getTextContentSize();if(h>=g)return l.select(g,g),!0;g-=h}return!1}))}else b()} | ||
function U(a,b){return C(a)&&C(b)?a.__text===b.__text&&a.__highlightType===b.__highlightType:r.$isLineBreakNode(a)&&r.$isLineBreakNode(b)?!0:!1}function V(a){var b=r.$getSelection();if(!r.$isRangeSelection(b)||b.isCollapsed())return!1;b=b.getNodes();for(var c=0;c<b.length;c++){var d=b[c];if(!C(d)&&!r.$isLineBreakNode(d))return!1}c=D(b[0]);null!=c&&W(c,a);for(c=1;c<b.length;c++)d=b[c],r.$isLineBreakNode(b[c-1])&&C(d)&&W(d,a);return!0} | ||
@@ -25,0 +25,0 @@ function W(a,b){let c=a.getTextContent();b===r.INDENT_CONTENT_COMMAND?0<c.length&&/\s/.test(c[0])?a.setTextContent("\t"+c):(b=A("\t"),a.insertBefore(b)):0===c.indexOf("\t")&&(1===c.length?a.remove():a.setTextContent(c.substring(1)))} |
@@ -11,9 +11,9 @@ { | ||
"license": "MIT", | ||
"version": "0.3.11", | ||
"version": "0.4.0", | ||
"main": "LexicalCode.js", | ||
"peerDependencies": { | ||
"lexical": "0.3.11" | ||
"lexical": "0.4.0" | ||
}, | ||
"dependencies": { | ||
"@lexical/utils": "0.3.11", | ||
"@lexical/utils": "0.4.0", | ||
"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
53710
1105
+ Added@lexical/list@0.4.0(transitive)
+ Added@lexical/table@0.4.0(transitive)
+ Added@lexical/utils@0.4.0(transitive)
+ Addedlexical@0.4.0(transitive)
- Removed@lexical/list@0.3.11(transitive)
- Removed@lexical/table@0.3.11(transitive)
- Removed@lexical/utils@0.3.11(transitive)
- Removedlexical@0.3.11(transitive)
Updated@lexical/utils@0.4.0