@rufous/ui 0.2.5 → 0.2.52

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.
Files changed (3) hide show
  1. package/dist/main.cjs +36 -20
  2. package/dist/main.js +36 -20
  3. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -41709,28 +41709,27 @@ var CustomTaskItem = import_extension_task_item.default.extend({
41709
41709
  }
41710
41710
  if (taskDepth === -1) {
41711
41711
  if (this.editor.storage.taskTodoEnabled === true) {
41712
- const schema = state.schema;
41713
- const taskItemType = schema.nodes.taskItem;
41714
- const taskListType = schema.nodes.taskList;
41712
+ const schema2 = state.schema;
41713
+ const taskItemType = schema2.nodes.taskItem;
41714
+ const taskListType = schema2.nodes.taskList;
41715
41715
  if (!taskItemType || !taskListType) return false;
41716
- const statusText = schema.text("Todo");
41717
- const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema.nodes.paragraph.create(null, statusText));
41716
+ const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema2.nodes.paragraph.create());
41718
41717
  const newTaskList = taskListType.create(null, newTaskItem);
41719
- const tr = state.tr;
41718
+ const tr2 = state.tr;
41720
41719
  const afterBlock = $from.after($from.depth > 0 ? 1 : 0);
41721
- tr.insert(afterBlock, newTaskList);
41722
- tr.setSelection(TextSelection.near(tr.doc.resolve(afterBlock + 3 + 4)));
41723
- this.editor.view.dispatch(tr);
41720
+ tr2.insert(afterBlock, newTaskList);
41721
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(afterBlock + 1)));
41722
+ this.editor.view.dispatch(tr2);
41724
41723
  return true;
41725
41724
  }
41726
41725
  return false;
41727
41726
  }
41728
41727
  if (this.editor.storage.taskTodoEnabled === false) {
41729
- const afterContent = $from.parent.content.cut($from.parentOffset);
41730
- const schema = state.schema;
41731
- const tr = state.tr;
41732
- if (afterContent.size > 0) {
41733
- tr.delete($from.pos, $from.end());
41728
+ const afterContent2 = $from.parent.content.cut($from.parentOffset);
41729
+ const schema2 = state.schema;
41730
+ const tr2 = state.tr;
41731
+ if (afterContent2.size > 0) {
41732
+ tr2.delete($from.pos, $from.end());
41734
41733
  }
41735
41734
  let taskListDepth = -1;
41736
41735
  for (let d = taskDepth - 1; d >= 0; d--) {
@@ -41739,14 +41738,31 @@ var CustomTaskItem = import_extension_task_item.default.extend({
41739
41738
  break;
41740
41739
  }
41741
41740
  }
41742
- const insertPos = taskListDepth !== -1 ? tr.mapping.map($from.after(taskListDepth)) : tr.mapping.map($from.after(taskDepth));
41743
- const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create();
41744
- tr.insert(insertPos, newPara);
41745
- tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos + 1)));
41746
- this.editor.view.dispatch(tr);
41741
+ const insertPos2 = taskListDepth !== -1 ? tr2.mapping.map($from.after(taskListDepth)) : tr2.mapping.map($from.after(taskDepth));
41742
+ const newPara2 = afterContent2.size > 0 ? schema2.nodes.paragraph.create(null, afterContent2) : schema2.nodes.paragraph.create();
41743
+ tr2.insert(insertPos2, newPara2);
41744
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(insertPos2 + 1)));
41745
+ this.editor.view.dispatch(tr2);
41747
41746
  return true;
41748
41747
  }
41749
- return this.editor.commands.splitListItem(this.name);
41748
+ const taskNode = $from.node(taskDepth);
41749
+ const status = taskNode.attrs.status || "todo";
41750
+ const schema = state.schema;
41751
+ const tr = state.tr;
41752
+ const afterContent = $from.parent.content.cut($from.parentOffset);
41753
+ if (afterContent.size > 0) {
41754
+ tr.delete($from.pos, $from.end());
41755
+ }
41756
+ const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create();
41757
+ const newItem = schema.nodes.taskItem.create(
41758
+ { status, checked: false },
41759
+ newPara
41760
+ );
41761
+ const insertPos = tr.mapping.map($from.after(taskDepth));
41762
+ tr.insert(insertPos, newItem);
41763
+ tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos + 1)));
41764
+ this.editor.view.dispatch(tr);
41765
+ return true;
41750
41766
  },
