@lexical/rich-text
Advanced tools
Comparing version 0.14.5 to 0.15.0
@@ -6,3 +6,5 @@ /** | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
'use strict'; | ||
@@ -67,9 +69,7 @@ | ||
*/ | ||
const documentMode = CAN_USE_DOM && 'documentMode' in document ? document.documentMode : null; | ||
CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform); | ||
CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent); | ||
const CAN_USE_BEFORE_INPUT = CAN_USE_DOM && 'InputEvent' in window && !documentMode ? 'getTargetRanges' in new window.InputEvent('input') : false; | ||
const IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent); | ||
const IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; | ||
const IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent); | ||
@@ -79,5 +79,2 @@ // Keep these in case we need to use them in the future. | ||
const IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent); | ||
// export const canUseTextInputEvent: boolean = CAN_USE_DOM && 'TextEvent' in window && !documentMode; | ||
CAN_USE_DOM && IS_ANDROID && IS_CHROME; | ||
const IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME; | ||
@@ -92,2 +89,3 @@ | ||
*/ | ||
const DRAG_DROP_PASTE = lexical.createCommand('DRAG_DROP_PASTE_FILE'); | ||
@@ -119,3 +117,3 @@ /** @noInheritDoc */ | ||
blockquote: node => ({ | ||
conversion: convertBlockquoteElement, | ||
conversion: $convertBlockquoteElement, | ||
priority: 0 | ||
@@ -218,23 +216,23 @@ }) | ||
h1: node => ({ | ||
conversion: convertHeadingElement, | ||
conversion: $convertHeadingElement, | ||
priority: 0 | ||
}), | ||
h2: node => ({ | ||
conversion: convertHeadingElement, | ||
conversion: $convertHeadingElement, | ||
priority: 0 | ||
}), | ||
h3: node => ({ | ||
conversion: convertHeadingElement, | ||
conversion: $convertHeadingElement, | ||
priority: 0 | ||
}), | ||
h4: node => ({ | ||
conversion: convertHeadingElement, | ||
conversion: $convertHeadingElement, | ||
priority: 0 | ||
}), | ||
h5: node => ({ | ||
conversion: convertHeadingElement, | ||
conversion: $convertHeadingElement, | ||
priority: 0 | ||
}), | ||
h6: node => ({ | ||
conversion: convertHeadingElement, | ||
conversion: $convertHeadingElement, | ||
priority: 0 | ||
@@ -337,3 +335,3 @@ }), | ||
} | ||
function convertHeadingElement(element) { | ||
function $convertHeadingElement(element) { | ||
const nodeName = element.nodeName.toLowerCase(); | ||
@@ -351,3 +349,3 @@ let node = null; | ||
} | ||
function convertBlockquoteElement(element) { | ||
function $convertBlockquoteElement(element) { | ||
const node = $createQuoteNode(); | ||
@@ -409,3 +407,3 @@ if (element.style !== null) { | ||
} | ||
function handleIndentAndOutdent(indentOrOutdent) { | ||
function $handleIndentAndOutdent(indentOrOutdent) { | ||
const selection = lexical.$getSelection(); | ||
@@ -423,3 +421,6 @@ if (!lexical.$isRangeSelection(selection)) { | ||
} | ||
const parentBlock = utils.$getNearestBlockElementAncestorOrThrow(node); | ||
const parentBlock = utils.$findMatchingParent(node, parentNode => lexical.$isElementNode(parentNode) && !parentNode.isInline()); | ||
if (parentBlock === null) { | ||
continue; | ||
} | ||
const parentKey = parentBlock.getKey(); | ||
@@ -537,3 +538,3 @@ if (parentBlock.canIndent() && !alreadyHandled.has(parentKey)) { | ||
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, () => { | ||
return handleIndentAndOutdent(block => { | ||
return $handleIndentAndOutdent(block => { | ||
const indent = block.getIndent(); | ||
@@ -543,3 +544,3 @@ block.setIndent(indent + 1); | ||
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => { | ||
return handleIndentAndOutdent(block => { | ||
return $handleIndentAndOutdent(block => { | ||
const indent = block.getIndent(); | ||
@@ -546,0 +547,0 @@ if (indent > 0) { |
@@ -6,5 +6,7 @@ /** | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
'use strict' | ||
const LexicalRichText = process.env.NODE_ENV === 'development' ? require('./LexicalRichText.dev.js') : require('./LexicalRichText.prod.js'); | ||
module.exports = LexicalRichText; |
@@ -6,6 +6,8 @@ /** | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
'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;n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent); | ||
let 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,u=n&&/Android/.test(navigator.userAgent),v=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent);n&&u&&v;let w=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!v,x=k.createCommand("DRAG_DROP_PASTE_FILE"); | ||
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(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(b&&h.isHTMLElement(b)){this.isEmpty()&&b.append(document.createElement("br"));var a=this.getFormatType();b.style.textAlign=a;if(a=this.getDirection())b.dir= | ||
@@ -19,4 +21,4 @@ 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}}function A(){return k.$applyNodeReplacement(new y)} | ||
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.$getNearestBlockElementAncestorOrThrow(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)}exports.$createHeadingNode=F;exports.$createQuoteNode=A;exports.$isHeadingNode=function(b){return b instanceof C}; | ||
exports.$isQuoteNode=function(b){return b instanceof y};exports.DRAG_DROP_PASTE=x;exports.HeadingNode=C;exports.QuoteNode=y;exports.eventFiles=I; | ||
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)}exports.$createHeadingNode=F;exports.$createQuoteNode=A; | ||
exports.$isHeadingNode=function(b){return b instanceof C};exports.$isQuoteNode=function(b){return b instanceof y};exports.DRAG_DROP_PASTE=x;exports.HeadingNode=C;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), | ||
@@ -32,4 +34,4 @@ 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, | ||
if(!k.$isRangeSelection(d))return!1;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:L}=e;var f=k.$getNearestNodeFromDOMNode(L);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 B=f.getParentOrThrow().getKey();f=f.getIndexWithinParent()+1;e.anchor.set(B,f,"element");e.focus.set(B,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), | ||
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 B=f.getParentOrThrow().getKey();f=f.getIndexWithinParent()+1;e.anchor.set(B,f,"element");e.focus.set(B,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.isSelectionCapturedInDecoratorInput(a.target)?!1:null!==k.$getSelection()?(G(a,b),!0):!1},k.COMMAND_PRIORITY_EDITOR))} |
@@ -10,3 +10,3 @@ { | ||
"license": "MIT", | ||
"version": "0.14.5", | ||
"version": "0.15.0", | ||
"main": "LexicalRichText.js", | ||
@@ -39,7 +39,7 @@ "types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/clipboard": "0.14.5", | ||
"@lexical/selection": "0.14.5", | ||
"@lexical/utils": "0.14.5", | ||
"lexical": "0.14.5" | ||
"@lexical/clipboard": "0.15.0", | ||
"@lexical/selection": "0.15.0", | ||
"@lexical/utils": "0.15.0", | ||
"lexical": "0.15.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
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
1724
85334
+ Added@lexical/clipboard@0.15.0(transitive)
+ Added@lexical/html@0.15.0(transitive)
+ Added@lexical/list@0.15.0(transitive)
+ Added@lexical/selection@0.15.0(transitive)
+ Added@lexical/table@0.15.0(transitive)
+ Added@lexical/utils@0.15.0(transitive)
+ Addedlexical@0.15.0(transitive)
- Removed@lexical/clipboard@0.14.5(transitive)
- Removed@lexical/html@0.14.5(transitive)
- Removed@lexical/list@0.14.5(transitive)
- Removed@lexical/selection@0.14.5(transitive)
- Removed@lexical/table@0.14.5(transitive)
- Removed@lexical/utils@0.14.5(transitive)
- Removedlexical@0.14.5(transitive)
Updated@lexical/clipboard@0.15.0
Updated@lexical/selection@0.15.0
Updated@lexical/utils@0.15.0
Updatedlexical@0.15.0