@rufous/ui 0.2.4 → 0.2.5

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 +51 -47
  2. package/dist/main.js +51 -47
  3. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -41672,12 +41672,6 @@ var STATUS_IMAGES = {
41672
41672
  blocked: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/blocked.svg",
41673
41673
  resolved: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/closed.svg"
41674
41674
  };
41675
- var STATUS_LABELS = {
41676
- todo: "Todo",
41677
- working: "Working",
41678
- blocked: "Blocked",
41679
- resolved: "Resolved"
41680
- };
41681
41675
  var STATUS_COLORS = {
41682
41676
  todo: { border: "#dc2626", bg: "#fff", color: "#dc2626" },
41683
41677
  working: { border: "#2563eb", bg: "#eff6ff", color: "#2563eb" },
@@ -41715,29 +41709,28 @@ var CustomTaskItem = import_extension_task_item.default.extend({
41715
41709
  }
41716
41710
  if (taskDepth === -1) {
41717
41711
  if (this.editor.storage.taskTodoEnabled === true) {
41718
- const schema2 = state.schema;
41719
- const taskItemType = schema2.nodes.taskItem;
41720
- const taskListType = schema2.nodes.taskList;
41712
+ const schema = state.schema;
41713
+ const taskItemType = schema.nodes.taskItem;
41714
+ const taskListType = schema.nodes.taskList;
41721
41715
  if (!taskItemType || !taskListType) return false;
41722
- const statusText = schema2.text("Todo");
41723
- const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema2.nodes.paragraph.create(null, statusText));
41716
+ const statusText = schema.text("Todo");
41717
+ const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema.nodes.paragraph.create(null, statusText));
41724
41718
  const newTaskList = taskListType.create(null, newTaskItem);
41725
- const tr2 = state.tr;
41726
- const pos = $from.pos;
41719
+ const tr = state.tr;
41727
41720
  const afterBlock = $from.after($from.depth > 0 ? 1 : 0);
41728
- tr2.insert(afterBlock, newTaskList);
41729
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(afterBlock + 3 + 4)));
41730
- this.editor.view.dispatch(tr2);
41721
+ tr.insert(afterBlock, newTaskList);
41722
+ tr.setSelection(TextSelection.near(tr.doc.resolve(afterBlock + 3 + 4)));
41723
+ this.editor.view.dispatch(tr);
41731
41724
  return true;
41732
41725
  }
41733
41726
  return false;
41734
41727
  }
41735
41728
  if (this.editor.storage.taskTodoEnabled === false) {
41736
- const afterContent2 = $from.parent.content.cut($from.parentOffset);
41737
- const schema2 = state.schema;
41738
- const tr2 = state.tr;
41739
- if (afterContent2.size > 0) {
41740
- tr2.delete($from.pos, $from.end());
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());
41741
41734
  }
41742
41735
  let taskListDepth = -1;
41743
41736
  for (let d = taskDepth - 1; d >= 0; d--) {
@@ -41746,33 +41739,14 @@ var CustomTaskItem = import_extension_task_item.default.extend({
41746
41739
  break;
41747
41740
  }
41748
41741
  }
41749
- const insertPos2 = taskListDepth !== -1 ? tr2.mapping.map($from.after(taskListDepth)) : tr2.mapping.map($from.after(taskDepth));
41750
- const newPara2 = afterContent2.size > 0 ? schema2.nodes.paragraph.create(null, afterContent2) : schema2.nodes.paragraph.create();
41751
- tr2.insert(insertPos2, newPara2);
41752
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(insertPos2 + 1)));
41753
- this.editor.view.dispatch(tr2);
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);
41754
41747
  return true;
41755
41748
  }
41756
- const taskNode = $from.node(taskDepth);
41757
- const status = taskNode.attrs.status || "todo";
41758
- const schema = state.schema;
41759
- const tr = state.tr;
41760
- const afterContent = $from.parent.content.cut($from.parentOffset);
41761
- if (afterContent.size > 0) {
41762
- tr.delete($from.pos, $from.end());
41763
- }
41764
- const statusLabel = STATUS_LABELS[status] || STATUS_LABELS.todo;
41765
- const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create(null, schema.text(statusLabel));
41766
- const newItem = schema.nodes.taskItem.create(
41767
- { status, checked: false },
41768
- newPara
41769
- );
41770
- const insertPos = tr.mapping.map($from.after(taskDepth));
41771
- tr.insert(insertPos, newItem);
41772
- const cursorOffset = afterContent.size > 0 ? 0 : statusLabel.length;
41773
- tr.setSelection(TextSelection.create(tr.doc, insertPos + 2 + cursorOffset));
41774
- this.editor.view.dispatch(tr);
41775
- return true;
41749
+ return this.editor.commands.splitListItem(this.name);
41776
41750
  },
