@rufous/ui 0.2.53 → 0.2.55

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 +52 -35
  2. package/dist/main.js +52 -35
  3. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -9592,6 +9592,12 @@ var STATUS_IMAGES = {
9592
9592
  blocked: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/blocked.svg",
9593
9593
  resolved: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/closed.svg"
9594
9594
  };
9595
+ var STATUS_LABELS = {
9596
+ todo: "Todo",
9597
+ working: "Working",
9598
+ blocked: "Blocked",
9599
+ resolved: "Resolved"
9600
+ };
9595
9601
  var STATUS_COLORS = {
9596
9602
  todo: { border: "#dc2626", bg: "#fff", color: "#dc2626" },
9597
9603
  working: { border: "#2563eb", bg: "#eff6ff", color: "#2563eb" },
@@ -9633,12 +9639,13 @@ var CustomTaskItem = import_extension_task_item.default.extend({
9633
9639
  const taskItemType = schema2.nodes.taskItem;
9634
9640
  const taskListType = schema2.nodes.taskList;
9635
9641
  if (!taskItemType || !taskListType) return false;
9636
- const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema2.nodes.paragraph.create());
9642
+ const statusText = schema2.text("Todo");
9643
+ const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema2.nodes.paragraph.create(null, statusText));
9637
9644
  const newTaskList = taskListType.create(null, newTaskItem);
9638
9645
  const tr2 = state.tr;
9639
9646
  const afterBlock = $from.after($from.depth > 0 ? 1 : 0);
9640
9647
  tr2.insert(afterBlock, newTaskList);
9641
- tr2.setSelection(import_prosemirror_state.TextSelection.near(tr2.doc.resolve(afterBlock + 1)));
9648
+ tr2.setSelection(import_prosemirror_state.TextSelection.near(tr2.doc.resolve(afterBlock + 2 + 4)));
9642
9649
  this.editor.view.dispatch(tr2);
9643
9650
  return true;
9644
9651
  }