41751
41767
  Backspace: () => {
41752
41768
  const { state } = this.editor;
package/dist/main.js CHANGED
@@ -13039,28 +13039,27 @@ var CustomTaskItem = TaskItem.extend({
13039
13039
  }
13040
13040
  if (taskDepth === -1) {
13041
13041
  if (this.editor.storage.taskTodoEnabled === true) {
13042
- const schema = state.schema;
13043
- const taskItemType = schema.nodes.taskItem;
13044
- const taskListType = schema.nodes.taskList;
13042
+ const schema2 = state.schema;
13043
+ const taskItemType = schema2.nodes.taskItem;
13044
+ const taskListType = schema2.nodes.taskList;
13045
13045
  if (!taskItemType || !taskListType) return false;
13046
- const statusText = schema.text("Todo");
13047
- const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema.nodes.paragraph.create(null, statusText));
13046
+ const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema2.nodes.paragraph.create());
13048
13047
  const newTaskList = taskListType.create(null, newTaskItem);
13049
- const tr = state.tr;
13048
+ const tr2 = state.tr;
13050
13049
  const afterBlock = $from.after($from.depth > 0 ? 1 : 0);
13051
- tr.insert(afterBlock, newTaskList);
13052
- tr.setSelection(TextSelection.near(tr.doc.resolve(afterBlock + 3 + 4)));
13053
- this.editor.view.dispatch(tr);
13050
+ tr2.insert(afterBlock, newTaskList);
13051
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(afterBlock + 1)));
13052
+ this.editor.view.dispatch(tr2);
13054
13053
  return true;
13055
13054
  }
13056
13055
  return false;
13057
13056
  }
13058
13057
  if (this.editor.storage.taskTodoEnabled === false) {
13059
- const afterContent = $from.parent.content.cut($from.parentOffset);
13060
- const schema = state.schema;
13061
- const tr = state.tr;
13062
- if (afterContent.size > 0) {
13063
- tr.delete($from.pos, $from.end());
13058
+ const afterContent2 = $from.parent.content.cut($from.parentOffset);
13059
+ const schema2 = state.schema;
13060
+ const tr2 = state.tr;
13061
+ if (afterContent2.size > 0) {
13062
+ tr2.delete($from.pos, $from.end());
13064
13063
  }
13065
13064
  let taskListDepth = -1;
13066
13065
  for (let d = taskDepth - 1; d >= 0; d--) {
@@ -13069,14 +13068,31 @@ var CustomTaskItem = TaskItem.extend({
13069
13068
  break;
13070
13069
  }
13071
13070
  }
13072
- const insertPos = taskListDepth !== -1 ? tr.mapping.map($from.after(taskListDepth)) : tr.mapping.map($from.after(taskDepth));
13073
- const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create();
13074
- tr.insert(insertPos, newPara);
13075
- tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos + 1)));
13076
- this.editor.view.dispatch(tr);
13071
+ const insertPos2 = taskListDepth !== -1 ? tr2.mapping.map($from.after(taskListDepth)) : tr2.mapping.map($from.after(taskDepth));
13072
+ const newPara2 = afterContent2.size > 0 ? schema2.nodes.paragraph.create(null, afterContent2) : schema2.nodes.paragraph.create();
13073
+ tr2.insert(insertPos2, newPara2);
13074
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(insertPos2 + 1)));
13075
+ this.editor.view.dispatch(tr2);
13077
13076
  return true;
13078
13077
  }
13079
- return this.editor.commands.splitListItem(this.name);
13078
+ const taskNode = $from.node(taskDepth);
13079
+ const status = taskNode.attrs.status || "todo";
13080
+ const schema = state.schema;
13081
+ const tr = state.tr;
13082
+ const afterContent = $from.parent.content.cut($from.parentOffset);
13083
+ if (afterContent.size > 0) {
13084
+ tr.delete($from.pos, $from.end());
13085
+ }
13086
+ const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create();
13087
+ const newItem = schema.nodes.taskItem.create(
13088
+ { status, checked: false },
13089
+ newPara
13090
+ );
13091
+ const insertPos = tr.mapping.map($from.after(taskDepth));
13092
+ tr.insert(insertPos, newItem);
13093
+ tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos + 1)));
13094
+ this.editor.view.dispatch(tr);
13095
+ return true;
13080
13096
  },
13081
13097
  Backspace: () => {
13082
13098
  const { state } = this.editor;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rufous/ui",
3
3
  "private": false,
4
- "version": "0.2.5",
4
+ "version": "0.2.52",
5
5
  "type": "module",
6
6
  "description": "Experimental: A lightweight React UI component library (Beta)",
7
7
  "style": "./dist/main.css",