41777
41751
  Backspace: () => {
41778
41752
  const { state } = this.editor;
@@ -41786,7 +41760,37 @@ var CustomTaskItem = import_extension_task_item.default.extend({
41786
41760
  break;
41787
41761
  }
41788
41762
  }
41789
- if (taskItemDepth === -1) return false;
41763
+ if (taskItemDepth === -1) {
41764
+ const parentDepth = $from.depth > 0 ? $from.depth - 1 : 0;
41765
+ const indexInParent = $from.index(parentDepth);
41766
+ if (indexInParent > 0) {
41767
+ const prevNode = $from.node(parentDepth).child(indexInParent - 1);
41768
+ if (prevNode.type.name === "taskList") {
41769
+ const lastTaskItem = prevNode.lastChild;
41770
+ if (lastTaskItem) {
41771
+ const tr = state.tr;
41772
+ const paraStart = $from.before($from.depth > 0 ? $from.depth : 1);
41773
+ const paraEnd = $from.after($from.depth > 0 ? $from.depth : 1);
41774
+ const paraContent = $from.parent.content;
41775
+ const taskListStart = $from.before(parentDepth) !== void 0 ? paraStart - 1 : null;
41776
+ if (taskListStart !== null) {
41777
+ const $taskListEnd = tr.doc.resolve(taskListStart);
41778
+ const lastItemParaEnd = $taskListEnd.end($taskListEnd.depth);
41779
+ tr.delete(paraStart, paraEnd);
41780
+ let insertAt = lastItemParaEnd;
41781
+ paraContent.forEach((inline) => {
41782
+ tr.insert(insertAt, inline);
41783
+ insertAt += inline.nodeSize;
41784
+ });
41785
+ tr.setSelection(TextSelection.create(tr.doc, lastItemParaEnd));
41786
+ this.editor.view.dispatch(tr);
41787
+ return true;
41788
+ }
41789
+ }
41790
+ }
41791
+ }
41792
+ return false;
41793
+ }
41790
41794
  const taskItem = $from.node(taskItemDepth);
41791
41795
  let taskListDepth = -1;
41792
41796
  for (let d = taskItemDepth - 1; d >= 0; d--) {
package/dist/main.js CHANGED
@@ -13002,12 +13002,6 @@ var STATUS_IMAGES = {
13002
13002
  blocked: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/blocked.svg",
13003
13003
  resolved: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/closed.svg"
13004
13004
  };
13005
- var STATUS_LABELS = {
13006
- todo: "Todo",
13007
- working: "Working",
13008
- blocked: "Blocked",
13009
- resolved: "Resolved"
13010
- };
13011
13005
  var STATUS_COLORS = {
13012
13006
  todo: { border: "#dc2626", bg: "#fff", color: "#dc2626" },
13013
13007
  working: { border: "#2563eb", bg: "#eff6ff", color: "#2563eb" },
@@ -13045,29 +13039,28 @@ var CustomTaskItem = TaskItem.extend({
13045
13039
  }
13046
13040
  if (taskDepth === -1) {
13047
13041
  if (this.editor.storage.taskTodoEnabled === true) {
13048
- const schema2 = state.schema;
13049
- const taskItemType = schema2.nodes.taskItem;
13050
- const taskListType = schema2.nodes.taskList;
13042
+ const schema = state.schema;
13043
+ const taskItemType = schema.nodes.taskItem;
13044
+ const taskListType = schema.nodes.taskList;
13051
13045
  if (!taskItemType || !taskListType) return false;
13052
- const statusText = schema2.text("Todo");
13053
- const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema2.nodes.paragraph.create(null, statusText));
13046
+ const statusText = schema.text("Todo");
13047
+ const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema.nodes.paragraph.create(null, statusText));
13054
13048
  const newTaskList = taskListType.create(null, newTaskItem);
13055
- const tr2 = state.tr;
13056
- const pos = $from.pos;
13049
+ const tr = state.tr;
13057
13050
  const afterBlock = $from.after($from.depth > 0 ? 1 : 0);
13058
- tr2.insert(afterBlock, newTaskList);
13059
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(afterBlock + 3 + 4)));
13060
- this.editor.view.dispatch(tr2);
13051
+ tr.insert(afterBlock, newTaskList);
13052
+ tr.setSelection(TextSelection.near(tr.doc.resolve(afterBlock + 3 + 4)));
13053
+ this.editor.view.dispatch(tr);
13061
13054
  return true;
13062
13055
  }
13063
13056
  return false;
13064
13057
  }
