@trafica/editor 1.0.40 → 1.0.41

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.mjs CHANGED
@@ -2505,6 +2505,30 @@ var toggleListOfType = (listType) => (engine) => {
2505
2505
  engine.dispatch(tr);
2506
2506
  return true;
2507
2507
  }
2508
+ if (block.type === "list_item" && (parentType === "bullet_list" || parentType === "ordered_list")) {
2509
+ tr.steps.push(tr_setNodeType(parentPath, listType, {}));
2510
+ engine.dispatch(tr);
2511
+ return true;
2512
+ }
2513
+ if (block.type === "check_list_item" && parentType === "check_list") {
2514
+ const checkList = parent;
2515
+ const grandParentPath = parentPath.slice(0, -1);
2516
+ const listIdx = parentPath[parentPath.length - 1];
2517
+ const convertedList = {
2518
+ type: listType,
2519
+ attrs: {},
2520
+ children: checkList.children.map((item) => ({
2521
+ type: "list_item",
2522
+ attrs: {},
2523
+ children: item.children
2524
+ }))
2525
+ };
2526
+ tr.steps.push({ type: "delete_node", path: parentPath });
2527
+ tr.steps.push({ type: "insert_node", parentPath: grandParentPath, index: listIdx, node: convertedList });
2528
+ tr.steps.push(tr_setSelection(makeCollapsedSelection(makePosition([...grandParentPath, listIdx, blockIdx, 0], 0))));
2529
+ engine.dispatch(tr);
2530
+ return true;
2531
+ }
2508
2532
  const listItem = {
2509
2533
  type: "list_item",
2510
2534
  attrs: {},
@@ -2663,6 +2687,25 @@ var toggleCheckList = (engine) => {
2663
2687
  engine.dispatch(tr);
2664
2688
  return true;
2665
2689
  }
2690
+ if (block.type === "list_item" && (parentType === "bullet_list" || parentType === "ordered_list")) {
2691
+ const listNode = parent;
2692
+ const grandParentPath = parentPath.slice(0, -1);
2693
+ const listIdx = parentPath[parentPath.length - 1];
2694
+ const convertedList = {
2695
+ type: "check_list",
2696
+ attrs: {},
2697
+ children: listNode.children.map((item) => ({
2698
+ type: "check_list_item",
2699
+ attrs: { checked: false },
2700
+ children: item.children
2701
+ }))
2702
+ };
2703
+ tr.steps.push({ type: "delete_node", path: parentPath });
2704
+ tr.steps.push({ type: "insert_node", parentPath: grandParentPath, index: listIdx, node: convertedList });
2705
+ tr.steps.push(tr_setSelection(makeCollapsedSelection(makePosition([...grandParentPath, listIdx, blockIdx, 0], 0))));
2706
+ engine.dispatch(tr);
2707
+ return true;
2708
+ }
2666
2709
  const checkListItem = { type: "check_list_item", attrs: { checked: false }, children: block.children };
2667
2710
  const checkListNode = { type: "check_list", attrs: {}, children: [checkListItem] };
2668
2711
  tr.steps.push({ type: "delete_node", path: blockPath });