@4399ywkf/editor 0.2.0 → 0.3.1
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/{DocView-BPODKQ57.js → DocView-WQIV7HIE.js} +3 -3
- package/dist/{DocView-BPODKQ57.js.map → DocView-WQIV7HIE.js.map} +1 -1
- package/dist/{chunk-3GZSG6KH.js → chunk-Y2XE4CYZ.js} +434 -3
- package/dist/chunk-Y2XE4CYZ.js.map +1 -0
- package/dist/doc-runtime.d.ts +33 -0
- package/dist/doc-runtime.js +87 -0
- package/dist/doc-runtime.js.map +1 -1
- package/dist/doc.js +1 -1
- package/dist/docx.d.ts +121 -6
- package/dist/docx.js +421 -40
- package/dist/docx.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +88 -0
- package/package.json +1 -1
- package/dist/chunk-3GZSG6KH.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorConfigProvider, NotionEditor } from './chunk-
|
|
1
|
+
import { EditorConfigProvider, NotionEditor } from './chunk-Y2XE4CYZ.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
function DocView({ content, readOnly, room, className, onReady }) {
|
|
@@ -14,5 +14,5 @@ function DocView({ content, readOnly, room, className, onReady }) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export { DocView as default };
|
|
17
|
-
//# sourceMappingURL=DocView-
|
|
18
|
-
//# sourceMappingURL=DocView-
|
|
17
|
+
//# sourceMappingURL=DocView-WQIV7HIE.js.map
|
|
18
|
+
//# sourceMappingURL=DocView-WQIV7HIE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/views/DocView.tsx"],"names":[],"mappings":";;;AAMe,SAAR,QAAyB,EAAE,OAAA,EAAS,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AAClG,EAAA,2BACG,KAAA,EAAA,EAAI,SAAA,EACH,8BAAC,oBAAA,EAAA,EAAqB,MAAA,EAAQ,EAAC,EAC7B,QAAA,kBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,MAAM,IAAA,IAAQ,SAAA;AAAA,MACd,OAAA;AAAA,MACA,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-
|
|
1
|
+
{"version":3,"sources":["../src/views/DocView.tsx"],"names":[],"mappings":";;;AAMe,SAAR,QAAyB,EAAE,OAAA,EAAS,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AAClG,EAAA,2BACG,KAAA,EAAA,EAAI,SAAA,EACH,8BAAC,oBAAA,EAAA,EAAqB,MAAA,EAAQ,EAAC,EAC7B,QAAA,kBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,MAAM,IAAA,IAAQ,SAAA;AAAA,MACd,OAAA;AAAA,MACA,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-WQIV7HIE.js","sourcesContent":["import type { Editor } from \"@tiptap/react\"\nimport { EditorConfigProvider } from \"../contexts/editor-config-context\"\nimport { NotionEditor } from \"../components/tiptap-templates/notion-like/notion-like-editor\"\nimport type { DocumentViewProps } from \"../registry\"\n\n/** doc 通道:云文档与本地 doc 是同一套 tiptap,不做区分 */\nexport default function DocView({ content, readOnly, room, className, onReady }: DocumentViewProps) {\n return (\n <div className={className}>\n <EditorConfigProvider config={{}}>\n <NotionEditor\n room={room ?? \"default\"}\n content={content as string}\n readOnly={readOnly}\n onEditorReady={(editor: Editor) => onReady?.(editor)}\n />\n </EditorConfigProvider>\n </div>\n )\n}\n"]}
|
|
@@ -17,7 +17,7 @@ import { CodeBlockLowlight } from '@tiptap/extension-code-block-lowlight';
|
|
|
17
17
|
import { createLowlight, common } from 'lowlight';
|
|
18
18
|
import { Mention } from '@tiptap/extension-mention';
|
|
19
19
|
import { TaskList, TaskItem } from '@tiptap/extension-list';
|
|
20
|
-
import { TextStyle, Color } from '@tiptap/extension-text-style';
|
|
20
|
+
import { TextStyle, FontSize, FontFamily, Color } from '@tiptap/extension-text-style';
|
|
21
21
|
import { Selection as Selection$1, Placeholder } from '@tiptap/extensions';
|
|
22
22
|
import { Collaboration, isChangeOrigin } from '@tiptap/extension-collaboration';
|
|
23
23
|
import { CollaborationCaret } from '@tiptap/extension-collaboration-caret';
|
|
@@ -4110,6 +4110,72 @@ var NodeAlignment = Extension.create({
|
|
|
4110
4110
|
};
|
|
4111
4111
|
}
|
|
4112
4112
|
});
|
|
4113
|
+
var BlockSpacing = Extension.create({
|
|
4114
|
+
name: "blockSpacing",
|
|
4115
|
+
addOptions() {
|
|
4116
|
+
return {
|
|
4117
|
+
types: ["paragraph", "heading", "blockquote"]
|
|
4118
|
+
};
|
|
4119
|
+
},
|
|
4120
|
+
addGlobalAttributes() {
|
|
4121
|
+
return [
|
|
4122
|
+
{
|
|
4123
|
+
types: this.options.types,
|
|
4124
|
+
attributes: {
|
|
4125
|
+
lineHeight: {
|
|
4126
|
+
default: null,
|
|
4127
|
+
parseHTML: (element) => element.style?.lineHeight || null,
|
|
4128
|
+
renderHTML: (attributes) => {
|
|
4129
|
+
const v = attributes.lineHeight;
|
|
4130
|
+
return v ? { style: `line-height: ${v}` } : {};
|
|
4131
|
+
}
|
|
4132
|
+
},
|
|
4133
|
+
spaceBefore: {
|
|
4134
|
+
default: null,
|
|
4135
|
+
parseHTML: (element) => element.style?.marginTop || null,
|
|
4136
|
+
renderHTML: (attributes) => {
|
|
4137
|
+
const v = attributes.spaceBefore;
|
|
4138
|
+
return v ? { style: `margin-top: ${v}` } : {};
|
|
4139
|
+
}
|
|
4140
|
+
},
|
|
4141
|
+
spaceAfter: {
|
|
4142
|
+
default: null,
|
|
4143
|
+
parseHTML: (element) => element.style?.marginBottom || null,
|
|
4144
|
+
renderHTML: (attributes) => {
|
|
4145
|
+
const v = attributes.spaceAfter;
|
|
4146
|
+
return v ? { style: `margin-bottom: ${v}` } : {};
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
];
|
|
4152
|
+
},
|
|
4153
|
+
addCommands() {
|
|
4154
|
+
const apply = (patch) => ({ state, tr }) => {
|
|
4155
|
+
const targets = getSelectedNodesOfType(
|
|
4156
|
+
state.selection,
|
|
4157
|
+
this.options.types
|
|
4158
|
+
);
|
|
4159
|
+
if (targets.length === 0) return false;
|
|
4160
|
+
let changed = false;
|
|
4161
|
+
for (const [name, value] of Object.entries(patch)) {
|
|
4162
|
+
if (updateNodesAttr(tr, targets, name, value)) changed = true;
|
|
4163
|
+
}
|
|
4164
|
+
return changed;
|
|
4165
|
+
};
|
|
4166
|
+
return {
|
|
4167
|
+
setLineHeight: (lineHeight) => apply({ lineHeight }),
|
|
4168
|
+
unsetLineHeight: () => apply({ lineHeight: null }),
|
|
4169
|
+
setBlockSpacing: (spaceBefore, spaceAfter) => {
|
|
4170
|
+
const patch = {};
|
|
4171
|
+
if (spaceBefore !== void 0) patch.spaceBefore = spaceBefore;
|
|
4172
|
+
if (spaceAfter !== void 0) patch.spaceAfter = spaceAfter;
|
|
4173
|
+
return apply(patch);
|
|
4174
|
+
},
|
|
4175
|
+
unsetBlockSpacing: () => apply({ spaceBefore: null, spaceAfter: null })
|
|
4176
|
+
};
|
|
4177
|
+
}
|
|
4178
|
+
});
|
|
4113
4179
|
var TocContext = createContext(void 0);
|
|
4114
4180
|
function normalizeHeadingDepths(items) {
|
|
4115
4181
|
if (items.length === 0) return [];
|
|
@@ -20907,6 +20973,359 @@ function MobileToolbar({ editor: providedEditor }) {
|
|
|
20907
20973
|
}
|
|
20908
20974
|
);
|
|
20909
20975
|
}
|
|
20976
|
+
var CONTEXT_WINDOW_SIZE = 300;
|
|
20977
|
+
function getNodeTypeAtSelection(editor) {
|
|
20978
|
+
const { from } = editor.state.selection;
|
|
20979
|
+
const $from = editor.state.doc.resolve(from);
|
|
20980
|
+
return $from.parent.type.name;
|
|
20981
|
+
}
|
|
20982
|
+
function getHeadingLevel(editor) {
|
|
20983
|
+
const { from } = editor.state.selection;
|
|
20984
|
+
const $from = editor.state.doc.resolve(from);
|
|
20985
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
20986
|
+
const node = $from.node(d);
|
|
20987
|
+
const match = node.type.name.match(/heading(\d)/);
|
|
20988
|
+
if (match) {
|
|
20989
|
+
return parseInt(match[1], 10);
|
|
20990
|
+
}
|
|
20991
|
+
}
|
|
20992
|
+
return void 0;
|
|
20993
|
+
}
|
|
20994
|
+
function getFullDocument(editor) {
|
|
20995
|
+
return editor.state.doc.textContent;
|
|
20996
|
+
}
|
|
20997
|
+
function useAIContext(editor) {
|
|
20998
|
+
const buildContext = useCallback(
|
|
20999
|
+
(prompt) => {
|
|
21000
|
+
if (!editor) {
|
|
21001
|
+
return null;
|
|
21002
|
+
}
|
|
21003
|
+
const { from, to } = editor.state.selection;
|
|
21004
|
+
const selectedText = editor.state.doc.textBetween(from, to);
|
|
21005
|
+
if (!selectedText) {
|
|
21006
|
+
return null;
|
|
21007
|
+
}
|
|
21008
|
+
const textBefore = editor.state.doc.textBetween(0, from);
|
|
21009
|
+
const lines = textBefore.split("\n");
|
|
21010
|
+
const line = lines.length;
|
|
21011
|
+
const column = lines[lines.length - 1].length;
|
|
21012
|
+
const precedingPos = Math.max(1, from - CONTEXT_WINDOW_SIZE);
|
|
21013
|
+
const followingPos = Math.min(editor.state.doc.content.size, to + CONTEXT_WINDOW_SIZE);
|
|
21014
|
+
const precedingText = editor.state.doc.textBetween(precedingPos, from);
|
|
21015
|
+
const followingText = editor.state.doc.textBetween(to, followingPos);
|
|
21016
|
+
return {
|
|
21017
|
+
prompt,
|
|
21018
|
+
selectedText,
|
|
21019
|
+
position: {
|
|
21020
|
+
line,
|
|
21021
|
+
column
|
|
21022
|
+
},
|
|
21023
|
+
precedingText,
|
|
21024
|
+
followingText,
|
|
21025
|
+
nodeType: getNodeTypeAtSelection(editor),
|
|
21026
|
+
currentHeadingLevel: getHeadingLevel(editor),
|
|
21027
|
+
fullDocument: getFullDocument(editor),
|
|
21028
|
+
documentFormat: "markdown"
|
|
21029
|
+
};
|
|
21030
|
+
},
|
|
21031
|
+
[editor]
|
|
21032
|
+
);
|
|
21033
|
+
return { buildContext };
|
|
21034
|
+
}
|
|
21035
|
+
var AIConfigContext = createContext(null);
|
|
21036
|
+
function useAIConfig() {
|
|
21037
|
+
return useContext(AIConfigContext);
|
|
21038
|
+
}
|
|
21039
|
+
var SparklesIcon = memo(({ className, ...props }) => {
|
|
21040
|
+
return /* @__PURE__ */ jsxs(
|
|
21041
|
+
"svg",
|
|
21042
|
+
{
|
|
21043
|
+
width: "24",
|
|
21044
|
+
height: "24",
|
|
21045
|
+
className,
|
|
21046
|
+
viewBox: "0 0 24 24",
|
|
21047
|
+
fill: "currentColor",
|
|
21048
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
21049
|
+
...props,
|
|
21050
|
+
children: [
|
|
21051
|
+
/* @__PURE__ */ jsx(
|
|
21052
|
+
"path",
|
|
21053
|
+
{
|
|
21054
|
+
d: "M12 2C12.5523 2 13 2.44772 13 3V5C13 5.55228 12.5523 6 12 6C11.4477 6 11 5.55228 11 5V3C11 2.44772 11.4477 2 12 2Z",
|
|
21055
|
+
fill: "currentColor"
|
|
21056
|
+
}
|
|
21057
|
+
),
|
|
21058
|
+
/* @__PURE__ */ jsx(
|
|
21059
|
+
"path",
|
|
21060
|
+
{
|
|
21061
|
+
d: "M19.5 4.5C19.8978 4.10221 20.5244 4.10221 20.9222 4.5C21.32 4.89779 21.32 5.52441 20.9222 5.92221L19.5 7.34442C19.1022 7.74221 18.4756 7.74221 18.0778 7.34442C17.68 6.94663 17.68 6.32001 18.0778 5.92221L19.5 4.5Z",
|
|
21062
|
+
fill: "currentColor"
|
|
21063
|
+
}
|
|
21064
|
+
),
|
|
21065
|
+
/* @__PURE__ */ jsx(
|
|
21066
|
+
"path",
|
|
21067
|
+
{
|
|
21068
|
+
d: "M22 11C22.5523 11 23 11.4477 23 12C23 12.5523 22.5523 13 22 13H20C19.4477 13 19 12.5523 19 12C19 11.4477 19.4477 11 20 11H22Z",
|
|
21069
|
+
fill: "currentColor"
|
|
21070
|
+
}
|
|
21071
|
+
),
|
|
21072
|
+
/* @__PURE__ */ jsx(
|
|
21073
|
+
"path",
|
|
21074
|
+
{
|
|
21075
|
+
d: "M19.5 19.5L20.9222 18.0778C21.32 17.68 21.32 17.0534 20.9222 16.6556C20.5244 16.2578 19.8978 16.2578 19.5 16.6556L18.0778 18.0778C17.68 18.4756 17.68 19.1022 18.0778 19.5C18.4756 19.8978 19.1022 19.8978 19.5 19.5Z",
|
|
21076
|
+
fill: "currentColor"
|
|
21077
|
+
}
|
|
21078
|
+
),
|
|
21079
|
+
/* @__PURE__ */ jsx(
|
|
21080
|
+
"path",
|
|
21081
|
+
{
|
|
21082
|
+
d: "M12 18C12.5523 18 13 18.4477 13 19V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V19C11 18.4477 11.4477 18 12 18Z",
|
|
21083
|
+
fill: "currentColor"
|
|
21084
|
+
}
|
|
21085
|
+
),
|
|
21086
|
+
/* @__PURE__ */ jsx(
|
|
21087
|
+
"path",
|
|
21088
|
+
{
|
|
21089
|
+
d: "M4.5 19.5C4.89779 19.8978 4.89779 20.5244 4.5 20.9222C4.10221 21.32 3.47559 21.32 3.0778 20.9222L1.65558 19.5C1.25779 19.1022 1.25779 18.4756 1.65558 18.0778C2.05337 17.68 2.67999 17.68 3.0778 18.0778L4.5 19.5Z",
|
|
21090
|
+
fill: "currentColor"
|
|
21091
|
+
}
|
|
21092
|
+
),
|
|
21093
|
+
/* @__PURE__ */ jsx(
|
|
21094
|
+
"path",
|
|
21095
|
+
{
|
|
21096
|
+
d: "M2 12C2.55228 12 3 12.4477 3 13C3 13.5523 2.55228 14 2 14H0C-0.552285 14 -1 13.5523 -1 13C-1 12.4477 -0.552285 12 0 12H2Z",
|
|
21097
|
+
fill: "currentColor"
|
|
21098
|
+
}
|
|
21099
|
+
),
|
|
21100
|
+
/* @__PURE__ */ jsx(
|
|
21101
|
+
"path",
|
|
21102
|
+
{
|
|
21103
|
+
d: "M4.5 4.5C4.89779 4.10221 5.52441 4.10221 5.92221 4.5C6.32001 4.89779 6.32001 5.52441 5.92221 5.92221L4.5 7.34442C4.10221 7.74221 3.47559 7.74221 3.0778 7.34442C2.68001 6.94663 2.68001 6.32001 3.0778 5.92221L4.5 4.5Z",
|
|
21104
|
+
fill: "currentColor"
|
|
21105
|
+
}
|
|
21106
|
+
),
|
|
21107
|
+
/* @__PURE__ */ jsx(
|
|
21108
|
+
"path",
|
|
21109
|
+
{
|
|
21110
|
+
d: "M12 8C10.3431 8 9 9.34315 9 11C9 12.6569 10.3431 14 12 14C13.6569 14 15 12.6569 15 11C15 9.34315 13.6569 8 12 8Z",
|
|
21111
|
+
fill: "currentColor"
|
|
21112
|
+
}
|
|
21113
|
+
)
|
|
21114
|
+
]
|
|
21115
|
+
}
|
|
21116
|
+
);
|
|
21117
|
+
});
|
|
21118
|
+
SparklesIcon.displayName = "SparklesIcon";
|
|
21119
|
+
var SendIcon = memo(({ className, ...props }) => {
|
|
21120
|
+
return /* @__PURE__ */ jsx(
|
|
21121
|
+
"svg",
|
|
21122
|
+
{
|
|
21123
|
+
width: "24",
|
|
21124
|
+
height: "24",
|
|
21125
|
+
className,
|
|
21126
|
+
viewBox: "0 0 24 24",
|
|
21127
|
+
fill: "currentColor",
|
|
21128
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
21129
|
+
...props,
|
|
21130
|
+
children: /* @__PURE__ */ jsx(
|
|
21131
|
+
"path",
|
|
21132
|
+
{
|
|
21133
|
+
d: "M16.6915026,12.4744748 L3.50612381,13.2599618 C3.19218622,13.2599618 3.03521743,13.4170592 3.03521743,13.5741566 L1.15159189,20.0151496 C0.8376543,20.8006365 0.99,21.89 1.77946707,22.52 C2.41,22.99 3.50612381,23.1 4.13399899,22.8429026 L21.714504,14.0454487 C22.6563168,13.5741566 23.1272231,12.6315722 22.9702544,11.6889879 L4.13399899,1.16865248 C3.34915502,0.9115551 2.40734225,1.01399899 1.77946707,1.4852911 C0.994623095,2.1181258 0.837654326,3.20946707 1.15159189,3.99495876 L3.03521743,10.4359518 C3.03521743,10.5930492 3.19218622,10.7501467 3.50612381,10.7501467 L16.6915026,11.5356335 C16.6915026,11.5356335 17.1624089,11.5356335 17.1624089,12.0068766 C17.1624089,12.4781197 16.6915026,12.4744748 16.6915026,12.4744748 Z",
|
|
21134
|
+
fill: "currentColor"
|
|
21135
|
+
}
|
|
21136
|
+
)
|
|
21137
|
+
}
|
|
21138
|
+
);
|
|
21139
|
+
});
|
|
21140
|
+
SendIcon.displayName = "SendIcon";
|
|
21141
|
+
function AIDialog({
|
|
21142
|
+
editor,
|
|
21143
|
+
config,
|
|
21144
|
+
buildContext,
|
|
21145
|
+
onClose
|
|
21146
|
+
}) {
|
|
21147
|
+
const [prompt, setPrompt] = useState("");
|
|
21148
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
21149
|
+
const [error, setError] = useState(null);
|
|
21150
|
+
const inputRef = useRef(null);
|
|
21151
|
+
useEffect(() => {
|
|
21152
|
+
inputRef.current?.focus();
|
|
21153
|
+
}, []);
|
|
21154
|
+
const handleSubmit = async () => {
|
|
21155
|
+
if (!prompt.trim()) {
|
|
21156
|
+
return;
|
|
21157
|
+
}
|
|
21158
|
+
setError(null);
|
|
21159
|
+
setIsLoading(true);
|
|
21160
|
+
try {
|
|
21161
|
+
const context = buildContext(prompt);
|
|
21162
|
+
if (!context) {
|
|
21163
|
+
setError("No text selected");
|
|
21164
|
+
setIsLoading(false);
|
|
21165
|
+
return;
|
|
21166
|
+
}
|
|
21167
|
+
const result = await config.plugin.process(context);
|
|
21168
|
+
if (result.error) {
|
|
21169
|
+
setError(result.error);
|
|
21170
|
+
setIsLoading(false);
|
|
21171
|
+
return;
|
|
21172
|
+
}
|
|
21173
|
+
const { from, to } = editor.state.selection;
|
|
21174
|
+
const tr = editor.state.tr.replaceWith(from, to, [
|
|
21175
|
+
editor.state.schema.text(result.result)
|
|
21176
|
+
]);
|
|
21177
|
+
editor.view.dispatch(tr);
|
|
21178
|
+
onClose();
|
|
21179
|
+
setPrompt("");
|
|
21180
|
+
} catch (err) {
|
|
21181
|
+
setError(err instanceof Error ? err.message : "An error occurred");
|
|
21182
|
+
} finally {
|
|
21183
|
+
setIsLoading(false);
|
|
21184
|
+
}
|
|
21185
|
+
};
|
|
21186
|
+
const handleKeyDown = (e) => {
|
|
21187
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
21188
|
+
e.preventDefault();
|
|
21189
|
+
handleSubmit();
|
|
21190
|
+
}
|
|
21191
|
+
};
|
|
21192
|
+
return /* @__PURE__ */ jsxs(Card, { className: "ai-dialog", children: [
|
|
21193
|
+
/* @__PURE__ */ jsx(CardItemGroup, { children: /* @__PURE__ */ jsxs("div", { className: "ai-dialog-header", children: [
|
|
21194
|
+
/* @__PURE__ */ jsx(SparklesIcon, { className: "ai-dialog-icon" }),
|
|
21195
|
+
/* @__PURE__ */ jsx("span", { children: "AI Assistant" })
|
|
21196
|
+
] }) }),
|
|
21197
|
+
/* @__PURE__ */ jsxs(CardBody, { className: "ai-dialog-body", children: [
|
|
21198
|
+
/* @__PURE__ */ jsx("div", { className: "ai-dialog-input-group", children: /* @__PURE__ */ jsx(
|
|
21199
|
+
Input,
|
|
21200
|
+
{
|
|
21201
|
+
ref: inputRef,
|
|
21202
|
+
type: "text",
|
|
21203
|
+
placeholder: "What would you like me to do with the selected text?",
|
|
21204
|
+
value: prompt,
|
|
21205
|
+
onChange: (e) => {
|
|
21206
|
+
setPrompt(e.target.value);
|
|
21207
|
+
setError(null);
|
|
21208
|
+
},
|
|
21209
|
+
onKeyDown: handleKeyDown,
|
|
21210
|
+
disabled: isLoading,
|
|
21211
|
+
className: "ai-dialog-input"
|
|
21212
|
+
}
|
|
21213
|
+
) }),
|
|
21214
|
+
error && /* @__PURE__ */ jsx("div", { className: "ai-dialog-error", children: error }),
|
|
21215
|
+
/* @__PURE__ */ jsxs("div", { className: "ai-dialog-actions", children: [
|
|
21216
|
+
/* @__PURE__ */ jsx(
|
|
21217
|
+
Button,
|
|
21218
|
+
{
|
|
21219
|
+
type: "button",
|
|
21220
|
+
variant: "ghost",
|
|
21221
|
+
onClick: onClose,
|
|
21222
|
+
disabled: isLoading,
|
|
21223
|
+
children: "Cancel"
|
|
21224
|
+
}
|
|
21225
|
+
),
|
|
21226
|
+
/* @__PURE__ */ jsxs(
|
|
21227
|
+
Button,
|
|
21228
|
+
{
|
|
21229
|
+
type: "button",
|
|
21230
|
+
variant: "primary",
|
|
21231
|
+
onClick: handleSubmit,
|
|
21232
|
+
disabled: isLoading || !prompt.trim(),
|
|
21233
|
+
children: [
|
|
21234
|
+
isLoading ? "Processing..." : "Send",
|
|
21235
|
+
!isLoading && /* @__PURE__ */ jsx(SendIcon, { className: "ai-dialog-button-icon" })
|
|
21236
|
+
]
|
|
21237
|
+
}
|
|
21238
|
+
)
|
|
21239
|
+
] })
|
|
21240
|
+
] })
|
|
21241
|
+
] });
|
|
21242
|
+
}
|
|
21243
|
+
var AIButton = forwardRef(
|
|
21244
|
+
({
|
|
21245
|
+
editor: providedEditor,
|
|
21246
|
+
config: providedConfig,
|
|
21247
|
+
hideWhenUnavailable = true,
|
|
21248
|
+
onClick,
|
|
21249
|
+
...buttonProps
|
|
21250
|
+
}, ref) => {
|
|
21251
|
+
const { editor } = useTiptapEditor(providedEditor);
|
|
21252
|
+
const { buildContext } = useAIContext(editor);
|
|
21253
|
+
const contextConfig = useAIConfig();
|
|
21254
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
21255
|
+
const [shouldShow, setShouldShow] = useState(false);
|
|
21256
|
+
const config = providedConfig || contextConfig;
|
|
21257
|
+
const isEnabled = config?.enabled !== false;
|
|
21258
|
+
useEffect(() => {
|
|
21259
|
+
if (!editor) {
|
|
21260
|
+
setShouldShow(false);
|
|
21261
|
+
return;
|
|
21262
|
+
}
|
|
21263
|
+
const updateVisibility = () => {
|
|
21264
|
+
const show = isEnabled && !hideWhenUnavailable && isSelectionValid(editor);
|
|
21265
|
+
setShouldShow(show);
|
|
21266
|
+
};
|
|
21267
|
+
updateVisibility();
|
|
21268
|
+
editor.on("selectionUpdate", updateVisibility);
|
|
21269
|
+
return () => {
|
|
21270
|
+
editor.off("selectionUpdate", updateVisibility);
|
|
21271
|
+
};
|
|
21272
|
+
}, [editor, hideWhenUnavailable, isEnabled]);
|
|
21273
|
+
const handleOpenChange = useCallback(
|
|
21274
|
+
(open) => {
|
|
21275
|
+
setIsOpen(open);
|
|
21276
|
+
},
|
|
21277
|
+
[]
|
|
21278
|
+
);
|
|
21279
|
+
const handleClick = useCallback(
|
|
21280
|
+
(event) => {
|
|
21281
|
+
onClick?.(event);
|
|
21282
|
+
if (!event.defaultPrevented) {
|
|
21283
|
+
setIsOpen(true);
|
|
21284
|
+
}
|
|
21285
|
+
},
|
|
21286
|
+
[onClick]
|
|
21287
|
+
);
|
|
21288
|
+
if (!shouldShow || !editor || !config) {
|
|
21289
|
+
return null;
|
|
21290
|
+
}
|
|
21291
|
+
return /* @__PURE__ */ jsxs(Popover, { open: isOpen, onOpenChange: handleOpenChange, children: [
|
|
21292
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
21293
|
+
Button,
|
|
21294
|
+
{
|
|
21295
|
+
ref,
|
|
21296
|
+
type: "button",
|
|
21297
|
+
variant: "ghost",
|
|
21298
|
+
role: "button",
|
|
21299
|
+
tabIndex: -1,
|
|
21300
|
+
"aria-label": "AI Assistant",
|
|
21301
|
+
tooltip: "AI Assistant",
|
|
21302
|
+
onClick: handleClick,
|
|
21303
|
+
...buttonProps,
|
|
21304
|
+
children: /* @__PURE__ */ jsx(SparklesIcon, { className: "tiptap-button-icon" })
|
|
21305
|
+
}
|
|
21306
|
+
) }),
|
|
21307
|
+
/* @__PURE__ */ jsx(
|
|
21308
|
+
PopoverContent,
|
|
21309
|
+
{
|
|
21310
|
+
side: "top",
|
|
21311
|
+
align: "start",
|
|
21312
|
+
sideOffset: 4,
|
|
21313
|
+
asChild: true,
|
|
21314
|
+
children: /* @__PURE__ */ jsx(
|
|
21315
|
+
AIDialog,
|
|
21316
|
+
{
|
|
21317
|
+
editor,
|
|
21318
|
+
config,
|
|
21319
|
+
buildContext,
|
|
21320
|
+
onClose: () => handleOpenChange(false)
|
|
21321
|
+
}
|
|
21322
|
+
)
|
|
21323
|
+
}
|
|
21324
|
+
)
|
|
21325
|
+
] });
|
|
21326
|
+
}
|
|
21327
|
+
);
|
|
21328
|
+
AIButton.displayName = "AIButton";
|
|
20910
21329
|
function NotionToolbarFloating() {
|
|
20911
21330
|
const { editor } = useTiptapEditor();
|
|
20912
21331
|
const isMobile = useIsBreakpoint("max", 480);
|
|
@@ -20939,6 +21358,8 @@ function NotionToolbarFloating() {
|
|
|
20939
21358
|
),
|
|
20940
21359
|
/* @__PURE__ */ jsx(ColorTextPopover, { hideWhenUnavailable: true })
|
|
20941
21360
|
] }),
|
|
21361
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
21362
|
+
/* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(AIButton, { hideWhenUnavailable: true }) }),
|
|
20942
21363
|
/* @__PURE__ */ jsx(MoreOptions, { hideWhenUnavailable: true })
|
|
20943
21364
|
] }) });
|
|
20944
21365
|
}
|
|
@@ -21645,7 +22066,17 @@ function EditorProvider(props) {
|
|
|
21645
22066
|
]
|
|
21646
22067
|
}),
|
|
21647
22068
|
NodeAlignment,
|
|
22069
|
+
// 行距 / 段前段后距:Word 把它们挂在每个段落上,导入时没有对应属性就会
|
|
22070
|
+
// 整篇塌回编辑器的统一边距,原文的疏密节奏全丢。
|
|
22071
|
+
BlockSpacing.configure({
|
|
22072
|
+
types: ["paragraph", "heading", "blockquote"]
|
|
22073
|
+
}),
|
|
21648
22074
|
TextStyle,
|
|
22075
|
+
// 字号与字体是 textStyle 上的属性。不注册这两个扩展,schema 里就没有
|
|
22076
|
+
// fontSize / fontFamily,ProseMirror 会**静默丢弃**这两个属性 ——
|
|
22077
|
+
// 表现是 docx 导入后全文一个字号(见 docx/parse.ts 的 fmtToMarks)。
|
|
22078
|
+
FontSize,
|
|
22079
|
+
FontFamily,
|
|
21649
22080
|
Mathematics,
|
|
21650
22081
|
Superscript,
|
|
21651
22082
|
Subscript,
|
|
@@ -21861,5 +22292,5 @@ function ArticleViewer({ content, placeholder = "" }) {
|
|
|
21861
22292
|
}
|
|
21862
22293
|
|
|
21863
22294
|
export { ArticleViewer, Audio, Button, CollabContext, CollabProvider, Column, Columns, DEFAULT_MAX_FILE_SIZES, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorProvider, FileAttachment, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MAC_SYMBOLS, MAX_FILE_SIZE, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, PasteDropMedia, Popover, PopoverContent, PopoverTrigger, SR_ONLY, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, Video, clamp, cn, defaultUiState, detectMediaKind, findNodeAtPosition, findNodePosition, findSelectionPosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, hasContentAbove, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, markHideFloatingOnNext, parseShortcutKeys, pickFile, removeEmptyParagraphs, resolveMaxSize, runMediaUpload, sanitizeUrl, selectCurrentBlockContent, selectNodeAndHideFloating, selectionWithinConvertibleTypes, updateNodesAttr, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useTiptapEditor, useUiEditorState, useUnmount, useUser, useWindowSize, use_ui_editor_state_default };
|
|
21864
|
-
//# sourceMappingURL=chunk-
|
|
21865
|
-
//# sourceMappingURL=chunk-
|
|
22295
|
+
//# sourceMappingURL=chunk-Y2XE4CYZ.js.map
|
|
22296
|
+
//# sourceMappingURL=chunk-Y2XE4CYZ.js.map
|