13065
13058
  if (this.editor.storage.taskTodoEnabled === false) {
13066
- const afterContent2 = $from.parent.content.cut($from.parentOffset);
13067
- const schema2 = state.schema;
13068
- const tr2 = state.tr;
13069
- if (afterContent2.size > 0) {
13070
- tr2.delete($from.pos, $from.end());
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());
13071
13064
  }
13072
13065
  let taskListDepth = -1;
13073
13066
  for (let d = taskDepth - 1; d >= 0; d--) {
@@ -13076,33 +13069,14 @@ var CustomTaskItem = TaskItem.extend({
13076
13069
  break;
13077
13070
  }
13078
13071
  }
13079
- const insertPos2 = taskListDepth !== -1 ? tr2.mapping.map($from.after(taskListDepth)) : tr2.mapping.map($from.after(taskDepth));
13080
- const newPara2 = afterContent2.size > 0 ? schema2.nodes.paragraph.create(null, afterContent2) : schema2.nodes.paragraph.create();
13081
- tr2.insert(insertPos2, newPara2);
13082
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(insertPos2 + 1)));
13083
- this.editor.view.dispatch(tr2);
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);
13084
13077
  return true;
13085
13078
  }
13086
- const taskNode = $from.node(taskDepth);
13087
- const status = taskNode.attrs.status || "todo";
13088
- const schema = state.schema;
13089
- const tr = state.tr;
13090
- const afterContent = $from.parent.content.cut($from.parentOffset);
13091
- if (afterContent.size > 0) {
13092
- tr.delete($from.pos, $from.end());
13093
- }
13094
- const statusLabel = STATUS_LABELS[status] || STATUS_LABELS.todo;
13095
- const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create(null, schema.text(statusLabel));
13096
- const newItem = schema.nodes.taskItem.create(
13097
- { status, checked: false },
13098
- newPara
13099
- );
13100
- const insertPos = tr.mapping.map($from.after(taskDepth));
13101
- tr.insert(insertPos, newItem);
13102
- const cursorOffset = afterContent.size > 0 ? 0 : statusLabel.length;
13103
- tr.setSelection(TextSelection.create(tr.doc, insertPos + 2 + cursorOffset));
13104
- this.editor.view.dispatch(tr);
13105
- return true;
13079
+ return this.editor.commands.splitListItem(this.name);
13106
13080
  },
13107
13081
  Backspace: () => {
13108
13082
  const { state } = this.editor;
@@ -13116,7 +13090,37 @@ var CustomTaskItem = TaskItem.extend({
13116
13090
  break;
13117
13091
  }
13118
13092
  }
13119
- if (taskItemDepth === -1) return false;
13093
+ if (taskItemDepth === -1) {
13094
+ const parentDepth = $from.depth > 0 ? $from.depth - 1 : 0;
13095
+ const indexInParent = $from.index(parentDepth);
13096
+ if (indexInParent > 0) {
13097
+ const prevNode = $from.node(parentDepth).child(indexInParent - 1);
13098
+ if (prevNode.type.name === "taskList") {
13099
+ const lastTaskItem = prevNode.lastChild;
13100
+ if (lastTaskItem) {
13101
+ const tr = state.tr;
13102
+ const paraStart = $from.before($from.depth > 0 ? $from.depth : 1);
13103
+ const paraEnd = $from.after($from.depth > 0 ? $from.depth : 1);
13104
+ const paraContent = $from.parent.content;
13105
+ const taskListStart = $from.before(parentDepth) !== void 0 ? paraStart - 1 : null;
13106
+ if (taskListStart !== null) {
13107
+ const $taskListEnd = tr.doc.resolve(taskListStart);
13108
+ const lastItemParaEnd = $taskListEnd.end($taskListEnd.depth);
13109
+ tr.delete(paraStart, paraEnd);
13110
+ let insertAt = lastItemParaEnd;
13111
+ paraContent.forEach((inline) => {
13112
+ tr.insert(insertAt, inline);
13113
+ insertAt += inline.nodeSize;
13114
+ });
13115
+ tr.setSelection(TextSelection.create(tr.doc, lastItemParaEnd));
13116
+ this.editor.view.dispatch(tr);
13117
+ return true;
13118
+ }
13119
+ }
13120
+ }
13121
+ }
13122
+ return false;
13123
+ }
13120
13124
  const taskItem = $from.node(taskItemDepth);
13121
13125
  let taskListDepth = -1;
13122
13126
  for (let d = taskItemDepth - 1; d >= 0; d--) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rufous/ui",
3
3
  "private": false,
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "type": "module",
6
6
  "description": "Experimental: A lightweight React UI component library (Beta)",
7
7
  "style": "./dist/main.css",