@lofcz/platejs-list-classic 52.0.11
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/LICENSE +24 -0
- package/README.md +11 -0
- package/dist/BaseListPlugin-n9uuTtLe.js +1390 -0
- package/dist/BaseListPlugin-n9uuTtLe.js.map +1 -0
- package/dist/index-CYSu3DSy.d.ts +328 -0
- package/dist/index-CYSu3DSy.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.d.ts +49 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +156 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { Ancestor, Descendant, EditorNodesOptions, ElementEntry, NodeEntry, OmitFirst, OverrideEditor, Path, PluginConfig, Point, SlateEditor, TElement, TLocation, TRange } from "platejs";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/transforms/indentListItems.d.ts
|
|
4
|
+
declare const indentListItems: (editor: SlateEditor) => void;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/lib/transforms/insertListItem.d.ts
|
|
7
|
+
type InsertListItemOptions = {
|
|
8
|
+
inheritCheckStateOnLineEndBreak?: boolean;
|
|
9
|
+
inheritCheckStateOnLineStartBreak?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** Insert list item if selection in li>p. TODO: test */
|
|
12
|
+
declare const insertListItem: (editor: SlateEditor, options?: InsertListItemOptions) => boolean;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/lib/transforms/insertTodoListItem.d.ts
|
|
15
|
+
/** Insert todo list item if selection in li>p. TODO: test */
|
|
16
|
+
declare const insertTodoListItem: (editor: SlateEditor) => boolean;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/lib/transforms/moveListItemDown.d.ts
|
|
19
|
+
type MoveListItemDownOptions = {
|
|
20
|
+
list: ElementEntry;
|
|
21
|
+
listItem: ElementEntry;
|
|
22
|
+
};
|
|
23
|
+
declare const moveListItemDown: (editor: SlateEditor, {
|
|
24
|
+
list,
|
|
25
|
+
listItem
|
|
26
|
+
}: MoveListItemDownOptions) => false | undefined;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/lib/transforms/moveListItemSublistItemsToListItemSublist.d.ts
|
|
29
|
+
type MoveListItemSublistItemsToListItemSublistOptions = {
|
|
30
|
+
/** The list item to merge. */
|
|
31
|
+
fromListItem: ElementEntry;
|
|
32
|
+
/** The list item where to merge. */
|
|
33
|
+
toListItem: ElementEntry;
|
|
34
|
+
/** Move to the start of the list instead of the end. */
|
|
35
|
+
start?: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Move fromListItem sublist list items to the end of `toListItem` sublist. If
|
|
39
|
+
* there is no `toListItem` sublist, insert one.
|
|
40
|
+
*/
|
|
41
|
+
declare const moveListItemSublistItemsToListItemSublist: (editor: SlateEditor, {
|
|
42
|
+
fromListItem,
|
|
43
|
+
start,
|
|
44
|
+
toListItem
|
|
45
|
+
}: MoveListItemSublistItemsToListItemSublistOptions) => boolean;
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/lib/transforms/moveListItemUp.d.ts
|
|
48
|
+
type MoveListItemUpOptions = {
|
|
49
|
+
list: ElementEntry;
|
|
50
|
+
listItem: ElementEntry;
|
|
51
|
+
};
|
|
52
|
+
/** Move a list item up. */
|
|
53
|
+
declare const moveListItemUp: (editor: SlateEditor, {
|
|
54
|
+
list,
|
|
55
|
+
listItem
|
|
56
|
+
}: MoveListItemUpOptions) => boolean;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/lib/transforms/moveListItems.d.ts
|
|
59
|
+
type MoveListItemsOptions = {
|
|
60
|
+
at?: EditorNodesOptions['at'];
|
|
61
|
+
enableResetOnShiftTab?: boolean;
|
|
62
|
+
increase?: boolean;
|
|
63
|
+
};
|
|
64
|
+
declare const moveListItems: (editor: SlateEditor, {
|
|
65
|
+
at,
|
|
66
|
+
enableResetOnShiftTab,
|
|
67
|
+
increase
|
|
68
|
+
}?: MoveListItemsOptions) => any;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/lib/transforms/moveListItemsToList.d.ts
|
|
71
|
+
type MergeListItemIntoListOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* Delete `fromListItem` sublist if true.
|
|
74
|
+
*
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
77
|
+
deleteFromList?: boolean;
|
|
78
|
+
/** List items of the list will be moved. */
|
|
79
|
+
fromList?: ElementEntry;
|
|
80
|
+
/** List items of the sublist of this node will be moved. */
|
|
81
|
+
fromListItem?: ElementEntry;
|
|
82
|
+
fromStartIndex?: number;
|
|
83
|
+
to?: Path;
|
|
84
|
+
/** List items will be moved in this list. */
|
|
85
|
+
toList?: ElementEntry;
|
|
86
|
+
/** List position where to move the list items. */
|
|
87
|
+
toListIndex?: number | null;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Move the list items of the sublist of `fromListItem` to `toList` (if
|
|
91
|
+
* `fromListItem` is defined). Move the list items of `fromList` to `toList` (if
|
|
92
|
+
* `fromList` is defined).
|
|
93
|
+
*/
|
|
94
|
+
declare const moveListItemsToList: (editor: SlateEditor, {
|
|
95
|
+
deleteFromList,
|
|
96
|
+
fromList,
|
|
97
|
+
fromListItem,
|
|
98
|
+
fromStartIndex,
|
|
99
|
+
to: _to,
|
|
100
|
+
toList,
|
|
101
|
+
toListIndex
|
|
102
|
+
}: MergeListItemIntoListOptions) => boolean;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/lib/transforms/moveListSiblingsAfterCursor.d.ts
|
|
105
|
+
declare const moveListSiblingsAfterCursor: (editor: SlateEditor, {
|
|
106
|
+
at,
|
|
107
|
+
to
|
|
108
|
+
}: {
|
|
109
|
+
at: Path;
|
|
110
|
+
to: Path;
|
|
111
|
+
}) => any;
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/lib/transforms/removeFirstListItem.d.ts
|
|
114
|
+
/** If list is not nested and if li is not the first child, move li up. */
|
|
115
|
+
declare const removeFirstListItem: (editor: SlateEditor, {
|
|
116
|
+
list,
|
|
117
|
+
listItem
|
|
118
|
+
}: {
|
|
119
|
+
list: ElementEntry;
|
|
120
|
+
listItem: ElementEntry;
|
|
121
|
+
}) => boolean;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/lib/transforms/removeListItem.d.ts
|
|
124
|
+
type RemoveListItemOptions = {
|
|
125
|
+
list: ElementEntry;
|
|
126
|
+
listItem: ElementEntry;
|
|
127
|
+
reverse?: boolean;
|
|
128
|
+
};
|
|
129
|
+
/** Remove list item and move its sublist to list if any. */
|
|
130
|
+
declare const removeListItem: (editor: SlateEditor, {
|
|
131
|
+
list,
|
|
132
|
+
listItem,
|
|
133
|
+
reverse
|
|
134
|
+
}: RemoveListItemOptions) => boolean;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/lib/transforms/toggleList.d.ts
|
|
137
|
+
declare const toggleList: (editor: SlateEditor, {
|
|
138
|
+
type
|
|
139
|
+
}: {
|
|
140
|
+
type: string;
|
|
141
|
+
}) => any;
|
|
142
|
+
declare const toggleBulletedList: (editor: SlateEditor) => any;
|
|
143
|
+
declare const toggleTaskList: (editor: SlateEditor, defaultChecked?: boolean) => any;
|
|
144
|
+
declare const toggleNumberedList: (editor: SlateEditor) => any;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/lib/transforms/unindentListItems.d.ts
|
|
147
|
+
type UnindentListItemsOptions = Omit<MoveListItemsOptions, 'increase'>;
|
|
148
|
+
declare const unindentListItems: (editor: SlateEditor, options?: UnindentListItemsOptions) => any;
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/lib/transforms/unwrapList.d.ts
|
|
151
|
+
declare const unwrapList: (editor: SlateEditor, {
|
|
152
|
+
at
|
|
153
|
+
}?: {
|
|
154
|
+
at?: Path;
|
|
155
|
+
}) => void;
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/lib/BaseListPlugin.d.ts
|
|
158
|
+
type ListConfig = PluginConfig<'listClassic', {
|
|
159
|
+
enableResetOnShiftTab?: boolean;
|
|
160
|
+
/** Inherit the checked state of above node after insert break at the end */
|
|
161
|
+
inheritCheckStateOnLineEndBreak?: boolean;
|
|
162
|
+
/** Inherit the checked state of below node after insert break at the start */
|
|
163
|
+
inheritCheckStateOnLineStartBreak?: boolean;
|
|
164
|
+
/** Valid children types for list items, in addition to p and ul types. */
|
|
165
|
+
validLiChildrenTypes?: string[];
|
|
166
|
+
}, {}, {
|
|
167
|
+
toggle: {
|
|
168
|
+
bulletedList: OmitFirst<typeof toggleBulletedList>;
|
|
169
|
+
list: OmitFirst<typeof toggleList>;
|
|
170
|
+
numberedList: OmitFirst<typeof toggleNumberedList>;
|
|
171
|
+
taskList: OmitFirst<typeof toggleTaskList>;
|
|
172
|
+
};
|
|
173
|
+
}>;
|
|
174
|
+
declare const BaseBulletedListPlugin: any;
|
|
175
|
+
declare const BaseNumberedListPlugin: any;
|
|
176
|
+
declare const BaseTaskListPlugin: any;
|
|
177
|
+
declare const BaseListItemPlugin: any;
|
|
178
|
+
declare const BaseListItemContentPlugin: any;
|
|
179
|
+
/** Enables support for bulleted, numbered and to-do lists. */
|
|
180
|
+
declare const BaseListPlugin: any;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/lib/BaseTodoListPlugin.d.ts
|
|
183
|
+
interface TTodoListItemElement extends TElement {
|
|
184
|
+
checked?: boolean;
|
|
185
|
+
}
|
|
186
|
+
declare const BaseTodoListPlugin: any;
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/lib/withDeleteBackwardList.d.ts
|
|
189
|
+
declare const withDeleteBackwardList: OverrideEditor<ListConfig>;
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/lib/withDeleteForwardList.d.ts
|
|
192
|
+
declare const withDeleteForwardList: OverrideEditor<ListConfig>;
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/lib/withDeleteFragmentList.d.ts
|
|
195
|
+
declare const withDeleteFragmentList: OverrideEditor<ListConfig>;
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/lib/withInsertBreakList.d.ts
|
|
198
|
+
declare const withInsertBreakList: OverrideEditor<ListConfig>;
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/lib/withInsertFragmentList.d.ts
|
|
201
|
+
declare const withInsertFragmentList: OverrideEditor<ListConfig>;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/lib/withList.d.ts
|
|
204
|
+
declare const withList: OverrideEditor<ListConfig>;
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/lib/withNormalizeList.d.ts
|
|
207
|
+
/** Normalize list node to force the ul>li>p+ul structure. */
|
|
208
|
+
declare const withNormalizeList: OverrideEditor<ListConfig>;
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/lib/normalizers/normalizeListItem.d.ts
|
|
211
|
+
/**
|
|
212
|
+
* Recursively get all the:
|
|
213
|
+
*
|
|
214
|
+
* - Block children
|
|
215
|
+
* - Inline children except those at excludeDepth
|
|
216
|
+
*/
|
|
217
|
+
declare const getDeepInlineChildren: (editor: SlateEditor, {
|
|
218
|
+
children
|
|
219
|
+
}: {
|
|
220
|
+
children: NodeEntry<Descendant>[];
|
|
221
|
+
}) => NodeEntry<Descendant>[];
|
|
222
|
+
/**
|
|
223
|
+
* If the list item has no child: insert an empty list item container. Else:
|
|
224
|
+
* move the children that are not valid to the list item container.
|
|
225
|
+
*/
|
|
226
|
+
declare const normalizeListItem: (editor: SlateEditor, {
|
|
227
|
+
listItem,
|
|
228
|
+
validLiChildrenTypes
|
|
229
|
+
}: {
|
|
230
|
+
listItem: ElementEntry;
|
|
231
|
+
} & ListConfig["options"]) => boolean;
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/lib/normalizers/normalizeNestedList.d.ts
|
|
234
|
+
declare const normalizeNestedList: (editor: SlateEditor, {
|
|
235
|
+
nestedListItem
|
|
236
|
+
}: {
|
|
237
|
+
nestedListItem: ElementEntry;
|
|
238
|
+
}) => boolean | undefined;
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/lib/queries/getHighestEmptyList.d.ts
|
|
241
|
+
/**
|
|
242
|
+
* Find the highest end list that can be deleted. Its path should be different
|
|
243
|
+
* to diffListPath. If the highest end list 2+ items, return liPath. Get the
|
|
244
|
+
* parent list until:
|
|
245
|
+
*
|
|
246
|
+
* - The list has less than 2 items.
|
|
247
|
+
* - Its path is not equals to diffListPath.
|
|
248
|
+
*/
|
|
249
|
+
declare const getHighestEmptyList: (editor: SlateEditor, {
|
|
250
|
+
diffListPath,
|
|
251
|
+
liPath
|
|
252
|
+
}: {
|
|
253
|
+
liPath: Path;
|
|
254
|
+
diffListPath?: Path;
|
|
255
|
+
}) => Path | undefined;
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/lib/queries/getListItemEntry.d.ts
|
|
258
|
+
/**
|
|
259
|
+
* Returns the nearest li and ul / ol wrapping node entries for a given path
|
|
260
|
+
* (default = selection)
|
|
261
|
+
*/
|
|
262
|
+
declare const getListItemEntry: (editor: SlateEditor, {
|
|
263
|
+
at
|
|
264
|
+
}?: {
|
|
265
|
+
at?: TLocation | null;
|
|
266
|
+
}) => {
|
|
267
|
+
list: ElementEntry;
|
|
268
|
+
listItem: ElementEntry;
|
|
269
|
+
} | undefined;
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/lib/queries/getListRoot.d.ts
|
|
272
|
+
/** Searches upward for the root list element */
|
|
273
|
+
declare const getListRoot: (editor: SlateEditor, at?: Path | Point | TRange | null) => ElementEntry | undefined;
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/lib/queries/getListTypes.d.ts
|
|
276
|
+
declare const getListTypes: (editor: SlateEditor) => any[];
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/lib/queries/getTaskListProps.d.ts
|
|
279
|
+
type GetPropsIfTaskListLiNodeOptions = {
|
|
280
|
+
liNode: TElement;
|
|
281
|
+
inherit?: boolean;
|
|
282
|
+
};
|
|
283
|
+
declare const getPropsIfTaskListLiNode: (editor: SlateEditor, {
|
|
284
|
+
inherit,
|
|
285
|
+
liNode: node
|
|
286
|
+
}: GetPropsIfTaskListLiNodeOptions) => {
|
|
287
|
+
checked: boolean;
|
|
288
|
+
} | undefined;
|
|
289
|
+
declare const getPropsIfTaskList: (editor: SlateEditor, type: string, partial?: {
|
|
290
|
+
checked?: boolean;
|
|
291
|
+
}) => {
|
|
292
|
+
checked: boolean;
|
|
293
|
+
} | undefined;
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/lib/queries/getTodoListItemEntry.d.ts
|
|
296
|
+
/**
|
|
297
|
+
* Returns the nearest li and ul / ol wrapping node entries for a given path
|
|
298
|
+
* (default = selection)
|
|
299
|
+
*/
|
|
300
|
+
declare const getTodoListItemEntry: (editor: SlateEditor, {
|
|
301
|
+
at
|
|
302
|
+
}?: {
|
|
303
|
+
at?: TLocation | null;
|
|
304
|
+
}) => {
|
|
305
|
+
list: ElementEntry;
|
|
306
|
+
listItem: ElementEntry;
|
|
307
|
+
} | undefined;
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/lib/queries/hasListChild.d.ts
|
|
310
|
+
/** Is there a list child in the node. */
|
|
311
|
+
declare const hasListChild: (editor: SlateEditor, node: Ancestor) => any;
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/lib/queries/isAcrossListItems.d.ts
|
|
314
|
+
/** Is selection across blocks with list items */
|
|
315
|
+
declare const isAcrossListItems: (editor: SlateEditor, at?: TRange | null) => any;
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/lib/queries/isListNested.d.ts
|
|
318
|
+
/** Is the list nested, i.e. its parent is a list item. */
|
|
319
|
+
declare const isListNested: (editor: SlateEditor, listPath: Path) => boolean;
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/lib/queries/isListRoot.d.ts
|
|
322
|
+
declare const isListRoot: (editor: SlateEditor, node: Descendant) => boolean;
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/lib/queries/someList.d.ts
|
|
325
|
+
declare const someList: (editor: SlateEditor, type: string) => boolean;
|
|
326
|
+
//#endregion
|
|
327
|
+
export { moveListItemDown as $, BaseNumberedListPlugin as A, RemoveListItemOptions as B, withDeleteBackwardList as C, BaseListItemContentPlugin as D, BaseBulletedListPlugin as E, unindentListItems as F, moveListItemsToList as G, removeFirstListItem as H, toggleBulletedList as I, MoveListItemUpOptions as J, MoveListItemsOptions as K, toggleList as L, ListConfig as M, unwrapList as N, BaseListItemPlugin as O, UnindentListItemsOptions as P, MoveListItemDownOptions as Q, toggleNumberedList as R, withDeleteForwardList as S, TTodoListItemElement as T, moveListSiblingsAfterCursor as U, removeListItem as V, MergeListItemIntoListOptions as W, MoveListItemSublistItemsToListItemSublistOptions as X, moveListItemUp as Y, moveListItemSublistItemsToListItemSublist as Z, withNormalizeList as _, hasListChild as a, withInsertBreakList as b, getPropsIfTaskList as c, getListRoot as d, insertTodoListItem as et, getListItemEntry as f, normalizeListItem as g, getDeepInlineChildren as h, isAcrossListItems as i, BaseTaskListPlugin as j, BaseListPlugin as k, getPropsIfTaskListLiNode as l, normalizeNestedList as m, isListRoot as n, insertListItem as nt, getTodoListItemEntry as o, getHighestEmptyList as p, moveListItems as q, isListNested as r, indentListItems as rt, GetPropsIfTaskListLiNodeOptions as s, someList as t, InsertListItemOptions as tt, getListTypes as u, withList as v, BaseTodoListPlugin as w, withDeleteFragmentList as x, withInsertFragmentList as y, toggleTaskList as z };
|
|
328
|
+
//# sourceMappingURL=index-CYSu3DSy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CYSu3DSy.d.ts","names":[],"sources":["../src/lib/transforms/indentListItems.ts","../src/lib/transforms/insertListItem.ts","../src/lib/transforms/insertTodoListItem.ts","../src/lib/transforms/moveListItemDown.ts","../src/lib/transforms/moveListItemSublistItemsToListItemSublist.ts","../src/lib/transforms/moveListItemUp.ts","../src/lib/transforms/moveListItems.ts","../src/lib/transforms/moveListItemsToList.ts","../src/lib/transforms/moveListSiblingsAfterCursor.ts","../src/lib/transforms/removeFirstListItem.ts","../src/lib/transforms/removeListItem.ts","../src/lib/transforms/toggleList.ts","../src/lib/transforms/unindentListItems.ts","../src/lib/transforms/unwrapList.ts","../src/lib/BaseListPlugin.ts","../src/lib/BaseTodoListPlugin.ts","../src/lib/withDeleteBackwardList.ts","../src/lib/withDeleteForwardList.ts","../src/lib/withDeleteFragmentList.ts","../src/lib/withInsertBreakList.ts","../src/lib/withInsertFragmentList.ts","../src/lib/withList.ts","../src/lib/withNormalizeList.ts","../src/lib/normalizers/normalizeListItem.ts","../src/lib/normalizers/normalizeNestedList.ts","../src/lib/queries/getHighestEmptyList.ts","../src/lib/queries/getListItemEntry.ts","../src/lib/queries/getListRoot.ts","../src/lib/queries/getListTypes.ts","../src/lib/queries/getTaskListProps.ts","../src/lib/queries/getTodoListItemEntry.ts","../src/lib/queries/hasListChild.ts","../src/lib/queries/isAcrossListItems.ts","../src/lib/queries/isListNested.ts","../src/lib/queries/isListRoot.ts","../src/lib/queries/someList.ts"],"sourcesContent":[],"mappings":";;;cAIa,0BAA2B;;;KCF5B,qBAAA;;EDEC,iCAA2B,CAAA,EAAA,OAAW;;;cCItC,yBACH,uBACC;;;;cCLE,6BAA8B;;;KCK/B,uBAAA;QACJ;EHPK,QAAA,EGQD,YHNX;;cGSY,2BACH;;;GACY;;;KCNV,gDAAA;;EJPC,YAAA,EISG,YJPf;;cIUa;;EHdF,KAAA,CAAA,EAAA,OAAA;AAMZ,CAAA;;;;ACHA;cEqBa,oDACH;;;;GAKL;;;KClBO,qBAAA;QACJ;ELXK,QAAA,EKYD,YLVX;;;cKcY,yBACH;;;GACY;;;KCRV,oBAAA;OACL;ENXM,qBAEZ,CAAA,EAAA,OAFuC;;;cMgB3B,wBACH;;;;IAKL;;;KChBO,4BAAA;;APNZ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BAAwB,mBAAmB;;;;cCF3C,4BACH,kBACJ;;;;cCAO,uBAAwB,uBAAuB;;;cCD/C,qBAAsB,mBAAmB;;;cCAzC,mBAAoB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $ as moveListItemDown, A as BaseNumberedListPlugin, B as RemoveListItemOptions, C as withDeleteBackwardList, D as BaseListItemContentPlugin, E as BaseBulletedListPlugin, F as unindentListItems, G as moveListItemsToList, H as removeFirstListItem, I as toggleBulletedList, J as MoveListItemUpOptions, K as MoveListItemsOptions, L as toggleList, M as ListConfig, N as unwrapList, O as BaseListItemPlugin, P as UnindentListItemsOptions, Q as MoveListItemDownOptions, R as toggleNumberedList, S as withDeleteForwardList, T as TTodoListItemElement, U as moveListSiblingsAfterCursor, V as removeListItem, W as MergeListItemIntoListOptions, X as MoveListItemSublistItemsToListItemSublistOptions, Y as moveListItemUp, Z as moveListItemSublistItemsToListItemSublist, _ as withNormalizeList, a as hasListChild, b as withInsertBreakList, c as getPropsIfTaskList, d as getListRoot, et as insertTodoListItem, f as getListItemEntry, g as normalizeListItem, h as getDeepInlineChildren, i as isAcrossListItems, j as BaseTaskListPlugin, k as BaseListPlugin, l as getPropsIfTaskListLiNode, m as normalizeNestedList, n as isListRoot, nt as insertListItem, o as getTodoListItemEntry, p as getHighestEmptyList, q as moveListItems, r as isListNested, rt as indentListItems, s as GetPropsIfTaskListLiNodeOptions, t as someList, tt as InsertListItemOptions, u as getListTypes, v as withList, w as BaseTodoListPlugin, x as withDeleteFragmentList, y as withInsertFragmentList, z as toggleTaskList } from "./index-CYSu3DSy";
|
|
2
|
+
export { BaseBulletedListPlugin, BaseListItemContentPlugin, BaseListItemPlugin, BaseListPlugin, BaseNumberedListPlugin, BaseTaskListPlugin, BaseTodoListPlugin, GetPropsIfTaskListLiNodeOptions, InsertListItemOptions, ListConfig, MergeListItemIntoListOptions, MoveListItemDownOptions, MoveListItemSublistItemsToListItemSublistOptions, MoveListItemUpOptions, MoveListItemsOptions, RemoveListItemOptions, TTodoListItemElement, UnindentListItemsOptions, getDeepInlineChildren, getHighestEmptyList, getListItemEntry, getListRoot, getListTypes, getPropsIfTaskList, getPropsIfTaskListLiNode, getTodoListItemEntry, hasListChild, indentListItems, insertListItem, insertTodoListItem, isAcrossListItems, isListNested, isListRoot, moveListItemDown, moveListItemSublistItemsToListItemSublist, moveListItemUp, moveListItems, moveListItemsToList, moveListSiblingsAfterCursor, normalizeListItem, normalizeNestedList, removeFirstListItem, removeListItem, someList, toggleBulletedList, toggleList, toggleNumberedList, toggleTaskList, unindentListItems, unwrapList, withDeleteBackwardList, withDeleteForwardList, withDeleteFragmentList, withInsertBreakList, withInsertFragmentList, withList, withNormalizeList };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { A as moveListItemsToList, B as getHighestEmptyList, C as insertTodoListItem, D as removeFirstListItem, E as moveListItems, F as getTodoListItemEntry, H as isListNested, I as getPropsIfTaskList, L as getPropsIfTaskListLiNode, M as isListRoot, N as isAcrossListItems, O as moveListItemUp, P as hasListChild, R as getListRoot, S as moveListItemSublistItemsToListItemSublist, T as insertListItem, V as getListTypes, _ as toggleBulletedList, a as BaseNumberedListPlugin, b as toggleTaskList, c as withNormalizeList, d as normalizeListItem, f as withInsertFragmentList, g as withDeleteBackwardList, h as withDeleteForwardList, i as BaseListPlugin, j as moveListItemDown, k as unwrapList, l as normalizeNestedList, m as withDeleteFragmentList, n as BaseListItemContentPlugin, o as BaseTaskListPlugin, p as withInsertBreakList, r as BaseListItemPlugin, s as withList, t as BaseBulletedListPlugin, u as getDeepInlineChildren, v as toggleList, w as BaseTodoListPlugin, x as removeListItem, y as toggleNumberedList, z as getListItemEntry } from "./BaseListPlugin-n9uuTtLe.js";
|
|
2
|
+
import { NodeApi, PathApi, match } from "platejs";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/queries/someList.ts
|
|
5
|
+
const someList = (editor, type) => getListItemEntry(editor)?.list?.[0].type === type;
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/lib/transforms/indentListItems.ts
|
|
9
|
+
const indentListItems = (editor) => {
|
|
10
|
+
moveListItems(editor, { increase: true });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/lib/transforms/moveListSiblingsAfterCursor.ts
|
|
15
|
+
const moveListSiblingsAfterCursor = (editor, { at, to }) => {
|
|
16
|
+
const offset = at.at(-1);
|
|
17
|
+
at = PathApi.parent(at);
|
|
18
|
+
const listNode = NodeApi.get(editor, at);
|
|
19
|
+
const listEntry = [listNode, at];
|
|
20
|
+
if (!match(listNode, [], { type: getListTypes(editor) }) || PathApi.isParent(at, to)) return false;
|
|
21
|
+
return editor.tf.moveNodes({
|
|
22
|
+
at: listEntry[1],
|
|
23
|
+
children: true,
|
|
24
|
+
fromIndex: offset + 1,
|
|
25
|
+
to
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/lib/transforms/unindentListItems.ts
|
|
31
|
+
const unindentListItems = (editor, options = {}) => moveListItems(editor, {
|
|
32
|
+
...options,
|
|
33
|
+
increase: false
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { BaseBulletedListPlugin, BaseListItemContentPlugin, BaseListItemPlugin, BaseListPlugin, BaseNumberedListPlugin, BaseTaskListPlugin, BaseTodoListPlugin, getDeepInlineChildren, getHighestEmptyList, getListItemEntry, getListRoot, getListTypes, getPropsIfTaskList, getPropsIfTaskListLiNode, getTodoListItemEntry, hasListChild, indentListItems, insertListItem, insertTodoListItem, isAcrossListItems, isListNested, isListRoot, moveListItemDown, moveListItemSublistItemsToListItemSublist, moveListItemUp, moveListItems, moveListItemsToList, moveListSiblingsAfterCursor, normalizeListItem, normalizeNestedList, removeFirstListItem, removeListItem, someList, toggleBulletedList, toggleList, toggleNumberedList, toggleTaskList, unindentListItems, unwrapList, withDeleteBackwardList, withDeleteForwardList, withDeleteFragmentList, withInsertBreakList, withInsertFragmentList, withList, withNormalizeList };
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["SlateEditor","getListItemEntry","someList","editor","type","list","SlateEditor","moveListItems","indentListItems","editor","increase","ElementEntry","Path","SlateEditor","TElement","match","NodeApi","PathApi","getListTypes","moveListSiblingsAfterCursor","editor","at","to","offset","parent","listNode","get","listEntry","type","isParent","tf","moveNodes","children","fromIndex","SlateEditor","MoveListItemsOptions","moveListItems","UnindentListItemsOptions","Omit","unindentListItems","editor","options","increase"],"sources":["../src/lib/queries/someList.ts","../src/lib/transforms/indentListItems.ts","../src/lib/transforms/moveListSiblingsAfterCursor.ts","../src/lib/transforms/unindentListItems.ts"],"sourcesContent":["import type { SlateEditor } from 'platejs';\n\nimport { getListItemEntry } from '../index';\n\nexport const someList = (editor: SlateEditor, type: string) =>\n getListItemEntry(editor)?.list?.[0].type === type;\n","import type { SlateEditor } from 'platejs';\n\nimport { moveListItems } from './moveListItems';\n\nexport const indentListItems = (editor: SlateEditor) => {\n moveListItems(editor, { increase: true });\n};\n","import {\n type ElementEntry,\n type Path,\n type SlateEditor,\n type TElement,\n match,\n NodeApi,\n PathApi,\n} from 'platejs';\n\nimport { getListTypes } from '../queries/getListTypes';\n\nexport const moveListSiblingsAfterCursor = (\n editor: SlateEditor,\n {\n at,\n to,\n }: {\n at: Path;\n to: Path;\n }\n) => {\n const offset = at.at(-1)!;\n at = PathApi.parent(at);\n const listNode = NodeApi.get<TElement>(editor, at)!;\n const listEntry: ElementEntry = [listNode, at];\n\n if (\n !match(listNode, [], { type: getListTypes(editor) }) ||\n PathApi.isParent(at, to) // avoid moving nodes within its own list\n ) {\n return false;\n }\n\n return editor.tf.moveNodes({\n at: listEntry[1],\n children: true,\n fromIndex: offset + 1,\n to,\n });\n};\n","import type { SlateEditor } from 'platejs';\n\nimport { type MoveListItemsOptions, moveListItems } from './moveListItems';\n\nexport type UnindentListItemsOptions = Omit<MoveListItemsOptions, 'increase'>;\n\nexport const unindentListItems = (\n editor: SlateEditor,\n options: UnindentListItemsOptions = {}\n) => moveListItems(editor, { ...options, increase: false });\n"],"mappings":";;;;AAIA,MAAaE,YAAYC,QAAqBC,SAC5CH,iBAAiBE,OAAO,EAAEE,OAAO,GAAGD,SAASA;;;;ACD/C,MAAaI,mBAAmBC,WAAwB;AACtDF,eAAcE,QAAQ,EAAEC,UAAU,MAAM,CAAC;;;;;ACO3C,MAAaS,+BACXC,QACA,EACEC,IACAC,SAKC;CACH,MAAMC,SAASF,GAAGA,GAAG,GAAG;AACxBA,MAAKJ,QAAQO,OAAOH,GAAG;CACvB,MAAMI,WAAWT,QAAQU,IAAcN,QAAQC,GAAG;CAClD,MAAMM,YAA0B,CAACF,UAAUJ,GAAG;AAE9C,KACE,CAACN,MAAMU,UAAU,EAAE,EAAE,EAAEG,MAAMV,aAAaE,OAAM,EAAG,CAAC,IACpDH,QAAQY,SAASR,IAAIC,GAAG,CAExB,QAAO;AAGT,QAAOF,OAAOU,GAAGC,UAAU;EACzBV,IAAIM,UAAU;EACdK,UAAU;EACVC,WAAWV,SAAS;EACpBD;EACD,CAAC;;;;;ACjCJ,MAAaiB,qBACXC,QACAC,UAAoC,EAAE,KACnCL,cAAcI,QAAQ;CAAE,GAAGC;CAASC,UAAU;CAAO,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { T as TTodoListItemElement } from "../index-CYSu3DSy";
|
|
2
|
+
|
|
3
|
+
//#region src/react/ListPlugin.d.ts
|
|
4
|
+
declare const BulletedListPlugin: any;
|
|
5
|
+
declare const TaskListPlugin: any;
|
|
6
|
+
declare const NumberedListPlugin: any;
|
|
7
|
+
declare const ListItemContentPlugin: any;
|
|
8
|
+
declare const ListItemPlugin: any;
|
|
9
|
+
/**
|
|
10
|
+
* Enables support for bulleted, numbered and to-do lists with React-specific
|
|
11
|
+
* features.
|
|
12
|
+
*/
|
|
13
|
+
declare const ListPlugin: any;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/react/TodoListPlugin.d.ts
|
|
16
|
+
declare const TodoListPlugin: any;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/react/hooks/useListToolbarButton.d.ts
|
|
19
|
+
declare const useListToolbarButtonState: ({
|
|
20
|
+
nodeType
|
|
21
|
+
}?: {
|
|
22
|
+
nodeType?: string | undefined;
|
|
23
|
+
}) => {
|
|
24
|
+
nodeType: string;
|
|
25
|
+
pressed: any;
|
|
26
|
+
};
|
|
27
|
+
declare const useListToolbarButton: (state: ReturnType<typeof useListToolbarButtonState>) => {
|
|
28
|
+
props: {
|
|
29
|
+
pressed: any;
|
|
30
|
+
onClick: () => void;
|
|
31
|
+
onMouseDown: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/react/hooks/useTodoListElement.d.ts
|
|
36
|
+
declare const useTodoListElementState: ({
|
|
37
|
+
element
|
|
38
|
+
}: {
|
|
39
|
+
element: TTodoListItemElement;
|
|
40
|
+
}) => any;
|
|
41
|
+
declare const useTodoListElement: (state: ReturnType<typeof useTodoListElementState>) => {
|
|
42
|
+
checkboxProps: {
|
|
43
|
+
checked: boolean;
|
|
44
|
+
onCheckedChange: (value: boolean) => void;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { BulletedListPlugin, ListItemContentPlugin, ListItemPlugin, ListPlugin, NumberedListPlugin, TaskListPlugin, TodoListPlugin, useListToolbarButton, useListToolbarButtonState, useTodoListElement, useTodoListElementState };
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react/ListPlugin.tsx","../../src/react/TodoListPlugin.tsx","../../src/react/hooks/useListToolbarButton.ts","../../src/react/hooks/useTodoListElement.ts"],"sourcesContent":[],"mappings":";;;cAWa;cAEA;cAEA;AAJA,cAMA,qBAN0D,EAAA,GAAA;AAE1D,cAMA,cANkD,EAAA,GAAA;AAE/D;AAEA;AAEA;AAMA;cAAa;;;cCrBA;;;cCCA;;;;;EFMA,QAAA,EAAA,MAAA;EAEA,OAAA,EAAA,GAAA;AAEb,CAAA;AAEa,cEIA,oBFJgE,EAAA,CAAA,KAAA,EEKpE,UFLoE,CAAA,OEKlD,yBFLkD,CAAA,EAAA,GAAA;EAEhE,KAAA,EAAA;IAMA,OAAA,EAQX,GAAA;;qBEAqB,KAAA,CAAM,WAAW;;AD7BxC,CAAA;;;cEAa;;AHOb;WGJW;AHIX,CAAA,EAAA,GAAa,GAAA;AAEA,cGQA,kBHRkD,EAAA,CAAA,KAAA,EGStD,UHTsD,CAAA,OGSpC,uBHToC,CAAA,EAAA,GAAA;EAElD,aAAA,EAAA;IAEA,OAAA,EAAA,OAAA;IAEA,eAAkD,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAAA,IAAA;EAMlD,CAAA"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { a as BaseNumberedListPlugin, i as BaseListPlugin, n as BaseListItemContentPlugin, o as BaseTaskListPlugin, r as BaseListItemPlugin, t as BaseBulletedListPlugin, w as BaseTodoListPlugin } from "../BaseListPlugin-n9uuTtLe.js";
|
|
2
|
+
import { KEYS } from "platejs";
|
|
3
|
+
import { toPlatePlugin, useEditorRef, useEditorSelector, useReadOnly } from "platejs/react";
|
|
4
|
+
import { c } from "react-compiler-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/react/ListPlugin.tsx
|
|
7
|
+
const BulletedListPlugin = toPlatePlugin(BaseBulletedListPlugin);
|
|
8
|
+
const TaskListPlugin = toPlatePlugin(BaseTaskListPlugin);
|
|
9
|
+
const NumberedListPlugin = toPlatePlugin(BaseNumberedListPlugin);
|
|
10
|
+
const ListItemContentPlugin = toPlatePlugin(BaseListItemContentPlugin);
|
|
11
|
+
const ListItemPlugin = toPlatePlugin(BaseListItemPlugin);
|
|
12
|
+
/**
|
|
13
|
+
* Enables support for bulleted, numbered and to-do lists with React-specific
|
|
14
|
+
* features.
|
|
15
|
+
*/
|
|
16
|
+
const ListPlugin = toPlatePlugin(BaseListPlugin, { plugins: [
|
|
17
|
+
BulletedListPlugin,
|
|
18
|
+
TaskListPlugin,
|
|
19
|
+
NumberedListPlugin,
|
|
20
|
+
ListItemPlugin,
|
|
21
|
+
ListItemContentPlugin
|
|
22
|
+
] });
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/react/TodoListPlugin.tsx
|
|
26
|
+
const TodoListPlugin = toPlatePlugin(BaseTodoListPlugin);
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/react/hooks/useListToolbarButton.ts
|
|
30
|
+
const useListToolbarButtonState = (t0) => {
|
|
31
|
+
const $ = c(8);
|
|
32
|
+
let t1;
|
|
33
|
+
if ($[0] !== t0) {
|
|
34
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
35
|
+
$[0] = t0;
|
|
36
|
+
$[1] = t1;
|
|
37
|
+
} else t1 = $[1];
|
|
38
|
+
const { nodeType: t2 } = t1;
|
|
39
|
+
const nodeType = t2 === void 0 ? KEYS.ulClassic : t2;
|
|
40
|
+
let t3;
|
|
41
|
+
let t4;
|
|
42
|
+
if ($[2] !== nodeType) {
|
|
43
|
+
t3 = (editor) => !!editor.selection && editor.api.some({ match: { type: editor.getType(nodeType) } });
|
|
44
|
+
t4 = [nodeType];
|
|
45
|
+
$[2] = nodeType;
|
|
46
|
+
$[3] = t3;
|
|
47
|
+
$[4] = t4;
|
|
48
|
+
} else {
|
|
49
|
+
t3 = $[3];
|
|
50
|
+
t4 = $[4];
|
|
51
|
+
}
|
|
52
|
+
const pressed = useEditorSelector(t3, t4);
|
|
53
|
+
let t5;
|
|
54
|
+
if ($[5] !== nodeType || $[6] !== pressed) {
|
|
55
|
+
t5 = {
|
|
56
|
+
nodeType,
|
|
57
|
+
pressed
|
|
58
|
+
};
|
|
59
|
+
$[5] = nodeType;
|
|
60
|
+
$[6] = pressed;
|
|
61
|
+
$[7] = t5;
|
|
62
|
+
} else t5 = $[7];
|
|
63
|
+
return t5;
|
|
64
|
+
};
|
|
65
|
+
const useListToolbarButton = (state) => {
|
|
66
|
+
const $ = c(8);
|
|
67
|
+
const editor = useEditorRef();
|
|
68
|
+
let t0;
|
|
69
|
+
if ($[0] !== editor) {
|
|
70
|
+
t0 = editor.getTransforms(ListPlugin);
|
|
71
|
+
$[0] = editor;
|
|
72
|
+
$[1] = t0;
|
|
73
|
+
} else t0 = $[1];
|
|
74
|
+
const tf = t0;
|
|
75
|
+
let t1;
|
|
76
|
+
if ($[2] !== state.nodeType || $[3] !== tf) {
|
|
77
|
+
t1 = () => {
|
|
78
|
+
tf.toggle.list({ type: state.nodeType });
|
|
79
|
+
};
|
|
80
|
+
$[2] = state.nodeType;
|
|
81
|
+
$[3] = tf;
|
|
82
|
+
$[4] = t1;
|
|
83
|
+
} else t1 = $[4];
|
|
84
|
+
let t2;
|
|
85
|
+
if ($[5] !== state.pressed || $[6] !== t1) {
|
|
86
|
+
t2 = { props: {
|
|
87
|
+
pressed: state.pressed,
|
|
88
|
+
onClick: t1,
|
|
89
|
+
onMouseDown: _temp
|
|
90
|
+
} };
|
|
91
|
+
$[5] = state.pressed;
|
|
92
|
+
$[6] = t1;
|
|
93
|
+
$[7] = t2;
|
|
94
|
+
} else t2 = $[7];
|
|
95
|
+
return t2;
|
|
96
|
+
};
|
|
97
|
+
function _temp(e) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/react/hooks/useTodoListElement.ts
|
|
103
|
+
const useTodoListElementState = (t0) => {
|
|
104
|
+
const $ = c(5);
|
|
105
|
+
const { element } = t0;
|
|
106
|
+
const editor = useEditorRef();
|
|
107
|
+
const { checked } = element;
|
|
108
|
+
const readOnly = useReadOnly();
|
|
109
|
+
let t1;
|
|
110
|
+
if ($[0] !== checked || $[1] !== editor || $[2] !== element || $[3] !== readOnly) {
|
|
111
|
+
t1 = {
|
|
112
|
+
checked,
|
|
113
|
+
editor,
|
|
114
|
+
element,
|
|
115
|
+
readOnly
|
|
116
|
+
};
|
|
117
|
+
$[0] = checked;
|
|
118
|
+
$[1] = editor;
|
|
119
|
+
$[2] = element;
|
|
120
|
+
$[3] = readOnly;
|
|
121
|
+
$[4] = t1;
|
|
122
|
+
} else t1 = $[4];
|
|
123
|
+
return t1;
|
|
124
|
+
};
|
|
125
|
+
const useTodoListElement = (state) => {
|
|
126
|
+
const $ = c(7);
|
|
127
|
+
const { checked, element, readOnly } = state;
|
|
128
|
+
const editor = useEditorRef();
|
|
129
|
+
const t0 = !!checked;
|
|
130
|
+
let t1;
|
|
131
|
+
if ($[0] !== editor || $[1] !== element || $[2] !== readOnly) {
|
|
132
|
+
t1 = (value) => {
|
|
133
|
+
if (readOnly) return;
|
|
134
|
+
editor.tf.setNodes({ checked: value }, { at: element });
|
|
135
|
+
};
|
|
136
|
+
$[0] = editor;
|
|
137
|
+
$[1] = element;
|
|
138
|
+
$[2] = readOnly;
|
|
139
|
+
$[3] = t1;
|
|
140
|
+
} else t1 = $[3];
|
|
141
|
+
let t2;
|
|
142
|
+
if ($[4] !== t0 || $[5] !== t1) {
|
|
143
|
+
t2 = { checkboxProps: {
|
|
144
|
+
checked: t0,
|
|
145
|
+
onCheckedChange: t1
|
|
146
|
+
} };
|
|
147
|
+
$[4] = t0;
|
|
148
|
+
$[5] = t1;
|
|
149
|
+
$[6] = t2;
|
|
150
|
+
} else t2 = $[6];
|
|
151
|
+
return t2;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
export { BulletedListPlugin, ListItemContentPlugin, ListItemPlugin, ListPlugin, NumberedListPlugin, TaskListPlugin, TodoListPlugin, useListToolbarButton, useListToolbarButtonState, useTodoListElement, useTodoListElementState };
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["toPlatePlugin","BaseBulletedListPlugin","BaseListItemContentPlugin","BaseListItemPlugin","BaseListPlugin","BaseNumberedListPlugin","BaseTaskListPlugin","BulletedListPlugin","TaskListPlugin","NumberedListPlugin","ListItemContentPlugin","ListItemPlugin","ListPlugin","plugins","toPlatePlugin","BaseTodoListPlugin","TodoListPlugin","KEYS","useEditorRef","useEditorSelector","ListPlugin","useListToolbarButtonState","t0","$","_c","t1","undefined","nodeType","t2","ulClassic","t3","t4","editor","selection","api","some","match","type","getType","pressed","t5","useListToolbarButton","state","getTransforms","tf","toggle","list","props","onClick","onMouseDown","_temp","e","preventDefault","useEditorRef","useReadOnly","TTodoListItemElement","useTodoListElementState","t0","$","_c","element","editor","checked","readOnly","t1","useTodoListElement","state","value","tf","setNodes","at","t2","checkboxProps","onCheckedChange"],"sources":["../../src/react/ListPlugin.tsx","../../src/react/TodoListPlugin.tsx","../../src/react/hooks/useListToolbarButton.ts","../../src/react/hooks/useTodoListElement.ts"],"sourcesContent":["import { toPlatePlugin } from 'platejs/react';\n\nimport {\n BaseBulletedListPlugin,\n BaseListItemContentPlugin,\n BaseListItemPlugin,\n BaseListPlugin,\n BaseNumberedListPlugin,\n BaseTaskListPlugin,\n} from '../lib';\n\nexport const BulletedListPlugin = toPlatePlugin(BaseBulletedListPlugin);\n\nexport const TaskListPlugin = toPlatePlugin(BaseTaskListPlugin);\n\nexport const NumberedListPlugin = toPlatePlugin(BaseNumberedListPlugin);\n\nexport const ListItemContentPlugin = toPlatePlugin(BaseListItemContentPlugin);\n\nexport const ListItemPlugin = toPlatePlugin(BaseListItemPlugin);\n\n/**\n * Enables support for bulleted, numbered and to-do lists with React-specific\n * features.\n */\nexport const ListPlugin = toPlatePlugin(BaseListPlugin, {\n plugins: [\n BulletedListPlugin,\n TaskListPlugin,\n NumberedListPlugin,\n ListItemPlugin,\n ListItemContentPlugin,\n ],\n});\n","import { toPlatePlugin } from 'platejs/react';\n\nimport { BaseTodoListPlugin } from '../lib/BaseTodoListPlugin';\n\nexport const TodoListPlugin = toPlatePlugin(BaseTodoListPlugin);\n","import { KEYS } from 'platejs';\nimport { useEditorRef, useEditorSelector } from 'platejs/react';\n\nimport { ListPlugin } from '../ListPlugin';\n\nexport const useListToolbarButtonState = ({\n nodeType = KEYS.ulClassic as string,\n} = {}) => {\n const pressed = useEditorSelector(\n (editor) =>\n !!editor.selection &&\n editor.api.some({ match: { type: editor.getType(nodeType) } }),\n [nodeType]\n );\n\n return {\n nodeType,\n pressed,\n };\n};\n\nexport const useListToolbarButton = (\n state: ReturnType<typeof useListToolbarButtonState>\n) => {\n const editor = useEditorRef();\n const tf = editor.getTransforms(ListPlugin);\n\n return {\n props: {\n pressed: state.pressed,\n onClick: () => {\n tf.toggle.list({ type: state.nodeType });\n },\n onMouseDown: (e: React.MouseEvent<HTMLButtonElement>) => {\n e.preventDefault();\n },\n },\n };\n};\n","import { useEditorRef, useReadOnly } from 'platejs/react';\n\nimport type { TTodoListItemElement } from '../../lib';\n\nexport const useTodoListElementState = ({\n element,\n}: {\n element: TTodoListItemElement;\n}): any => {\n const editor = useEditorRef();\n const { checked } = element;\n const readOnly = useReadOnly();\n\n return {\n checked,\n editor,\n element,\n readOnly,\n };\n};\n\nexport const useTodoListElement = (\n state: ReturnType<typeof useTodoListElementState>\n) => {\n const { checked, element, readOnly } = state;\n const editor = useEditorRef();\n\n return {\n checkboxProps: {\n checked: !!checked,\n onCheckedChange: (value: boolean) => {\n if (readOnly) return;\n\n editor.tf.setNodes<TTodoListItemElement>(\n { checked: value },\n { at: element }\n );\n },\n },\n };\n};\n"],"mappings":";;;;;;AAWA,MAAaO,qBAAqBP,cAAcC,uBAAuB;AAEvE,MAAaO,iBAAiBR,cAAcM,mBAAmB;AAE/D,MAAaG,qBAAqBT,cAAc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