@4399ywkf/editor 0.4.0 → 0.4.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.
@@ -117,6 +117,14 @@ var AIConfigContext = createContext(null);
117
117
  function useAIConfig() {
118
118
  return useContext(AIConfigContext);
119
119
  }
120
+
121
+ // src/plugins/ai/ai-button-visibility.ts
122
+ var shouldShowAIButton = ({
123
+ enabled,
124
+ hideWhenUnavailable,
125
+ isEditable,
126
+ hasValidSelection
127
+ }) => enabled && (hideWhenUnavailable ? hasValidSelection : isEditable);
120
128
  var SparklesIcon = memo(({ className, ...props }) => {
121
129
  return /* @__PURE__ */ jsxs(
122
130
  "svg",
@@ -125,71 +133,28 @@ var SparklesIcon = memo(({ className, ...props }) => {
125
133
  height: "24",
126
134
  className,
127
135
  viewBox: "0 0 24 24",
128
- fill: "currentColor",
136
+ fill: "none",
129
137
  xmlns: "http://www.w3.org/2000/svg",
130
138
  ...props,
131
139
  children: [
132
140
  /* @__PURE__ */ jsx(
133
141
  "path",
134
142
  {
135
- 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",
136
- fill: "currentColor"
137
- }
138
- ),
139
- /* @__PURE__ */ jsx(
140
- "path",
141
- {
142
- 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",
143
- fill: "currentColor"
144
- }
145
- ),
146
- /* @__PURE__ */ jsx(
147
- "path",
148
- {
149
- 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",
150
- fill: "currentColor"
151
- }
152
- ),
153
- /* @__PURE__ */ jsx(
154
- "path",
155
- {
156
- 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",
157
- fill: "currentColor"
158
- }
159
- ),
160
- /* @__PURE__ */ jsx(
161
- "path",
162
- {
163
- 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",
164
- fill: "currentColor"
165
- }
166
- ),
167
- /* @__PURE__ */ jsx(
168
- "path",
169
- {
170
- 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",
171
- fill: "currentColor"
143
+ d: "M12 3L13.6392 8.20749C13.8353 8.83063 13.9333 9.14219 14.0982 9.40653C14.2442 9.64066 14.4276 9.84607 14.6402 10.0143C14.8802 10.2042 15.1679 10.3345 15.7434 10.5952L20.5 12L15.7434 13.4048C15.1679 13.6655 14.8802 13.7958 14.6402 13.9857C14.4276 14.1539 14.2442 14.3593 14.0982 14.5935C13.9333 14.8578 13.8353 15.1694 13.6392 15.7925L12 21L10.3608 15.7925C10.1647 15.1694 10.0667 14.8578 9.90182 14.5935C9.75583 14.3593 9.57241 14.1539 9.35983 13.9857C9.11985 13.7958 8.83209 13.6655 8.25659 13.4048L3.5 12L8.25659 10.5952C8.83209 10.3345 9.11985 10.2042 9.35983 10.0143C9.57241 9.84607 9.75583 9.64066 9.90182 9.40653C10.0667 9.14219 10.1647 8.83063 10.3608 8.20749L12 3Z",
144
+ stroke: "currentColor",
145
+ strokeWidth: "1.6",
146
+ strokeLinecap: "round",
147
+ strokeLinejoin: "round"
172
148
  }
173
149
  ),
174
150
  /* @__PURE__ */ jsx(
175
151
  "path",
176
152
  {
177
- 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",
178
- fill: "currentColor"
179
- }
180
- ),
181
- /* @__PURE__ */ jsx(
182
- "path",
183
- {
184
- 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",
185
- fill: "currentColor"
186
- }
187
- ),
188
- /* @__PURE__ */ jsx(
189
- "path",
190
- {
191
- 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",
192
- fill: "currentColor"
153
+ d: "M18.5 3.5L18.9 4.85C19 5.15 19.05 5.3 19.14 5.42C19.21 5.53 19.31 5.63 19.42 5.7C19.54 5.79 19.69 5.84 19.99 5.94L21.34 6.34L19.99 6.74C19.69 6.84 19.54 6.89 19.42 6.98C19.31 7.05 19.21 7.15 19.14 7.26C19.05 7.38 19 7.53 18.9 7.83L18.5 9.18L18.1 7.83C18 7.53 17.95 7.38 17.86 7.26C17.79 7.15 17.69 7.05 17.58 6.98C17.46 6.89 17.31 6.84 17.01 6.74L15.66 6.34L17.01 5.94C17.31 5.84 17.46 5.79 17.58 5.7C17.69 5.63 17.79 5.53 17.86 5.42C17.95 5.3 18 5.15 18.1 4.85L18.5 3.5Z",
154
+ stroke: "currentColor",
155
+ strokeWidth: "1.4",
156
+ strokeLinecap: "round",
157
+ strokeLinejoin: "round"
193
158
  }
194
159
  )
195
160
  ]
@@ -757,80 +722,6 @@ function PopoverContent({
757
722
  }
758
723
  ) });
759
724
  }
760
- function Input({ className, type, ...props }) {
761
- return /* @__PURE__ */ jsx(
762
- "input",
763
- {
764
- type,
765
- "data-slot": "tiptap-input",
766
- className: cn("tiptap-input", className),
767
- ...props
768
- }
769
- );
770
- }
771
- var Card = forwardRef(
772
- ({ className, ...props }, ref) => {
773
- return /* @__PURE__ */ jsx("div", { ref, className: cn("tiptap-card", className), ...props });
774
- }
775
- );
776
- Card.displayName = "Card";
777
- var CardHeader = forwardRef(
778
- ({ className, ...props }, ref) => {
779
- return /* @__PURE__ */ jsx(
780
- "div",
781
- {
782
- ref,
783
- className: cn("tiptap-card-header", className),
784
- ...props
785
- }
786
- );
787
- }
788
- );
789
- CardHeader.displayName = "CardHeader";
790
- var CardBody = forwardRef(
791
- ({ className, ...props }, ref) => {
792
- return /* @__PURE__ */ jsx("div", { ref, className: cn("tiptap-card-body", className), ...props });
793
- }
794
- );
795
- CardBody.displayName = "CardBody";
796
- var CardItemGroup = forwardRef(({ className, orientation = "vertical", ...props }, ref) => {
797
- return /* @__PURE__ */ jsx(
798
- "div",
799
- {
800
- ref,
801
- "data-orientation": orientation,
802
- className: cn("tiptap-card-item-group", className),
803
- ...props
804
- }
805
- );
806
- });
807
- CardItemGroup.displayName = "CardItemGroup";
808
- var CardGroupLabel = forwardRef(
809
- ({ className, ...props }, ref) => {
810
- return /* @__PURE__ */ jsx(
811
- "div",
812
- {
813
- ref,
814
- className: cn("tiptap-card-group-label", className),
815
- ...props
816
- }
817
- );
818
- }
819
- );
820
- CardGroupLabel.displayName = "CardGroupLabel";
821
- var CardFooter = forwardRef(
822
- ({ className, ...props }, ref) => {
823
- return /* @__PURE__ */ jsx(
824
- "div",
825
- {
826
- ref,
827
- className: cn("tiptap-card-footer", className),
828
- ...props
829
- }
830
- );
831
- }
832
- );
833
- CardFooter.displayName = "CardFooter";
834
725
  var SendIcon = memo(({ className, ...props }) => {
835
726
  return /* @__PURE__ */ jsx(
836
727
  "svg",
@@ -839,14 +730,17 @@ var SendIcon = memo(({ className, ...props }) => {
839
730
  height: "24",
840
731
  className,
841
732
  viewBox: "0 0 24 24",
842
- fill: "currentColor",
733
+ fill: "none",
843
734
  xmlns: "http://www.w3.org/2000/svg",
844
735
  ...props,
845
736
  children: /* @__PURE__ */ jsx(
846
737
  "path",
847
738
  {
848
- 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",
849
- fill: "currentColor"
739
+ d: "M12 19V5M12 5L6 11M12 5L18 11",
740
+ stroke: "currentColor",
741
+ strokeWidth: "2",
742
+ strokeLinecap: "round",
743
+ strokeLinejoin: "round"
850
744
  }
851
745
  )
852
746
  }
@@ -866,36 +760,34 @@ function AIDialog({
866
760
  useEffect(() => {
867
761
  inputRef.current?.focus();
868
762
  }, []);
763
+ const canSubmit = Boolean(prompt.trim()) && !isLoading;
869
764
  const handleSubmit = async () => {
870
- if (!prompt.trim()) {
871
- return;
872
- }
765
+ if (!canSubmit) return;
873
766
  setError(null);
874
767
  setIsLoading(true);
875
768
  try {
876
769
  const context = buildContext(prompt);
877
770
  if (!context) {
878
- setError("No text selected");
879
- setIsLoading(false);
771
+ setError("没有选中内容");
880
772
  return;
881
773
  }
882
774
  const result = await config.plugin.process(context);
883
775
  if (result.error) {
884
776
  setError(result.error);
885
- setIsLoading(false);
886
777
  return;
887
778
  }
888
779
  if (result.result) {
889
780
  const { from, to } = editor.state.selection;
890
- const tr = editor.state.tr.replaceWith(from, to, [
891
- editor.state.schema.text(result.result)
892
- ]);
893
- editor.view.dispatch(tr);
781
+ editor.view.dispatch(
782
+ editor.state.tr.replaceWith(from, to, [
783
+ editor.state.schema.text(result.result)
784
+ ])
785
+ );
894
786
  }
895
- onClose();
896
787
  setPrompt("");
788
+ onClose();
897
789
  } catch (err) {
898
- setError(err instanceof Error ? err.message : "An error occurred");
790
+ setError(err instanceof Error ? err.message : "出错了");
899
791
  } finally {
900
792
  setIsLoading(false);
901
793
  }
@@ -903,58 +795,44 @@ function AIDialog({
903
795
  const handleKeyDown = (e) => {
904
796
  if (e.key === "Enter" && !e.shiftKey) {
905
797
  e.preventDefault();
906
- handleSubmit();
798
+ void handleSubmit();
799
+ }
800
+ if (e.key === "Escape") {
801
+ e.preventDefault();
802
+ onClose();
907
803
  }
908
804
  };
909
- return /* @__PURE__ */ jsxs(Card, { className: "ai-dialog", children: [
910
- /* @__PURE__ */ jsx(CardItemGroup, { children: /* @__PURE__ */ jsxs("div", { className: "ai-dialog-header", children: [
911
- /* @__PURE__ */ jsx(SparklesIcon, { className: "ai-dialog-icon" }),
912
- /* @__PURE__ */ jsx("span", { children: "AI Assistant" })
913
- ] }) }),
914
- /* @__PURE__ */ jsxs(CardBody, { className: "ai-dialog-body", children: [
915
- /* @__PURE__ */ jsx("div", { className: "ai-dialog-input-group", children: /* @__PURE__ */ jsx(
916
- Input,
805
+ return /* @__PURE__ */ jsxs("div", { className: "tiptap-ai-dialog", children: [
806
+ /* @__PURE__ */ jsxs("div", { className: "tiptap-ai-dialog-field", "data-loading": isLoading, children: [
807
+ /* @__PURE__ */ jsx(
808
+ "input",
917
809
  {
918
810
  ref: inputRef,
919
811
  type: "text",
920
- placeholder: "What would you like me to do with the selected text?",
812
+ className: "tiptap-ai-dialog-input",
813
+ placeholder: "描述你想要的修改",
921
814
  value: prompt,
815
+ disabled: isLoading,
922
816
  onChange: (e) => {
923
817
  setPrompt(e.target.value);
924
818
  setError(null);
925
819
  },
926
- onKeyDown: handleKeyDown,
927
- disabled: isLoading,
928
- className: "ai-dialog-input"
820
+ onKeyDown: handleKeyDown
929
821
  }
930
- ) }),
931
- error && /* @__PURE__ */ jsx("div", { className: "ai-dialog-error", children: error }),
932
- /* @__PURE__ */ jsxs("div", { className: "ai-dialog-actions", children: [
933
- /* @__PURE__ */ jsx(
934
- Button,
935
- {
936
- type: "button",
937
- variant: "ghost",
938
- onClick: onClose,
939
- disabled: isLoading,
940
- children: "Cancel"
941
- }
942
- ),
943
- /* @__PURE__ */ jsxs(
944
- Button,
945
- {
946
- type: "button",
947
- variant: "primary",
948
- onClick: handleSubmit,
949
- disabled: isLoading || !prompt.trim(),
950
- children: [
951
- isLoading ? "Processing..." : "Send",
952
- !isLoading && /* @__PURE__ */ jsx(SendIcon, { className: "ai-dialog-button-icon" })
953
- ]
954
- }
955
- )
956
- ] })
957
- ] })
822
+ ),
823
+ /* @__PURE__ */ jsx(
824
+ "button",
825
+ {
826
+ type: "button",
827
+ className: "tiptap-ai-dialog-submit",
828
+ "aria-label": "发送",
829
+ disabled: !canSubmit,
830
+ onClick: () => void handleSubmit(),
831
+ children: /* @__PURE__ */ jsx(SendIcon, {})
832
+ }
833
+ )
834
+ ] }),
835
+ error && /* @__PURE__ */ jsx("div", { className: "tiptap-ai-dialog-error", children: error })
958
836
  ] });
959
837
  }
960
838
  var NODE_TYPE_LABELS = {
@@ -1069,8 +947,14 @@ var AIButton = forwardRef(
1069
947
  return;
1070
948
  }
1071
949
  const updateVisibility = () => {
1072
- const show = isEnabled && !hideWhenUnavailable && isSelectionValid(editor);
1073
- setShouldShow(show);
950
+ setShouldShow(
951
+ shouldShowAIButton({
952
+ enabled: isEnabled,
953
+ hasValidSelection: isSelectionValid(editor),
954
+ hideWhenUnavailable,
955
+ isEditable: editor.isEditable
956
+ })
957
+ );
1074
958
  };
1075
959
  updateVisibility();
1076
960
  editor.on("selectionUpdate", updateVisibility);
@@ -1112,29 +996,20 @@ var AIButton = forwardRef(
1112
996
  children: /* @__PURE__ */ jsx(SparklesIcon, { className: "tiptap-button-icon" })
1113
997
  }
1114
998
  ) }),
1115
- /* @__PURE__ */ jsx(
1116
- PopoverContent,
999
+ /* @__PURE__ */ jsx(PopoverContent, { side: "top", align: "start", sideOffset: 4, children: /* @__PURE__ */ jsx(
1000
+ AIDialog,
1117
1001
  {
1118
- side: "top",
1119
- align: "start",
1120
- sideOffset: 4,
1121
- asChild: true,
1122
- children: /* @__PURE__ */ jsx(
1123
- AIDialog,
1124
- {
1125
- editor,
1126
- config,
1127
- buildContext,
1128
- onClose: () => handleOpenChange(false)
1129
- }
1130
- )
1002
+ editor,
1003
+ config,
1004
+ buildContext,
1005
+ onClose: () => handleOpenChange(false)
1131
1006
  }
1132
- )
1007
+ ) })
1133
1008
  ] });
1134
1009
  }
1135
1010
  );
1136
1011
  AIButton.displayName = "AIButton";
1137
1012
 
1138
- export { AIButton, AIConfigContext, AIDialog, Button, Card, CardBody, CardGroupLabel, CardItemGroup, Input, MAC_SYMBOLS, MAX_FILE_SIZE, Popover, PopoverContent, PopoverTrigger, SR_ONLY, clamp, cn, findNodeAtPosition, findNodePosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, parseShortcutKeys, removeEmptyParagraphs, sanitizeUrl, selectCurrentBlockContent, selectionWithinConvertibleTypes, updateNodesAttr, useAIConfig, useAIContext, useTiptapEditor };
1139
- //# sourceMappingURL=chunk-GSBPP62I.js.map
1140
- //# sourceMappingURL=chunk-GSBPP62I.js.map
1013
+ export { AIButton, AIConfigContext, AIDialog, Button, MAC_SYMBOLS, MAX_FILE_SIZE, Popover, PopoverContent, PopoverTrigger, SR_ONLY, clamp, cn, findNodeAtPosition, findNodePosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, parseShortcutKeys, removeEmptyParagraphs, sanitizeUrl, selectCurrentBlockContent, selectionWithinConvertibleTypes, updateNodesAttr, useAIConfig, useAIContext, useTiptapEditor };
1014
+ //# sourceMappingURL=chunk-QMYT5WXO.js.map
1015
+ //# sourceMappingURL=chunk-QMYT5WXO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-tiptap-editor.ts","../src/plugins/ai/use-ai-context.ts","../src/plugins/ai/ai-context.ts","../src/plugins/ai/ai-button-visibility.ts","../src/components/tiptap-icons/sparkles-icon.tsx","../src/components/tiptap-ui-primitive/tooltip/tooltip.tsx","../src/lib/tiptap-utils.ts","../src/components/tiptap-ui-primitive/button/button.tsx","../src/components/tiptap-ui-primitive/popover/popover.tsx","../src/components/tiptap-icons/send-icon.tsx","../src/plugins/ai/ai-dialog.tsx","../src/lib/tiptap-collab-utils.ts","../src/plugins/ai/ai-button.tsx"],"names":["useState","createContext","useContext","jsx","TooltipTrigger","TooltipContent","isMac","jsxs","forwardRef","useMemo","memo","useEffect","NodeSelection","nodeType","CellSelection","useCallback"],"mappings":";;;;;;;;;AAIA,SAAS,oBAAoB,MAAA,EAA+B;AAC1D,EAAA,MAAM,UAAU,MAAA,CAAO,OAAA;AACvB,EAAA,MAAM,QAAQ,OAAA,CAAQ,KAAA;AACtB,EAAA,IAAI,CAAC,KAAA,IAAS,EAAE,cAAA,IAAkB,QAAQ,OAAO,IAAA;AACjD,EAAA,OAAO,MAAM,YAAA,IAAgB,IAAA;AAC/B;AAEO,SAAS,gBAAgB,cAAA,EA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AAAA,QAAA;AAAA,UACC,MAAA;AAAA,UACA,MAAA;AAAA,UACA,YAAA;AAAA,UACA,OAAA,EAAS,MAAM,gBAAA,CAAiB,KAAK;AAAA;AAAA,OACvC,EACF;AAAA,KAAA,EACF,CAAA;AAAA,EAEJ;AACF;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"chunk-QMYT5WXO.js","sourcesContent":["import type { Editor } from \"@tiptap/react\"\nimport { useCurrentEditor, useEditorState } from \"@tiptap/react\"\nimport { useEffect, useState } from \"react\"\n\nfunction getActivePageEditor(editor: Editor): Editor | null {\n const storage = editor.storage as unknown as Record<string, unknown>\n const pages = storage.pages as { activeEditor?: Editor | null } | undefined\n if (!pages || !(\"activeEditor\" in pages)) return null\n return pages.activeEditor ?? null\n}\n\nexport function useTiptapEditor(providedEditor?: Editor | null): {\n editor: Editor | null\n editorState?: Editor[\"state\"]\n canCommand?: Editor[\"can\"]\n} {\n const { editor: coreEditor } = useCurrentEditor()\n const mainEditor = providedEditor ?? coreEditor\n\n const [storageEditor, setStorageEditor] = useState<Editor | null>(null)\n\n useEffect(() => {\n if (!mainEditor) {\n setStorageEditor(null)\n return\n }\n\n const updateHandler = () =>\n setStorageEditor(getActivePageEditor(mainEditor))\n\n updateHandler()\n\n mainEditor.on(\"update\", updateHandler)\n mainEditor.on(\"selectionUpdate\", updateHandler)\n\n return () => {\n mainEditor.off(\"update\", updateHandler)\n mainEditor.off(\"selectionUpdate\", updateHandler)\n }\n }, [mainEditor])\n\n useEffect(() => {\n if (!storageEditor) return\n\n const handleDestroy = () => setStorageEditor(null)\n\n storageEditor.on(\"destroy\", handleDestroy)\n return () => {\n storageEditor.off(\"destroy\", handleDestroy)\n }\n }, [storageEditor])\n\n const editorState = useEditorState({\n editor: storageEditor ?? mainEditor,\n selector(context) {\n if (!context.editor) {\n return { editor: null, editorState: undefined, canCommand: undefined }\n }\n\n return {\n editor: context.editor,\n editorState: context.editor.state,\n canCommand: context.editor.can,\n }\n },\n })\n\n return editorState ?? { editor: null }\n}\n","import { useCallback } from \"react\"\nimport type { Editor } from \"@tiptap/react\"\nimport type { AIContextData } from \"./types\"\n\nconst CONTEXT_WINDOW_SIZE = 300\n\n/**\n * Extract text content from a Tiptap node recursively\n */\nfunction extractTextFromNode(node: any): string {\n if (node.isText) {\n return node.text || \"\"\n }\n if (node.content) {\n return node.content.map(extractTextFromNode).join(\"\")\n }\n return \"\"\n}\n\n/**\n * Get text at a specific position in the document\n */\nfunction getTextAtPosition(editor: Editor, pos: number, length: number): string {\n try {\n const { from, to } = editor.state.selection\n const $from = editor.state.doc.resolve(Math.max(1, pos - length))\n const $to = editor.state.doc.resolve(Math.min(editor.state.doc.content.size, pos + length))\n return editor.state.doc.textBetween($from.pos, $to.pos, \"\\n\", \" \")\n } catch {\n return \"\"\n }\n}\n\n/**\n * Get the node type at the current selection\n */\nfunction getNodeTypeAtSelection(editor: Editor): string | undefined {\n const { from } = editor.state.selection\n const $from = editor.state.doc.resolve(from)\n return $from.parent.type.name\n}\n\n/**\n * Get the heading level if the selection is inside a heading\n */\nfunction getHeadingLevel(editor: Editor): number | undefined {\n const { from } = editor.state.selection\n const $from = editor.state.doc.resolve(from)\n\n for (let d = $from.depth; d > 0; d--) {\n const node = $from.node(d)\n const match = node.type.name.match(/heading(\\d)/)\n if (match) {\n return parseInt(match[1], 10)\n }\n }\n\n return undefined\n}\n\n/**\n * Get the full document as text\n */\nfunction getFullDocument(editor: Editor): string {\n return editor.state.doc.textContent\n}\n\nexport function useAIContext(editor: Editor | null) {\n const buildContext = useCallback(\n (prompt: string): AIContextData | null => {\n if (!editor) {\n return null\n }\n\n const { from, to } = editor.state.selection\n const selectedText = editor.state.doc.textBetween(from, to)\n\n if (!selectedText) {\n return null\n }\n\n // Get the line and column number (simplified: count newlines before selection)\n const textBefore = editor.state.doc.textBetween(0, from)\n const lines = textBefore.split(\"\\n\")\n const line = lines.length\n const column = lines[lines.length - 1].length\n\n // Get surrounding context\n const precedingPos = Math.max(1, from - CONTEXT_WINDOW_SIZE)\n const followingPos = Math.min(editor.state.doc.content.size, to + CONTEXT_WINDOW_SIZE)\n\n const precedingText = editor.state.doc.textBetween(precedingPos, from)\n const followingText = editor.state.doc.textBetween(to, followingPos)\n\n return {\n prompt,\n selectedText,\n position: {\n line,\n column,\n },\n precedingText,\n followingText,\n nodeType: getNodeTypeAtSelection(editor),\n currentHeadingLevel: getHeadingLevel(editor),\n fullDocument: getFullDocument(editor),\n documentFormat: \"markdown\",\n }\n },\n [editor]\n )\n\n return { buildContext }\n}\n","import { createContext, useContext } from \"react\"\nimport type { AIPluginConfig } from \"./types\"\n\nexport const AIConfigContext = createContext<AIPluginConfig | null>(null)\n\nexport function useAIConfig(): AIPluginConfig | null {\n return useContext(AIConfigContext)\n}\n","export interface AIButtonVisibilityInput {\n /** 插件配置里的开关(`enabled !== false`)。 */\n enabled: boolean\n /** 「没得用就藏起来」。 */\n hideWhenUnavailable: boolean\n /** 编辑器是否可编辑。 */\n isEditable: boolean\n /** 当前选区是否可以拿去问 AI。 */\n hasValidSelection: boolean\n}\n\n/**\n * AI 按钮该不该渲染。\n *\n * 抽成纯函数不是为了复用,是为了能测 —— 这个判断写在组件里时曾经把\n * `hideWhenUnavailable` 取反用(`!hideWhenUnavailable && hasValidSelection`),\n * 于是工具栏传 `true` 的那条路上按钮**永远**渲染不出来,而构建、类型、\n * 导出检查全是绿的。一个布尔取反,静态手段一个都拦不住。\n */\nexport const shouldShowAIButton = ({\n enabled,\n hideWhenUnavailable,\n isEditable,\n hasValidSelection,\n}: AIButtonVisibilityInput): boolean =>\n enabled && (hideWhenUnavailable ? hasValidSelection : isEditable)\n","import { memo } from \"react\"\n\ntype SvgProps = React.ComponentPropsWithoutRef<\"svg\">\n\nexport const SparklesIcon = memo(({ className, ...props }: SvgProps) => {\n return (\n <svg\n width=\"24\"\n height=\"24\"\n className={className}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n {...props}\n >\n <path\n d=\"M12 3L13.6392 8.20749C13.8353 8.83063 13.9333 9.14219 14.0982 9.40653C14.2442 9.64066 14.4276 9.84607 14.6402 10.0143C14.8802 10.2042 15.1679 10.3345 15.7434 10.5952L20.5 12L15.7434 13.4048C15.1679 13.6655 14.8802 13.7958 14.6402 13.9857C14.4276 14.1539 14.2442 14.3593 14.0982 14.5935C13.9333 14.8578 13.8353 15.1694 13.6392 15.7925L12 21L10.3608 15.7925C10.1647 15.1694 10.0667 14.8578 9.90182 14.5935C9.75583 14.3593 9.57241 14.1539 9.35983 13.9857C9.11985 13.7958 8.83209 13.6655 8.25659 13.4048L3.5 12L8.25659 10.5952C8.83209 10.3345 9.11985 10.2042 9.35983 10.0143C9.57241 9.84607 9.75583 9.64066 9.90182 9.40653C10.0667 9.14219 10.1647 8.83063 10.3608 8.20749L12 3Z\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M18.5 3.5L18.9 4.85C19 5.15 19.05 5.3 19.14 5.42C19.21 5.53 19.31 5.63 19.42 5.7C19.54 5.79 19.69 5.84 19.99 5.94L21.34 6.34L19.99 6.74C19.69 6.84 19.54 6.89 19.42 6.98C19.31 7.05 19.21 7.15 19.14 7.26C19.05 7.38 19 7.53 18.9 7.83L18.5 9.18L18.1 7.83C18 7.53 17.95 7.38 17.86 7.26C17.79 7.15 17.69 7.05 17.58 6.98C17.46 6.89 17.31 6.84 17.01 6.74L15.66 6.34L17.01 5.94C17.31 5.84 17.46 5.79 17.58 5.7C17.69 5.63 17.79 5.53 17.86 5.42C17.95 5.3 18 5.15 18.1 4.85L18.5 3.5Z\"\n stroke=\"currentColor\"\n strokeWidth=\"1.4\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )\n})\n\nSparklesIcon.displayName = \"SparklesIcon\"\n","import {\n cloneElement,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n useMemo,\n useState,\n version,\n} from \"react\"\nimport {\n useFloating,\n autoUpdate,\n offset,\n flip,\n shift,\n useHover,\n useFocus,\n useDismiss,\n useRole,\n useInteractions,\n useMergeRefs,\n FloatingPortal,\n type Placement,\n type UseFloatingReturn,\n type ReferenceType,\n FloatingDelayGroup,\n} from \"@floating-ui/react\"\nimport \"./tooltip.scss\"\n\ninterface TooltipProviderProps {\n children: React.ReactNode\n initialOpen?: boolean\n placement?: Placement\n open?: boolean\n onOpenChange?: (open: boolean) => void\n delay?: number\n closeDelay?: number\n timeout?: number\n useDelayGroup?: boolean\n}\n\ninterface TooltipTriggerProps extends Omit<\n React.HTMLProps<HTMLElement>,\n \"ref\"\n> {\n asChild?: boolean\n children: React.ReactNode\n}\n\ninterface TooltipContentProps extends Omit<\n React.HTMLProps<HTMLDivElement>,\n \"ref\"\n> {\n children?: React.ReactNode\n portal?: boolean\n portalProps?: Omit<React.ComponentProps<typeof FloatingPortal>, \"children\">\n}\n\ninterface TooltipContextValue extends UseFloatingReturn<ReferenceType> {\n open: boolean\n setOpen: (open: boolean) => void\n getReferenceProps: (\n userProps?: React.HTMLProps<HTMLElement>\n ) => Record<string, unknown>\n getFloatingProps: (\n userProps?: React.HTMLProps<HTMLDivElement>\n ) => Record<string, unknown>\n}\n\nfunction useTooltip({\n initialOpen = false,\n placement = \"top\",\n open: controlledOpen,\n onOpenChange: setControlledOpen,\n delay = 600,\n closeDelay = 0,\n}: Omit<TooltipProviderProps, \"children\"> = {}) {\n const [uncontrolledOpen, setUncontrolledOpen] = useState<boolean>(initialOpen)\n\n const open = controlledOpen ?? uncontrolledOpen\n const setOpen = setControlledOpen ?? setUncontrolledOpen\n\n const data = useFloating({\n placement,\n open,\n onOpenChange: setOpen,\n whileElementsMounted: autoUpdate,\n middleware: [\n offset(4),\n flip({\n crossAxis: placement.includes(\"-\"),\n fallbackAxisSideDirection: \"start\",\n padding: 4,\n }),\n shift({ padding: 4 }),\n ],\n })\n\n const context = data.context\n\n const hover = useHover(context, {\n mouseOnly: true,\n move: false,\n restMs: delay,\n enabled: controlledOpen == null,\n delay: {\n close: closeDelay,\n },\n })\n const focus = useFocus(context, {\n enabled: controlledOpen == null,\n })\n const dismiss = useDismiss(context)\n const role = useRole(context, { role: \"tooltip\" })\n\n const interactions = useInteractions([hover, focus, dismiss, role])\n\n return useMemo(\n () => ({\n open,\n setOpen,\n ...interactions,\n ...data,\n }),\n [open, setOpen, interactions, data]\n )\n}\n\nconst TooltipContext = createContext<TooltipContextValue | null>(null)\n\nfunction useTooltipContext() {\n const context = useContext(TooltipContext)\n\n if (context == null) {\n throw new Error(\"Tooltip components must be wrapped in <TooltipProvider />\")\n }\n\n return context\n}\n\nexport function Tooltip({ children, ...props }: TooltipProviderProps) {\n const tooltip = useTooltip(props)\n\n if (!props.useDelayGroup) {\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n )\n }\n\n return (\n <FloatingDelayGroup\n delay={{ open: props.delay ?? 0, close: props.closeDelay ?? 0 }}\n timeoutMs={props.timeout}\n >\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n </FloatingDelayGroup>\n )\n}\n\nexport const TooltipTrigger = forwardRef<HTMLElement, TooltipTriggerProps>(\n function TooltipTrigger({ children, asChild = false, ...props }, propRef) {\n const context = useTooltipContext()\n const childrenRef = isValidElement(children)\n ? parseInt(version, 10) >= 19\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (children as { props: { ref?: React.Ref<any> } }).props.ref\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (children as any).ref\n : undefined\n const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef])\n\n if (asChild && isValidElement(children)) {\n const dataAttributes = {\n \"data-tooltip-state\": context.open ? \"open\" : \"closed\",\n }\n\n return cloneElement(\n children,\n context.getReferenceProps({\n ref,\n ...props,\n ...(typeof children.props === \"object\" ? children.props : {}),\n ...dataAttributes,\n })\n )\n }\n\n return (\n <button\n ref={ref}\n data-tooltip-state={context.open ? \"open\" : \"closed\"}\n {...context.getReferenceProps(props)}\n >\n {children}\n </button>\n )\n }\n)\n\nexport const TooltipContent = forwardRef<HTMLDivElement, TooltipContentProps>(\n function TooltipContent(\n { style, children, portal = true, portalProps = {}, ...props },\n propRef\n ) {\n const context = useTooltipContext()\n const ref = useMergeRefs([context.refs.setFloating, propRef])\n\n if (!context.open) return null\n\n const content = (\n <div\n ref={ref}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...context.getFloatingProps(props)}\n className=\"tiptap-tooltip\"\n >\n {children}\n </div>\n )\n\n if (portal) {\n return <FloatingPortal {...portalProps}>{content}</FloatingPortal>\n }\n\n return content\n }\n)\n\nTooltip.displayName = \"Tooltip\"\nTooltipTrigger.displayName = \"TooltipTrigger\"\nTooltipContent.displayName = \"TooltipContent\"\n","import type { Node as PMNode } from \"@tiptap/pm/model\"\nimport type { Transaction } from \"@tiptap/pm/state\"\nimport {\n AllSelection,\n NodeSelection,\n Selection,\n TextSelection,\n} from \"@tiptap/pm/state\"\nimport { cellAround, CellSelection } from \"@tiptap/pm/tables\"\nimport {\n findParentNodeClosestToPos,\n type Editor,\n type NodeWithPos,\n} from \"@tiptap/react\"\n\nexport const MAX_FILE_SIZE = 5 * 1024 * 1024 // 5MB\n\nexport const MAC_SYMBOLS: Record<string, string> = {\n mod: \"⌘\",\n command: \"⌘\",\n meta: \"⌘\",\n ctrl: \"⌃\",\n control: \"⌃\",\n alt: \"⌥\",\n option: \"⌥\",\n shift: \"⇧\",\n backspace: \"Del\",\n delete: \"⌦\",\n enter: \"⏎\",\n escape: \"⎋\",\n capslock: \"⇪\",\n} as const\n\nexport const SR_ONLY = {\n position: \"absolute\",\n width: \"1px\",\n height: \"1px\",\n padding: 0,\n margin: \"-1px\",\n overflow: \"hidden\",\n clip: \"rect(0, 0, 0, 0)\",\n whiteSpace: \"nowrap\",\n borderWidth: 0,\n} as const\n\nexport function cn(\n ...classes: (string | boolean | undefined | null)[]\n): string {\n return classes.filter(Boolean).join(\" \")\n}\n\n/**\n * Determines if the current platform is macOS\n * @returns boolean indicating if the current platform is Mac\n */\nexport function isMac(): boolean {\n return (\n typeof navigator !== \"undefined\" &&\n navigator.platform.toLowerCase().includes(\"mac\")\n )\n}\n\n/**\n * Formats a shortcut key based on the platform (Mac or non-Mac)\n * @param key - The key to format (e.g., \"ctrl\", \"alt\", \"shift\")\n * @param isMac - Boolean indicating if the platform is Mac\n * @param capitalize - Whether to capitalize the key (default: true)\n * @returns Formatted shortcut key symbol\n */\nexport const formatShortcutKey = (\n key: string,\n isMac: boolean,\n capitalize: boolean = true\n) => {\n if (isMac) {\n const lowerKey = key.toLowerCase()\n return MAC_SYMBOLS[lowerKey] || (capitalize ? key.toUpperCase() : key)\n }\n\n return capitalize ? key.charAt(0).toUpperCase() + key.slice(1) : key\n}\n\n/**\n * Parses a shortcut key string into an array of formatted key symbols\n * @param shortcutKeys - The string of shortcut keys (e.g., \"ctrl-alt-shift\")\n * @param delimiter - The delimiter used to split the keys (default: \"-\")\n * @param capitalize - Whether to capitalize the keys (default: true)\n * @returns Array of formatted shortcut key symbols\n */\nexport const parseShortcutKeys = (props: {\n shortcutKeys: string | undefined\n delimiter?: string\n capitalize?: boolean\n}) => {\n const { shortcutKeys, delimiter = \"+\", capitalize = true } = props\n\n if (!shortcutKeys) return []\n\n return shortcutKeys\n .split(delimiter)\n .map((key) => key.trim())\n .map((key) => formatShortcutKey(key, isMac(), capitalize))\n}\n\n/**\n * Checks if a mark exists in the editor schema\n * @param markName - The name of the mark to check\n * @param editor - The editor instance\n * @returns boolean indicating if the mark exists in the schema\n */\nexport const isMarkInSchema = (\n markName: string,\n editor: Editor | null\n): boolean => {\n if (!editor?.schema) return false\n return editor.schema.spec.marks.get(markName) !== undefined\n}\n\n/**\n * Checks if a node exists in the editor schema\n * @param nodeName - The name of the node to check\n * @param editor - The editor instance\n * @returns boolean indicating if the node exists in the schema\n */\nexport const isNodeInSchema = (\n nodeName: string,\n editor: Editor | null\n): boolean => {\n if (!editor?.schema) return false\n return editor.schema.spec.nodes.get(nodeName) !== undefined\n}\n\n/**\n * Moves the focus to the next node in the editor\n * @param editor - The editor instance\n * @returns boolean indicating if the focus was moved\n */\nexport function focusNextNode(editor: Editor) {\n const { state, view } = editor\n const { doc, selection } = state\n\n const nextSel = Selection.findFrom(selection.$to, 1, true)\n if (nextSel) {\n view.dispatch(state.tr.setSelection(nextSel).scrollIntoView())\n return true\n }\n\n const paragraphType = state.schema.nodes.paragraph\n if (!paragraphType) {\n console.warn(\"No paragraph node type found in schema.\")\n return false\n }\n\n const end = doc.content.size\n const para = paragraphType.create()\n let tr = state.tr.insert(end, para)\n\n // Place the selection inside the new paragraph\n const $inside = tr.doc.resolve(end + 1)\n tr = tr.setSelection(TextSelection.near($inside)).scrollIntoView()\n view.dispatch(tr)\n return true\n}\n\n/**\n * Checks if a value is a valid number (not null, undefined, or NaN)\n * @param value - The value to check\n * @returns boolean indicating if the value is a valid number\n */\nexport function isValidPosition(pos: number | null | undefined): pos is number {\n return typeof pos === \"number\" && pos >= 0\n}\n\n/**\n * Checks if one or more extensions are registered in the Tiptap editor.\n * @param editor - The Tiptap editor instance\n * @param extensionNames - A single extension name or an array of names to check\n * @returns True if at least one of the extensions is available, false otherwise\n */\nexport function isExtensionAvailable(\n editor: Editor | null,\n extensionNames: string | string[]\n): boolean {\n if (!editor) return false\n\n const names = Array.isArray(extensionNames)\n ? extensionNames\n : [extensionNames]\n\n const found = names.some((name) =>\n editor.extensionManager.extensions.some((ext) => ext.name === name)\n )\n\n if (!found) {\n console.warn(\n `None of the extensions [${names.join(\", \")}] were found in the editor schema. Ensure they are included in the editor configuration.`\n )\n }\n\n return found\n}\n\n/**\n * Finds a node at the specified position with error handling\n * @param editor The Tiptap editor instance\n * @param position The position in the document to find the node\n * @returns The node at the specified position, or null if not found\n */\nexport function findNodeAtPosition(editor: Editor, position: number) {\n try {\n const node = editor.state.doc.nodeAt(position)\n if (!node) {\n console.warn(`No node found at position ${position}`)\n return null\n }\n return node\n } catch (error) {\n console.error(`Error getting node at position ${position}:`, error)\n return null\n }\n}\n\n/**\n * Finds the position and instance of a node in the document\n * @param props Object containing editor, node (optional), and nodePos (optional)\n * @param props.editor The Tiptap editor instance\n * @param props.node The node to find (optional if nodePos is provided)\n * @param props.nodePos The position of the node to find (optional if node is provided)\n * @returns An object with the position and node, or null if not found\n */\nexport function findNodePosition(props: {\n editor: Editor | null\n node?: PMNode | null\n nodePos?: number | null\n}): { pos: number; node: PMNode } | null {\n const { editor, node, nodePos } = props\n\n if (!editor || !editor.state?.doc) return null\n\n // Zero is valid position\n const hasValidNode = node !== undefined && node !== null\n const hasValidPos = isValidPosition(nodePos)\n\n if (!hasValidNode && !hasValidPos) {\n return null\n }\n\n // First search for the node in the document if we have a node\n if (hasValidNode) {\n let foundPos = -1\n let foundNode: PMNode | null = null\n\n editor.state.doc.descendants((currentNode, pos) => {\n // TODO: Needed?\n // if (currentNode.type && currentNode.type.name === node!.type.name) {\n if (currentNode === node) {\n foundPos = pos\n foundNode = currentNode\n return false\n }\n return true\n })\n\n if (foundPos !== -1 && foundNode !== null) {\n return { pos: foundPos, node: foundNode }\n }\n }\n\n // If we have a valid position, use findNodeAtPosition\n if (hasValidPos) {\n const nodeAtPos = findNodeAtPosition(editor, nodePos!)\n if (nodeAtPos) {\n return { pos: nodePos!, node: nodeAtPos }\n }\n }\n\n return null\n}\n\n/**\n * Determines whether the current selection contains a node whose type matches\n * any of the provided node type names.\n * @param editor Tiptap editor instance\n * @param nodeTypeNames List of node type names to match against\n * @param checkAncestorNodes Whether to check ancestor node types up the depth chain\n */\nexport function isNodeTypeSelected(\n editor: Editor | null,\n nodeTypeNames: string[] = [],\n checkAncestorNodes: boolean = false\n): boolean {\n if (!editor || !editor.state.selection) return false\n\n const { selection } = editor.state\n if (selection.empty) return false\n\n // Direct node selection check\n if (selection instanceof NodeSelection) {\n const selectedNode = selection.node\n return selectedNode ? nodeTypeNames.includes(selectedNode.type.name) : false\n }\n\n // Depth-based ancestor node check\n if (checkAncestorNodes) {\n const { $from } = selection\n for (let depth = $from.depth; depth > 0; depth--) {\n const ancestorNode = $from.node(depth)\n if (nodeTypeNames.includes(ancestorNode.type.name)) {\n return true\n }\n }\n }\n\n return false\n}\n\n/**\n * Check whether the current selection is fully within nodes\n * whose type names are in the provided `types` list.\n *\n * - NodeSelection → checks the selected node.\n * - Text/AllSelection → ensures all textblocks within [from, to) are allowed.\n */\nexport function selectionWithinConvertibleTypes(\n editor: Editor,\n types: string[] = []\n): boolean {\n if (!editor || types.length === 0) return false\n\n const { state } = editor\n const { selection } = state\n const allowed = new Set(types)\n\n if (selection instanceof NodeSelection) {\n const nodeType = selection.node?.type?.name\n return !!nodeType && allowed.has(nodeType)\n }\n\n if (selection instanceof TextSelection || selection instanceof AllSelection) {\n let valid = true\n state.doc.nodesBetween(selection.from, selection.to, (node) => {\n if (node.isTextblock && !allowed.has(node.type.name)) {\n valid = false\n return false // stop early\n }\n return valid\n })\n return valid\n }\n\n return false\n}\n\n/**\n * Handles image upload with progress tracking and abort capability\n * @param file The file to upload\n * @param onProgress Optional callback for tracking upload progress\n * @param abortSignal Optional AbortSignal for cancelling the upload\n * @returns Promise resolving to the URL of the uploaded image\n */\nexport const handleImageUpload = async (\n file: File,\n onProgress?: (event: { progress: number }) => void,\n abortSignal?: AbortSignal\n): Promise<string> => {\n // Validate file\n if (!file) {\n throw new Error(\"No file provided\")\n }\n\n if (file.size > MAX_FILE_SIZE) {\n throw new Error(\n `File size exceeds maximum allowed (${MAX_FILE_SIZE / (1024 * 1024)}MB)`\n )\n }\n\n // For demo/testing: Simulate upload progress. In production, replace the following code\n // with your own upload implementation.\n for (let progress = 0; progress <= 100; progress += 10) {\n if (abortSignal?.aborted) {\n throw new Error(\"Upload cancelled\")\n }\n await new Promise((resolve) => setTimeout(resolve, 500))\n onProgress?.({ progress })\n }\n\n return \"/images/tiptap-ui-placeholder-image.jpg\"\n}\n\ntype ProtocolOptions = {\n /**\n * The protocol scheme to be registered.\n * @default '''\n * @example 'ftp'\n * @example 'git'\n */\n scheme: string\n\n /**\n * If enabled, it allows optional slashes after the protocol.\n * @default false\n * @example true\n */\n optionalSlashes?: boolean\n}\n\ntype ProtocolConfig = Array<ProtocolOptions | string>\n\nconst ATTR_WHITESPACE =\n // eslint-disable-next-line no-control-regex\n /[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g\n\nexport function isAllowedUri(\n uri: string | undefined,\n protocols?: ProtocolConfig\n) {\n const allowedProtocols: string[] = [\n \"http\",\n \"https\",\n \"ftp\",\n \"ftps\",\n \"mailto\",\n \"tel\",\n \"callto\",\n \"sms\",\n \"cid\",\n \"xmpp\",\n ]\n\n if (protocols) {\n protocols.forEach((protocol) => {\n const nextProtocol =\n typeof protocol === \"string\" ? protocol : protocol.scheme\n\n if (nextProtocol) {\n allowedProtocols.push(nextProtocol)\n }\n })\n }\n\n return (\n !uri ||\n uri.replace(ATTR_WHITESPACE, \"\").match(\n new RegExp(\n // eslint-disable-next-line no-useless-escape\n `^(?:(?:${allowedProtocols.join(\"|\")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,\n \"i\"\n )\n )\n )\n}\n\nexport function sanitizeUrl(\n inputUrl: string,\n baseUrl: string,\n protocols?: ProtocolConfig\n): string {\n try {\n const url = new URL(inputUrl, baseUrl)\n\n if (isAllowedUri(url.href, protocols)) {\n return url.href\n }\n } catch {\n // If URL creation fails, it's considered invalid\n }\n return \"#\"\n}\n\n/**\n * Update a single attribute on multiple nodes.\n *\n * @param tr - The transaction to mutate\n * @param targets - Array of { node, pos }\n * @param attrName - Attribute key to update\n * @param next - New value OR updater function receiving previous value\n * Pass `undefined` to remove the attribute.\n * @returns true if at least one node was updated, false otherwise\n */\nexport function updateNodesAttr<A extends string = string, V = unknown>(\n tr: Transaction,\n targets: readonly NodeWithPos[],\n attrName: A,\n next: V | ((prev: V | undefined) => V | undefined)\n): boolean {\n if (!targets.length) return false\n\n let changed = false\n\n for (const { pos } of targets) {\n // Always re-read from the transaction's current doc\n const currentNode = tr.doc.nodeAt(pos)\n if (!currentNode) continue\n\n const prevValue = (currentNode.attrs as Record<string, unknown>)[\n attrName\n ] as V | undefined\n const resolvedNext =\n typeof next === \"function\"\n ? (next as (p: V | undefined) => V | undefined)(prevValue)\n : next\n\n if (prevValue === resolvedNext) continue\n\n const nextAttrs: Record<string, unknown> = { ...currentNode.attrs }\n if (resolvedNext === undefined) {\n // Remove the key entirely instead of setting null\n delete nextAttrs[attrName]\n } else {\n nextAttrs[attrName] = resolvedNext\n }\n\n tr.setNodeMarkup(pos, undefined, nextAttrs)\n changed = true\n }\n\n return changed\n}\n\n/**\n * Selects the entire content of the current block node if the selection is empty.\n * If the selection is not empty, it does nothing.\n * @param editor The Tiptap editor instance\n */\nexport function selectCurrentBlockContent(editor: Editor) {\n const { selection, doc } = editor.state\n\n if (!selection.empty) return\n\n const $pos = selection.$from\n let blockNode: PMNode | null = null\n let blockPos = -1\n\n for (let depth = $pos.depth; depth >= 0; depth--) {\n const node = $pos.node(depth)\n const pos = $pos.start(depth)\n\n if (node.isBlock && node.textContent.trim()) {\n blockNode = node\n blockPos = pos\n break\n }\n }\n\n if (blockNode && blockPos >= 0) {\n const from = blockPos\n const to = blockPos + blockNode.nodeSize - 2 // -2 to exclude the closing tag\n\n if (from < to) {\n const $from = doc.resolve(from)\n const $to = doc.resolve(to)\n const newSelection = TextSelection.between($from, $to, 1)\n\n if (newSelection && !selection.eq(newSelection)) {\n editor.view.dispatch(editor.state.tr.setSelection(newSelection))\n }\n }\n }\n}\n\n/**\n * Retrieves all nodes of specified types from the current selection.\n * @param selection The current editor selection\n * @param allowedNodeTypes An array of node type names to look for (e.g., [\"image\", \"table\"])\n * @returns An array of objects containing the node and its position\n */\nexport function getSelectedNodesOfType(\n selection: Selection,\n allowedNodeTypes: string[]\n): NodeWithPos[] {\n const results: NodeWithPos[] = []\n const allowed = new Set(allowedNodeTypes)\n\n if (selection instanceof CellSelection) {\n selection.forEachCell((node: PMNode, pos: number) => {\n if (allowed.has(node.type.name)) {\n results.push({ node, pos })\n }\n })\n return results\n }\n\n if (selection instanceof NodeSelection) {\n const { node, from: pos } = selection\n if (node && allowed.has(node.type.name)) {\n results.push({ node, pos })\n }\n return results\n }\n\n const { $anchor } = selection\n const cell = cellAround($anchor)\n\n if (cell) {\n const cellNode = selection.$anchor.doc.nodeAt(cell.pos)\n if (cellNode && allowed.has(cellNode.type.name)) {\n results.push({ node: cellNode, pos: cell.pos })\n return results\n }\n }\n\n // Fallback: find parent nodes of allowed types\n const parentNode = findParentNodeClosestToPos($anchor, (node) =>\n allowed.has(node.type.name)\n )\n\n if (parentNode) {\n results.push({ node: parentNode.node, pos: parentNode.pos })\n }\n\n return results\n}\n\n/**\n * Clamps a value between min and max bounds\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(value, max))\n}\n\nexport function getSelectedBlockNodes(editor: Editor): PMNode[] {\n const { doc } = editor.state\n const { from, to } = editor.state.selection\n\n const blocks: PMNode[] = []\n const seen = new Set<number>()\n\n doc.nodesBetween(from, to, (node, pos) => {\n if (!node.isBlock) return\n\n if (!seen.has(pos)) {\n seen.add(pos)\n blocks.push(node)\n }\n\n return false\n })\n\n return blocks\n}\n","import { forwardRef, Fragment, useMemo } from \"react\"\n\n// --- Tiptap UI Primitive ---\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../tooltip\"\n\n// --- Lib ---\nimport { cn, parseShortcutKeys } from \"../../../lib/tiptap-utils\"\n\nimport \"./button-colors.scss\"\nimport \"./button.scss\"\n\nexport type ButtonVariant = \"ghost\" | \"primary\"\nexport type ButtonSize = \"small\" | \"default\" | \"large\"\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n showTooltip?: boolean\n tooltip?: React.ReactNode\n shortcutKeys?: string\n variant?: ButtonVariant\n size?: ButtonSize\n}\n\nexport const ShortcutDisplay: React.FC<{ shortcuts: string[] }> = ({\n shortcuts,\n}) => {\n if (shortcuts.length === 0) return null\n\n return (\n <div>\n {shortcuts.map((key, index) => (\n <Fragment key={index}>\n {index > 0 && <kbd>+</kbd>}\n <kbd>{key}</kbd>\n </Fragment>\n ))}\n </div>\n )\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n className,\n children,\n tooltip,\n showTooltip = true,\n shortcutKeys,\n variant,\n size,\n ...props\n },\n ref\n ) => {\n const shortcuts = useMemo<string[]>(\n () => parseShortcutKeys({ shortcutKeys }),\n [shortcutKeys]\n )\n\n if (!tooltip || !showTooltip) {\n return (\n <button\n data-slot=\"tiptap-button\"\n className={cn(\"tiptap-button\", className)}\n ref={ref}\n data-style={variant}\n data-size={size}\n {...props}\n >\n {children}\n </button>\n )\n }\n\n return (\n <Tooltip delay={200}>\n <TooltipTrigger\n data-slot=\"tiptap-button\"\n className={cn(\"tiptap-button\", className)}\n ref={ref}\n data-style={variant}\n data-size={size}\n {...props}\n >\n {children}\n </TooltipTrigger>\n <TooltipContent>\n {tooltip}\n <ShortcutDisplay shortcuts={shortcuts} />\n </TooltipContent>\n </Tooltip>\n )\n }\n)\n\nButton.displayName = \"Button\"\n\nexport default Button\n","\"use client\"\n\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\"\nimport { cn } from \"../../../lib/tiptap-utils\"\nimport \"./popover.scss\"\n\nfunction Popover({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n return <PopoverPrimitive.Root {...props} />\n}\n\nfunction PopoverTrigger({\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {\n return <PopoverPrimitive.Trigger {...props} />\n}\n\nfunction PopoverContent({\n className,\n align = \"center\",\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Content>) {\n return (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n align={align}\n sideOffset={sideOffset}\n className={cn(\"tiptap-popover\", className)}\n {...props}\n />\n </PopoverPrimitive.Portal>\n )\n}\n\nexport { Popover, PopoverTrigger, PopoverContent }\n","import { memo } from \"react\"\n\ntype SvgProps = React.ComponentPropsWithoutRef<\"svg\">\n\n/** 向上的箭头 —— 提交态用,和聊天输入框那颗圆形发送键同义。 */\nexport const SendIcon = memo(({ className, ...props }: SvgProps) => {\n return (\n <svg\n width=\"24\"\n height=\"24\"\n className={className}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n {...props}\n >\n <path\n d=\"M12 19V5M12 5L6 11M12 5L18 11\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )\n})\n\nSendIcon.displayName = \"SendIcon\"\n","\"use client\"\n\nimport { useEffect, useRef, useState } from \"react\"\nimport type { Editor } from \"@tiptap/react\"\n\n// --- Types ---\nimport type { AIContextData, AIPluginConfig } from \"./types\"\n\n// --- Icons ---\nimport { SendIcon } from \"../../components/tiptap-icons/send-icon\"\n\nimport \"./ai-dialog.scss\"\n\nexport interface AIDialogProps {\n editor: Editor\n config: AIPluginConfig\n buildContext: (prompt: string) => AIContextData | null\n onClose: () => void\n}\n\n/**\n * 一行输入 + 一颗提交键。\n *\n * 刻意不做成带标题栏和按钮行的卡片:它浮在正文上方紧贴选区,任何一行多余的\n * 装饰都会把用户正在读的那段文字挡掉。同类产品(ChatGPT canvas / Notion AI)\n * 也都收敛成单行胶囊。\n */\nexport function AIDialog({\n editor,\n config,\n buildContext,\n onClose,\n}: AIDialogProps) {\n const [prompt, setPrompt] = useState(\"\")\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n inputRef.current?.focus()\n }, [])\n\n const canSubmit = Boolean(prompt.trim()) && !isLoading\n\n const handleSubmit = async () => {\n if (!canSubmit) return\n\n setError(null)\n setIsLoading(true)\n\n try {\n const context = buildContext(prompt)\n\n if (!context) {\n setError(\"没有选中内容\")\n return\n }\n\n const result = await config.plugin.process(context)\n\n if (result.error) {\n setError(result.error)\n return\n }\n\n // 插件自己落盘时不返回文本 —— 这里再替换一次会把它的改动冲掉。\n if (result.result) {\n const { from, to } = editor.state.selection\n editor.view.dispatch(\n editor.state.tr.replaceWith(from, to, [\n editor.state.schema.text(result.result),\n ])\n )\n }\n\n setPrompt(\"\")\n onClose()\n } catch (err) {\n setError(err instanceof Error ? err.message : \"出错了\")\n } finally {\n setIsLoading(false)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault()\n void handleSubmit()\n }\n if (e.key === \"Escape\") {\n e.preventDefault()\n onClose()\n }\n }\n\n return (\n <div className=\"tiptap-ai-dialog\">\n <div className=\"tiptap-ai-dialog-field\" data-loading={isLoading}>\n <input\n ref={inputRef}\n type=\"text\"\n className=\"tiptap-ai-dialog-input\"\n placeholder=\"描述你想要的修改\"\n value={prompt}\n disabled={isLoading}\n onChange={(e) => {\n setPrompt(e.target.value)\n setError(null)\n }}\n onKeyDown={handleKeyDown}\n />\n\n <button\n type=\"button\"\n className=\"tiptap-ai-dialog-submit\"\n aria-label=\"发送\"\n disabled={!canSubmit}\n onClick={() => void handleSubmit()}\n >\n <SendIcon />\n </button>\n </div>\n\n {error && <div className=\"tiptap-ai-dialog-error\">{error}</div>}\n </div>\n )\n}\n","import { NodeSelection, type Selection } from \"@tiptap/pm/state\"\nimport { CellSelection } from \"@tiptap/pm/tables\"\nimport type { JSONContent, Editor } from \"@tiptap/react\"\nimport { isTextSelection, isNodeSelection, posToDOMRect } from \"@tiptap/react\"\n\n\nconst NODE_TYPE_LABELS: Record<string, string> = {\n paragraph: \"Text\",\n heading: \"Heading\",\n blockquote: \"Blockquote\",\n listItem: \"List Item\",\n codeBlock: \"Code Block\",\n table: \"Table\",\n tocNode: \"Table of contents\",\n}\nexport type OverflowPosition = \"none\" | \"top\" | \"bottom\" | \"both\"\n\n/**\n * Utility function to get URL parameters\n */\nexport const getUrlParam = (param: string): string | null => {\n if (typeof window === \"undefined\") return null\n const params = new URLSearchParams(window.location.search)\n return params.get(param)\n}\n\n/**\n * Returns a display name for the current node in the editor\n * @param editor The Tiptap editor instance\n * @returns The display name of the current node\n */\nexport const getNodeDisplayName = (editor: Editor | null): string => {\n if (!editor) return \"Node\"\n\n const { selection } = editor.state\n\n if (selection instanceof NodeSelection) {\n const nodeType = selection.node.type.name\n return NODE_TYPE_LABELS[nodeType] || nodeType.toLowerCase()\n }\n\n if (selection instanceof CellSelection) {\n return \"Table\"\n }\n\n const { $anchor } = selection\n const nodeType = $anchor.parent.type.name\n return NODE_TYPE_LABELS[nodeType] || nodeType.toLowerCase()\n}\n\n/**\n * Removes empty paragraph nodes from content\n */\nexport const removeEmptyParagraphs = (content: JSONContent) => ({\n ...content,\n content: content.content?.filter(\n (node) =>\n node.type !== \"paragraph\" ||\n node.content?.some((child) => child.text?.trim() || child.type !== \"text\")\n ),\n})\n\n/**\n * Determines how a target element overflows relative to a container element\n */\nexport function getElementOverflowPosition(\n targetElement: Element,\n containerElement: HTMLElement\n): OverflowPosition {\n const targetBounds = targetElement.getBoundingClientRect()\n const containerBounds = containerElement.getBoundingClientRect()\n\n const isOverflowingTop = targetBounds.top < containerBounds.top\n const isOverflowingBottom = targetBounds.bottom > containerBounds.bottom\n\n if (isOverflowingTop && isOverflowingBottom) return \"both\"\n if (isOverflowingTop) return \"top\"\n if (isOverflowingBottom) return \"bottom\"\n return \"none\"\n}\n\n/**\n * Checks if the current selection is valid for a given editor\n */\nexport const isSelectionValid = (\n editor: Editor | null,\n selection?: Selection,\n excludedNodeTypes: string[] = [\"imageUpload\", \"horizontalRule\"]\n): boolean => {\n if (!editor) return false\n if (!selection) selection = editor.state.selection\n\n const { state } = editor\n const { doc } = state\n const { empty, from, to } = selection\n\n const isEmptyTextBlock =\n !doc.textBetween(from, to).length && isTextSelection(selection)\n const isCodeBlock =\n selection.$from.parent.type.spec.code ||\n (isNodeSelection(selection) && selection.node.type.spec.code)\n const isExcludedNode =\n isNodeSelection(selection) &&\n excludedNodeTypes.includes(selection.node.type.name)\n const isTableCell = selection instanceof CellSelection\n\n return (\n !empty &&\n !isEmptyTextBlock &&\n !isCodeBlock &&\n !isExcludedNode &&\n !isTableCell\n )\n}\n\n/**\n * Checks if the current text selection is valid for editing\n * - Not empty\n * - Not a code block\n * - Not a node selection\n */\nexport const isTextSelectionValid = (editor: Editor | null): boolean => {\n if (!editor) return false\n const { state } = editor\n const { selection } = state\n const isValid =\n isTextSelection(selection) &&\n !selection.empty &&\n !selection.$from.parent.type.spec.code &&\n !isNodeSelection(selection)\n\n return isValid\n}\n\n/**\n * Gets the bounding rect of the current selection in the editor.\n */\nexport const getSelectionBoundingRect = (editor: Editor): DOMRect | null => {\n const { state } = editor.view\n const { selection } = state\n const { ranges } = selection\n\n const from = Math.min(...ranges.map((range) => range.$from.pos))\n const to = Math.max(...ranges.map((range) => range.$to.pos))\n\n if (isNodeSelection(selection)) {\n const node = editor.view.nodeDOM(from) as HTMLElement\n if (node) {\n return node.getBoundingClientRect()\n }\n }\n\n return posToDOMRect(editor.view, from, to)\n}\n\n/**\n * Generates a deterministic avatar URL from a user name\n */\nexport const getAvatar = (name: string) => {\n if (!name) {\n return \"/avatars/memoji_01.png\"\n }\n\n let hash = 0\n for (let i = 0; i < name.length; i++) {\n hash = name.charCodeAt(i) + ((hash << 5) - hash)\n hash = hash & hash\n }\n\n const randomFraction = (Math.abs(hash) % 1000000) / 1000000\n const id = 1 + Math.floor(randomFraction * 20)\n const idString = id.toString().padStart(2, \"0\")\n return `/avatars/memoji_${idString}.png`\n}\n\n\n","\"use client\"\n\nimport { forwardRef, useCallback, useEffect, useState } from \"react\"\nimport type { Editor } from \"@tiptap/react\"\n\n// --- Hooks ---\nimport { useTiptapEditor } from \"../../hooks/use-tiptap-editor\"\nimport { useAIContext } from \"./use-ai-context\"\nimport { useAIConfig } from \"./ai-context\"\nimport { shouldShowAIButton } from \"./ai-button-visibility\"\n\n// --- Types ---\nimport type { AIPluginConfig } from \"./types\"\n\n// --- Icons ---\nimport { SparklesIcon } from \"../../components/tiptap-icons/sparkles-icon\"\n\n// --- UI Primitives ---\nimport type { ButtonProps } from \"../../components/tiptap-ui-primitive/button\"\nimport { Button } from \"../../components/tiptap-ui-primitive/button\"\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"../../components/tiptap-ui-primitive/popover\"\n\n// --- AI Dialog ---\nimport { AIDialog } from \"./ai-dialog\"\nimport { isSelectionValid } from \"../../lib/tiptap-collab-utils\"\n\nexport interface AIButtonProps extends Omit<ButtonProps, \"type\"> {\n /**\n * The Tiptap editor instance\n */\n editor?: Editor | null\n\n /**\n * AI plugin configuration (optional, will use context if not provided)\n */\n config?: AIPluginConfig\n\n /**\n * Whether to hide the button when no valid selection\n * @default true\n */\n hideWhenUnavailable?: boolean\n}\n\n/**\n * AI Button component for triggering the AI processing dialog\n *\n * Usage:\n * ```tsx\n * <AIButton\n * config={{ plugin: new MyAIPlugin() }}\n * hideWhenUnavailable\n * />\n * ```\n */\nexport const AIButton = forwardRef<HTMLButtonElement, AIButtonProps>(\n (\n {\n editor: providedEditor,\n config: providedConfig,\n hideWhenUnavailable = true,\n onClick,\n ...buttonProps\n },\n ref\n ) => {\n const { editor } = useTiptapEditor(providedEditor)\n const { buildContext } = useAIContext(editor)\n const contextConfig = useAIConfig()\n const [isOpen, setIsOpen] = useState(false)\n const [shouldShow, setShouldShow] = useState(false)\n\n const config = providedConfig || contextConfig\n const isEnabled = config?.enabled !== false\n\n useEffect(() => {\n if (!editor) {\n setShouldShow(false)\n return\n }\n\n const updateVisibility = () => {\n setShouldShow(\n shouldShowAIButton({\n enabled: isEnabled,\n hasValidSelection: isSelectionValid(editor),\n hideWhenUnavailable,\n isEditable: editor.isEditable,\n })\n )\n }\n\n updateVisibility()\n editor.on(\"selectionUpdate\", updateVisibility)\n\n return () => {\n editor.off(\"selectionUpdate\", updateVisibility)\n }\n }, [editor, hideWhenUnavailable, isEnabled])\n\n const handleOpenChange = useCallback(\n (open: boolean) => {\n setIsOpen(open)\n },\n []\n )\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n setIsOpen(true)\n }\n },\n [onClick]\n )\n\n if (!shouldShow || !editor || !config) {\n return null\n }\n\n return (\n <Popover open={isOpen} onOpenChange={handleOpenChange}>\n <PopoverTrigger asChild>\n <Button\n ref={ref}\n type=\"button\"\n variant=\"ghost\"\n role=\"button\"\n tabIndex={-1}\n aria-label=\"AI Assistant\"\n tooltip=\"AI Assistant\"\n onClick={handleClick}\n {...buttonProps}\n >\n <SparklesIcon className=\"tiptap-button-icon\" />\n </Button>\n </PopoverTrigger>\n\n {/* 不用 asChild:AIDialog 不转发 ref,Radix 量不到尺寸会定位错位 */}\n <PopoverContent side=\"top\" align=\"start\" sideOffset={4}>\n <AIDialog\n editor={editor}\n config={config}\n buildContext={buildContext}\n onClose={() => handleOpenChange(false)}\n />\n </PopoverContent>\n </Popover>\n )\n }\n)\n\nAIButton.displayName = \"AIButton\"\n"]}
package/dist/doc.js CHANGED
@@ -1,5 +1,5 @@
1
- export { ArticleViewer, Audio, CollabContext, CollabProvider, Column, Columns, DEFAULT_MAX_FILE_SIZES, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, FileAttachment, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, Video, defaultUiState, detectMediaKind, findSelectionPosition, hasContentAbove, markHideFloatingOnNext, pickFile, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, use_ui_editor_state_default as useUiEditorStateDefault, useUnmount, useUser, useWindowSize } from './chunk-BBZGFBWU.js';
2
- export { Button, MAC_SYMBOLS, MAX_FILE_SIZE, Popover, PopoverContent, PopoverTrigger, SR_ONLY, clamp, cn, findNodeAtPosition, findNodePosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, parseShortcutKeys, removeEmptyParagraphs, sanitizeUrl, selectCurrentBlockContent, selectionWithinConvertibleTypes, updateNodesAttr, useTiptapEditor } from './chunk-GSBPP62I.js';
1
+ export { ArticleViewer, Audio, CollabContext, CollabProvider, Column, Columns, DEFAULT_MAX_FILE_SIZES, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, FileAttachment, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, Video, defaultUiState, detectMediaKind, findSelectionPosition, hasContentAbove, markHideFloatingOnNext, pickFile, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, use_ui_editor_state_default as useUiEditorStateDefault, useUnmount, useUser, useWindowSize } from './chunk-FQCG2HNJ.js';
2
+ export { Button, MAC_SYMBOLS, MAX_FILE_SIZE, Popover, PopoverContent, PopoverTrigger, SR_ONLY, clamp, cn, findNodeAtPosition, findNodePosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, parseShortcutKeys, removeEmptyParagraphs, sanitizeUrl, selectCurrentBlockContent, selectionWithinConvertibleTypes, updateNodesAttr, useTiptapEditor } from './chunk-QMYT5WXO.js';
3
3
  import { useState, useEffect } from 'react';
4
4
 
5
5
  function useScrolling(target, options = {}) {
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ registerFormat({
29
29
  importExtensions: [".docx", ".md", ".html"],
30
30
  exportFormats: ["docx", "html", "json", "markdown"]
31
31
  },
32
- load: () => import('./DocView-7QREDSQJ.js')
32
+ load: () => import('./DocView-IZ4JBSIA.js')
33
33
  });
34
34
  registerFormat({
35
35
  format: "sheet",
@@ -115,6 +115,13 @@ interface AIDialogProps {
115
115
  buildContext: (prompt: string) => AIContextData | null;
116
116
  onClose: () => void;
117
117
  }
118
+ /**
119
+ * 一行输入 + 一颗提交键。
120
+ *
121
+ * 刻意不做成带标题栏和按钮行的卡片:它浮在正文上方紧贴选区,任何一行多余的
122
+ * 装饰都会把用户正在读的那段文字挡掉。同类产品(ChatGPT canvas / Notion AI)
123
+ * 也都收敛成单行胶囊。
124
+ */
118
125
  declare function AIDialog({ editor, config, buildContext, onClose, }: AIDialogProps): react.JSX.Element;
119
126
 
120
127
  declare function useAIContext(editor: Editor | null): {
@@ -1,3 +1,3 @@
1
- export { AIButton, AIConfigContext, AIDialog, useAIConfig, useAIContext } from '../chunk-GSBPP62I.js';
1
+ export { AIButton, AIConfigContext, AIDialog, useAIConfig, useAIContext } from '../chunk-QMYT5WXO.js';
2
2
  //# sourceMappingURL=ai.js.map
3
3
  //# sourceMappingURL=ai.js.map