@rufous/ui 0.2.1 → 0.2.2
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 +74 -29
- package/dist/main.js +74 -29
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -41685,6 +41685,9 @@ var STATUS_COLORS = {
|
|
|
41685
41685
|
resolved: { border: "#16a34a", bg: "#16a34a", color: "#fff" }
|
|
41686
41686
|
};
|
|
41687
41687
|
var CustomTaskItem = import_extension_task_item.default.extend({
|
|
41688
|
+
addStorage() {
|
|
41689
|
+
return { taskTodoEnabled: true };
|
|
41690
|
+
},
|
|
41688
41691
|
addAttributes() {
|
|
41689
41692
|
return {
|
|
41690
41693
|
...this.parent?.(),
|
|
@@ -41711,6 +41714,27 @@ var CustomTaskItem = import_extension_task_item.default.extend({
|
|
|
41711
41714
|
}
|
|
41712
41715
|
}
|
|
41713
41716
|
if (taskDepth === -1) return false;
|
|
41717
|
+
if (this.editor.storage.taskTodoEnabled === false) {
|
|
41718
|
+
const afterContent2 = $from.parent.content.cut($from.parentOffset);
|
|
41719
|
+
const schema2 = state.schema;
|
|
41720
|
+
const tr2 = state.tr;
|
|
41721
|
+
if (afterContent2.size > 0) {
|
|
41722
|
+
tr2.delete($from.pos, $from.end());
|
|
41723
|
+
}
|
|
41724
|
+
let taskListDepth = -1;
|
|
41725
|
+
for (let d = taskDepth - 1; d >= 0; d--) {
|
|
41726
|
+
if ($from.node(d).type.name === "taskList") {
|
|
41727
|
+
taskListDepth = d;
|
|
41728
|
+
break;
|
|
41729
|
+
}
|
|
41730
|
+
}
|
|
41731
|
+
const insertPos2 = taskListDepth !== -1 ? tr2.mapping.map($from.after(taskListDepth)) : tr2.mapping.map($from.after(taskDepth));
|
|
41732
|
+
const newPara2 = afterContent2.size > 0 ? schema2.nodes.paragraph.create(null, afterContent2) : schema2.nodes.paragraph.create();
|
|
41733
|
+
tr2.insert(insertPos2, newPara2);
|
|
41734
|
+
tr2.setSelection(TextSelection.near(tr2.doc.resolve(insertPos2 + 1)));
|
|
41735
|
+
this.editor.view.dispatch(tr2);
|
|
41736
|
+
return true;
|
|
41737
|
+
}
|
|
41714
41738
|
const taskNode = $from.node(taskDepth);
|
|
41715
41739
|
const status = taskNode.attrs.status || "todo";
|
|
41716
41740
|
const schema = state.schema;
|
|
@@ -41770,7 +41794,10 @@ var CustomTaskItem = import_extension_task_item.default.extend({
|
|
|
41770
41794
|
const from = $from.before(taskItemDepth);
|
|
41771
41795
|
const to = $from.after(taskItemDepth);
|
|
41772
41796
|
tr.delete(from, to);
|
|
41773
|
-
|
|
41797
|
+
const prevPos = Math.max(0, from - 1);
|
|
41798
|
+
const $prev = tr.doc.resolve(prevPos);
|
|
41799
|
+
const cursorPos = $prev.end($prev.depth);
|
|
41800
|
+
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
41774
41801
|
this.editor.view.dispatch(tr);
|
|
41775
41802
|
return true;
|
|
41776
41803
|
}
|
|
@@ -42340,6 +42367,7 @@ var ColorPickerPanel = ({ editor, onClose }) => {
|
|
|
42340
42367
|
var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTextToSpeech, onClose, onImageUpload }) => {
|
|
42341
42368
|
const [, setEditorState] = (0, import_react56.useState)(0);
|
|
42342
42369
|
const [isFullscreen, setIsFullscreen] = (0, import_react56.useState)(false);
|
|
42370
|
+
const [todoEnabled, setTodoEnabled] = (0, import_react56.useState)(false);
|
|
42343
42371
|
(0, import_react56.useEffect)(() => {
|
|
42344
42372
|
if (!editor) return;
|
|
42345
42373
|
const onTransaction = () => setEditorState((n) => n + 1);
|
|
@@ -42840,24 +42868,25 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
42840
42868
|
{
|
|
42841
42869
|
trigger: { label: /* @__PURE__ */ import_react56.default.createElement(IconCode, null), title: "Code", className: editor.isActive("code") || editor.isActive("codeBlock") ? "is-active" : "" }
|
|
42842
42870
|
},
|
|
42843
|
-
/* @__PURE__ */ import_react56.default.createElement("button", { className: "dropdown-item", onClick: () =>
|
|
42844
|
-
|
|
42845
|
-
|
|
42846
|
-
|
|
42847
|
-
|
|
42848
|
-
|
|
42849
|
-
|
|
42850
|
-
|
|
42851
|
-
|
|
42852
|
-
})();
|
|
42853
|
-
if (text) {
|
|
42871
|
+
/* @__PURE__ */ import_react56.default.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
42872
|
+
if (editor.isActive("codeBlock")) {
|
|
42873
|
+
const text = (() => {
|
|
42874
|
+
const { $from } = editor.state.selection;
|
|
42875
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
42876
|
+
if ($from.node(d).type.name === "codeBlock") return $from.node(d).textContent;
|
|
42877
|
+
}
|
|
42878
|
+
return "";
|
|
42879
|
+
})();
|
|
42854
42880
|
editor.chain().focus().toggleCodeBlock().run();
|
|
42855
|
-
|
|
42856
|
-
|
|
42881
|
+
if (text) {
|
|
42882
|
+
const { from } = editor.state.selection;
|
|
42883
|
+
editor.chain().focus().setTextSelection({ from, to: from + text.length }).toggleCode().run();
|
|
42884
|
+
}
|
|
42857
42885
|
} else {
|
|
42858
|
-
editor.chain().focus().
|
|
42886
|
+
editor.chain().focus().toggleCode().run();
|
|
42859
42887
|
}
|
|
42860
|
-
} }, "</>
|
|
42888
|
+
} }, "</>", " Inline Code"),
|
|
42889
|
+
/* @__PURE__ */ import_react56.default.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleCodeBlock().run() }, "{ }", " Code Block")
|
|
42861
42890
|
), /* @__PURE__ */ import_react56.default.createElement(
|
|
42862
42891
|
"button",
|
|
42863
42892
|
{
|
|
@@ -42877,11 +42906,15 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
42877
42906
|
), /* @__PURE__ */ import_react56.default.createElement(Dropdown, { trigger: { label: "", title: "Translate options", className: "translate-arrow-btn" } }, /* @__PURE__ */ import_react56.default.createElement("button", { className: "dropdown-item", onClick: () => setShowTranslateModal(true) }, "Options")), translateStatus && /* @__PURE__ */ import_react56.default.createElement("span", { className: `translate-toast-popup ${translateStatus === "Please select the text" || translateStatus === "Translation failed" ? "error" : ""}` }, translateStatus)), /* @__PURE__ */ import_react56.default.createElement("div", { className: "todo-split-btn" }, /* @__PURE__ */ import_react56.default.createElement(
|
|
42878
42907
|
"button",
|
|
42879
42908
|
{
|
|
42880
|
-
className: `toolbar-btn ${
|
|
42909
|
+
className: `toolbar-btn ${todoEnabled ? "is-active" : ""}`,
|
|
42881
42910
|
onClick: () => {
|
|
42882
|
-
if (
|
|
42883
|
-
|
|
42911
|
+
if (todoEnabled) {
|
|
42912
|
+
setTodoEnabled(false);
|
|
42913
|
+
editor.storage.taskTodoEnabled = false;
|
|
42914
|
+
editor.chain().focus().run();
|
|
42884
42915
|
} else {
|
|
42916
|
+
setTodoEnabled(true);
|
|
42917
|
+
editor.storage.taskTodoEnabled = true;
|
|
42885
42918
|
const { state } = editor;
|
|
42886
42919
|
const { schema } = state;
|
|
42887
42920
|
const taskItemType = schema.nodes.taskItem;
|
|
@@ -42889,18 +42922,30 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
42889
42922
|
if (!taskItemType || !taskListType) return;
|
|
42890
42923
|
const statusText = schema.text("Todo");
|
|
42891
42924
|
const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema.nodes.paragraph.create(null, statusText));
|
|
42892
|
-
const
|
|
42893
|
-
|
|
42894
|
-
|
|
42895
|
-
|
|
42896
|
-
|
|
42897
|
-
|
|
42898
|
-
|
|
42899
|
-
|
|
42900
|
-
|
|
42925
|
+
const { $from } = state.selection;
|
|
42926
|
+
let insideTask = false;
|
|
42927
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
42928
|
+
if ($from.node(d).type.name === "taskItem") {
|
|
42929
|
+
insideTask = true;
|
|
42930
|
+
break;
|
|
42931
|
+
}
|
|
42932
|
+
}
|
|
42933
|
+
if (insideTask) {
|
|
42934
|
+
editor.chain().focus().run();
|
|
42935
|
+
} else {
|
|
42936
|
+
const newTaskList = taskListType.create(null, newTaskItem);
|
|
42937
|
+
editor.chain().focus().command(({ tr, dispatch, state: cmdState }) => {
|
|
42938
|
+
if (!dispatch) return true;
|
|
42939
|
+
const pos = tr.selection.from;
|
|
42940
|
+
tr.replaceSelectionWith(newTaskList);
|
|
42941
|
+
const resolvedPos = tr.doc.resolve(pos + 2 + 4);
|
|
42942
|
+
tr.setSelection(cmdState.selection.constructor.near(resolvedPos));
|
|
42943
|
+
return true;
|
|
42944
|
+
}).run();
|
|
42945
|
+
}
|
|
42901
42946
|
}
|
|
42902
42947
|
},
|
|
42903
|
-
title:
|
|
42948
|
+
title: todoEnabled ? "Disable Task List" : "Enable Task List"
|
|
42904
42949
|
},
|
|
42905
42950
|
/* @__PURE__ */ import_react56.default.createElement(IconTaskList, null)
|
|
42906
42951
|
), /* @__PURE__ */ import_react56.default.createElement(Dropdown, { trigger: { label: "", title: "Task status", className: "todo-arrow-btn" }, keepOpen: true }, ["todo", "working", "blocked", "resolved"].map((status) => {
|
package/dist/main.js
CHANGED
|
@@ -13015,6 +13015,9 @@ var STATUS_COLORS = {
|
|
|
13015
13015
|
resolved: { border: "#16a34a", bg: "#16a34a", color: "#fff" }
|
|
13016
13016
|
};
|
|
13017
13017
|
var CustomTaskItem = TaskItem.extend({
|
|
13018
|
+
addStorage() {
|
|
13019
|
+
return { taskTodoEnabled: true };
|
|
13020
|
+
},
|
|
13018
13021
|
addAttributes() {
|
|
13019
13022
|
return {
|
|
13020
13023
|
...this.parent?.(),
|
|
@@ -13041,6 +13044,27 @@ var CustomTaskItem = TaskItem.extend({
|
|
|
13041
13044
|
}
|
|
13042
13045
|
}
|
|
13043
13046
|
if (taskDepth === -1) return false;
|
|
13047
|
+
if (this.editor.storage.taskTodoEnabled === false) {
|
|
13048
|
+
const afterContent2 = $from.parent.content.cut($from.parentOffset);
|
|
13049
|
+
const schema2 = state.schema;
|
|
13050
|
+
const tr2 = state.tr;
|
|
13051
|
+
if (afterContent2.size > 0) {
|
|
13052
|
+
tr2.delete($from.pos, $from.end());
|
|
13053
|
+
}
|
|
13054
|
+
let taskListDepth = -1;
|
|
13055
|
+
for (let d = taskDepth - 1; d >= 0; d--) {
|
|
13056
|
+
if ($from.node(d).type.name === "taskList") {
|
|
13057
|
+
taskListDepth = d;
|
|
13058
|
+
break;
|
|
13059
|
+
}
|
|
13060
|
+
}
|
|
13061
|
+
const insertPos2 = taskListDepth !== -1 ? tr2.mapping.map($from.after(taskListDepth)) : tr2.mapping.map($from.after(taskDepth));
|
|
13062
|
+
const newPara2 = afterContent2.size > 0 ? schema2.nodes.paragraph.create(null, afterContent2) : schema2.nodes.paragraph.create();
|
|
13063
|
+
tr2.insert(insertPos2, newPara2);
|
|
13064
|
+
tr2.setSelection(TextSelection.near(tr2.doc.resolve(insertPos2 + 1)));
|
|
13065
|
+
this.editor.view.dispatch(tr2);
|
|
13066
|
+
return true;
|
|
13067
|
+
}
|
|
13044
13068
|
const taskNode = $from.node(taskDepth);
|
|
13045
13069
|
const status = taskNode.attrs.status || "todo";
|
|
13046
13070
|
const schema = state.schema;
|
|
@@ -13100,7 +13124,10 @@ var CustomTaskItem = TaskItem.extend({
|
|
|
13100
13124
|
const from = $from.before(taskItemDepth);
|
|
13101
13125
|
const to = $from.after(taskItemDepth);
|
|
13102
13126
|
tr.delete(from, to);
|
|
13103
|
-
|
|
13127
|
+
const prevPos = Math.max(0, from - 1);
|
|
13128
|
+
const $prev = tr.doc.resolve(prevPos);
|
|
13129
|
+
const cursorPos = $prev.end($prev.depth);
|
|
13130
|
+
tr.setSelection(TextSelection.create(tr.doc, cursorPos));
|
|
13104
13131
|
this.editor.view.dispatch(tr);
|
|
13105
13132
|
return true;
|
|
13106
13133
|
}
|
|
@@ -13670,6 +13697,7 @@ var ColorPickerPanel = ({ editor, onClose }) => {
|
|
|
13670
13697
|
var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTextToSpeech, onClose, onImageUpload }) => {
|
|
13671
13698
|
const [, setEditorState] = useState31(0);
|
|
13672
13699
|
const [isFullscreen, setIsFullscreen] = useState31(false);
|
|
13700
|
+
const [todoEnabled, setTodoEnabled] = useState31(false);
|
|
13673
13701
|
useEffect24(() => {
|
|
13674
13702
|
if (!editor) return;
|
|
13675
13703
|
const onTransaction = () => setEditorState((n) => n + 1);
|
|
@@ -14170,24 +14198,25 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
14170
14198
|
{
|
|
14171
14199
|
trigger: { label: /* @__PURE__ */ React113.createElement(IconCode, null), title: "Code", className: editor.isActive("code") || editor.isActive("codeBlock") ? "is-active" : "" }
|
|
14172
14200
|
},
|
|
14173
|
-
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () =>
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
})();
|
|
14183
|
-
if (text) {
|
|
14201
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
14202
|
+
if (editor.isActive("codeBlock")) {
|
|
14203
|
+
const text = (() => {
|
|
14204
|
+
const { $from } = editor.state.selection;
|
|
14205
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
14206
|
+
if ($from.node(d).type.name === "codeBlock") return $from.node(d).textContent;
|
|
14207
|
+
}
|
|
14208
|
+
return "";
|
|
14209
|
+
})();
|
|
14184
14210
|
editor.chain().focus().toggleCodeBlock().run();
|
|
14185
|
-
|
|
14186
|
-
|
|
14211
|
+
if (text) {
|
|
14212
|
+
const { from } = editor.state.selection;
|
|
14213
|
+
editor.chain().focus().setTextSelection({ from, to: from + text.length }).toggleCode().run();
|
|
14214
|
+
}
|
|
14187
14215
|
} else {
|
|
14188
|
-
editor.chain().focus().
|
|
14216
|
+
editor.chain().focus().toggleCode().run();
|
|
14189
14217
|
}
|
|
14190
|
-
} }, "</>
|
|
14218
|
+
} }, "</>", " Inline Code"),
|
|
14219
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleCodeBlock().run() }, "{ }", " Code Block")
|
|
14191
14220
|
), /* @__PURE__ */ React113.createElement(
|
|
14192
14221
|
"button",
|
|
14193
14222
|
{
|
|
@@ -14207,11 +14236,15 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
14207
14236
|
), /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "", title: "Translate options", className: "translate-arrow-btn" } }, /* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => setShowTranslateModal(true) }, "Options")), translateStatus && /* @__PURE__ */ React113.createElement("span", { className: `translate-toast-popup ${translateStatus === "Please select the text" || translateStatus === "Translation failed" ? "error" : ""}` }, translateStatus)), /* @__PURE__ */ React113.createElement("div", { className: "todo-split-btn" }, /* @__PURE__ */ React113.createElement(
|
|
14208
14237
|
"button",
|
|
14209
14238
|
{
|
|
14210
|
-
className: `toolbar-btn ${
|
|
14239
|
+
className: `toolbar-btn ${todoEnabled ? "is-active" : ""}`,
|
|
14211
14240
|
onClick: () => {
|
|
14212
|
-
if (
|
|
14213
|
-
|
|
14241
|
+
if (todoEnabled) {
|
|
14242
|
+
setTodoEnabled(false);
|
|
14243
|
+
editor.storage.taskTodoEnabled = false;
|
|
14244
|
+
editor.chain().focus().run();
|
|
14214
14245
|
} else {
|
|
14246
|
+
setTodoEnabled(true);
|
|
14247
|
+
editor.storage.taskTodoEnabled = true;
|
|
14215
14248
|
const { state } = editor;
|
|
14216
14249
|
const { schema } = state;
|
|
14217
14250
|
const taskItemType = schema.nodes.taskItem;
|
|
@@ -14219,18 +14252,30 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
14219
14252
|
if (!taskItemType || !taskListType) return;
|
|
14220
14253
|
const statusText = schema.text("Todo");
|
|
14221
14254
|
const newTaskItem = taskItemType.create({ status: "todo", checked: false }, schema.nodes.paragraph.create(null, statusText));
|
|
14222
|
-
const
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14255
|
+
const { $from } = state.selection;
|
|
14256
|
+
let insideTask = false;
|
|
14257
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
14258
|
+
if ($from.node(d).type.name === "taskItem") {
|
|
14259
|
+
insideTask = true;
|
|
14260
|
+
break;
|
|
14261
|
+
}
|
|
14262
|
+
}
|
|
14263
|
+
if (insideTask) {
|
|
14264
|
+
editor.chain().focus().run();
|
|
14265
|
+
} else {
|
|
14266
|
+
const newTaskList = taskListType.create(null, newTaskItem);
|
|
14267
|
+
editor.chain().focus().command(({ tr, dispatch, state: cmdState }) => {
|
|
14268
|
+
if (!dispatch) return true;
|
|
14269
|
+
const pos = tr.selection.from;
|
|
14270
|
+
tr.replaceSelectionWith(newTaskList);
|
|
14271
|
+
const resolvedPos = tr.doc.resolve(pos + 2 + 4);
|
|
14272
|
+
tr.setSelection(cmdState.selection.constructor.near(resolvedPos));
|
|
14273
|
+
return true;
|
|
14274
|
+
}).run();
|
|
14275
|
+
}
|
|
14231
14276
|
}
|
|
14232
14277
|
},
|
|
14233
|
-
title:
|
|
14278
|
+
title: todoEnabled ? "Disable Task List" : "Enable Task List"
|
|
14234
14279
|
},
|
|
14235
14280
|
/* @__PURE__ */ React113.createElement(IconTaskList, null)
|
|
14236
14281
|
), /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "", title: "Task status", className: "todo-arrow-btn" }, keepOpen: true }, ["todo", "working", "blocked", "resolved"].map((status) => {
|