@lexical/mark 0.3.3 → 0.3.6
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 +4 -3
- package/LexicalMark.prod.js +7 -7
- package/MarkNode.d.ts +38 -0
- package/index.d.ts +13 -0
- package/package.json +3 -3
- package/LexicalMark.d.ts +0 -35
package/LexicalMark.dev.js
CHANGED
|
@@ -40,7 +40,8 @@ class MarkNode extends lexical.ElementNode {
|
|
|
40
40
|
exportJSON() {
|
|
41
41
|
return { ...super.exportJSON(),
|
|
42
42
|
ids: this.getIDs(),
|
|
43
|
-
type: 'mark'
|
|
43
|
+
type: 'mark',
|
|
44
|
+
version: 1
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -230,7 +231,7 @@ function $wrapSelectionInMarkNode(selection, isBackward, id) {
|
|
|
230
231
|
|
|
231
232
|
const isFirstNode = i === 0;
|
|
232
233
|
const isLastNode = i === nodesLength - 1;
|
|
233
|
-
let targetNode;
|
|
234
|
+
let targetNode = null;
|
|
234
235
|
|
|
235
236
|
if (lexical.$isTextNode(node)) {
|
|
236
237
|
const textContentSize = node.getTextContentSize();
|
|
@@ -247,7 +248,7 @@ function $wrapSelectionInMarkNode(selection, isBackward, id) {
|
|
|
247
248
|
targetNode = node;
|
|
248
249
|
}
|
|
249
250
|
|
|
250
|
-
if (targetNode !==
|
|
251
|
+
if (targetNode !== null) {
|
|
251
252
|
if (targetNode && targetNode.is(currentNodeParent)) {
|
|
252
253
|
continue;
|
|
253
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
|
|
9
|
-
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
|
-
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
|
-
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(
|
|
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
|
+
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(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/MarkNode.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { EditorConfig, GridSelection, LexicalNode, NodeKey, NodeSelection, RangeSelection, SerializedElementNode, Spread } from 'lexical';
|
|
9
|
+
import { ElementNode } from 'lexical';
|
|
10
|
+
export declare type SerializedMarkNode = Spread<{
|
|
11
|
+
ids: Array<string>;
|
|
12
|
+
type: 'mark';
|
|
13
|
+
version: 1;
|
|
14
|
+
}, SerializedElementNode>;
|
|
15
|
+
export declare class MarkNode extends ElementNode {
|
|
16
|
+
__ids: Array<string>;
|
|
17
|
+
static getType(): string;
|
|
18
|
+
static clone(node: MarkNode): MarkNode;
|
|
19
|
+
static importDOM(): null;
|
|
20
|
+
static importJSON(serializedNode: SerializedMarkNode): MarkNode;
|
|
21
|
+
exportJSON(): SerializedMarkNode;
|
|
22
|
+
constructor(ids: Array<string>, key?: NodeKey);
|
|
23
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
24
|
+
updateDOM(prevNode: MarkNode, element: HTMLElement, config: EditorConfig): boolean;
|
|
25
|
+
hasID(id: string): boolean;
|
|
26
|
+
getIDs(): Array<string>;
|
|
27
|
+
addID(id: string): void;
|
|
28
|
+
deleteID(id: string): void;
|
|
29
|
+
insertNewAfter(selection: RangeSelection): null | ElementNode;
|
|
30
|
+
canInsertTextBefore(): false;
|
|
31
|
+
canInsertTextAfter(): false;
|
|
32
|
+
canBeEmpty(): false;
|
|
33
|
+
isInline(): true;
|
|
34
|
+
extractWithChild(child: LexicalNode, selection: RangeSelection | NodeSelection | GridSelection, destination: 'clone' | 'html'): boolean;
|
|
35
|
+
excludeFromCopy(destination: 'clone' | 'html'): boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function $createMarkNode(ids: Array<string>): MarkNode;
|
|
38
|
+
export declare function $isMarkNode(node: LexicalNode | null): node is MarkNode;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import type { RangeSelection, TextNode } from 'lexical';
|
|
9
|
+
import { $createMarkNode, $isMarkNode, MarkNode } from './MarkNode';
|
|
10
|
+
export declare function $unwrapMarkNode(node: MarkNode): void;
|
|
11
|
+
export declare function $wrapSelectionInMarkNode(selection: RangeSelection, isBackward: boolean, id: string): void;
|
|
12
|
+
export declare function $getMarkIDs(node: TextNode, offset: number): null | Array<string>;
|
|
13
|
+
export { $createMarkNode, $isMarkNode, MarkNode };
|
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.6",
|
|
12
12
|
"main": "LexicalMark.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.3.
|
|
14
|
+
"lexical": "0.3.6"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.3.
|
|
17
|
+
"@lexical/utils": "0.3.6"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
package/LexicalMark.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import type {NodeKey, RangeSelection, TextNode} from 'lexical';
|
|
9
|
-
import {ElementNode, LexicalNode} from 'lexical';
|
|
10
|
-
export declare class MarkNode extends ElementNode {
|
|
11
|
-
__ids: Array<string>;
|
|
12
|
-
clone(node: MarkNode): MarkNode;
|
|
13
|
-
constructor(ids: Array<string>, key?: NodeKey);
|
|
14
|
-
hasID(id: string): boolean;
|
|
15
|
-
getIDs(): Array<string>;
|
|
16
|
-
addID(id: string): void;
|
|
17
|
-
deleteID(id: string): void;
|
|
18
|
-
canInsertTextBefore(): false;
|
|
19
|
-
canInsertTextAfter(): false;
|
|
20
|
-
isInline(): true;
|
|
21
|
-
}
|
|
22
|
-
export function $isMarkNode(
|
|
23
|
-
node: LexicalNode | null | undefined,
|
|
24
|
-
): node is MarkNode;
|
|
25
|
-
export function $createMarkNode(ids: Array<string>): MarkNode;
|
|
26
|
-
export function $getMarkIDs(
|
|
27
|
-
node: TextNode,
|
|
28
|
-
offset: number,
|
|
29
|
-
): null | Array<string>;
|
|
30
|
-
export function $wrapSelectionInMarkNode(
|
|
31
|
-
selection: RangeSelection,
|
|
32
|
-
isBackward: boolean,
|
|
33
|
-
id: string,
|
|
34
|
-
): void;
|
|
35
|
-
export function $unwrapMarkNode(node: MarkNode): void;
|