@@ -9673,14 +9680,16 @@ var CustomTaskItem = import_extension_task_item.default.extend({
9673
9680
  if (afterContent.size > 0) {
9674
9681
  tr.delete($from.pos, $from.end());
9675
9682
  }
9676
- const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create();
9683
+ const statusLabel = STATUS_LABELS[status] || STATUS_LABELS.todo;
9684
+ const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create(null, schema.text(statusLabel));
9677
9685
  const newItem = schema.nodes.taskItem.create(
9678
9686
  { status, checked: false },
9679
9687
  newPara
9680
9688
  );
9681
9689
  const insertPos = tr.mapping.map($from.after(taskDepth));
9682
9690
  tr.insert(insertPos, newItem);
9683
- tr.setSelection(import_prosemirror_state.TextSelection.near(tr.doc.resolve(insertPos + 1)));
9691
+ const cursorAt = afterContent.size > 0 ? insertPos + 2 : insertPos + 2 + statusLabel.length;
9692
+ tr.setSelection(import_prosemirror_state.TextSelection.near(tr.doc.resolve(cursorAt)));
9684
9693
  this.editor.view.dispatch(tr);
9685
9694
  return true;
9686
9695
  },
@@ -9697,31 +9706,32 @@ var CustomTaskItem = import_extension_task_item.default.extend({
9697
9706
  }
9698
9707
  }
9699
9708
  if (taskItemDepth === -1) {
9700
- const parentDepth = $from.depth > 0 ? $from.depth - 1 : 0;
9709
+ if ($from.depth < 1) return false;
9710
+ const parentDepth = $from.depth - 1;
9701
9711
  const indexInParent = $from.index(parentDepth);
9702
9712
  if (indexInParent > 0) {
9703
9713
  const prevNode = $from.node(parentDepth).child(indexInParent - 1);
9704
9714
  if (prevNode.type.name === "taskList") {
9705
- const lastTaskItem = prevNode.lastChild;
9706
- if (lastTaskItem) {
9715
+ try {
9707
9716
  const tr = state.tr;
9708
- const paraStart = $from.before($from.depth > 0 ? $from.depth : 1);
9709
- const paraEnd = $from.after($from.depth > 0 ? $from.depth : 1);
9717
+ const paraStart = $from.before($from.depth);
9718
+ const paraEnd = $from.after($from.depth);
9710
9719
  const paraContent = $from.parent.content;
9711
- const taskListStart = $from.before(parentDepth) !== void 0 ? paraStart - 1 : null;
9712
- if (taskListStart !== null) {
9713
- const $taskListEnd = tr.doc.resolve(taskListStart);
9714
- const lastItemParaEnd = $taskListEnd.end($taskListEnd.depth);
9715
- tr.delete(paraStart, paraEnd);
9716
- let insertAt = lastItemParaEnd;
9717
- paraContent.forEach((inline) => {
9718
- tr.insert(insertAt, inline);
9719
- insertAt += inline.nodeSize;
9720
- });
9721
- tr.setSelection(import_prosemirror_state.TextSelection.create(tr.doc, lastItemParaEnd));
9722
- this.editor.view.dispatch(tr);
9723
- return true;
9724
- }
9720
+ const taskListEndPos = paraStart - 1;
9721
+ if (taskListEndPos < 0) return false;
9722
+ const $taskListEnd = tr.doc.resolve(taskListEndPos);
9723
+ const lastItemParaEnd = $taskListEnd.end($taskListEnd.depth);
9724
+ tr.delete(paraStart, paraEnd);
9725
+ let insertAt = lastItemParaEnd;
9726
+ paraContent.forEach((inline) => {
9727
+ tr.insert(insertAt, inline);
9728
+ insertAt += inline.nodeSize;
9729
+ });
9730
+ tr.setSelection(import_prosemirror_state.TextSelection.create(tr.doc, lastItemParaEnd));
9731
+ this.editor.view.dispatch(tr);
9732
+ return true;
9733
+ } catch {
9734
+ return false;
9725
9735
  }
9726
9736
  }
9727
9737
  }
@@ -11648,6 +11658,25 @@ var RufousTextEditor = ({
11648
11658
  if ((event.ctrlKey || event.metaKey) && event.key === "k") {
11649
11659
  event.preventDefault();
11650
11660
  setLinkRef.current?.();
11661
+ return;
11662
+ }
11663
+ if (event.key === " " && editor.isActive("link")) {
11664
+ const { $from } = editor.state.selection;
11665
+ const linkMark = editor.state.schema.marks.link;
11666
+ const parent = $from.parent;
11667
+ let atLinkEnd = false;
11668
+ parent.forEach((child, offset2) => {
11669
+ if (child.isText && child.marks.some((m) => m.type === linkMark)) {
11670
+ const childEnd = offset2 + child.nodeSize;
11671
+ if ($from.parentOffset === childEnd) {
11672
+ atLinkEnd = true;
11673
+ }
11674
+ }
11675
+ });
11676
+ if (atLinkEnd) {
11677
+ event.preventDefault();
11678
+ editor.chain().focus().unsetMark("link").insertContent(" ").run();
11679
+ }
11651
11680
  }
11652
11681
  };
11653
11682
  editor.view.dom.addEventListener("keydown", handleKeyDown);
@@ -11895,18 +11924,6 @@ var RufousTextEditor = ({
11895
11924
  },
11896
11925
  placeholder: "Link text"
11897
11926
  }
11898
- )), /* @__PURE__ */ import_react58.default.createElement("div", { className: "link-modal-field" }, /* @__PURE__ */ import_react58.default.createElement("label", { className: "link-modal-label" }, "Class name"), /* @__PURE__ */ import_react58.default.createElement(
11899
- "input",
11900
- {
11901
- type: "text",
11902
- className: "link-modal-input",
11903
- value: linkClassName,
11904
- onChange: (e) => setLinkClassName(e.target.value),
11905
- onKeyDown: (e) => {
11906
- if (e.key === "Enter") handleLinkSubmit();
11907
- },
11908
- placeholder: ""
11909
- }
11910
11927
  )), /* @__PURE__ */ import_react58.default.createElement("div", { className: "link-modal-checkboxes" }, /* @__PURE__ */ import_react58.default.createElement("label", { className: "link-modal-checkbox" }, /* @__PURE__ */ import_react58.default.createElement(
11911
11928
  "input",
11912
11929
  {
package/dist/main.js CHANGED
@@ -9527,6 +9527,12 @@ var STATUS_IMAGES = {
9527
9527
  blocked: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/blocked.svg",
9528
9528
  resolved: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/closed.svg"
9529
9529
  };
9530
+ var STATUS_LABELS = {
9531
+ todo: "Todo",
9532
+ working: "Working",
9533
+ blocked: "Blocked",
9534
+ resolved: "Resolved"
9535
+ };
9530
9536
  var STATUS_COLORS = {
9531
9537
  todo: { border: "#dc2626", bg: "#fff", color: "#dc2626" },
9532
9538
  working: { border: "#2563eb", bg: "#eff6ff", color: "#2563eb" },
@@ -9568,12 +9574,13 @@ var CustomTaskItem = TaskItem.extend({
9568
9574
  const taskItemType = schema2.nodes.taskItem;
9569
9575
  const taskListType = schema2.nodes.taskList;
9570
9576
  if (!taskItemType || !taskListType) return false;
9571
- const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema2.nodes.paragraph.create());
9577
+ const statusText = schema2.text("Todo");
9578
+ const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema2.nodes.paragraph.create(null, statusText));
9572
9579
  const newTaskList = taskListType.create(null, newTaskItem);
9573
9580
  const tr2 = state.tr;
9574
9581
  const afterBlock = $from.after($from.depth > 0 ? 1 : 0);
9575
9582
  tr2.insert(afterBlock, newTaskList);
9576
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(afterBlock + 1)));
9583
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(afterBlock + 2 + 4)));
9577
9584
  this.editor.view.dispatch(tr2);
9578
9585
  return true;
9579
9586
  }
@@ -9608,14 +9615,16 @@ var CustomTaskItem = TaskItem.extend({
9608
9615
  if (afterContent.size > 0) {
9609
9616
  tr.delete($from.pos, $from.end());
9610
9617
  }
9611
- const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create();
9618
+ const statusLabel = STATUS_LABELS[status] || STATUS_LABELS.todo;
9619
+ const newPara = afterContent.size > 0 ? schema.nodes.paragraph.create(null, afterContent) : schema.nodes.paragraph.create(null, schema.text(statusLabel));
9612
9620
  const newItem = schema.nodes.taskItem.create(
9613
9621
  { status, checked: false },
9614
9622
  newPara
9615
9623
  );
9616
9624
  const insertPos = tr.mapping.map($from.after(taskDepth));
9617
9625
  tr.insert(insertPos, newItem);
9618
- tr.setSelection(TextSelection.near(tr.doc.resolve(insertPos + 1)));
9626
+ const cursorAt = afterContent.size > 0 ? insertPos + 2 : insertPos + 2 + statusLabel.length;
9627
+ tr.setSelection(TextSelection.near(tr.doc.resolve(cursorAt)));
9619
9628
  this.editor.view.dispatch(tr);
9620
9629
  return true;
9621
9630
  },
@@ -9632,31 +9641,32 @@ var CustomTaskItem = TaskItem.extend({
9632
9641
  }
9633
9642
  }
9634
9643
  if (taskItemDepth === -1) {
9635
- const parentDepth = $from.depth > 0 ? $from.depth - 1 : 0;
9644
+ if ($from.depth < 1) return false;
9645
+ const parentDepth = $from.depth - 1;
9636
9646
  const indexInParent = $from.index(parentDepth);
9637
9647
  if (indexInParent > 0) {
9638
9648
  const prevNode = $from.node(parentDepth).child(indexInParent - 1);
9639
9649
  if (prevNode.type.name === "taskList") {
9640
- const lastTaskItem = prevNode.lastChild;
9641
- if (lastTaskItem) {
9650
+ try {
9642
9651
  const tr = state.tr;
9643
- const paraStart = $from.before($from.depth > 0 ? $from.depth : 1);
9644
- const paraEnd = $from.after($from.depth > 0 ? $from.depth : 1);
9652
+ const paraStart = $from.before($from.depth);
9653
+ const paraEnd = $from.after($from.depth);
9645
9654
  const paraContent = $from.parent.content;
9646
- const taskListStart = $from.before(parentDepth) !== void 0 ? paraStart - 1 : null;
9647
- if (taskListStart !== null) {
9648
- const $taskListEnd = tr.doc.resolve(taskListStart);
9649
- const lastItemParaEnd = $taskListEnd.end($taskListEnd.depth);
9650
- tr.delete(paraStart, paraEnd);
9651
- let insertAt = lastItemParaEnd;
9652
- paraContent.forEach((inline) => {
9653
- tr.insert(insertAt, inline);
9654
- insertAt += inline.nodeSize;
9655
- });
9656
- tr.setSelection(TextSelection.create(tr.doc, lastItemParaEnd));
9657
- this.editor.view.dispatch(tr);
9658
- return true;
9659
- }
9655
+ const taskListEndPos = paraStart - 1;
9656
+ if (taskListEndPos < 0) return false;
9657
+ const $taskListEnd = tr.doc.resolve(taskListEndPos);
9658
+ const lastItemParaEnd = $taskListEnd.end($taskListEnd.depth);
9659
+ tr.delete(paraStart, paraEnd);
9660
+ let insertAt = lastItemParaEnd;
9661
+ paraContent.forEach((inline) => {
9662
+ tr.insert(insertAt, inline);
9663
+ insertAt += inline.nodeSize;
9664
+ });
9665
+ tr.setSelection(TextSelection.create(tr.doc, lastItemParaEnd));
9666
+ this.editor.view.dispatch(tr);
9667
+ return true;
9668
+ } catch {
9669
+ return false;
9660
9670
  }
9661
9671
  }
9662
9672
  }
@@ -11583,6 +11593,25 @@ var RufousTextEditor = ({
11583
11593
  if ((event.ctrlKey || event.metaKey) && event.key === "k") {
11584
11594
  event.preventDefault();
11585
11595
  setLinkRef.current?.();
11596
+ return;
11597
+ }
11598
+ if (event.key === " " && editor.isActive("link")) {
11599
+ const { $from } = editor.state.selection;
11600
+ const linkMark = editor.state.schema.marks.link;
11601
+ const parent = $from.parent;
11602
+ let atLinkEnd = false;
11603
+ parent.forEach((child, offset2) => {
11604
+ if (child.isText && child.marks.some((m) => m.type === linkMark)) {
11605
+ const childEnd = offset2 + child.nodeSize;
11606
+ if ($from.parentOffset === childEnd) {
11607
+ atLinkEnd = true;
11608
+ }
11609
+ }
11610
+ });
11611
+ if (atLinkEnd) {
11612
+ event.preventDefault();
11613
+ editor.chain().focus().unsetMark("link").insertContent(" ").run();
11614
+ }
11586
11615
  }
11587
11616
  };
11588
11617
  editor.view.dom.addEventListener("keydown", handleKeyDown);
@@ -11830,18 +11859,6 @@ var RufousTextEditor = ({
11830
11859
  },
11831
11860
  placeholder: "Link text"
11832
11861
  }
11833
- )), /* @__PURE__ */ React115.createElement("div", { className: "link-modal-field" }, /* @__PURE__ */ React115.createElement("label", { className: "link-modal-label" }, "Class name"), /* @__PURE__ */ React115.createElement(
11834
- "input",
11835
- {
11836
- type: "text",
11837
- className: "link-modal-input",
11838
- value: linkClassName,
11839
- onChange: (e) => setLinkClassName(e.target.value),
11840
- onKeyDown: (e) => {
11841
- if (e.key === "Enter") handleLinkSubmit();
11842
- },
11843
- placeholder: ""
11844
- }
11845
11862
  )), /* @__PURE__ */ React115.createElement("div", { className: "link-modal-checkboxes" }, /* @__PURE__ */ React115.createElement("label", { className: "link-modal-checkbox" }, /* @__PURE__ */ React115.createElement(
11846
11863
  "input",
11847
11864
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rufous/ui",
3
3
  "private": false,
4
- "version": "0.2.53",
4
+ "version": "0.2.55",
5
5
  "type": "module",
6
6
  "description": "Experimental: A lightweight React UI component library (Beta)",
7
7
  "style": "./dist/main.css",