@etrepum/lexical-builder-list 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -0
- package/dist/CheckListPlan.d.ts +9 -0
- package/dist/CheckListPlan.d.ts.map +1 -0
- package/dist/ListPlan.d.ts +2 -0
- package/dist/ListPlan.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +174 -0
- package/dist/registerList.d.ts +4 -0
- package/dist/registerList.d.ts.map +1 -0
- package/dist/shared/invariant.d.ts +9 -0
- package/dist/shared/invariant.d.ts.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
@@ -0,0 +1,9 @@
|
|
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
|
+
export declare const CheckListPlan: import('@etrepum/lexical-builder').LexicalPlan<import('@etrepum/lexical-builder').PlanConfigBase, "@etrepum/lexical-builder-list/CheckList", unknown, unknown>;
|
9
|
+
//# sourceMappingURL=CheckListPlan.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CheckListPlan.d.ts","sourceRoot":"","sources":["../src/CheckListPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgCH,eAAO,MAAM,aAAa,gKAIxB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ListPlan.d.ts","sourceRoot":"","sources":["../src/ListPlan.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,2JAInB,CAAC"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,11 @@
|
|
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
|
+
export declare const PACKAGE_VERSION: string;
|
9
|
+
export { ListPlan } from './ListPlan';
|
10
|
+
export { CheckListPlan } from './CheckListPlan';
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAwC,CAAC;AAEvE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
import { definePlan as E } from "@etrepum/lexical-builder";
|
2
|
+
import { INSERT_ORDERED_LIST_COMMAND as I, insertList as g, INSERT_UNORDERED_LIST_COMMAND as M, REMOVE_LIST_COMMAND as O, removeList as R, $handleListInsertParagraph as D, ListNode as A, ListItemNode as S, INSERT_CHECK_LIST_COMMAND as v, $isListItemNode as c, $isListNode as h } from "@lexical/list";
|
3
|
+
import { mergeRegister as p, $findMatchingParent as P, isHTMLElement as N, calculateZoomLevel as T } from "@lexical/utils";
|
4
|
+
import { COMMAND_PRIORITY_LOW as o, INSERT_PARAGRAPH_COMMAND as k, KEY_ARROW_DOWN_COMMAND as y, KEY_ARROW_UP_COMMAND as b, KEY_ESCAPE_COMMAND as K, KEY_SPACE_COMMAND as x, $getNearestNodeFromDOMNode as f, KEY_ARROW_LEFT_COMMAND as $, $getSelection as Y, $isRangeSelection as w, $isElementNode as F } from "lexical";
|
5
|
+
function W(e) {
|
6
|
+
return p(
|
7
|
+
e.registerCommand(
|
8
|
+
I,
|
9
|
+
() => (g(e, "number"), !0),
|
10
|
+
o
|
11
|
+
),
|
12
|
+
e.registerCommand(
|
13
|
+
M,
|
14
|
+
() => (g(e, "bullet"), !0),
|
15
|
+
o
|
16
|
+
),
|
17
|
+
e.registerCommand(
|
18
|
+
O,
|
19
|
+
() => (R(e), !0),
|
20
|
+
o
|
21
|
+
),
|
22
|
+
e.registerCommand(
|
23
|
+
k,
|
24
|
+
() => D(),
|
25
|
+
o
|
26
|
+
)
|
27
|
+
);
|
28
|
+
}
|
29
|
+
const U = E({
|
30
|
+
name: "@etrepum/lexical-builder-list/List",
|
31
|
+
nodes: [A, S],
|
32
|
+
register: W
|
33
|
+
}), j = E({
|
34
|
+
name: "@etrepum/lexical-builder-list/CheckList",
|
35
|
+
dependencies: [U],
|
36
|
+
register: B
|
37
|
+
});
|
38
|
+
function B(e) {
|
39
|
+
function l(t) {
|
40
|
+
L(t, () => {
|
41
|
+
const n = t.target;
|
42
|
+
e.isEditable() && e.update(() => {
|
43
|
+
if (t.target) {
|
44
|
+
const i = f(n);
|
45
|
+
c(i) && (n.focus(), i.toggleChecked());
|
46
|
+
}
|
47
|
+
});
|
48
|
+
});
|
49
|
+
}
|
50
|
+
function r(t) {
|
51
|
+
L(t, () => {
|
52
|
+
t.preventDefault();
|
53
|
+
});
|
54
|
+
}
|
55
|
+
return p(
|
56
|
+
e.registerCommand(
|
57
|
+
v,
|
58
|
+
() => (g(e, "check"), !0),
|
59
|
+
o
|
60
|
+
),
|
61
|
+
e.registerCommand(
|
62
|
+
y,
|
63
|
+
(t) => _(t, e, !1),
|
64
|
+
o
|
65
|
+
),
|
66
|
+
e.registerCommand(
|
67
|
+
b,
|
68
|
+
(t) => _(t, e, !0),
|
69
|
+
o
|
70
|
+
),
|
71
|
+
e.registerCommand(
|
72
|
+
K,
|
73
|
+
(t) => {
|
74
|
+
if (C() != null) {
|
75
|
+
const i = e.getRootElement();
|
76
|
+
return i != null && i.focus(), !0;
|
77
|
+
}
|
78
|
+
return !1;
|
79
|
+
},
|
80
|
+
o
|
81
|
+
),
|
82
|
+
e.registerCommand(
|
83
|
+
x,
|
84
|
+
(t) => {
|
85
|
+
const n = C();
|
86
|
+
return n != null && e.isEditable() ? (e.update(() => {
|
87
|
+
const i = f(n);
|
88
|
+
c(i) && (t.preventDefault(), i.toggleChecked());
|
89
|
+
}), !0) : !1;
|
90
|
+
},
|
91
|
+
o
|
92
|
+
),
|
93
|
+
e.registerCommand(
|
94
|
+
$,
|
95
|
+
(t) => e.getEditorState().read(() => {
|
96
|
+
const n = Y();
|
97
|
+
if (w(n) && n.isCollapsed()) {
|
98
|
+
const { anchor: i } = n, s = i.type === "element";
|
99
|
+
if (s || i.offset === 0) {
|
100
|
+
const d = i.getNode(), u = P(
|
101
|
+
d,
|
102
|
+
(a) => F(a) && !a.isInline()
|
103
|
+
);
|
104
|
+
if (c(u)) {
|
105
|
+
const a = u.getParent();
|
106
|
+
if (h(a) && a.getListType() === "check" && (s || u.getFirstDescendant() === d)) {
|
107
|
+
const m = e.getElementByKey(u.__key);
|
108
|
+
if (m != null && document.activeElement !== m)
|
109
|
+
return m.focus(), t.preventDefault(), !0;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
return !1;
|
115
|
+
}),
|
116
|
+
o
|
117
|
+
),
|
118
|
+
e.registerRootListener((t, n) => {
|
119
|
+
t !== null && (t.addEventListener("click", l), t.addEventListener("pointerdown", r)), n !== null && (n.removeEventListener("click", l), n.removeEventListener("pointerdown", r));
|
120
|
+
})
|
121
|
+
);
|
122
|
+
}
|
123
|
+
function L(e, l) {
|
124
|
+
const r = e.target;
|
125
|
+
if (r === null || !N(r))
|
126
|
+
return;
|
127
|
+
const t = r.firstChild;
|
128
|
+
if (t != null && N(t) && (t.tagName === "UL" || t.tagName === "OL"))
|
129
|
+
return;
|
130
|
+
const n = r.parentNode;
|
131
|
+
if (!n || n.__lexicalListType !== "check")
|
132
|
+
return;
|
133
|
+
const i = r.getBoundingClientRect(), s = e.pageX / T(r);
|
134
|
+
(r.dir === "rtl" ? s < i.right && s > i.right - 20 : s > i.left && s < i.left + 20) && l();
|
135
|
+
}
|
136
|
+
function C() {
|
137
|
+
const e = document.activeElement;
|
138
|
+
return e != null && e.tagName === "LI" && e.parentNode != null && // @ts-ignore internal field
|
139
|
+
e.parentNode.__lexicalListType === "check" ? e : null;
|
140
|
+
}
|
141
|
+
function H(e, l) {
|
142
|
+
let r = l ? e.getPreviousSibling() : e.getNextSibling(), t = e;
|
143
|
+
for (; r == null && c(t); )
|
144
|
+
t = t.getParentOrThrow().getParent(), t != null && (r = l ? t.getPreviousSibling() : t.getNextSibling());
|
145
|
+
for (; c(r); ) {
|
146
|
+
const n = l ? r.getLastChild() : r.getFirstChild();
|
147
|
+
if (!h(n))
|
148
|
+
return r;
|
149
|
+
r = l ? n.getLastChild() : n.getFirstChild();
|
150
|
+
}
|
151
|
+
return null;
|
152
|
+
}
|
153
|
+
function _(e, l, r) {
|
154
|
+
const t = C();
|
155
|
+
return t != null && l.update(() => {
|
156
|
+
const n = f(t);
|
157
|
+
if (!c(n))
|
158
|
+
return;
|
159
|
+
const i = H(n, r);
|
160
|
+
if (i != null) {
|
161
|
+
i.selectStart();
|
162
|
+
const s = l.getElementByKey(i.__key);
|
163
|
+
s != null && (e.preventDefault(), setTimeout(() => {
|
164
|
+
s.focus();
|
165
|
+
}, 0));
|
166
|
+
}
|
167
|
+
}), !1;
|
168
|
+
}
|
169
|
+
const q = "0.0.27";
|
170
|
+
export {
|
171
|
+
j as CheckListPlan,
|
172
|
+
U as ListPlan,
|
173
|
+
q as PACKAGE_VERSION
|
174
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"registerList.d.ts","sourceRoot":"","sources":["../src/registerList.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAa7C,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,cAgCjD"}
|
@@ -0,0 +1,9 @@
|
|
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
|
+
export default function invariant(cond?: boolean, message?: string, ...args: string[]): asserts cond;
|
9
|
+
//# sourceMappingURL=invariant.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../src/shared/invariant.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAQd"}
|
package/package.json
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
{
|
2
|
+
"name": "@etrepum/lexical-builder-list",
|
3
|
+
"description": "[EXPERIMENTAL] Lexical Builder @etrepum/lexical-builder-list",
|
4
|
+
"type": "module",
|
5
|
+
"keywords": [
|
6
|
+
"lexical",
|
7
|
+
"lexical-builder",
|
8
|
+
"plug-in",
|
9
|
+
"plan"
|
10
|
+
],
|
11
|
+
"scripts": {
|
12
|
+
"build": "tsc --noEmit && vite build",
|
13
|
+
"dev": "vite",
|
14
|
+
"test": "vitest run",
|
15
|
+
"test:watch": "vitest",
|
16
|
+
"lint": "eslint"
|
17
|
+
},
|
18
|
+
"version": "0.0.27",
|
19
|
+
"license": "MIT",
|
20
|
+
"repository": {
|
21
|
+
"type": "git",
|
22
|
+
"url": "git+https://github.com/etrepum/lexical-builder.git",
|
23
|
+
"directory": "packages/lexical-builder-list"
|
24
|
+
},
|
25
|
+
"bugs": {
|
26
|
+
"url": "https://github.com/etrepum/lexical-builder/issues"
|
27
|
+
},
|
28
|
+
"homepage": "https://github.com/etrepum/lexical-builder",
|
29
|
+
"dependencies": {
|
30
|
+
"@etrepum/lexical-builder": "*"
|
31
|
+
},
|
32
|
+
"peerDependencies": {
|
33
|
+
"lexical": ">=0.16.1-nightly.20240626",
|
34
|
+
"@lexical/list": ">=0.16.1-nightly.20240626"
|
35
|
+
},
|
36
|
+
"sideEffects": false,
|
37
|
+
"devDependencies": {
|
38
|
+
"@testing-library/dom": "^10.1.0",
|
39
|
+
"@testing-library/jest-dom": "^6.4.5",
|
40
|
+
"@testing-library/user-event": "^14.5.2",
|
41
|
+
"@repo/eslint-config": "*",
|
42
|
+
"eslint": "^8.57.0",
|
43
|
+
"jsdom": "^24.1.0",
|
44
|
+
"tslib": "^2.6.2",
|
45
|
+
"typescript": "^5.4.5",
|
46
|
+
"vite": "^5.2.11",
|
47
|
+
"vite-plugin-dts": "^3.9.1",
|
48
|
+
"vite-plugin-package-version": "^1.1.0",
|
49
|
+
"vitest": "^1.6.0"
|
50
|
+
},
|
51
|
+
"module": "dist/index.js",
|
52
|
+
"types": "dist/index.d.ts",
|
53
|
+
"files": [
|
54
|
+
"dist"
|
55
|
+
]
|
56
|
+
}
|