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