zs_library 0.4.12 → 0.4.13
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/components/desktop/types.d.ts +1 -1
- package/dist/components/desktop/utils.d.ts +1 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4146 -12
- package/package.json +1 -6
- package/dist/components/desktop/config.js +0 -15
- package/dist/components/desktop/context/config/context.js +0 -14
- package/dist/components/desktop/context/config/hooks.js +0 -7
- package/dist/components/desktop/context/state/context.js +0 -221
- package/dist/components/desktop/context/state/hooks.js +0 -7
- package/dist/components/desktop/context-menu/index.js +0 -312
- package/dist/components/desktop/index.js +0 -40
- package/dist/components/desktop/items/group-item.js +0 -305
- package/dist/components/desktop/items/modal/group-item-modal.js +0 -158
- package/dist/components/desktop/items/modal/info-modal.js +0 -33
- package/dist/components/desktop/items/sortable-item.js +0 -120
- package/dist/components/desktop/sortable.js +0 -272
- package/dist/components/desktop/style.js +0 -18
- package/dist/components/desktop/theme.js +0 -32
- package/dist/components/desktop/utils.js +0 -15
- package/dist/components/dock/dock-desktop.js +0 -83
- package/dist/components/dock/dock-mobile.js +0 -69
- package/dist/components/dock/index.js +0 -24
- package/dist/components/dock/utils.js +0 -9
- package/dist/components/editor/editor.js +0 -199
- package/dist/components/editor/extensions/drag-handle/clipboard-serializer.js +0 -20
- package/dist/components/editor/extensions/drag-handle/index.js +0 -273
- package/dist/components/editor/extensions.js +0 -131
- package/dist/components/editor/generative/ai-completion-command.js +0 -59
- package/dist/components/editor/generative/ai-selector-commands.js +0 -78
- package/dist/components/editor/generative/ai-selector.js +0 -90
- package/dist/components/editor/generative/drag-handle.js +0 -70
- package/dist/components/editor/generative/generative-dropdown-menu.js +0 -55
- package/dist/components/editor/generative/generative-menu-switch.js +0 -59
- package/dist/components/editor/image-upload.js +0 -36
- package/dist/components/editor/index.js +0 -8
- package/dist/components/editor/lib/colors.js +0 -98
- package/dist/components/editor/lib/content.js +0 -8
- package/dist/components/editor/lib/nodes.js +0 -70
- package/dist/components/editor/lib/url-utils.js +0 -21
- package/dist/components/editor/preview.js +0 -12
- package/dist/components/editor/selectors/color-selector.js +0 -100
- package/dist/components/editor/selectors/link-selector.js +0 -82
- package/dist/components/editor/selectors/math-selector.js +0 -37
- package/dist/components/editor/selectors/node-selector.js +0 -56
- package/dist/components/editor/selectors/text-buttons.js +0 -75
- package/dist/components/editor/slash-command.js +0 -129
- package/dist/components/editor/ui/button.js +0 -44
- package/dist/components/editor/ui/command.js +0 -94
- package/dist/components/editor/ui/dialog.js +0 -68
- package/dist/components/editor/ui/dropdown-menu.js +0 -99
- package/dist/components/editor/ui/icons/crazy-spinner.js +0 -10
- package/dist/components/editor/ui/popover.js +0 -24
- package/dist/components/editor/ui/scroll-area.js +0 -39
- package/dist/components/editor/ui/separator.js +0 -25
- package/dist/components/editor/ui/tooltip.js +0 -25
- package/dist/components/md-editor/editor.js +0 -104
- package/dist/components/md-editor/i18n/index.js +0 -12
- package/dist/components/md-editor/i18n/zh_CN.js +0 -122
- package/dist/components/md-editor/index.js +0 -8
- package/dist/components/md-editor/preview.js +0 -81
- package/dist/components/md-editor/style.js +0 -267
- package/dist/components/md-editor/utils.js +0 -8
- package/dist/i18n/index.js +0 -23
- package/dist/i18n/locales/en-US.js +0 -30
- package/dist/i18n/locales/zh-CN.js +0 -30
- package/dist/node_modules/.pnpm/@tiptap_pm@2.11.5/node_modules/@tiptap/pm/view/dist/index.js +0 -3
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
3
|
-
import { createImageUpload as Q, EditorRoot as V, EditorContent as Y, handleImageDrop as Z, handleImagePaste as ee, handleCommandNavigation as te, EditorCommand as oe, EditorCommandEmpty as ne, EditorCommandList as re, EditorCommandItem as ae, ImageResizer as se } from "novel";
|
|
4
|
-
import { useState as a, useMemo as ie, useEffect as le } from "react";
|
|
5
|
-
import { useDebouncedCallback as de } from "use-debounce";
|
|
6
|
-
import { defaultExtensions as me } from "./extensions.js";
|
|
7
|
-
import { ColorSelector as ce } from "./selectors/color-selector.js";
|
|
8
|
-
import { LinkSelector as pe } from "./selectors/link-selector.js";
|
|
9
|
-
import { MathSelector as ue } from "./selectors/math-selector.js";
|
|
10
|
-
import { NodeSelector as fe } from "./selectors/node-selector.js";
|
|
11
|
-
import { Separator as l } from "./ui/separator.js";
|
|
12
|
-
import he from "./generative/generative-menu-switch.js";
|
|
13
|
-
import { uploadFn as ge } from "./image-upload.js";
|
|
14
|
-
import { TextButtons as we } from "./selectors/text-buttons.js";
|
|
15
|
-
import { slashCommand as xe, suggestionItems as be } from "./slash-command.js";
|
|
16
|
-
import ve from "highlight.js";
|
|
17
|
-
import { defaultEditorContent as Ce } from "./lib/content.js";
|
|
18
|
-
/* empty css */
|
|
19
|
-
/* empty css */
|
|
20
|
-
import { cx as Se } from "@emotion/css";
|
|
21
|
-
import Ee from "./generative/drag-handle.js";
|
|
22
|
-
const Ke = (F) => {
|
|
23
|
-
const {
|
|
24
|
-
className: M,
|
|
25
|
-
initialContent: j = {},
|
|
26
|
-
onChange: p,
|
|
27
|
-
cacheKey: u = "novel-content",
|
|
28
|
-
enableCache: i = !1,
|
|
29
|
-
showSaveStatus: w = !0,
|
|
30
|
-
showWordCount: x = !0,
|
|
31
|
-
uploadImageProps: f,
|
|
32
|
-
editorRef: b,
|
|
33
|
-
enableAI: v = !1,
|
|
34
|
-
aiOptions: z
|
|
35
|
-
} = F, [C, S] = a(
|
|
36
|
-
j
|
|
37
|
-
), [D, E] = a("Saved"), [N, P] = a(), [L, A] = a(!1), [T, U] = a(!1), [R, _] = a(!1), [B, J] = a(!1), W = (e) => {
|
|
38
|
-
const o = new DOMParser().parseFromString(e, "text/html");
|
|
39
|
-
return o.querySelectorAll("pre code").forEach((m) => {
|
|
40
|
-
ve.highlightElement(m);
|
|
41
|
-
}), new XMLSerializer().serializeToString(o);
|
|
42
|
-
}, H = de(
|
|
43
|
-
async (e) => {
|
|
44
|
-
const o = e.getJSON();
|
|
45
|
-
P(e.storage.characterCount.words()), p == null || p(o), i && (window.localStorage.setItem(
|
|
46
|
-
"html-content",
|
|
47
|
-
W(e.getHTML())
|
|
48
|
-
), window.localStorage.setItem(u, JSON.stringify(o)), window.localStorage.setItem(
|
|
49
|
-
"markdown",
|
|
50
|
-
e.storage.markdown.getMarkdown()
|
|
51
|
-
), E("Saved"));
|
|
52
|
-
},
|
|
53
|
-
500
|
|
54
|
-
), d = ie(() => {
|
|
55
|
-
if (!f) return ge;
|
|
56
|
-
const {
|
|
57
|
-
beforeUpload: e,
|
|
58
|
-
maxSize: o,
|
|
59
|
-
action: m,
|
|
60
|
-
headers: h,
|
|
61
|
-
method: q,
|
|
62
|
-
name: G,
|
|
63
|
-
onSuccess: y,
|
|
64
|
-
onError: I
|
|
65
|
-
} = f;
|
|
66
|
-
return Q({
|
|
67
|
-
onUpload: (s) => {
|
|
68
|
-
const O = new FormData();
|
|
69
|
-
O.append(G || "file", s);
|
|
70
|
-
const X = fetch(m, {
|
|
71
|
-
method: q || "POST",
|
|
72
|
-
headers: {
|
|
73
|
-
...h
|
|
74
|
-
},
|
|
75
|
-
body: O
|
|
76
|
-
});
|
|
77
|
-
return new Promise((g, $) => {
|
|
78
|
-
X.then(async (r) => {
|
|
79
|
-
if (y) {
|
|
80
|
-
const c = await r.json();
|
|
81
|
-
g(y(c));
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
if (r.status === 200) {
|
|
85
|
-
const { url: c } = await r.json(), k = new Image();
|
|
86
|
-
k.src = c, k.onload = () => {
|
|
87
|
-
g(c);
|
|
88
|
-
};
|
|
89
|
-
} else throw r.status === 401 ? (g(s), new Error(
|
|
90
|
-
"`BLOB_READ_WRITE_TOKEN` environment variable not found, reading image locally instead."
|
|
91
|
-
)) : new Error("Error uploading image. Please try again.");
|
|
92
|
-
}).catch((r) => {
|
|
93
|
-
I && I(r), $(r);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
validateFn: (s) => e ? e(s) : s.type.includes("image/") ? o && s.size > o ? (console.error("File size too big (max 20MB)."), !1) : !0 : (console.error("File type not supported."), !1)
|
|
98
|
-
});
|
|
99
|
-
}, [f]);
|
|
100
|
-
if (le(() => {
|
|
101
|
-
if (!i) return;
|
|
102
|
-
const e = window.localStorage.getItem(u);
|
|
103
|
-
S(e ? JSON.parse(e) : Ce);
|
|
104
|
-
}, [u, i]), !C) return null;
|
|
105
|
-
const K = [
|
|
106
|
-
...me,
|
|
107
|
-
xe({
|
|
108
|
-
uploadFn: d
|
|
109
|
-
})
|
|
110
|
-
];
|
|
111
|
-
return /* @__PURE__ */ n("div", { className: Se("relative w-full max-w-screen-lg", M), children: [
|
|
112
|
-
(i && w || x) && /* @__PURE__ */ n("div", { className: "flex absolute right-5 top-5 z-10 mb-5 gap-2", children: [
|
|
113
|
-
i && w && /* @__PURE__ */ t("div", { className: "rounded-lg bg-accent px-2 py-1 text-sm text-muted-foreground", children: D }),
|
|
114
|
-
x && /* @__PURE__ */ n(
|
|
115
|
-
"div",
|
|
116
|
-
{
|
|
117
|
-
className: N ? "rounded-lg bg-accent px-2 py-1 text-sm text-muted-foreground" : "hidden",
|
|
118
|
-
children: [
|
|
119
|
-
N,
|
|
120
|
-
" Words"
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
)
|
|
124
|
-
] }),
|
|
125
|
-
/* @__PURE__ */ t(V, { children: /* @__PURE__ */ n(
|
|
126
|
-
Y,
|
|
127
|
-
{
|
|
128
|
-
onCreate: ({ editor: e }) => {
|
|
129
|
-
b && (b.current = e);
|
|
130
|
-
},
|
|
131
|
-
initialContent: C,
|
|
132
|
-
extensions: K,
|
|
133
|
-
className: "relative min-h-[500px] w-full max-w-screen-lg border-muted bg-background sm:mb-[calc(20vh)] sm:rounded-lg sm:border sm:shadow-lg editor-content",
|
|
134
|
-
editorProps: {
|
|
135
|
-
handleDOMEvents: {
|
|
136
|
-
keydown: (e, o) => te(o)
|
|
137
|
-
},
|
|
138
|
-
handlePaste: (e, o) => ee(e, o, d),
|
|
139
|
-
handleDrop: (e, o, m, h) => Z(e, o, h, d),
|
|
140
|
-
attributes: {
|
|
141
|
-
class: "prose prose-lg dark:prose-invert prose-headings:font-title font-default focus:outline-none max-w-full"
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
onUpdate: ({ editor: e }) => {
|
|
145
|
-
H(e), E("Unsaved");
|
|
146
|
-
},
|
|
147
|
-
slotAfter: /* @__PURE__ */ t(se, {}),
|
|
148
|
-
children: [
|
|
149
|
-
/* @__PURE__ */ n(oe, { className: "z-50 h-auto max-h-[330px] overflow-y-auto rounded-md border border-muted bg-background px-1 py-2 shadow-md transition-all", children: [
|
|
150
|
-
/* @__PURE__ */ t(ne, { className: "px-2 text-muted-foreground", children: "没有结果" }),
|
|
151
|
-
/* @__PURE__ */ t(re, { children: be({
|
|
152
|
-
uploadFn: d
|
|
153
|
-
}).map((e) => /* @__PURE__ */ n(
|
|
154
|
-
ae,
|
|
155
|
-
{
|
|
156
|
-
value: e.title,
|
|
157
|
-
onCommand: (o) => e.command(o),
|
|
158
|
-
className: "flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm hover:bg-accent aria-selected:bg-accent",
|
|
159
|
-
children: [
|
|
160
|
-
/* @__PURE__ */ t("div", { className: "flex h-10 w-10 items-center justify-center rounded-md border border-muted bg-background", children: e.icon }),
|
|
161
|
-
/* @__PURE__ */ n("div", { children: [
|
|
162
|
-
/* @__PURE__ */ t("p", { className: "font-medium", children: e.title }),
|
|
163
|
-
/* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: e.description })
|
|
164
|
-
] })
|
|
165
|
-
]
|
|
166
|
-
},
|
|
167
|
-
e.title
|
|
168
|
-
)) })
|
|
169
|
-
] }),
|
|
170
|
-
/* @__PURE__ */ n(
|
|
171
|
-
he,
|
|
172
|
-
{
|
|
173
|
-
open: B,
|
|
174
|
-
onOpenChange: J,
|
|
175
|
-
enableAI: v,
|
|
176
|
-
aiOptions: z,
|
|
177
|
-
children: [
|
|
178
|
-
v && /* @__PURE__ */ t(l, { orientation: "vertical" }),
|
|
179
|
-
/* @__PURE__ */ t(fe, { open: L, onOpenChange: A }),
|
|
180
|
-
/* @__PURE__ */ t(l, { orientation: "vertical" }),
|
|
181
|
-
/* @__PURE__ */ t(pe, { open: R, onOpenChange: _ }),
|
|
182
|
-
/* @__PURE__ */ t(l, { orientation: "vertical" }),
|
|
183
|
-
/* @__PURE__ */ t(ue, {}),
|
|
184
|
-
/* @__PURE__ */ t(l, { orientation: "vertical" }),
|
|
185
|
-
/* @__PURE__ */ t(we, {}),
|
|
186
|
-
/* @__PURE__ */ t(l, { orientation: "vertical" }),
|
|
187
|
-
/* @__PURE__ */ t(ce, { open: T, onOpenChange: U })
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
),
|
|
191
|
-
/* @__PURE__ */ t(Ee, {})
|
|
192
|
-
]
|
|
193
|
-
}
|
|
194
|
-
) })
|
|
195
|
-
] });
|
|
196
|
-
};
|
|
197
|
-
export {
|
|
198
|
-
Ke as Editor
|
|
199
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
import * as t from "../../../../node_modules/.pnpm/@tiptap_pm@2.11.5/node_modules/@tiptap/pm/view/dist/index.js";
|
|
3
|
-
function e() {
|
|
4
|
-
try {
|
|
5
|
-
return t;
|
|
6
|
-
} catch {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function a(r, i) {
|
|
11
|
-
if (r && typeof r.serializeForClipboard == "function")
|
|
12
|
-
return r.serializeForClipboard(i);
|
|
13
|
-
const o = e();
|
|
14
|
-
if (o && typeof (o == null ? void 0 : o.__serializeForClipboard) == "function")
|
|
15
|
-
return o.__serializeForClipboard(r, i);
|
|
16
|
-
throw new Error("No supported clipboard serialization method found.");
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
a as serializeForClipboard
|
|
20
|
-
};
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
import { Extension as E } from "@tiptap/core";
|
|
3
|
-
import { Plugin as $, PluginKey as O, NodeSelection as h, TextSelection as R } from "prosemirror-state";
|
|
4
|
-
import { Slice as M, Fragment as W } from "prosemirror-model";
|
|
5
|
-
import { serializeForClipboard as Y } from "./clipboard-serializer.js";
|
|
6
|
-
function k(n) {
|
|
7
|
-
const c = n.getBoundingClientRect(), a = n.closest('[role="dialog"]'), p = n.closest(".ProseMirror"), t = p == null ? void 0 : p.getBoundingClientRect(), d = window.pageXOffset || document.documentElement.scrollLeft, L = window.pageYOffset || document.documentElement.scrollTop;
|
|
8
|
-
if (a && window.getComputedStyle(a).transform !== "none") {
|
|
9
|
-
const S = a.getBoundingClientRect();
|
|
10
|
-
return {
|
|
11
|
-
top: c.top - S.top + L,
|
|
12
|
-
left: c.left - S.left + d,
|
|
13
|
-
width: c.width
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
top: t ? c.top - t.top : c.top + L,
|
|
18
|
-
left: t ? c.left - t.left : c.left + d,
|
|
19
|
-
width: c.width
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function H(n, c) {
|
|
23
|
-
const a = [
|
|
24
|
-
"li",
|
|
25
|
-
"p:not(:first-child)",
|
|
26
|
-
"pre",
|
|
27
|
-
"blockquote",
|
|
28
|
-
"h1",
|
|
29
|
-
"h2",
|
|
30
|
-
"h3",
|
|
31
|
-
"h4",
|
|
32
|
-
"h5",
|
|
33
|
-
"h6",
|
|
34
|
-
...c.customNodes.map((p) => `[data-type=${p}]`)
|
|
35
|
-
].join(", ");
|
|
36
|
-
return document.elementsFromPoint(n.x, n.y).find(
|
|
37
|
-
(p) => {
|
|
38
|
-
var t, d;
|
|
39
|
-
return ((d = (t = p.parentElement) == null ? void 0 : t.matches) == null ? void 0 : d.call(t, ".ProseMirror")) || p.matches(a);
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
function x(n, c, a) {
|
|
44
|
-
var t;
|
|
45
|
-
const p = n.getBoundingClientRect();
|
|
46
|
-
return (t = c.posAtCoords({
|
|
47
|
-
left: p.left + 50 + a.dragHandleWidth,
|
|
48
|
-
top: p.top + 1
|
|
49
|
-
})) == null ? void 0 : t.inside;
|
|
50
|
-
}
|
|
51
|
-
function D(n, c) {
|
|
52
|
-
const a = c.state.doc.resolve(n);
|
|
53
|
-
return a.depth > 1 ? a.before(a.depth) : n;
|
|
54
|
-
}
|
|
55
|
-
function A(n) {
|
|
56
|
-
let c = "", a = !1;
|
|
57
|
-
function p(e, o) {
|
|
58
|
-
if (o.focus(), !e.dataTransfer) return;
|
|
59
|
-
const s = H(
|
|
60
|
-
{
|
|
61
|
-
x: e.clientX + 50 + n.dragHandleWidth,
|
|
62
|
-
y: e.clientY
|
|
63
|
-
},
|
|
64
|
-
n
|
|
65
|
-
);
|
|
66
|
-
if (!(s instanceof Element)) return;
|
|
67
|
-
let r = x(s, o, n);
|
|
68
|
-
if (r == null || r < 0) return;
|
|
69
|
-
r = D(r, o);
|
|
70
|
-
const { from: u, to: f } = o.state.selection, g = u - f, y = D(u, o);
|
|
71
|
-
let m = !1;
|
|
72
|
-
const i = o.state.doc.resolve(y);
|
|
73
|
-
if (i.node().type.name === "doc") m = !0;
|
|
74
|
-
else {
|
|
75
|
-
const P = h.create(
|
|
76
|
-
o.state.doc,
|
|
77
|
-
i.before()
|
|
78
|
-
);
|
|
79
|
-
m = !(r + 1 >= P.$from.pos && r <= P.$to.pos);
|
|
80
|
-
}
|
|
81
|
-
let l = o.state.selection;
|
|
82
|
-
if (!m && g !== 0 && !(o.state.selection instanceof h)) {
|
|
83
|
-
const P = h.create(o.state.doc, f - 1);
|
|
84
|
-
l = R.create(
|
|
85
|
-
o.state.doc,
|
|
86
|
-
r,
|
|
87
|
-
P.$to.pos
|
|
88
|
-
);
|
|
89
|
-
} else if (l = h.create(o.state.doc, r), l.node.type.isInline || l.node.type.name === "tableRow") {
|
|
90
|
-
const P = o.state.doc.resolve(l.from);
|
|
91
|
-
l = h.create(o.state.doc, P.before());
|
|
92
|
-
}
|
|
93
|
-
o.dispatch(o.state.tr.setSelection(l)), o.state.selection instanceof h && o.state.selection.node.type.name === "listItem" && (c = s.parentElement.tagName);
|
|
94
|
-
const T = o.state.selection.content(), { dom: C, text: I } = Y(o, T);
|
|
95
|
-
e.dataTransfer.clearData(), e.dataTransfer.setData("text/html", C.innerHTML), e.dataTransfer.setData("text/plain", I), e.dataTransfer.effectAllowed = "copyMove", e.dataTransfer.setDragImage(s, 0, 0), o.dragging = { slice: T, move: e.ctrlKey };
|
|
96
|
-
}
|
|
97
|
-
let t = null;
|
|
98
|
-
function d() {
|
|
99
|
-
t && t.classList.add("hide");
|
|
100
|
-
}
|
|
101
|
-
function L() {
|
|
102
|
-
t && t.classList.remove("hide");
|
|
103
|
-
}
|
|
104
|
-
function S(e, o) {
|
|
105
|
-
const s = D(o, e), r = h.create(e.state.doc, s);
|
|
106
|
-
e.dispatch(e.state.tr.setSelection(r)), e.focus(), a = !0;
|
|
107
|
-
}
|
|
108
|
-
function N(e) {
|
|
109
|
-
if (a = e.state.selection instanceof h, a && (t != null && t.dataset.nodePos)) {
|
|
110
|
-
const s = parseInt(t.dataset.nodePos, 10);
|
|
111
|
-
try {
|
|
112
|
-
const r = e.state.doc.resolve(s);
|
|
113
|
-
r && r.parent && r.parent.type.name !== "doc" || (a = !1, d());
|
|
114
|
-
} catch {
|
|
115
|
-
a = !1, d();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
a && t && !t.classList.contains("hide") ? L() : a || d();
|
|
119
|
-
}
|
|
120
|
-
function b(e) {
|
|
121
|
-
if (!(e.target instanceof Element)) return;
|
|
122
|
-
const o = e.relatedTarget;
|
|
123
|
-
if (!o) {
|
|
124
|
-
a || d();
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const s = o.closest(".drag-handle") || o.classList.contains("drag-handle"), r = o.closest(".tiptap") || o.classList.contains("tiptap");
|
|
128
|
-
!s && !r && !a && d();
|
|
129
|
-
}
|
|
130
|
-
return new $({
|
|
131
|
-
key: new O(n.pluginKey),
|
|
132
|
-
view: (e) => {
|
|
133
|
-
var f, g, y, m;
|
|
134
|
-
const o = n.dragHandleSelector ? document.querySelector(n.dragHandleSelector) : null;
|
|
135
|
-
t = o ?? document.createElement("div"), t.draggable = !0, t.dataset.dragHandle = "", t.classList.add("drag-handle");
|
|
136
|
-
function s(i) {
|
|
137
|
-
p(i, e);
|
|
138
|
-
}
|
|
139
|
-
t.addEventListener("dragstart", s);
|
|
140
|
-
function r(i) {
|
|
141
|
-
o || (i.preventDefault(), i.stopPropagation());
|
|
142
|
-
const l = t == null ? void 0 : t.dataset.nodePos;
|
|
143
|
-
l && S(e, parseInt(l, 10));
|
|
144
|
-
}
|
|
145
|
-
t.addEventListener("click", r);
|
|
146
|
-
function u(i) {
|
|
147
|
-
d();
|
|
148
|
-
const l = window.scrollY;
|
|
149
|
-
i.clientY < n.scrollTreshold ? window.scrollTo({ top: l - 30, behavior: "smooth" }) : window.innerHeight - i.clientY < n.scrollTreshold && window.scrollTo({ top: l + 30, behavior: "smooth" });
|
|
150
|
-
}
|
|
151
|
-
return t.addEventListener("drag", u), d(), o || (g = (f = e == null ? void 0 : e.dom) == null ? void 0 : f.parentElement) == null || g.appendChild(t), (m = (y = e == null ? void 0 : e.dom) == null ? void 0 : y.parentElement) == null || m.addEventListener(
|
|
152
|
-
"mouseout",
|
|
153
|
-
b
|
|
154
|
-
), {
|
|
155
|
-
destroy: () => {
|
|
156
|
-
var i, l, T;
|
|
157
|
-
o || (i = t == null ? void 0 : t.remove) == null || i.call(t), t == null || t.removeEventListener("drag", u), t == null || t.removeEventListener(
|
|
158
|
-
"dragstart",
|
|
159
|
-
s
|
|
160
|
-
), t == null || t.removeEventListener("click", r), t = null, (T = (l = e == null ? void 0 : e.dom) == null ? void 0 : l.parentElement) == null || T.removeEventListener(
|
|
161
|
-
"mouseout",
|
|
162
|
-
b
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
},
|
|
167
|
-
props: {
|
|
168
|
-
handleDOMEvents: {
|
|
169
|
-
mousemove: (e, o) => {
|
|
170
|
-
if (!e.editable)
|
|
171
|
-
return;
|
|
172
|
-
const s = H(
|
|
173
|
-
{
|
|
174
|
-
x: o.clientX + 50 + n.dragHandleWidth,
|
|
175
|
-
y: o.clientY
|
|
176
|
-
},
|
|
177
|
-
n
|
|
178
|
-
), r = s == null ? void 0 : s.closest(".not-draggable"), u = n.excludedTags.concat(["ol", "ul"]).join(", ");
|
|
179
|
-
if (!(s instanceof Element) || s.matches(u) || r) {
|
|
180
|
-
a || d();
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
const f = x(s, e, n);
|
|
184
|
-
f != null && f >= 0 && (t.dataset.nodePos = String(
|
|
185
|
-
D(f, e)
|
|
186
|
-
));
|
|
187
|
-
const g = window.getComputedStyle(s), y = parseInt(g.lineHeight, 10), m = isNaN(y) ? parseInt(g.fontSize) * 1.2 : y, i = parseInt(g.paddingTop, 10), l = k(s);
|
|
188
|
-
l.top += (m - 24) / 2, l.top += i, s.matches("ul:not([data-type=taskList]) li, ol li") && (l.left -= n.dragHandleWidth - 28), l.width = n.dragHandleWidth, t && (t.style.position = "absolute", t.style.left = `${l.left - l.width}px`, t.style.top = `${l.top}px`, L());
|
|
189
|
-
},
|
|
190
|
-
keydown: () => {
|
|
191
|
-
a || d();
|
|
192
|
-
},
|
|
193
|
-
mousewheel: () => {
|
|
194
|
-
a || d();
|
|
195
|
-
},
|
|
196
|
-
// 在选择状态变化时更新拖拽按钮的状态
|
|
197
|
-
selectionChange: (e) => {
|
|
198
|
-
N(e);
|
|
199
|
-
},
|
|
200
|
-
// dragging class is used for CSS
|
|
201
|
-
dragstart: (e) => {
|
|
202
|
-
e.dom.classList.add("dragging");
|
|
203
|
-
},
|
|
204
|
-
drop: (e, o) => {
|
|
205
|
-
var g;
|
|
206
|
-
e.dom.classList.remove("dragging"), d();
|
|
207
|
-
let s = null;
|
|
208
|
-
const r = e.posAtCoords({
|
|
209
|
-
left: o.clientX,
|
|
210
|
-
top: o.clientY
|
|
211
|
-
});
|
|
212
|
-
if (!r || (e.state.selection instanceof h && (s = e.state.selection.node), !s)) return;
|
|
213
|
-
const f = e.state.doc.resolve(r.pos).parent.type.name === "listItem";
|
|
214
|
-
if (e.state.selection instanceof h && e.state.selection.node.type.name === "listItem" && !f && c == "OL") {
|
|
215
|
-
const y = (g = e.state.schema.nodes.orderedList) == null ? void 0 : g.createAndFill(
|
|
216
|
-
null,
|
|
217
|
-
s
|
|
218
|
-
), m = new M(W.from(y), 0, 0);
|
|
219
|
-
e.dragging = { slice: m, move: o.ctrlKey };
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
dragend: (e) => {
|
|
223
|
-
e.dom.classList.remove("dragging");
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
// 简化对文档变化的监听
|
|
228
|
-
state: {
|
|
229
|
-
init() {
|
|
230
|
-
return {};
|
|
231
|
-
},
|
|
232
|
-
apply(e, o, s, r) {
|
|
233
|
-
if (e.docChanged && t && t.dataset.nodePos) {
|
|
234
|
-
const u = parseInt(t.dataset.nodePos, 10);
|
|
235
|
-
try {
|
|
236
|
-
const f = r.doc.resolve(u);
|
|
237
|
-
(!f || f.parent.type.name === "doc") && (a = !1, d());
|
|
238
|
-
} catch {
|
|
239
|
-
a = !1, d();
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return o;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
const j = E.create({
|
|
248
|
-
name: "globalDragHandle",
|
|
249
|
-
addOptions() {
|
|
250
|
-
return {
|
|
251
|
-
dragHandleWidth: 20,
|
|
252
|
-
scrollTreshold: 100,
|
|
253
|
-
excludedTags: [],
|
|
254
|
-
customNodes: []
|
|
255
|
-
};
|
|
256
|
-
},
|
|
257
|
-
addProseMirrorPlugins() {
|
|
258
|
-
return [
|
|
259
|
-
A({
|
|
260
|
-
pluginKey: "globalDragHandle",
|
|
261
|
-
dragHandleWidth: this.options.dragHandleWidth,
|
|
262
|
-
scrollTreshold: this.options.scrollTreshold,
|
|
263
|
-
dragHandleSelector: this.options.dragHandleSelector,
|
|
264
|
-
excludedTags: this.options.excludedTags,
|
|
265
|
-
customNodes: this.options.customNodes
|
|
266
|
-
})
|
|
267
|
-
];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
export {
|
|
271
|
-
A as DragHandlePlugin,
|
|
272
|
-
j as default
|
|
273
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
import { Placeholder as e, TiptapLink as r, TiptapImage as o, UploadImagesPlugin as s, UpdatedImage as i, TaskList as a, TaskItem as l, HorizontalRule as n, StarterKit as d, CodeBlockLowlight as c, Mathematics as u, CharacterCount as m, AIHighlight as g, TiptapUnderline as f, HighlightExtension as p, TextStyle as b, Color as h, CustomKeymap as L } from "novel";
|
|
3
|
-
import { Markdown as H } from "tiptap-markdown";
|
|
4
|
-
import { cx as t } from "class-variance-authority";
|
|
5
|
-
import { createLowlight as T, common as k } from "lowlight";
|
|
6
|
-
import x from "./extensions/drag-handle/index.js";
|
|
7
|
-
const M = g, A = e.configure({
|
|
8
|
-
placeholder: "撰写任何内容,或者按“/”输入命令..."
|
|
9
|
-
}), w = r.configure({
|
|
10
|
-
HTMLAttributes: {
|
|
11
|
-
class: t(
|
|
12
|
-
"text-muted-foreground underline underline-offset-[3px] hover:text-primary transition-colors cursor-pointer"
|
|
13
|
-
)
|
|
14
|
-
}
|
|
15
|
-
}), C = o.extend({
|
|
16
|
-
addProseMirrorPlugins() {
|
|
17
|
-
return [
|
|
18
|
-
s({
|
|
19
|
-
imageClass: t("opacity-40 rounded-lg border border-stone-200")
|
|
20
|
-
})
|
|
21
|
-
];
|
|
22
|
-
}
|
|
23
|
-
}).configure({
|
|
24
|
-
allowBase64: !0,
|
|
25
|
-
HTMLAttributes: {
|
|
26
|
-
class: t("rounded-lg border border-muted")
|
|
27
|
-
}
|
|
28
|
-
}), I = i.configure({
|
|
29
|
-
HTMLAttributes: {
|
|
30
|
-
class: t("rounded-lg border border-muted")
|
|
31
|
-
}
|
|
32
|
-
}), y = a.configure({
|
|
33
|
-
HTMLAttributes: {
|
|
34
|
-
class: t("not-prose pl-2 ")
|
|
35
|
-
}
|
|
36
|
-
}), E = l.configure({
|
|
37
|
-
HTMLAttributes: {
|
|
38
|
-
class: t("flex gap-2 items-start my-4")
|
|
39
|
-
},
|
|
40
|
-
nested: !0
|
|
41
|
-
}), B = n.configure({
|
|
42
|
-
HTMLAttributes: {
|
|
43
|
-
class: t("mt-4 mb-6 border-t border-muted-foreground")
|
|
44
|
-
}
|
|
45
|
-
}), P = d.configure({
|
|
46
|
-
bulletList: {
|
|
47
|
-
HTMLAttributes: {
|
|
48
|
-
class: t("list-disc list-outside leading-3 -mt-2")
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
orderedList: {
|
|
52
|
-
HTMLAttributes: {
|
|
53
|
-
class: t("list-decimal list-outside leading-3 -mt-2")
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
listItem: {
|
|
57
|
-
HTMLAttributes: {
|
|
58
|
-
class: t("leading-normal -mb-2")
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
blockquote: {
|
|
62
|
-
HTMLAttributes: {
|
|
63
|
-
class: t("border-l-4 border-primary")
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
codeBlock: {
|
|
67
|
-
HTMLAttributes: {
|
|
68
|
-
class: t(
|
|
69
|
-
"rounded-md bg-muted text-muted-foreground border p-5 font-mono font-medium"
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
code: {
|
|
74
|
-
HTMLAttributes: {
|
|
75
|
-
class: t("rounded-md bg-muted px-1.5 py-1 font-mono font-medium"),
|
|
76
|
-
spellcheck: "false"
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
horizontalRule: !1,
|
|
80
|
-
dropcursor: {
|
|
81
|
-
color: "#DBEAFE",
|
|
82
|
-
width: 4
|
|
83
|
-
},
|
|
84
|
-
gapcursor: !1
|
|
85
|
-
}), z = c.configure({
|
|
86
|
-
// configure lowlight: common / all / use highlightJS in case there is a need to specify certain language grammars only
|
|
87
|
-
// common: covers 37 language grammars which should be good enough in most cases
|
|
88
|
-
lowlight: T(k)
|
|
89
|
-
}), K = u.configure({
|
|
90
|
-
HTMLAttributes: {
|
|
91
|
-
class: t("text-foreground rounded p-1 hover:bg-accent cursor-pointer")
|
|
92
|
-
},
|
|
93
|
-
katexOptions: {
|
|
94
|
-
throwOnError: !1
|
|
95
|
-
}
|
|
96
|
-
}), R = m.configure(), S = H.configure({
|
|
97
|
-
html: !0,
|
|
98
|
-
tightLists: !0,
|
|
99
|
-
tightListClass: "tight",
|
|
100
|
-
bulletListMarker: "-",
|
|
101
|
-
linkify: !1,
|
|
102
|
-
breaks: !1,
|
|
103
|
-
transformPastedText: !1,
|
|
104
|
-
transformCopiedText: !1
|
|
105
|
-
}), U = x.configure({
|
|
106
|
-
dragHandleWidth: 56,
|
|
107
|
-
dragHandleSelector: ".custom-drag-handle"
|
|
108
|
-
}), W = [
|
|
109
|
-
P,
|
|
110
|
-
A,
|
|
111
|
-
w,
|
|
112
|
-
C,
|
|
113
|
-
I,
|
|
114
|
-
y,
|
|
115
|
-
E,
|
|
116
|
-
B,
|
|
117
|
-
M,
|
|
118
|
-
z,
|
|
119
|
-
K,
|
|
120
|
-
R,
|
|
121
|
-
f,
|
|
122
|
-
S,
|
|
123
|
-
p,
|
|
124
|
-
b,
|
|
125
|
-
h,
|
|
126
|
-
L,
|
|
127
|
-
U
|
|
128
|
-
];
|
|
129
|
-
export {
|
|
130
|
-
W as defaultExtensions
|
|
131
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
import { jsxs as e, Fragment as c, jsx as t } from "react/jsx-runtime";
|
|
3
|
-
import { CommandGroup as a, CommandItem as n, CommandSeparator as i } from "../ui/command.js";
|
|
4
|
-
import { useEditor as l } from "novel";
|
|
5
|
-
import { Check as d, TextQuote as u, TrashIcon as h } from "lucide-react";
|
|
6
|
-
const N = ({
|
|
7
|
-
completion: s,
|
|
8
|
-
onDiscard: m
|
|
9
|
-
}) => {
|
|
10
|
-
const { editor: o } = l();
|
|
11
|
-
return /* @__PURE__ */ e(c, { children: [
|
|
12
|
-
/* @__PURE__ */ e(a, { children: [
|
|
13
|
-
/* @__PURE__ */ e(
|
|
14
|
-
n,
|
|
15
|
-
{
|
|
16
|
-
className: "gap-2 px-4",
|
|
17
|
-
value: "replace",
|
|
18
|
-
onSelect: () => {
|
|
19
|
-
const r = o.view.state.selection;
|
|
20
|
-
o.chain().focus().insertContentAt(
|
|
21
|
-
{
|
|
22
|
-
from: r.from,
|
|
23
|
-
to: r.to
|
|
24
|
-
},
|
|
25
|
-
s
|
|
26
|
-
).run();
|
|
27
|
-
},
|
|
28
|
-
children: [
|
|
29
|
-
/* @__PURE__ */ t(d, { className: "h-4 w-4 text-muted-foreground" }),
|
|
30
|
-
"替换选择"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
),
|
|
34
|
-
/* @__PURE__ */ e(
|
|
35
|
-
n,
|
|
36
|
-
{
|
|
37
|
-
className: "gap-2 px-4",
|
|
38
|
-
value: "insert",
|
|
39
|
-
onSelect: () => {
|
|
40
|
-
const r = o.view.state.selection;
|
|
41
|
-
o.chain().focus().insertContentAt(r.to + 1, s).run();
|
|
42
|
-
},
|
|
43
|
-
children: [
|
|
44
|
-
/* @__PURE__ */ t(u, { className: "h-4 w-4 text-muted-foreground" }),
|
|
45
|
-
"在下面插入"
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
] }),
|
|
50
|
-
/* @__PURE__ */ t(i, {}),
|
|
51
|
-
/* @__PURE__ */ t(a, { children: /* @__PURE__ */ e(n, { onSelect: m, value: "thrash", className: "gap-2 px-4", children: [
|
|
52
|
-
/* @__PURE__ */ t(h, { className: "h-4 w-4 text-muted-foreground" }),
|
|
53
|
-
"丢弃"
|
|
54
|
-
] }) })
|
|
55
|
-
] });
|
|
56
|
-
};
|
|
57
|
-
export {
|
|
58
|
-
N as default
|
|
59
|
-
};
|