@rufous/ui 0.2.3 → 0.2.4
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/main.cjs +32 -32
- package/dist/main.js +32 -32
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -41672,6 +41672,12 @@ 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
|
+
};
|
|
41675
41681
|
var STATUS_COLORS = {
|
|
41676
41682
|
todo: { border: "#dc2626", bg: "#fff", color: "#dc2626" },
|
|
41677
41683
|
working: { border: "#2563eb", bg: "#eff6ff", color: "#2563eb" },
|
|
@@ -41755,14 +41761,16 @@ var CustomTaskItem = import_extension_task_item.default.extend({
|
|
|
41755
41761
|
if (afterContent.size > 0) {
|
|
41756
41762
|
tr.delete($from.pos, $from.end());
|
|
41757
41763
|
}
|
|
41758
|
-
const
|
|
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));
|
|
41759
41766
|
const newItem = schema.nodes.taskItem.create(
|
|
41760
41767
|
{ status, checked: false },
|
|
41761
41768
|
newPara
|
|
41762
41769
|
);
|
|
41763
41770
|
const insertPos = tr.mapping.map($from.after(taskDepth));
|
|
41764
41771
|
tr.insert(insertPos, newItem);
|
|
41765
|
-
|
|
41772
|
+
const cursorOffset = afterContent.size > 0 ? 0 : statusLabel.length;
|
|
41773
|
+
tr.setSelection(TextSelection.create(tr.doc, insertPos + 2 + cursorOffset));
|
|
41766
41774
|
this.editor.view.dispatch(tr);
|
|
41767
41775
|
return true;
|
|
41768
41776
|
},
|
|
@@ -41793,8 +41801,8 @@ var CustomTaskItem = import_extension_task_item.default.extend({
|
|
|
41793
41801
|
const from2 = $from.before(taskListDepth);
|
|
41794
41802
|
const to2 = $from.after(taskListDepth);
|
|
41795
41803
|
tr2.replaceWith(from2, to2, state.schema.nodes.paragraph.create());
|
|
41796
|
-
const
|
|
41797
|
-
tr2.setSelection(TextSelection.near(
|
|
41804
|
+
const resolvedPos2 = tr2.doc.resolve(from2);
|
|
41805
|
+
tr2.setSelection(TextSelection.near(resolvedPos2));
|
|
41798
41806
|
this.editor.view.dispatch(tr2);
|
|
41799
41807
|
return true;
|
|
41800
41808
|
}
|
|
@@ -41802,37 +41810,12 @@ var CustomTaskItem = import_extension_task_item.default.extend({
|
|
|
41802
41810
|
const from = $from.before(taskItemDepth);
|
|
41803
41811
|
const to = $from.after(taskItemDepth);
|
|
41804
41812
|
tr.delete(from, to);
|
|
41805
|
-
const
|
|
41806
|
-
|
|
41807
|
-
const cursorPos = $prev.end($prev.depth);
|
|
41808
|
-
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
41813
|
+
const resolvedPos = tr.doc.resolve(Math.max(0, from));
|
|
41814
|
+
tr.setSelection(TextSelection.near(resolvedPos, -1));
|
|
41809
41815
|
this.editor.view.dispatch(tr);
|
|
41810
41816
|
return true;
|
|
41811
41817
|
}
|
|
41812
|
-
|
|
41813
|
-
if (indexInList > 0 && taskListDepth !== -1) {
|
|
41814
|
-
const tr = state.tr;
|
|
41815
|
-
const itemStart = $from.before(taskItemDepth);
|
|
41816
|
-
const itemEnd = $from.after(taskItemDepth);
|
|
41817
|
-
if (tr.doc.resolve(itemStart).nodeBefore) {
|
|
41818
|
-
const contentSlice = taskItem.content;
|
|
41819
|
-
tr.delete(itemStart, itemEnd);
|
|
41820
|
-
const prevPos = Math.max(0, itemStart - 1);
|
|
41821
|
-
const $prevEnd = tr.doc.resolve(prevPos);
|
|
41822
|
-
const prevParaEnd = $prevEnd.end($prevEnd.depth);
|
|
41823
|
-
let insertAt = prevParaEnd;
|
|
41824
|
-
contentSlice.forEach((child) => {
|
|
41825
|
-
child.content.forEach((inline) => {
|
|
41826
|
-
tr.insert(insertAt, inline);
|
|
41827
|
-
insertAt += inline.nodeSize;
|
|
41828
|
-
});
|
|
41829
|
-
});
|
|
41830
|
-
tr.setSelection(TextSelection.create(tr.doc, prevParaEnd));
|
|
41831
|
-
this.editor.view.dispatch(tr);
|
|
41832
|
-
return true;
|
|
41833
|
-
}
|
|
41834
|
-
}
|
|
41835
|
-
return this.editor.commands.liftListItem(this.name);
|
|
41818
|
+
return false;
|
|
41836
41819
|
},
|
|
41837
41820
|
"Shift-Tab": () => this.editor.commands.liftListItem(this.name),
|
|
41838
41821
|
...this.options.nested ? { Tab: () => this.editor.commands.sinkListItem(this.name) } : {}
|
|
@@ -43671,6 +43654,7 @@ var RufousTextEditor = ({
|
|
|
43671
43654
|
editor.off("blur", handler);
|
|
43672
43655
|
};
|
|
43673
43656
|
}, [editor]);
|
|
43657
|
+
const setLinkRef = (0, import_react59.useRef)(null);
|
|
43674
43658
|
const [linkModalOpen, setLinkModalOpen] = (0, import_react59.useState)(false);
|
|
43675
43659
|
const [linkUrl, setLinkUrl] = (0, import_react59.useState)("");
|
|
43676
43660
|
const [linkText, setLinkText] = (0, import_react59.useState)("");
|
|
@@ -43715,6 +43699,22 @@ var RufousTextEditor = ({
|
|
|
43715
43699
|
setLinkSelection({ from, to });
|
|
43716
43700
|
setLinkModalOpen(true);
|
|
43717
43701
|
}, [editor]);
|
|
43702
|
+
(0, import_react59.useEffect)(() => {
|
|
43703
|
+
setLinkRef.current = setLink;
|
|
43704
|
+
}, [setLink]);
|
|
43705
|
+
(0, import_react59.useEffect)(() => {
|
|
43706
|
+
if (!editor?.view) return;
|
|
43707
|
+
const handleKeyDown = (event) => {
|
|
43708
|
+
if ((event.ctrlKey || event.metaKey) && event.key === "k") {
|
|
43709
|
+
event.preventDefault();
|
|
43710
|
+
setLinkRef.current?.();
|
|
43711
|
+
}
|
|
43712
|
+
};
|
|
43713
|
+
editor.view.dom.addEventListener("keydown", handleKeyDown);
|
|
43714
|
+
return () => {
|
|
43715
|
+
editor.view.dom.removeEventListener("keydown", handleKeyDown);
|
|
43716
|
+
};
|
|
43717
|
+
}, [editor]);
|
|
43718
43718
|
const handleLinkSubmit = (0, import_react59.useCallback)(() => {
|
|
43719
43719
|
if (!editor || !linkSelection) return;
|
|
43720
43720
|
editor.chain().focus().setTextSelection(linkSelection).run();
|
package/dist/main.js
CHANGED
|
@@ -13002,6 +13002,12 @@ 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
|
+
};
|
|
13005
13011
|
var STATUS_COLORS = {
|
|
13006
13012
|
todo: { border: "#dc2626", bg: "#fff", color: "#dc2626" },
|
|
13007
13013
|
working: { border: "#2563eb", bg: "#eff6ff", color: "#2563eb" },
|
|
@@ -13085,14 +13091,16 @@ var CustomTaskItem = TaskItem.extend({
|
|
|
13085
13091
|
if (afterContent.size > 0) {
|
|
13086
13092
|
tr.delete($from.pos, $from.end());
|
|
13087
13093
|
}
|
|
13088
|
-
const
|
|
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));
|
|
13089
13096
|
const newItem = schema.nodes.taskItem.create(
|
|
13090
13097
|
{ status, checked: false },
|
|
13091
13098
|
newPara
|
|
13092
13099
|
);
|
|
13093
13100
|
const insertPos = tr.mapping.map($from.after(taskDepth));
|
|
13094
13101
|
tr.insert(insertPos, newItem);
|
|
13095
|
-
|
|
13102
|
+
const cursorOffset = afterContent.size > 0 ? 0 : statusLabel.length;
|
|
13103
|
+
tr.setSelection(TextSelection.create(tr.doc, insertPos + 2 + cursorOffset));
|
|
13096
13104
|
this.editor.view.dispatch(tr);
|
|
13097
13105
|
return true;
|
|
13098
13106
|
},
|
|
@@ -13123,8 +13131,8 @@ var CustomTaskItem = TaskItem.extend({
|
|
|
13123
13131
|
const from2 = $from.before(taskListDepth);
|
|
13124
13132
|
const to2 = $from.after(taskListDepth);
|
|
13125
13133
|
tr2.replaceWith(from2, to2, state.schema.nodes.paragraph.create());
|
|
13126
|
-
const
|
|
13127
|
-
tr2.setSelection(TextSelection.near(
|
|
13134
|
+
const resolvedPos2 = tr2.doc.resolve(from2);
|
|
13135
|
+
tr2.setSelection(TextSelection.near(resolvedPos2));
|
|
13128
13136
|
this.editor.view.dispatch(tr2);
|
|
13129
13137
|
return true;
|
|
13130
13138
|
}
|
|
@@ -13132,37 +13140,12 @@ var CustomTaskItem = TaskItem.extend({
|
|
|
13132
13140
|
const from = $from.before(taskItemDepth);
|
|
13133
13141
|
const to = $from.after(taskItemDepth);
|
|
13134
13142
|
tr.delete(from, to);
|
|
13135
|
-
const
|
|
13136
|
-
|
|
13137
|
-
const cursorPos = $prev.end($prev.depth);
|
|
13138
|
-
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
13143
|
+
const resolvedPos = tr.doc.resolve(Math.max(0, from));
|
|
13144
|
+
tr.setSelection(TextSelection.near(resolvedPos, -1));
|
|
13139
13145
|
this.editor.view.dispatch(tr);
|
|
13140
13146
|
return true;
|
|
13141
13147
|
}
|
|
13142
|
-
|
|
13143
|
-
if (indexInList > 0 && taskListDepth !== -1) {
|
|
13144
|
-
const tr = state.tr;
|
|
13145
|
-
const itemStart = $from.before(taskItemDepth);
|
|
13146
|
-
const itemEnd = $from.after(taskItemDepth);
|
|
13147
|
-
if (tr.doc.resolve(itemStart).nodeBefore) {
|
|
13148
|
-
const contentSlice = taskItem.content;
|
|
13149
|
-
tr.delete(itemStart, itemEnd);
|
|
13150
|
-
const prevPos = Math.max(0, itemStart - 1);
|
|
13151
|
-
const $prevEnd = tr.doc.resolve(prevPos);
|
|
13152
|
-
const prevParaEnd = $prevEnd.end($prevEnd.depth);
|
|
13153
|
-
let insertAt = prevParaEnd;
|
|
13154
|
-
contentSlice.forEach((child) => {
|
|
13155
|
-
child.content.forEach((inline) => {
|
|
13156
|
-
tr.insert(insertAt, inline);
|
|
13157
|
-
insertAt += inline.nodeSize;
|
|
13158
|
-
});
|
|
13159
|
-
});
|
|
13160
|
-
tr.setSelection(TextSelection.create(tr.doc, prevParaEnd));
|
|
13161
|
-
this.editor.view.dispatch(tr);
|
|
13162
|
-
return true;
|
|
13163
|
-
}
|
|
13164
|
-
}
|
|
13165
|
-
return this.editor.commands.liftListItem(this.name);
|
|
13148
|
+
return false;
|
|
13166
13149
|
},
|
|
13167
13150
|
"Shift-Tab": () => this.editor.commands.liftListItem(this.name),
|
|
13168
13151
|
...this.options.nested ? { Tab: () => this.editor.commands.sinkListItem(this.name) } : {}
|
|
@@ -15001,6 +14984,7 @@ var RufousTextEditor = ({
|
|
|
15001
14984
|
editor.off("blur", handler);
|
|
15002
14985
|
};
|
|
15003
14986
|
}, [editor]);
|
|
14987
|
+
const setLinkRef = useRef30(null);
|
|
15004
14988
|
const [linkModalOpen, setLinkModalOpen] = useState34(false);
|
|
15005
14989
|
const [linkUrl, setLinkUrl] = useState34("");
|
|
15006
14990
|
const [linkText, setLinkText] = useState34("");
|
|
@@ -15045,6 +15029,22 @@ var RufousTextEditor = ({
|
|
|
15045
15029
|
setLinkSelection({ from, to });
|
|
15046
15030
|
setLinkModalOpen(true);
|
|
15047
15031
|
}, [editor]);
|
|
15032
|
+
useEffect27(() => {
|
|
15033
|
+
setLinkRef.current = setLink;
|
|
15034
|
+
}, [setLink]);
|
|
15035
|
+
useEffect27(() => {
|
|
15036
|
+
if (!editor?.view) return;
|
|
15037
|
+
const handleKeyDown = (event) => {
|
|
15038
|
+
if ((event.ctrlKey || event.metaKey) && event.key === "k") {
|
|
15039
|
+
event.preventDefault();
|
|
15040
|
+
setLinkRef.current?.();
|
|
15041
|
+
}
|
|
15042
|
+
};
|
|
15043
|
+
editor.view.dom.addEventListener("keydown", handleKeyDown);
|
|
15044
|
+
return () => {
|
|
15045
|
+
editor.view.dom.removeEventListener("keydown", handleKeyDown);
|
|
15046
|
+
};
|
|
15047
|
+
}, [editor]);
|
|
15048
15048
|
const handleLinkSubmit = useCallback13(() => {
|
|
15049
15049
|
if (!editor || !linkSelection) return;
|
|
15050
15050
|
editor.chain().focus().setTextSelection(linkSelection).run();
|