@lexical/mark 0.3.5 → 0.3.8
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/LexicalMark.dev.js +2 -2
- package/LexicalMark.prod.js +6 -6
- package/package.json +3 -3
package/LexicalMark.dev.js
CHANGED
|
@@ -231,7 +231,7 @@ function $wrapSelectionInMarkNode(selection, isBackward, id) {
|
|
|
231
231
|
|
|
232
232
|
const isFirstNode = i === 0;
|
|
233
233
|
const isLastNode = i === nodesLength - 1;
|
|
234
|
-
let targetNode;
|
|
234
|
+
let targetNode = null;
|
|
235
235
|
|
|
236
236
|
if (lexical.$isTextNode(node)) {
|
|
237
237
|
const textContentSize = node.getTextContentSize();
|
|
@@ -248,7 +248,7 @@ function $wrapSelectionInMarkNode(selection, isBackward, id) {
|
|
|
248
248
|
targetNode = node;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
if (targetNode !==
|
|
251
|
+
if (targetNode !== null) {
|
|
252
252
|
if (targetNode && targetNode.is(currentNodeParent)) {
|
|
253
253
|
continue;
|
|
254
254
|
}
|
package/LexicalMark.prod.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';var
|
|
8
|
-
class n extends
|
|
7
|
+
'use strict';var l=require("lexical"),m=require("@lexical/utils");
|
|
8
|
+
class n extends l.ElementNode{static getType(){return"mark"}static clone(a){return new n(Array.from(a.__ids),a.__key)}static importDOM(){return null}static importJSON(a){let b=p(a.ids);b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}exportJSON(){return{...super.exportJSON(),ids:this.getIDs(),type:"mark",version:1}}constructor(a,b){super(b);this.__ids=a||[]}createDOM(a){let b=document.createElement("mark");m.addClassNamesToElement(b,a.theme.mark);1<this.__ids.length&&
|
|
9
9
|
m.addClassNamesToElement(b,a.theme.markOverlap);return b}updateDOM(a,b,c){a=a.__ids.length;let e=this.__ids.length;c=c.theme.markOverlap;a!==e&&(1===a?2===e&&m.addClassNamesToElement(b,c):1===e&&m.removeClassNamesFromElement(b,c));return!1}hasID(a){let b=this.getIDs();for(let c=0;c<b.length;c++)if(a===b[c])return!0;return!1}getIDs(){let a=this.getLatest();return q(a)?a.__ids:[]}addID(a){var b=this.getWritable();if(q(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b])return;c.push(a)}}deleteID(a){var b=
|
|
10
|
-
this.getWritable();if(q(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b]){c.splice(b,1);break}}}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(
|
|
11
|
-
d.offset:d.offset-e.offset;return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b}excludeFromCopy(a){return"clone"!==a}}function p(a){return new n(a)}function q(a){return a instanceof n}exports.$createMarkNode=p;exports.$getMarkIDs=function(a,b){for(;null!==a;){if(q(a))return a.getIDs();if(
|
|
10
|
+
this.getWritable();if(q(b)){let c=b.__ids;b.__ids=c;for(b=0;b<c.length;b++)if(a===c[b]){c.splice(b,1);break}}}insertNewAfter(a){a=this.getParentOrThrow().insertNewAfter(a);if(l.$isElementNode(a)){let b=p(this.__ids);a.append(b);return b}return null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(a,b,c){if(!l.$isRangeSelection(b)||"html"===c)return!1;let e=b.anchor,d=b.focus;a=e.getNode();c=d.getNode();b=b.isBackward()?e.offset-
|
|
11
|
+
d.offset:d.offset-e.offset;return this.isParentOf(a)&&this.isParentOf(c)&&this.getTextContent().length===b}excludeFromCopy(a){return"clone"!==a}}function p(a){return new n(a)}function q(a){return a instanceof n}exports.$createMarkNode=p;exports.$getMarkIDs=function(a,b){for(;null!==a;){if(q(a))return a.getIDs();if(l.$isTextNode(a)&&b===a.getTextContentSize()){let c=a.getNextSibling();if(q(c))return c.getIDs()}a=a.getParent()}return null};exports.$isMarkNode=q;
|
|
12
12
|
exports.$unwrapMarkNode=function(a){let b=a.getChildren(),c=null;for(let e=0;e<b.length;e++){let d=b[e];null===c?a.insertBefore(d):c.insertAfter(d);c=d}a.remove()};
|
|
13
|
-
exports.$wrapSelectionInMarkNode=function(a,b,c){let e=a.getNodes();var d=a.anchor.offset,
|
|
14
|
-
null!=
|
|
13
|
+
exports.$wrapSelectionInMarkNode=function(a,b,c){let e=a.getNodes();var d=a.anchor.offset,h=a.focus.offset;a=e.length;let w=b?h:d;b=b?d:h;let r,k;for(d=0;d<a;d++){var f=e[d];if(l.$isElementNode(k)&&k.isParentOf(f))continue;h=0===d;let u=d===a-1;var g=null;if(l.$isTextNode(f)){g=f.getTextContentSize();let v=h?w:0,t=u?b:g;if(0===v&&0===t)continue;f=f.splitText(v,t);g=1<f.length&&(3===f.length||h&&!u||t===g)?f[1]:f[0]}else l.$isElementNode(f)&&f.isInline()&&(g=f);null!==g?g&&g.is(r)||(h=g.getParent(),
|
|
14
|
+
null!=h&&h.is(r)||(k=void 0),r=h,void 0===k&&(k=p([c]),g.insertBefore(k)),k.append(g)):k=r=void 0}};exports.MarkNode=n
|
package/package.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"mark"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.3.
|
|
11
|
+
"version": "0.3.8",
|
|
12
12
|
"main": "LexicalMark.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.3.
|
|
14
|
+
"lexical": "0.3.8"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.3.
|
|
17
|
+
"@lexical/utils": "0.3.8"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|