@lexical/mark 0.14.4 → 0.15.0
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 -0
- package/LexicalMark.dev.mjs +5 -1
- package/LexicalMark.js +2 -0
- package/LexicalMark.mjs +2 -0
- package/LexicalMark.node.mjs +2 -0
- package/LexicalMark.prod.js +2 -0
- package/LexicalMark.prod.mjs +3 -1
- package/package.json +3 -3
package/LexicalMark.dev.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';
|
|
8
10
|
|
|
9
11
|
var lexical = require('lexical');
|
|
@@ -16,6 +18,7 @@ var utils = require('@lexical/utils');
|
|
|
16
18
|
* LICENSE file in the root directory of this source tree.
|
|
17
19
|
*
|
|
18
20
|
*/
|
|
21
|
+
|
|
19
22
|
/** @noInheritDoc */
|
|
20
23
|
class MarkNode extends lexical.ElementNode {
|
|
21
24
|
/** @internal */
|
|
@@ -160,6 +163,7 @@ function $isMarkNode(node) {
|
|
|
160
163
|
* LICENSE file in the root directory of this source tree.
|
|
161
164
|
*
|
|
162
165
|
*/
|
|
166
|
+
|
|
163
167
|
function $unwrapMarkNode(node) {
|
|
164
168
|
const children = node.getChildren();
|
|
165
169
|
let target = null;
|
package/LexicalMark.dev.mjs
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import { ElementNode, $isRangeSelection, $applyNodeReplacement, $isElementNode, $isTextNode } from 'lexical';
|
|
8
10
|
import { addClassNamesToElement, removeClassNamesFromElement } from '@lexical/utils';
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -14,6 +16,7 @@ import { addClassNamesToElement, removeClassNamesFromElement } from '@lexical/ut
|
|
|
14
16
|
* LICENSE file in the root directory of this source tree.
|
|
15
17
|
*
|
|
16
18
|
*/
|
|
19
|
+
|
|
17
20
|
/** @noInheritDoc */
|
|
18
21
|
class MarkNode extends ElementNode {
|
|
19
22
|
/** @internal */
|
|
@@ -158,6 +161,7 @@ function $isMarkNode(node) {
|
|
|
158
161
|
* LICENSE file in the root directory of this source tree.
|
|
159
162
|
*
|
|
160
163
|
*/
|
|
164
|
+
|
|
161
165
|
function $unwrapMarkNode(node) {
|
|
162
166
|
const children = node.getChildren();
|
|
163
167
|
let target = null;
|
package/LexicalMark.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict'
|
|
8
10
|
const LexicalMark = process.env.NODE_ENV === 'development' ? require('./LexicalMark.dev.js') : require('./LexicalMark.prod.js');
|
|
9
11
|
module.exports = LexicalMark;
|
package/LexicalMark.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
import * as modDev from './LexicalMark.dev.mjs';
|
|
8
10
|
import * as modProd from './LexicalMark.prod.mjs';
|
|
9
11
|
const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
|
package/LexicalMark.node.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalMark.dev.mjs') : import('./LexicalMark.prod.mjs'));
|
|
8
10
|
export const $createMarkNode = mod.$createMarkNode;
|
|
9
11
|
export const $getMarkIDs = mod.$getMarkIDs;
|
package/LexicalMark.prod.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
8
|
+
|
|
7
9
|
'use strict';var k=require("lexical"),m=require("@lexical/utils");
|
|
8
10
|
class p extends k.ElementNode{static getType(){return"mark"}static clone(a){return new p(Array.from(a.__ids),a.__key)}static importDOM(){return null}static importJSON(a){let b=q(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
11
|
m.addClassNamesToElement(b,a.theme.markOverlap);return b}updateDOM(a,b,c){a=a.__ids.length;let d=this.__ids.length;c=c.theme.markOverlap;a!==d&&(1===a?2===d&&m.addClassNamesToElement(b,c):1===d&&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 r(a)?a.__ids:[]}addID(a){var b=this.getWritable();if(r(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=
|
package/LexicalMark.prod.mjs
CHANGED
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*
|
|
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
|
*/
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
import{ElementNode as t,$isRangeSelection as e,$applyNodeReplacement as n,$isElementNode as r,$isTextNode as i}from"lexical";import{addClassNamesToElement as s,removeClassNamesFromElement as o}from"@lexical/utils";class l extends t{static getType(){return"mark"}static clone(t){return new l(Array.from(t.__ids),t.__key)}static importDOM(){return null}static importJSON(t){const e=c(t.ids);return e.setFormat(t.format),e.setIndent(t.indent),e.setDirection(t.direction),e}exportJSON(){return{...super.exportJSON(),ids:this.getIDs(),type:"mark",version:1}}constructor(t,e){super(e),this.__ids=t||[]}createDOM(t){const e=document.createElement("mark");return s(e,t.theme.mark),this.__ids.length>1&&s(e,t.theme.markOverlap),e}updateDOM(t,e,n){const r=t.__ids,i=this.__ids,l=r.length,c=i.length,f=n.theme.markOverlap;return l!==c&&(1===l?2===c&&s(e,f):1===c&&o(e,f)),!1}hasID(t){const e=this.getIDs();for(let n=0;n<e.length;n++)if(t===e[n])return!0;return!1}getIDs(){const t=this.getLatest();return f(t)?t.__ids:[]}addID(t){const e=this.getWritable();if(f(e)){const n=e.__ids;e.__ids=n;for(let e=0;e<n.length;e++)if(t===n[e])return;n.push(t)}}deleteID(t){const e=this.getWritable();if(f(e)){const n=e.__ids;e.__ids=n;for(let e=0;e<n.length;e++)if(t===n[e])return void n.splice(e,1)}}insertNewAfter(t,e=!0){const n=c(this.__ids);return this.insertAfter(n,e),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(t,n,r){if(!e(n)||"html"===r)return!1;const i=n.anchor,s=n.focus,o=i.getNode(),l=s.getNode(),c=n.isBackward()?i.offset-s.offset:s.offset-i.offset;return this.isParentOf(o)&&this.isParentOf(l)&&this.getTextContent().length===c}excludeFromCopy(t){return"clone"!==t}}function c(t){return n(new l(t))}function f(t){return t instanceof l}function u(t){const e=t.getChildren();let n=null;for(let r=0;r<e.length;r++){const i=e[r];null===n?t.insertBefore(i):n.insertAfter(i),n=i}t.remove()}function a(t,e,n,s){const o=t.getNodes(),l=t.anchor.offset,u=t.focus.offset,a=o.length,d=e?u:l,h=e?l:u;let g,m;for(let t=0;t<a;t++){const e=o[t];if(r(m)&&m.isParentOf(e))continue;const l=0===t,u=t===a-1;let _=null;if(i(e)){const t=e.getTextContentSize(),n=l?d:0,r=u?h:t;if(0===n&&0===r)continue;const i=e.splitText(n,r);_=i.length>1&&(3===i.length||l&&!u||r===t)?i[1]:i[0]}else{if(f(e))continue;r(e)&&e.isInline()&&(_=e)}if(null!==_){if(_&&_.is(g))continue;const t=_.getParent();if(null!=t&&t.is(g)||(m=void 0),g=t,void 0===m){m=(s||c)([n]),_.insertBefore(m)}m.append(_)}else g=void 0,m=void 0}r(m)&&(e?m.selectStart():m.selectEnd())}function d(t,e){let n=t;for(;null!==n;){if(f(n))return n.getIDs();if(i(n)&&e===n.getTextContentSize()){const t=n.getNextSibling();if(f(t))return t.getIDs()}n=n.getParent()}return null}export{c as $createMarkNode,d as $getMarkIDs,f as $isMarkNode,u as $unwrapMarkNode,a as $wrapSelectionInMarkNode,l as MarkNode};
|
package/package.json
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"mark"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.15.0",
|
|
12
12
|
"main": "LexicalMark.js",
|
|
13
13
|
"types": "index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@lexical/utils": "0.
|
|
16
|
-
"lexical": "0.
|
|
15
|
+
"@lexical/utils": "0.15.0",
|
|
16
|
+
"lexical": "0.15.0"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|