@lexical/rich-text 0.12.0 → 0.12.1
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/LexicalRichText.dev.js +4 -10
- package/LexicalRichText.prod.js +3 -3
- package/package.json +5 -5
package/LexicalRichText.dev.js
CHANGED
|
@@ -118,11 +118,8 @@ class QuoteNode extends lexical.ElementNode {
|
|
|
118
118
|
element
|
|
119
119
|
} = super.exportDOM(editor);
|
|
120
120
|
|
|
121
|
-
if (element &&
|
|
122
|
-
element.append(document.createElement('br'));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (element) {
|
|
121
|
+
if (element && utils.isHTMLElement(element)) {
|
|
122
|
+
if (this.isEmpty()) element.append(document.createElement('br'));
|
|
126
123
|
const formatType = this.getFormatType();
|
|
127
124
|
element.style.textAlign = formatType;
|
|
128
125
|
const direction = this.getDirection();
|
|
@@ -279,11 +276,8 @@ class HeadingNode extends lexical.ElementNode {
|
|
|
279
276
|
element
|
|
280
277
|
} = super.exportDOM(editor);
|
|
281
278
|
|
|
282
|
-
if (element &&
|
|
283
|
-
element.append(document.createElement('br'));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (element) {
|
|
279
|
+
if (element && utils.isHTMLElement(element)) {
|
|
280
|
+
if (this.isEmpty()) element.append(document.createElement('br'));
|
|
287
281
|
const formatType = this.getFormatType();
|
|
288
282
|
element.style.textAlign = formatType;
|
|
289
283
|
const direction = this.getDirection();
|
package/LexicalRichText.prod.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
'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}
|
|
8
8
|
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);
|
|
9
9
|
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&&/^(?=.*Chrome).*/i.test(navigator.userAgent),v=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!u,w=k.createCommand("DRAG_DROP_PASTE_FILE");
|
|
10
|
-
class x extends k.ElementNode{static getType(){return"quote"}static clone(b){return new x(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:y,priority:0})}}exportDOM(b){({element:b}=super.exportDOM(b));b&&this.isEmpty()&&b.append(document.createElement("br"));
|
|
10
|
+
class x extends k.ElementNode{static getType(){return"quote"}static clone(b){return new x(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:y,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=
|
|
11
11
|
a}return{element:b}}static importJSON(b){let a=z();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 z(){return k.$applyNodeReplacement(new x)}
|
|
12
12
|
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,
|
|
13
|
-
priority:0}),h6:()=>({conversion:C,priority:0}),p:b=>{b=b.firstChild;return null!==b&&D(b)?{conversion:()=>({node:null}),priority:3}:null},span:b=>D(b)?{conversion:()=>({node:E("h1")}),priority:3}:null}}exportDOM(b){({element:b}=super.exportDOM(b));b&&this.isEmpty()&&b.append(document.createElement("br"));
|
|
14
|
-
return a}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(b,a=!0){b=b?b.anchor.offset:0;b=0<b&&b<this.getTextContentSize()?E(this.getTag()):k.$createParagraphNode();let d=this.getDirection();b.setDirection(d);this.insertAfter(b,a);return b}collapseAtStart(){let b=this.isEmpty()?k.$createParagraphNode():E(this.getTag());this.getChildren().forEach(a=>b.append(a));this.replace(b);return!0}extractWithChild(){return!0}}
|
|
13
|
+
priority:0}),h6:()=>({conversion:C,priority:0}),p:b=>{b=b.firstChild;return null!==b&&D(b)?{conversion:()=>({node:null}),priority:3}:null},span:b=>D(b)?{conversion:()=>({node:E("h1")}),priority:3}:null}}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=a}return{element:b}}static importJSON(b){let a=E(b.tag);a.setFormat(b.format);a.setIndent(b.indent);
|
|
14
|
+
a.setDirection(b.direction);return a}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(b,a=!0){b=b?b.anchor.offset:0;b=0<b&&b<this.getTextContentSize()?E(this.getTag()):k.$createParagraphNode();let d=this.getDirection();b.setDirection(d);this.insertAfter(b,a);return b}collapseAtStart(){let b=this.isEmpty()?k.$createParagraphNode():E(this.getTag());this.getChildren().forEach(a=>b.append(a));this.replace(b);return!0}extractWithChild(){return!0}}
|
|
15
15
|
function D(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=E(a),null!==b.style&&d.setFormat(b.style.textAlign);return{node:d}}function y(b){let a=z();null!==b.style&&a.setFormat(b.style.textAlign);return{node:a}}function E(b){return k.$applyNodeReplacement(new B(b))}
|
|
16
16
|
function F(b,a){b.preventDefault();a.update(()=>{let d=k.$getSelection(),e=b instanceof InputEvent||b instanceof KeyboardEvent?null:b.clipboardData;null!=e&&(k.$isRangeSelection(d)||k.DEPRECATED_$isGridSelection(d))&&c.$insertDataTransferForRichText(e,d,a)},{tag:"paste"})}
|
|
17
17
|
async function G(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 H(b){let a=null;b instanceof DragEvent?a=b.dataTransfer:b instanceof 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]}
|
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"rich-text"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.12.
|
|
10
|
+
"version": "0.12.1",
|
|
11
11
|
"main": "LexicalRichText.js",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"lexical": "0.12.
|
|
14
|
-
"@lexical/selection": "0.12.
|
|
15
|
-
"@lexical/clipboard": "0.12.
|
|
16
|
-
"@lexical/utils": "0.12.
|
|
13
|
+
"lexical": "0.12.1",
|
|
14
|
+
"@lexical/selection": "0.12.1",
|
|
15
|
+
"@lexical/clipboard": "0.12.1",
|
|
16
|
+
"@lexical/utils": "0.12.1"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|