@lofcz/platejs-list 53.0.2 → 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.
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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-
|
|
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
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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as someTodoList, F as ListStyleType, i as BaseListPlugin, l as toggleList, w as someList } from "../src-
|
|
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
|
|
|
@@ -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) => {
|
|
@@ -318,11 +342,10 @@ const normalizeListStart = (editor, entry, options) => editor.tf.withoutNormaliz
|
|
|
318
342
|
}
|
|
319
343
|
return;
|
|
320
344
|
}
|
|
321
|
-
const expectedListStart = getListExpectedListStart(entry, getPreviousList(editor, entry, {
|
|
345
|
+
const expectedListStart = getListExpectedListStart(entry, getPreviousList(editor, entry, getListSequenceSiblingOptions(editor, {
|
|
322
346
|
breakOnEqIndentNeqListStyleType: false,
|
|
323
|
-
query: (nextNode, curNode) => nextNode[KEYS.listType] === curNode[KEYS.listType],
|
|
324
347
|
...options
|
|
325
|
-
}));
|
|
348
|
+
})));
|
|
326
349
|
if (isDefined(listStart) && expectedListStart === 1) {
|
|
327
350
|
editor.tf.unsetNodes(KEYS.listStart, { at: path });
|
|
328
351
|
return true;
|
|
@@ -491,6 +514,11 @@ const toggleListUnset = (editor, [node, path], { listStyleType = ListStyleType.D
|
|
|
491
514
|
/** Toggle indent list. */
|
|
492
515
|
const toggleList = (editor, options, getSiblingListOptions) => {
|
|
493
516
|
const { listRestart, listRestartPolite, listStyleType } = options;
|
|
517
|
+
const { getSiblingListOptions: pluginGetSiblingListOptions } = editor.getOptions(BaseListPlugin);
|
|
518
|
+
const mergedGetSiblingListOptions = {
|
|
519
|
+
...pluginGetSiblingListOptions,
|
|
520
|
+
...getSiblingListOptions
|
|
521
|
+
};
|
|
494
522
|
/**
|
|
495
523
|
* True - One or more blocks were converted to lists or changed such that they
|
|
496
524
|
* remain lists.
|
|
@@ -500,17 +528,13 @@ const toggleList = (editor, options, getSiblingListOptions) => {
|
|
|
500
528
|
* Null - No action was taken.
|
|
501
529
|
*/
|
|
502
530
|
const setList = (() => {
|
|
503
|
-
const { getSiblingListOptions: _getSiblingListOptions } = editor.getOptions(BaseListPlugin);
|
|
504
531
|
if (editor.api.isCollapsed()) {
|
|
505
532
|
const entry = editor.api.block();
|
|
506
533
|
if (!entry) return null;
|
|
507
534
|
if (toggleListSet(editor, entry, options)) return true;
|
|
508
535
|
if (toggleListUnset(editor, entry, { listStyleType })) return false;
|
|
509
536
|
setListSiblingNodes(editor, entry, {
|
|
510
|
-
getSiblingListOptions:
|
|
511
|
-
..._getSiblingListOptions,
|
|
512
|
-
...getSiblingListOptions
|
|
513
|
-
},
|
|
537
|
+
getSiblingListOptions: mergedGetSiblingListOptions,
|
|
514
538
|
listStyleType
|
|
515
539
|
});
|
|
516
540
|
return true;
|
|
@@ -543,7 +567,10 @@ const toggleList = (editor, options, getSiblingListOptions) => {
|
|
|
543
567
|
if (setList && restartValue) {
|
|
544
568
|
const entry = getListAbove(editor, { at: editor.api.start(editor.selection) });
|
|
545
569
|
if (!entry) return;
|
|
546
|
-
const isFirst = !getPreviousList(editor, entry
|
|
570
|
+
const isFirst = !getPreviousList(editor, entry, getListSequenceSiblingOptions(editor, {
|
|
571
|
+
breakOnEqIndentNeqListStyleType: false,
|
|
572
|
+
...mergedGetSiblingListOptions
|
|
573
|
+
}));
|
|
547
574
|
/**
|
|
548
575
|
* Only apply listRestartPolite if this is the first item and restartValue >
|
|
549
576
|
* 1.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lofcz/platejs-list",
|
|
3
|
-
"version": "53.
|
|
3
|
+
"version": "53.2.1",
|
|
4
4
|
"description": "List plugin for Plate",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plate",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@plate/scripts": "1.0.0",
|
|
39
|
-
"platejs": "npm:@lofcz/platejs@53.
|
|
39
|
+
"platejs": "npm:@lofcz/platejs@53.1.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"platejs": ">=53.0.0",
|