@lexical/rich-text
Advanced tools
Comparing version 0.21.1-nightly.20241213.0 to 0.21.1-nightly.20241216.0
@@ -21,3 +21,3 @@ /** | ||
createDOM(config: EditorConfig): HTMLElement; | ||
updateDOM(prevNode: QuoteNode, dom: HTMLElement): boolean; | ||
updateDOM(prevNode: this, dom: HTMLElement): boolean; | ||
static importDOM(): DOMConversionMap | null; | ||
@@ -43,3 +43,3 @@ exportDOM(editor: LexicalEditor): DOMExportOutput; | ||
createDOM(config: EditorConfig): HTMLElement; | ||
updateDOM(prevNode: HeadingNode, dom: HTMLElement): boolean; | ||
updateDOM(prevNode: this, dom: HTMLElement): boolean; | ||
static importDOM(): DOMConversionMap | null; | ||
@@ -46,0 +46,0 @@ exportDOM(editor: LexicalEditor): DOMExportOutput; |
@@ -122,3 +122,3 @@ /** | ||
} = super.exportDOM(editor); | ||
if (element && utils.isHTMLElement(element)) { | ||
if (utils.isHTMLElement(element)) { | ||
if (this.isEmpty()) { | ||
@@ -271,3 +271,3 @@ element.append(document.createElement('br')); | ||
} = super.exportDOM(editor); | ||
if (element && utils.isHTMLElement(element)) { | ||
if (utils.isHTMLElement(element)) { | ||
if (this.isEmpty()) { | ||
@@ -441,2 +441,15 @@ element.append(document.createElement('br')); | ||
} | ||
/** | ||
* Resets the capitalization of the selection to default. | ||
* Called when the user presses space, tab, or enter key. | ||
* @param selection The selection to reset the capitalization of. | ||
*/ | ||
function $resetCapitalization(selection) { | ||
for (const format of ['lowercase', 'uppercase', 'capitalize']) { | ||
if (selection.hasFormat(format)) { | ||
selection.toggleFormat(format); | ||
} | ||
} | ||
} | ||
function registerRichText(editor) { | ||
@@ -677,2 +690,3 @@ const removeListener = utils.mergeRegister(editor.registerCommand(lexical.CLICK_COMMAND, payload => { | ||
} | ||
$resetCapitalization(selection); | ||
if (event !== null) { | ||
@@ -780,3 +794,3 @@ // If we have beforeinput, then we can avoid blocking | ||
// if inputs then paste within the input ignore creating a new node on paste event | ||
if (lexical.isSelectionCapturedInDecoratorInput(event.target)) { | ||
if (lexical.isDOMNode(event.target) && lexical.isSelectionCapturedInDecoratorInput(event.target)) { | ||
return false; | ||
@@ -790,2 +804,14 @@ } | ||
return false; | ||
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_SPACE_COMMAND, _ => { | ||
const selection = lexical.$getSelection(); | ||
if (lexical.$isRangeSelection(selection)) { | ||
$resetCapitalization(selection); | ||
} | ||
return false; | ||
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.KEY_TAB_COMMAND, _ => { | ||
const selection = lexical.$getSelection(); | ||
if (lexical.$isRangeSelection(selection)) { | ||
$resetCapitalization(selection); | ||
} | ||
return false; | ||
}, lexical.COMMAND_PRIORITY_EDITOR)); | ||
@@ -792,0 +818,0 @@ return removeListener; |
@@ -9,30 +9,30 @@ /** | ||
'use strict';var c=require("@lexical/clipboard"),g=require("@lexical/selection"),h=require("@lexical/utils"),k=require("lexical");function l(a,b){return"undefined"!==typeof document.caretRangeFromPoint?(a=document.caretRangeFromPoint(a,b),null===a?null:{node:a.startContainer,offset:a.startOffset}):"undefined"!==document.caretPositionFromPoint?(a=document.caretPositionFromPoint(a,b),null===a?null:{node:a.offsetNode,offset:a.offset}):null} | ||
'use strict';var c=require("@lexical/clipboard"),g=require("@lexical/selection"),h=require("@lexical/utils"),k=require("lexical");function l(b,a){return"undefined"!==typeof document.caretRangeFromPoint?(b=document.caretRangeFromPoint(b,a),null===b?null:{node:b.startContainer,offset:b.startOffset}):"undefined"!==document.caretPositionFromPoint?(b=document.caretPositionFromPoint(b,a),null===b?null:{node:b.offsetNode,offset:b.offset}):null} | ||
let n="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement,p=n&&"documentMode"in document?document.documentMode:null,q=n&&"InputEvent"in window&&!p?"getTargetRanges"in new window.InputEvent("input"):!1,r=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),t=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,v=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),w=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!v,x= | ||
k.createCommand("DRAG_DROP_PASTE_FILE"); | ||
class y extends k.ElementNode{static getType(){return"quote"}static clone(a){return new y(a.__key)}constructor(a){super(a)}createDOM(a){let b=document.createElement("blockquote");h.addClassNamesToElement(b,a.theme.quote);return b}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:z,priority:0})}}exportDOM(a){({element:a}=super.exportDOM(a));if(a&&h.isHTMLElement(a)){this.isEmpty()&&a.append(document.createElement("br"));var b=this.getFormatType();a.style.textAlign=b;if(b=this.getDirection())a.dir= | ||
b}return{element:a}}static importJSON(a){let b=A();b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(a,b){a=k.$createParagraphNode();let d=this.getDirection();a.setDirection(d);this.insertAfter(a,b);return a}collapseAtStart(){let a=k.$createParagraphNode();this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}canMergeWhenEmpty(){return!0}} | ||
class y extends k.ElementNode{static getType(){return"quote"}static clone(b){return new y(b.__key)}constructor(b){super(b)}createDOM(b){let a=document.createElement("blockquote");h.addClassNamesToElement(a,b.theme.quote);return a}updateDOM(){return!1}static importDOM(){return{blockquote:()=>({conversion:z,priority:0})}}exportDOM(b){({element:b}=super.exportDOM(b));if(h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir= | ||
a}return{element:b}}static importJSON(b){let a=A();a.setFormat(b.format);a.setIndent(b.indent);a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(b,a){b=k.$createParagraphNode();let d=this.getDirection();b.setDirection(d);this.insertAfter(b,a);return b}collapseAtStart(){let b=k.$createParagraphNode();this.getChildren().forEach(a=>b.append(a));this.replace(b);return!0}canMergeWhenEmpty(){return!0}} | ||
function A(){return k.$applyNodeReplacement(new y)} | ||
class B extends k.ElementNode{static getType(){return"heading"}static clone(a){return new B(a.__tag,a.__key)}constructor(a,b){super(b);this.__tag=a}getTag(){return this.__tag}createDOM(a){let b=this.__tag,d=document.createElement(b);a=a.theme.heading;void 0!==a&&h.addClassNamesToElement(d,a[b]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:D,priority:0}),h2:()=>({conversion:D,priority:0}),h3:()=>({conversion:D,priority:0}),h4:()=>({conversion:D,priority:0}),h5:()=>({conversion:D, | ||
priority:0}),h6:()=>({conversion:D,priority:0}),p:a=>{a=a.firstChild;return null!==a&&E(a)?{conversion:()=>({node:null}),priority:3}:null},span:a=>E(a)?{conversion:()=>({node:F("h1")}),priority:3}:null}}exportDOM(a){({element:a}=super.exportDOM(a));if(a&&h.isHTMLElement(a)){this.isEmpty()&&a.append(document.createElement("br"));var b=this.getFormatType();a.style.textAlign=b;if(b=this.getDirection())a.dir=b}return{element:a}}static importJSON(a){let b=F(a.tag);b.setFormat(a.format);b.setIndent(a.indent); | ||
b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(a,b=!0){let d=a?a.anchor.offset:0;var e=this.getLastDescendant();e=!e||a&&a.anchor.key===e.getKey()&&d===e.getTextContentSize()||!a?k.$createParagraphNode():F(this.getTag());let f=this.getDirection();e.setDirection(f);this.insertAfter(e,b);0===d&&!this.isEmpty()&&a&&(a=k.$createParagraphNode(),a.select(),this.replace(a,!0));return e}collapseAtStart(){let a=this.isEmpty()? | ||
k.$createParagraphNode():F(this.getTag());this.getChildren().forEach(b=>a.append(b));this.replace(a);return!0}extractWithChild(){return!0}}function E(a){return"span"===a.nodeName.toLowerCase()?"26pt"===a.style.fontSize:!1}function D(a){let b=a.nodeName.toLowerCase(),d=null;if("h1"===b||"h2"===b||"h3"===b||"h4"===b||"h5"===b||"h6"===b)d=F(b),null!==a.style&&(k.setNodeIndentFromDOM(a,d),d.setFormat(a.style.textAlign));return{node:d}} | ||
function z(a){let b=A();null!==a.style&&(b.setFormat(a.style.textAlign),k.setNodeIndentFromDOM(a,b));return{node:b}}function F(a){return k.$applyNodeReplacement(new B(a))}function G(a,b){a.preventDefault();b.update(()=>{let d=k.$getSelection(),e=h.objectKlassEquals(a,InputEvent)||h.objectKlassEquals(a,KeyboardEvent)?null:a.clipboardData;null!=e&&null!==d&&c.$insertDataTransferForRichText(e,d,b)},{tag:"paste"})} | ||
async function H(a,b){await c.copyToClipboard(b,h.objectKlassEquals(a,ClipboardEvent)?a:null);b.update(()=>{let d=k.$getSelection();k.$isRangeSelection(d)?d.removeText():k.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())})} | ||
function I(a){let b=null;h.objectKlassEquals(a,DragEvent)?b=a.dataTransfer:h.objectKlassEquals(a,ClipboardEvent)&&(b=a.clipboardData);if(null===b)return[!1,[],!1];var d=b.types;a=d.includes("Files");d=d.includes("text/html")||d.includes("text/plain");return[a,Array.from(b.files),d]} | ||
function J(a){var b=k.$getSelection();if(!k.$isRangeSelection(b))return!1;let d=new Set;b=b.getNodes();for(let m=0;m<b.length;m++){var e=b[m],f=e.getKey();d.has(f)||(e=h.$findMatchingParent(e,u=>k.$isElementNode(u)&&!u.isInline()),null!==e&&(f=e.getKey(),e.canIndent()&&!d.has(f)&&(d.add(f),a(e))))}return 0<d.size}function K(a){a=k.$getNearestNodeFromDOMNode(a);return k.$isDecoratorNode(a)}exports.$createHeadingNode=F;exports.$createQuoteNode=A; | ||
exports.$isHeadingNode=function(a){return a instanceof B};exports.$isQuoteNode=function(a){return a instanceof y};exports.DRAG_DROP_PASTE=x;exports.HeadingNode=B;exports.QuoteNode=y;exports.eventFiles=I; | ||
exports.registerRichText=function(a){return h.mergeRegister(a.registerCommand(k.CLICK_COMMAND,()=>{const b=k.$getSelection();return k.$isNodeSelection(b)?(b.clear(),!0):!1},0),a.registerCommand(k.DELETE_CHARACTER_COMMAND,b=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteCharacter(b);return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.DELETE_WORD_COMMAND,b=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteWord(b);return!0},k.COMMAND_PRIORITY_EDITOR), | ||
a.registerCommand(k.DELETE_LINE_COMMAND,b=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteLine(b);return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.CONTROLLED_TEXT_INSERTION_COMMAND,b=>{const d=k.$getSelection();if("string"===typeof b)null!==d&&d.insertText(b);else{if(null===d)return!1;const e=b.dataTransfer;null!=e?c.$insertDataTransferForRichText(e,d,a):k.$isRangeSelection(d)&&(b=b.data)&&d.insertText(b)}return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.REMOVE_TEXT_COMMAND, | ||
()=>{const b=k.$getSelection();if(!k.$isRangeSelection(b))return!1;b.removeText();return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.FORMAT_TEXT_COMMAND,b=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.formatText(b);return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.FORMAT_ELEMENT_COMMAND,b=>{var d=k.$getSelection();if(!k.$isRangeSelection(d)&&!k.$isNodeSelection(d))return!1;d=d.getNodes();for(const e of d)d=h.$findMatchingParent(e,f=>k.$isElementNode(f)&&!f.isInline()), | ||
null!==d&&d.setFormat(b);return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.INSERT_LINE_BREAK_COMMAND,b=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.insertLineBreak(b);return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.INSERT_PARAGRAPH_COMMAND,()=>{const b=k.$getSelection();if(!k.$isRangeSelection(b))return!1;b.insertParagraph();return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.INSERT_TAB_COMMAND,()=>{k.$insertNodes([k.$createTabNode()]);return!0},k.COMMAND_PRIORITY_EDITOR), | ||
a.registerCommand(k.INDENT_CONTENT_COMMAND,()=>J(b=>{const d=b.getIndent();b.setIndent(d+1)}),k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.OUTDENT_CONTENT_COMMAND,()=>J(b=>{const d=b.getIndent();0<d&&b.setIndent(d-1)}),k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.KEY_ARROW_UP_COMMAND,b=>{var d=k.$getSelection();if(k.$isNodeSelection(d)&&!K(b.target)){if(b=d.getNodes(),0<b.length)return b[0].selectPrevious(),!0}else if(k.$isRangeSelection(d)&&(d=k.$getAdjacentNode(d.focus,!0),!b.shiftKey&&k.$isDecoratorNode(d)&& | ||
!d.isIsolated()&&!d.isInline()))return d.selectPrevious(),b.preventDefault(),!0;return!1},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.KEY_ARROW_DOWN_COMMAND,b=>{var d=k.$getSelection();if(k.$isNodeSelection(d)){if(b=d.getNodes(),0<b.length)return b[0].selectNext(0,0),!0}else if(k.$isRangeSelection(d)){let e=d.focus;if("root"===e.key&&e.offset===k.$getRoot().getChildrenSize())return b.preventDefault(),!0;d=k.$getAdjacentNode(d.focus,!1);if(!b.shiftKey&&k.$isDecoratorNode(d)&&!d.isIsolated()&&!d.isInline())return d.selectNext(), | ||
b.preventDefault(),!0}return!1},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.KEY_ARROW_LEFT_COMMAND,b=>{const d=k.$getSelection();if(k.$isNodeSelection(d)){var e=d.getNodes();if(0<e.length)return b.preventDefault(),e[0].selectPrevious(),!0}return k.$isRangeSelection(d)?g.$shouldOverrideDefaultCharacterSelection(d,!0)?(e=b.shiftKey,b.preventDefault(),g.$moveCharacter(d,e,!0),!0):!1:!1},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.KEY_ARROW_RIGHT_COMMAND,b=>{const d=k.$getSelection();if(k.$isNodeSelection(d)&& | ||
!K(b.target)){var e=d.getNodes();if(0<e.length)return b.preventDefault(),e[0].selectNext(0,0),!0}if(!k.$isRangeSelection(d))return!1;e=b.shiftKey;return g.$shouldOverrideDefaultCharacterSelection(d,!1)?(b.preventDefault(),g.$moveCharacter(d,e,!1),!0):!1},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.KEY_BACKSPACE_COMMAND,b=>{if(K(b.target))return!1;const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;const {anchor:e}=d,f=e.getNode();if(d.isCollapsed()&&0===e.offset&&!k.$isRootNode(f)&&0< | ||
h.$getNearestBlockElementAncestorOrThrow(f).getIndent())return b.preventDefault(),a.dispatchCommand(k.OUTDENT_CONTENT_COMMAND,void 0);if(t&&"ko-KR"===navigator.language)return!1;b.preventDefault();return a.dispatchCommand(k.DELETE_CHARACTER_COMMAND,!0)},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.KEY_DELETE_COMMAND,b=>{if(K(b.target))return!1;const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;b.preventDefault();return a.dispatchCommand(k.DELETE_CHARACTER_COMMAND,!1)},k.COMMAND_PRIORITY_EDITOR), | ||
a.registerCommand(k.KEY_ENTER_COMMAND,b=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;if(null!==b){if((t||r||w)&&q)return!1;b.preventDefault();if(b.shiftKey)return a.dispatchCommand(k.INSERT_LINE_BREAK_COMMAND,!1)}return a.dispatchCommand(k.INSERT_PARAGRAPH_COMMAND,void 0)},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.KEY_ESCAPE_COMMAND,()=>{const b=k.$getSelection();if(!k.$isRangeSelection(b))return!1;a.blur();return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.DROP_COMMAND, | ||
b=>{const [,d]=I(b);if(0<d.length){var e=l(b.clientX,b.clientY);if(null!==e){const {offset:m,node:u}=e;var f=k.$getNearestNodeFromDOMNode(u);if(null!==f){e=k.$createRangeSelection();if(k.$isTextNode(f))e.anchor.set(f.getKey(),m,"text"),e.focus.set(f.getKey(),m,"text");else{const C=f.getParentOrThrow().getKey();f=f.getIndexWithinParent()+1;e.anchor.set(C,f,"element");e.focus.set(C,f,"element")}e=k.$normalizeSelection__EXPERIMENTAL(e);k.$setSelection(e)}a.dispatchCommand(x,d)}b.preventDefault();return!0}b= | ||
k.$getSelection();return k.$isRangeSelection(b)?!0:!1},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.DRAGSTART_COMMAND,b=>{[b]=I(b);const d=k.$getSelection();return b&&!k.$isRangeSelection(d)?!1:!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.DRAGOVER_COMMAND,b=>{var [d]=I(b);const e=k.$getSelection();if(d&&!k.$isRangeSelection(e))return!1;d=l(b.clientX,b.clientY);null!==d&&(d=k.$getNearestNodeFromDOMNode(d.node),k.$isDecoratorNode(d)&&b.preventDefault());return!0},k.COMMAND_PRIORITY_EDITOR), | ||
a.registerCommand(k.SELECT_ALL_COMMAND,()=>{k.$selectAll();return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.COPY_COMMAND,b=>{c.copyToClipboard(a,h.objectKlassEquals(b,ClipboardEvent)?b:null);return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.CUT_COMMAND,b=>{H(b,a);return!0},k.COMMAND_PRIORITY_EDITOR),a.registerCommand(k.PASTE_COMMAND,b=>{const [,d,e]=I(b);return 0<d.length&&!e?(a.dispatchCommand(x,d),!0):k.isSelectionCapturedInDecoratorInput(b.target)?!1:null!==k.$getSelection()?(G(b, | ||
a),!0):!1},k.COMMAND_PRIORITY_EDITOR))} | ||
class B extends k.ElementNode{static getType(){return"heading"}static clone(b){return new B(b.__tag,b.__key)}constructor(b,a){super(a);this.__tag=b}getTag(){return this.__tag}createDOM(b){let a=this.__tag,d=document.createElement(a);b=b.theme.heading;void 0!==b&&h.addClassNamesToElement(d,b[a]);return d}updateDOM(){return!1}static importDOM(){return{h1:()=>({conversion:C,priority:0}),h2:()=>({conversion:C,priority:0}),h3:()=>({conversion:C,priority:0}),h4:()=>({conversion:C,priority:0}),h5:()=>({conversion:C, | ||
priority:0}),h6:()=>({conversion:C,priority:0}),p:b=>{b=b.firstChild;return null!==b&&E(b)?{conversion:()=>({node:null}),priority:3}:null},span:b=>E(b)?{conversion:()=>({node:F("h1")}),priority:3}:null}}exportDOM(b){({element:b}=super.exportDOM(b));if(h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir=a}return{element:b}}static importJSON(b){let a=F(b.tag);a.setFormat(b.format);a.setIndent(b.indent); | ||
a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(b,a=!0){let d=b?b.anchor.offset:0;var e=this.getLastDescendant();e=!e||b&&b.anchor.key===e.getKey()&&d===e.getTextContentSize()||!b?k.$createParagraphNode():F(this.getTag());let f=this.getDirection();e.setDirection(f);this.insertAfter(e,a);0===d&&!this.isEmpty()&&b&&(b=k.$createParagraphNode(),b.select(),this.replace(b,!0));return e}collapseAtStart(){let b=this.isEmpty()? | ||
k.$createParagraphNode():F(this.getTag());this.getChildren().forEach(a=>b.append(a));this.replace(b);return!0}extractWithChild(){return!0}}function E(b){return"span"===b.nodeName.toLowerCase()?"26pt"===b.style.fontSize:!1}function C(b){let a=b.nodeName.toLowerCase(),d=null;if("h1"===a||"h2"===a||"h3"===a||"h4"===a||"h5"===a||"h6"===a)d=F(a),null!==b.style&&(k.setNodeIndentFromDOM(b,d),d.setFormat(b.style.textAlign));return{node:d}} | ||
function z(b){let a=A();null!==b.style&&(a.setFormat(b.style.textAlign),k.setNodeIndentFromDOM(b,a));return{node:a}}function F(b){return k.$applyNodeReplacement(new B(b))}function G(b,a){b.preventDefault();a.update(()=>{let d=k.$getSelection(),e=h.objectKlassEquals(b,InputEvent)||h.objectKlassEquals(b,KeyboardEvent)?null:b.clipboardData;null!=e&&null!==d&&c.$insertDataTransferForRichText(e,d,a)},{tag:"paste"})} | ||
async function H(b,a){await c.copyToClipboard(a,h.objectKlassEquals(b,ClipboardEvent)?b:null);a.update(()=>{let d=k.$getSelection();k.$isRangeSelection(d)?d.removeText():k.$isNodeSelection(d)&&d.getNodes().forEach(e=>e.remove())})} | ||
function I(b){let a=null;h.objectKlassEquals(b,DragEvent)?a=b.dataTransfer:h.objectKlassEquals(b,ClipboardEvent)&&(a=b.clipboardData);if(null===a)return[!1,[],!1];var d=a.types;b=d.includes("Files");d=d.includes("text/html")||d.includes("text/plain");return[b,Array.from(a.files),d]} | ||
function J(b){var a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;let d=new Set;a=a.getNodes();for(let m=0;m<a.length;m++){var e=a[m],f=e.getKey();d.has(f)||(e=h.$findMatchingParent(e,u=>k.$isElementNode(u)&&!u.isInline()),null!==e&&(f=e.getKey(),e.canIndent()&&!d.has(f)&&(d.add(f),b(e))))}return 0<d.size}function K(b){b=k.$getNearestNodeFromDOMNode(b);return k.$isDecoratorNode(b)}function L(b){for(let a of["lowercase","uppercase","capitalize"])b.hasFormat(a)&&b.toggleFormat(a)} | ||
exports.$createHeadingNode=F;exports.$createQuoteNode=A;exports.$isHeadingNode=function(b){return b instanceof B};exports.$isQuoteNode=function(b){return b instanceof y};exports.DRAG_DROP_PASTE=x;exports.HeadingNode=B;exports.QuoteNode=y;exports.eventFiles=I; | ||
exports.registerRichText=function(b){return h.mergeRegister(b.registerCommand(k.CLICK_COMMAND,()=>{const a=k.$getSelection();return k.$isNodeSelection(a)?(a.clear(),!0):!1},0),b.registerCommand(k.DELETE_CHARACTER_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteCharacter(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DELETE_WORD_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteWord(a);return!0},k.COMMAND_PRIORITY_EDITOR), | ||
b.registerCommand(k.DELETE_LINE_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.deleteLine(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.CONTROLLED_TEXT_INSERTION_COMMAND,a=>{const d=k.$getSelection();if("string"===typeof a)null!==d&&d.insertText(a);else{if(null===d)return!1;const e=a.dataTransfer;null!=e?c.$insertDataTransferForRichText(e,d,b):k.$isRangeSelection(d)&&(a=a.data)&&d.insertText(a)}return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.REMOVE_TEXT_COMMAND, | ||
()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;a.removeText();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.FORMAT_TEXT_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.formatText(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.FORMAT_ELEMENT_COMMAND,a=>{var d=k.$getSelection();if(!k.$isRangeSelection(d)&&!k.$isNodeSelection(d))return!1;d=d.getNodes();for(const e of d)d=h.$findMatchingParent(e,f=>k.$isElementNode(f)&&!f.isInline()), | ||
null!==d&&d.setFormat(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_LINE_BREAK_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;d.insertLineBreak(a);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_PARAGRAPH_COMMAND,()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;a.insertParagraph();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.INSERT_TAB_COMMAND,()=>{k.$insertNodes([k.$createTabNode()]);return!0},k.COMMAND_PRIORITY_EDITOR), | ||
b.registerCommand(k.INDENT_CONTENT_COMMAND,()=>J(a=>{const d=a.getIndent();a.setIndent(d+1)}),k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.OUTDENT_CONTENT_COMMAND,()=>J(a=>{const d=a.getIndent();0<d&&a.setIndent(d-1)}),k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ARROW_UP_COMMAND,a=>{var d=k.$getSelection();if(k.$isNodeSelection(d)&&!K(a.target)){if(a=d.getNodes(),0<a.length)return a[0].selectPrevious(),!0}else if(k.$isRangeSelection(d)&&(d=k.$getAdjacentNode(d.focus,!0),!a.shiftKey&&k.$isDecoratorNode(d)&& | ||
!d.isIsolated()&&!d.isInline()))return d.selectPrevious(),a.preventDefault(),!0;return!1},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ARROW_DOWN_COMMAND,a=>{var d=k.$getSelection();if(k.$isNodeSelection(d)){if(a=d.getNodes(),0<a.length)return a[0].selectNext(0,0),!0}else if(k.$isRangeSelection(d)){let e=d.focus;if("root"===e.key&&e.offset===k.$getRoot().getChildrenSize())return a.preventDefault(),!0;d=k.$getAdjacentNode(d.focus,!1);if(!a.shiftKey&&k.$isDecoratorNode(d)&&!d.isIsolated()&&!d.isInline())return d.selectNext(), | ||
a.preventDefault(),!0}return!1},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ARROW_LEFT_COMMAND,a=>{const d=k.$getSelection();if(k.$isNodeSelection(d)){var e=d.getNodes();if(0<e.length)return a.preventDefault(),e[0].selectPrevious(),!0}return k.$isRangeSelection(d)?g.$shouldOverrideDefaultCharacterSelection(d,!0)?(e=a.shiftKey,a.preventDefault(),g.$moveCharacter(d,e,!0),!0):!1:!1},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ARROW_RIGHT_COMMAND,a=>{const d=k.$getSelection();if(k.$isNodeSelection(d)&& | ||
!K(a.target)){var e=d.getNodes();if(0<e.length)return a.preventDefault(),e[0].selectNext(0,0),!0}if(!k.$isRangeSelection(d))return!1;e=a.shiftKey;return g.$shouldOverrideDefaultCharacterSelection(d,!1)?(a.preventDefault(),g.$moveCharacter(d,e,!1),!0):!1},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_BACKSPACE_COMMAND,a=>{if(K(a.target))return!1;const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;const {anchor:e}=d,f=e.getNode();if(d.isCollapsed()&&0===e.offset&&!k.$isRootNode(f)&&0< | ||
h.$getNearestBlockElementAncestorOrThrow(f).getIndent())return a.preventDefault(),b.dispatchCommand(k.OUTDENT_CONTENT_COMMAND,void 0);if(t&&"ko-KR"===navigator.language)return!1;a.preventDefault();return b.dispatchCommand(k.DELETE_CHARACTER_COMMAND,!0)},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_DELETE_COMMAND,a=>{if(K(a.target))return!1;const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;a.preventDefault();return b.dispatchCommand(k.DELETE_CHARACTER_COMMAND,!1)},k.COMMAND_PRIORITY_EDITOR), | ||
b.registerCommand(k.KEY_ENTER_COMMAND,a=>{const d=k.$getSelection();if(!k.$isRangeSelection(d))return!1;L(d);if(null!==a){if((t||r||w)&&q)return!1;a.preventDefault();if(a.shiftKey)return b.dispatchCommand(k.INSERT_LINE_BREAK_COMMAND,!1)}return b.dispatchCommand(k.INSERT_PARAGRAPH_COMMAND,void 0)},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_ESCAPE_COMMAND,()=>{const a=k.$getSelection();if(!k.$isRangeSelection(a))return!1;b.blur();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DROP_COMMAND, | ||
a=>{const [,d]=I(a);if(0<d.length){var e=l(a.clientX,a.clientY);if(null!==e){const {offset:m,node:u}=e;var f=k.$getNearestNodeFromDOMNode(u);if(null!==f){e=k.$createRangeSelection();if(k.$isTextNode(f))e.anchor.set(f.getKey(),m,"text"),e.focus.set(f.getKey(),m,"text");else{const D=f.getParentOrThrow().getKey();f=f.getIndexWithinParent()+1;e.anchor.set(D,f,"element");e.focus.set(D,f,"element")}e=k.$normalizeSelection__EXPERIMENTAL(e);k.$setSelection(e)}b.dispatchCommand(x,d)}a.preventDefault();return!0}a= | ||
k.$getSelection();return k.$isRangeSelection(a)?!0:!1},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DRAGSTART_COMMAND,a=>{[a]=I(a);const d=k.$getSelection();return a&&!k.$isRangeSelection(d)?!1:!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.DRAGOVER_COMMAND,a=>{var [d]=I(a);const e=k.$getSelection();if(d&&!k.$isRangeSelection(e))return!1;d=l(a.clientX,a.clientY);null!==d&&(d=k.$getNearestNodeFromDOMNode(d.node),k.$isDecoratorNode(d)&&a.preventDefault());return!0},k.COMMAND_PRIORITY_EDITOR), | ||
b.registerCommand(k.SELECT_ALL_COMMAND,()=>{k.$selectAll();return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.COPY_COMMAND,a=>{c.copyToClipboard(b,h.objectKlassEquals(a,ClipboardEvent)?a:null);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.CUT_COMMAND,a=>{H(a,b);return!0},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.PASTE_COMMAND,a=>{const [,d,e]=I(a);return 0<d.length&&!e?(b.dispatchCommand(x,d),!0):k.isDOMNode(a.target)&&k.isSelectionCapturedInDecoratorInput(a.target)?!1:null!== | ||
k.$getSelection()?(G(a,b),!0):!1},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_SPACE_COMMAND,()=>{const a=k.$getSelection();k.$isRangeSelection(a)&&L(a);return!1},k.COMMAND_PRIORITY_EDITOR),b.registerCommand(k.KEY_TAB_COMMAND,()=>{const a=k.$getSelection();k.$isRangeSelection(a)&&L(a);return!1},k.COMMAND_PRIORITY_EDITOR))} |
@@ -10,3 +10,3 @@ { | ||
"license": "MIT", | ||
"version": "0.21.1-nightly.20241213.0", | ||
"version": "0.21.1-nightly.20241216.0", | ||
"main": "LexicalRichText.js", | ||
@@ -39,7 +39,7 @@ "types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/clipboard": "0.21.1-nightly.20241213.0", | ||
"@lexical/selection": "0.21.1-nightly.20241213.0", | ||
"@lexical/utils": "0.21.1-nightly.20241213.0", | ||
"lexical": "0.21.1-nightly.20241213.0" | ||
"@lexical/clipboard": "0.21.1-nightly.20241216.0", | ||
"@lexical/selection": "0.21.1-nightly.20241216.0", | ||
"@lexical/utils": "0.21.1-nightly.20241216.0", | ||
"lexical": "0.21.1-nightly.20241216.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
89499
1804
+ Added@lexical/clipboard@0.21.1-nightly.20241216.0(transitive)
+ Added@lexical/html@0.21.1-nightly.20241216.0(transitive)
+ Added@lexical/list@0.21.1-nightly.20241216.0(transitive)
+ Added@lexical/selection@0.21.1-nightly.20241216.0(transitive)
+ Added@lexical/table@0.21.1-nightly.20241216.0(transitive)
+ Added@lexical/utils@0.21.1-nightly.20241216.0(transitive)
+ Addedlexical@0.21.1-nightly.20241216.0(transitive)
- Removed@lexical/clipboard@0.21.1-nightly.20241213.0(transitive)
- Removed@lexical/html@0.21.1-nightly.20241213.0(transitive)
- Removed@lexical/list@0.21.1-nightly.20241213.0(transitive)
- Removed@lexical/selection@0.21.1-nightly.20241213.0(transitive)
- Removed@lexical/table@0.21.1-nightly.20241213.0(transitive)
- Removed@lexical/utils@0.21.1-nightly.20241213.0(transitive)
- Removedlexical@0.21.1-nightly.20241213.0(transitive)