@lofcz/platejs-list 52.3.6 → 53.2.1
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.
|
@@ -112,6 +112,33 @@ type BaseListConfig = PluginConfig<'list', {
|
|
|
112
112
|
}>;
|
|
113
113
|
declare const BaseListPlugin: platejs1.SlatePlugin<BaseListConfig>;
|
|
114
114
|
//#endregion
|
|
115
|
+
//#region src/lib/BulletedListRules.d.ts
|
|
116
|
+
declare const BulletedListRules: {
|
|
117
|
+
markdown: (options?: {
|
|
118
|
+
variant?: "*" | "-" | undefined;
|
|
119
|
+
enabled?: ((context: platejs1.SelectionInputRuleContext<SlateEditor> | platejs1.InsertTextInputRuleContext<SlateEditor> | platejs1.InsertBreakInputRuleContext<SlateEditor> | platejs1.InsertDataInputRuleContext<SlateEditor>) => boolean) | undefined;
|
|
120
|
+
priority?: number | undefined;
|
|
121
|
+
} | undefined) => platejs1.AnyInputRule<unknown>;
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/lib/OrderedListRules.d.ts
|
|
125
|
+
declare const OrderedListRules: {
|
|
126
|
+
markdown: (options?: {
|
|
127
|
+
variant?: "." | ")" | undefined;
|
|
128
|
+
enabled?: ((context: platejs1.SelectionInputRuleContext<SlateEditor> | platejs1.InsertTextInputRuleContext<SlateEditor> | platejs1.InsertBreakInputRuleContext<SlateEditor> | platejs1.InsertDataInputRuleContext<SlateEditor>) => boolean) | undefined;
|
|
129
|
+
priority?: number | undefined;
|
|
130
|
+
} | undefined) => platejs1.AnyInputRule<unknown>;
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/lib/TaskListRules.d.ts
|
|
134
|
+
declare const TaskListRules: {
|
|
135
|
+
markdown: (options?: {
|
|
136
|
+
checked?: boolean | undefined;
|
|
137
|
+
enabled?: ((context: platejs1.SelectionInputRuleContext<SlateEditor> | platejs1.InsertTextInputRuleContext<SlateEditor> | platejs1.InsertBreakInputRuleContext<SlateEditor> | platejs1.InsertDataInputRuleContext<SlateEditor>) => boolean) | undefined;
|
|
138
|
+
priority?: number | undefined;
|
|
139
|
+
} | undefined) => platejs1.AnyInputRule<unknown>;
|
|
140
|
+
};
|
|
141
|
+
//#endregion
|
|
115
142
|
//#region src/lib/withList.d.ts
|
|
116
143
|
declare const withList: OverrideEditor<BaseListConfig>;
|
|
117
144
|
//#endregion
|
|
@@ -286,4 +313,4 @@ declare const toggleListUnset: (editor: Editor, [node, path]: NodeEntry, {
|
|
|
286
313
|
listStyleType?: string;
|
|
287
314
|
}) => true | undefined;
|
|
288
315
|
//#endregion
|
|
289
|
-
export { withNormalizeList as A, getListAbove as C, getListExpectedListStart as D, withInsertBreakList as E,
|
|
316
|
+
export { withNormalizeList as A, getSiblingList as B, getListAbove as C, getListExpectedListStart as D, withInsertBreakList as E, BaseListConfig as F, BaseListPlugin as I, ListStyleType as L, TaskListRules as M, OrderedListRules as N, normalizeListStart as O, BulletedListRules as P, ULIST_STYLE_TYPES as R, getListChildren as S, areEqListStyleType as T, getSiblingListStyleType as _, toggleList as a, GetListSiblingsOptions as b, setIndentTodoNode as c, ListOptions as d, indentList as f, isOrderedList as g, someList as h, toggleListByPathUnSet as i, withList as j, normalizeListNotIndented as k, setListNode as l, someTodoList as m, toggleListSet as n, setListSiblingNodes as o, indentTodo as p, toggleListByPath as r, setListNodes as s, toggleListUnset as t, outdentList as u, getPreviousList as v, expandListItemsWithChildren as w, getListSiblings as x, getNextList as y, GetSiblingListOptions as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as withNormalizeList, C as getListAbove, D as getListExpectedListStart, E as withInsertBreakList, F as
|
|
2
|
-
export { BaseListConfig, BaseListPlugin, GetListSiblingsOptions, GetSiblingListOptions, ListOptions, ListStyleType, ULIST_STYLE_TYPES, areEqListStyleType, expandListItemsWithChildren, getListAbove, getListChildren, getListExpectedListStart, getListSiblings, getNextList, getPreviousList, getSiblingList, getSiblingListStyleType, indentList, indentTodo, isOrderedList, normalizeListNotIndented, normalizeListStart, outdentList, setIndentTodoNode, setListNode, setListNodes, setListSiblingNodes, someList, someTodoList, toggleList, toggleListByPath, toggleListByPathUnSet, toggleListSet, toggleListUnset, withInsertBreakList, withList, withNormalizeList };
|
|
1
|
+
import { A as withNormalizeList, B as getSiblingList, C as getListAbove, D as getListExpectedListStart, E as withInsertBreakList, F as BaseListConfig, I as BaseListPlugin, L as ListStyleType, M as TaskListRules, N as OrderedListRules, O as normalizeListStart, P as BulletedListRules, R as ULIST_STYLE_TYPES, S as getListChildren, T as areEqListStyleType, _ as getSiblingListStyleType, a as toggleList, b as GetListSiblingsOptions, c as setIndentTodoNode, d as ListOptions, f as indentList, g as isOrderedList, h as someList, i as toggleListByPathUnSet, j as withList, k as normalizeListNotIndented, l as setListNode, m as someTodoList, n as toggleListSet, o as setListSiblingNodes, p as indentTodo, r as toggleListByPath, s as setListNodes, t as toggleListUnset, u as outdentList, v as getPreviousList, w as expandListItemsWithChildren, x as getListSiblings, y as getNextList, z as GetSiblingListOptions } from "./index-DaxjrSb0";
|
|
2
|
+
export { BaseListConfig, BaseListPlugin, BulletedListRules, GetListSiblingsOptions, GetSiblingListOptions, ListOptions, ListStyleType, OrderedListRules, TaskListRules, ULIST_STYLE_TYPES, areEqListStyleType, expandListItemsWithChildren, getListAbove, getListChildren, getListExpectedListStart, getListSiblings, getNextList, getPreviousList, getSiblingList, getSiblingListStyleType, indentList, indentTodo, isOrderedList, normalizeListNotIndented, normalizeListStart, outdentList, setIndentTodoNode, setListNode, setListNodes, setListSiblingNodes, someList, someTodoList, toggleList, toggleListByPath, toggleListByPathUnSet, toggleListSet, toggleListUnset, withInsertBreakList, withList, withNormalizeList };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as getSiblingList, C as someTodoList, D as getListSiblings, E as getSiblingListStyleType, F as ListStyleType, I as ULIST_STYLE_TYPES, M as expandListItemsWithChildren, N as getListChildren, O as getPreviousList, P as areEqListStyleType, S as normalizeListNotIndented, T as isOrderedList, _ as indentList, a as withList, b as getListExpectedListStart, c as toggleListByPathUnSet, d as toggleListSet, f as setListSiblingNodes, g as outdentList, h as setListNode, i as BaseListPlugin, j as getListAbove, k as getNextList, l as toggleList, m as setIndentTodoNode, n as OrderedListRules, o as withNormalizeList, p as setListNodes, r as BulletedListRules, s as toggleListByPath, t as TaskListRules, u as toggleListUnset, v as indentTodo, w as someList, x as normalizeListStart, y as withInsertBreakList } from "./src-DAKg18OL.js";
|
|
2
2
|
|
|
3
|
-
export { BaseListPlugin, ListStyleType, ULIST_STYLE_TYPES, areEqListStyleType, expandListItemsWithChildren, getListAbove, getListChildren, getListExpectedListStart, getListSiblings, getNextList, getPreviousList, getSiblingList, getSiblingListStyleType, indentList, indentTodo, isOrderedList, normalizeListNotIndented, normalizeListStart, outdentList, setIndentTodoNode, setListNode, setListNodes, setListSiblingNodes, someList, someTodoList, toggleList, toggleListByPath, toggleListByPathUnSet, toggleListSet, toggleListUnset, withInsertBreakList, withList, withNormalizeList };
|
|
3
|
+
export { BaseListPlugin, BulletedListRules, ListStyleType, OrderedListRules, TaskListRules, ULIST_STYLE_TYPES, areEqListStyleType, expandListItemsWithChildren, getListAbove, getListChildren, getListExpectedListStart, getListSiblings, getNextList, getPreviousList, getSiblingList, getSiblingListStyleType, indentList, indentTodo, isOrderedList, normalizeListNotIndented, normalizeListStart, outdentList, setIndentTodoNode, setListNode, setListNodes, setListSiblingNodes, someList, someTodoList, toggleList, toggleListByPath, toggleListByPathUnSet, toggleListSet, toggleListUnset, withInsertBreakList, withList, withNormalizeList };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as BaseListConfig, L as ListStyleType, z as GetSiblingListOptions } from "../index-DaxjrSb0";
|
|
2
2
|
import * as platejs0 from "platejs";
|
|
3
3
|
import { TElement } from "platejs";
|
|
4
4
|
import * as platejs_react0 from "platejs/react";
|
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as someTodoList, F as ListStyleType, i as BaseListPlugin, l as toggleList, w as someList } from "../src-DAKg18OL.js";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { toPlatePlugin, useEditorRef, useEditorSelector, useReadOnly } from "platejs/react";
|
|
4
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c } from "react-compiler-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { KEYS, NodeApi, PathApi, createTSlatePlugin, getInjectMatch, isDefined, isHtmlBlockElement, postCleanHtml, traverseHtmlElements } from "platejs";
|
|
3
|
+
import { KEYS, NodeApi, PathApi, createRuleFactory, createTSlatePlugin, getInjectMatch, isDefined, isHtmlBlockElement, postCleanHtml, traverseHtmlElements } from "platejs";
|
|
4
4
|
import { setIndent } from "@platejs/indent";
|
|
5
5
|
|
|
6
6
|
//#region src/lib/types.ts
|
|
@@ -294,6 +294,30 @@ const normalizeListNotIndented = (editor, [node, path]) => {
|
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
296
|
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/lib/internal/isSameListSequence.ts
|
|
299
|
+
const getHeadingType = (editor, headingKey) => {
|
|
300
|
+
const getType = editor.getType;
|
|
301
|
+
return typeof getType === "function" ? getType.call(editor, headingKey) : headingKey;
|
|
302
|
+
};
|
|
303
|
+
const isHeadingListNode = (editor, node) => {
|
|
304
|
+
const type = node.type;
|
|
305
|
+
return typeof type === "string" && KEYS.heading.some((headingKey) => type === getHeadingType(editor, headingKey));
|
|
306
|
+
};
|
|
307
|
+
const isSameListSequence = (editor, siblingNode, currentNode) => siblingNode[KEYS.listType] === currentNode[KEYS.listType] && isHeadingListNode(editor, siblingNode) === isHeadingListNode(editor, currentNode);
|
|
308
|
+
const isListSequenceBoundary = (editor, siblingNode, currentNode) => {
|
|
309
|
+
const siblingListType = siblingNode[KEYS.listType];
|
|
310
|
+
return siblingNode[KEYS.indent] === currentNode[KEYS.indent] && siblingListType != null && siblingListType === currentNode[KEYS.listType] && isHeadingListNode(editor, siblingNode) !== isHeadingListNode(editor, currentNode);
|
|
311
|
+
};
|
|
312
|
+
const getListSequenceSiblingOptions = (editor, options) => {
|
|
313
|
+
const { breakQuery, query, ...rest } = options ?? {};
|
|
314
|
+
return {
|
|
315
|
+
...rest,
|
|
316
|
+
breakQuery: (siblingNode, currentNode) => isListSequenceBoundary(editor, siblingNode, currentNode) || !!breakQuery?.(siblingNode, currentNode),
|
|
317
|
+
query: (siblingNode, currentNode) => isSameListSequence(editor, siblingNode, currentNode) && (query ? !!query(siblingNode, currentNode) : true)
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
|
|
297
321
|
//#endregion
|
|
298
322
|
//#region src/lib/normalizers/normalizeListStart.ts
|
|
299
323
|
const getListExpectedListStart = (entry, prevEntry) => {
|
|
@@ -311,7 +335,17 @@ const normalizeListStart = (editor, entry, options) => editor.tf.withoutNormaliz
|
|
|
311
335
|
const listStyleType = node[KEYS.listType];
|
|
312
336
|
const listStart = node[KEYS.listStart];
|
|
313
337
|
if (!listStyleType) return;
|
|
314
|
-
|
|
338
|
+
if (ULIST_STYLE_TYPES.includes(listStyleType)) {
|
|
339
|
+
if (isDefined(listStart)) {
|
|
340
|
+
editor.tf.unsetNodes(KEYS.listStart, { at: path });
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const expectedListStart = getListExpectedListStart(entry, getPreviousList(editor, entry, getListSequenceSiblingOptions(editor, {
|
|
346
|
+
breakOnEqIndentNeqListStyleType: false,
|
|
347
|
+
...options
|
|
348
|
+
})));
|
|
315
349
|
if (isDefined(listStart) && expectedListStart === 1) {
|
|
316
350
|
editor.tf.unsetNodes(KEYS.listStart, { at: path });
|
|
317
351
|
return true;
|
|
@@ -480,6 +514,11 @@ const toggleListUnset = (editor, [node, path], { listStyleType = ListStyleType.D
|
|
|
480
514
|
/** Toggle indent list. */
|
|
481
515
|
const toggleList = (editor, options, getSiblingListOptions) => {
|
|
482
516
|
const { listRestart, listRestartPolite, listStyleType } = options;
|
|
517
|
+
const { getSiblingListOptions: pluginGetSiblingListOptions } = editor.getOptions(BaseListPlugin);
|
|
518
|
+
const mergedGetSiblingListOptions = {
|
|
519
|
+
...pluginGetSiblingListOptions,
|
|
520
|
+
...getSiblingListOptions
|
|
521
|
+
};
|
|
483
522
|
/**
|
|
484
523
|
* True - One or more blocks were converted to lists or changed such that they
|
|
485
524
|
* remain lists.
|
|
@@ -489,17 +528,13 @@ const toggleList = (editor, options, getSiblingListOptions) => {
|
|
|
489
528
|
* Null - No action was taken.
|
|
490
529
|
*/
|
|
491
530
|
const setList = (() => {
|
|
492
|
-
const { getSiblingListOptions: _getSiblingListOptions } = editor.getOptions(BaseListPlugin);
|
|
493
531
|
if (editor.api.isCollapsed()) {
|
|
494
532
|
const entry = editor.api.block();
|
|
495
533
|
if (!entry) return null;
|
|
496
534
|
if (toggleListSet(editor, entry, options)) return true;
|
|
497
535
|
if (toggleListUnset(editor, entry, { listStyleType })) return false;
|
|
498
536
|
setListSiblingNodes(editor, entry, {
|
|
499
|
-
getSiblingListOptions:
|
|
500
|
-
..._getSiblingListOptions,
|
|
501
|
-
...getSiblingListOptions
|
|
502
|
-
},
|
|
537
|
+
getSiblingListOptions: mergedGetSiblingListOptions,
|
|
503
538
|
listStyleType
|
|
504
539
|
});
|
|
505
540
|
return true;
|
|
@@ -532,7 +567,10 @@ const toggleList = (editor, options, getSiblingListOptions) => {
|
|
|
532
567
|
if (setList && restartValue) {
|
|
533
568
|
const entry = getListAbove(editor, { at: editor.api.start(editor.selection) });
|
|
534
569
|
if (!entry) return;
|
|
535
|
-
const isFirst = !getPreviousList(editor, entry
|
|
570
|
+
const isFirst = !getPreviousList(editor, entry, getListSequenceSiblingOptions(editor, {
|
|
571
|
+
breakOnEqIndentNeqListStyleType: false,
|
|
572
|
+
...mergedGetSiblingListOptions
|
|
573
|
+
}));
|
|
536
574
|
/**
|
|
537
575
|
* Only apply listRestartPolite if this is the first item and restartValue >
|
|
538
576
|
* 1.
|
|
@@ -799,4 +837,61 @@ function List(props) {
|
|
|
799
837
|
}
|
|
800
838
|
|
|
801
839
|
//#endregion
|
|
802
|
-
|
|
840
|
+
//#region src/lib/BulletedListRules.ts
|
|
841
|
+
const isListInputBlocked$2 = (editor) => editor.api.some({ match: { type: [editor.getType(KEYS.codeBlock)] } });
|
|
842
|
+
const BulletedListRules = { markdown: createRuleFactory({
|
|
843
|
+
type: "blockStart",
|
|
844
|
+
variant: "-",
|
|
845
|
+
enabled: ({ editor }) => !isListInputBlocked$2(editor),
|
|
846
|
+
trigger: " ",
|
|
847
|
+
match: ({ variant }) => variant,
|
|
848
|
+
apply: ({ editor }, match) => {
|
|
849
|
+
editor.tf.delete({ at: match.range });
|
|
850
|
+
toggleList(editor, { listStyleType: KEYS.ul });
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
853
|
+
}) };
|
|
854
|
+
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region src/lib/OrderedListRules.ts
|
|
857
|
+
const isListInputBlocked$1 = (editor) => editor.api.some({ match: { type: [editor.getType(KEYS.codeBlock)] } });
|
|
858
|
+
const getOrderedListPattern = (variant) => /* @__PURE__ */ new RegExp(`^(\\d+)${variant === ")" ? "\\)" : "\\."}$`);
|
|
859
|
+
const OrderedListRules = { markdown: createRuleFactory({
|
|
860
|
+
type: "blockStart",
|
|
861
|
+
variant: ".",
|
|
862
|
+
enabled: ({ editor }) => !isListInputBlocked$1(editor),
|
|
863
|
+
trigger: " ",
|
|
864
|
+
match: ({ variant }) => getOrderedListPattern(variant),
|
|
865
|
+
resolveMatch: ({ match }) => ({ start: Number(match[1]) }),
|
|
866
|
+
apply: ({ editor }, match) => {
|
|
867
|
+
editor.tf.delete({ at: match.range });
|
|
868
|
+
toggleList(editor, {
|
|
869
|
+
listRestartPolite: match.start || 1,
|
|
870
|
+
listStyleType: KEYS.ol
|
|
871
|
+
});
|
|
872
|
+
return true;
|
|
873
|
+
}
|
|
874
|
+
}) };
|
|
875
|
+
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/lib/TaskListRules.ts
|
|
878
|
+
const isListInputBlocked = (editor) => editor.api.some({ match: { type: [editor.getType(KEYS.codeBlock)] } });
|
|
879
|
+
const TaskListRules = { markdown: createRuleFactory({
|
|
880
|
+
type: "blockStart",
|
|
881
|
+
checked: false,
|
|
882
|
+
enabled: ({ editor }) => !isListInputBlocked(editor),
|
|
883
|
+
trigger: " ",
|
|
884
|
+
match: ({ checked }) => checked ? "[x]" : "[]",
|
|
885
|
+
apply: ({ editor, checked }, match) => {
|
|
886
|
+
editor.tf.delete({ at: match.range });
|
|
887
|
+
toggleList(editor, { listStyleType: KEYS.listTodo });
|
|
888
|
+
editor.tf.setNodes({
|
|
889
|
+
checked,
|
|
890
|
+
listStyleType: KEYS.listTodo
|
|
891
|
+
});
|
|
892
|
+
return true;
|
|
893
|
+
}
|
|
894
|
+
}) };
|
|
895
|
+
|
|
896
|
+
//#endregion
|
|
897
|
+
export { getSiblingList as A, someTodoList as C, getListSiblings as D, getSiblingListStyleType as E, ListStyleType as F, ULIST_STYLE_TYPES as I, expandListItemsWithChildren as M, getListChildren as N, getPreviousList as O, areEqListStyleType as P, normalizeListNotIndented as S, isOrderedList as T, indentList as _, withList as a, getListExpectedListStart as b, toggleListByPathUnSet as c, toggleListSet as d, setListSiblingNodes as f, outdentList as g, setListNode as h, BaseListPlugin as i, getListAbove as j, getNextList as k, toggleList as l, setIndentTodoNode as m, OrderedListRules as n, withNormalizeList as o, setListNodes as p, BulletedListRules as r, toggleListByPath as s, TaskListRules as t, toggleListUnset as u, indentTodo as v, someList as w, normalizeListStart as x, withInsertBreakList as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/platejs-list",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "53.2.1",
|
|
4
4
|
"description": "List plugin for Plate",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plate",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"clsx": "^2.1.1",
|
|
33
33
|
"lodash": "^4.17.23",
|
|
34
34
|
"react-compiler-runtime": "^1.0.0",
|
|
35
|
-
"@platejs/indent": "npm:@lofcz/platejs-indent@
|
|
35
|
+
"@platejs/indent": "npm:@lofcz/platejs-indent@53.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@plate/scripts": "1.0.0",
|
|
39
|
-
"platejs": "npm:@lofcz/platejs@
|
|
39
|
+
"platejs": "npm:@lofcz/platejs@53.1.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"platejs": ">=
|
|
42
|
+
"platejs": ">=53.0.0",
|
|
43
43
|
"react": ">=18.0.0",
|
|
44
44
|
"react-dom": ">=18.0.0"
|
|
45
45
|
},
|