@lofcz/platejs-list 52.3.6 → 53.0.2
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-B6T8hhDs.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-B6T8hhDs.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
|
|
@@ -311,7 +311,18 @@ const normalizeListStart = (editor, entry, options) => editor.tf.withoutNormaliz
|
|
|
311
311
|
const listStyleType = node[KEYS.listType];
|
|
312
312
|
const listStart = node[KEYS.listStart];
|
|
313
313
|
if (!listStyleType) return;
|
|
314
|
-
|
|
314
|
+
if (ULIST_STYLE_TYPES.includes(listStyleType)) {
|
|
315
|
+
if (isDefined(listStart)) {
|
|
316
|
+
editor.tf.unsetNodes(KEYS.listStart, { at: path });
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const expectedListStart = getListExpectedListStart(entry, getPreviousList(editor, entry, {
|
|
322
|
+
breakOnEqIndentNeqListStyleType: false,
|
|
323
|
+
query: (nextNode, curNode) => nextNode[KEYS.listType] === curNode[KEYS.listType],
|
|
324
|
+
...options
|
|
325
|
+
}));
|
|
315
326
|
if (isDefined(listStart) && expectedListStart === 1) {
|
|
316
327
|
editor.tf.unsetNodes(KEYS.listStart, { at: path });
|
|
317
328
|
return true;
|
|
@@ -799,4 +810,61 @@ function List(props) {
|
|
|
799
810
|
}
|
|
800
811
|
|
|
801
812
|
//#endregion
|
|
802
|
-
|
|
813
|
+
//#region src/lib/BulletedListRules.ts
|
|
814
|
+
const isListInputBlocked$2 = (editor) => editor.api.some({ match: { type: [editor.getType(KEYS.codeBlock)] } });
|
|
815
|
+
const BulletedListRules = { markdown: createRuleFactory({
|
|
816
|
+
type: "blockStart",
|
|
817
|
+
variant: "-",
|
|
818
|
+
enabled: ({ editor }) => !isListInputBlocked$2(editor),
|
|
819
|
+
trigger: " ",
|
|
820
|
+
match: ({ variant }) => variant,
|
|
821
|
+
apply: ({ editor }, match) => {
|
|
822
|
+
editor.tf.delete({ at: match.range });
|
|
823
|
+
toggleList(editor, { listStyleType: KEYS.ul });
|
|
824
|
+
return true;
|
|
825
|
+
}
|
|
826
|
+
}) };
|
|
827
|
+
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region src/lib/OrderedListRules.ts
|
|
830
|
+
const isListInputBlocked$1 = (editor) => editor.api.some({ match: { type: [editor.getType(KEYS.codeBlock)] } });
|
|
831
|
+
const getOrderedListPattern = (variant) => /* @__PURE__ */ new RegExp(`^(\\d+)${variant === ")" ? "\\)" : "\\."}$`);
|
|
832
|
+
const OrderedListRules = { markdown: createRuleFactory({
|
|
833
|
+
type: "blockStart",
|
|
834
|
+
variant: ".",
|
|
835
|
+
enabled: ({ editor }) => !isListInputBlocked$1(editor),
|
|
836
|
+
trigger: " ",
|
|
837
|
+
match: ({ variant }) => getOrderedListPattern(variant),
|
|
838
|
+
resolveMatch: ({ match }) => ({ start: Number(match[1]) }),
|
|
839
|
+
apply: ({ editor }, match) => {
|
|
840
|
+
editor.tf.delete({ at: match.range });
|
|
841
|
+
toggleList(editor, {
|
|
842
|
+
listRestartPolite: match.start || 1,
|
|
843
|
+
listStyleType: KEYS.ol
|
|
844
|
+
});
|
|
845
|
+
return true;
|
|
846
|
+
}
|
|
847
|
+
}) };
|
|
848
|
+
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region src/lib/TaskListRules.ts
|
|
851
|
+
const isListInputBlocked = (editor) => editor.api.some({ match: { type: [editor.getType(KEYS.codeBlock)] } });
|
|
852
|
+
const TaskListRules = { markdown: createRuleFactory({
|
|
853
|
+
type: "blockStart",
|
|
854
|
+
checked: false,
|
|
855
|
+
enabled: ({ editor }) => !isListInputBlocked(editor),
|
|
856
|
+
trigger: " ",
|
|
857
|
+
match: ({ checked }) => checked ? "[x]" : "[]",
|
|
858
|
+
apply: ({ editor, checked }, match) => {
|
|
859
|
+
editor.tf.delete({ at: match.range });
|
|
860
|
+
toggleList(editor, { listStyleType: KEYS.listTodo });
|
|
861
|
+
editor.tf.setNodes({
|
|
862
|
+
checked,
|
|
863
|
+
listStyleType: KEYS.listTodo
|
|
864
|
+
});
|
|
865
|
+
return true;
|
|
866
|
+
}
|
|
867
|
+
}) };
|
|
868
|
+
|
|
869
|
+
//#endregion
|
|
870
|
+
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.0.2",
|
|
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.0.0"
|
|
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
|
},
|