@kopexa/tiptap 17.0.17 → 17.2.0
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/chunk-2U5CQUZH.mjs +91 -0
- package/dist/chunk-2V6VOAPI.mjs +139 -0
- package/dist/chunk-32SUXCAQ.mjs +115 -0
- package/dist/chunk-3VRQUYYW.mjs +169 -0
- package/dist/chunk-4CDZ547I.mjs +185 -0
- package/dist/chunk-5GFFTVMZ.mjs +62 -0
- package/dist/{chunk-FJAGUXEO.mjs → chunk-7SRL3P4B.mjs} +32 -19
- package/dist/{chunk-WHJ4B43N.mjs → chunk-7VGROP26.mjs} +69 -25
- package/dist/chunk-7VW67NVL.mjs +80 -0
- package/dist/chunk-BXHPO3T7.mjs +152 -0
- package/dist/{chunk-QF3YHPWM.mjs → chunk-E5NW3MJZ.mjs} +4 -4
- package/dist/chunk-FRJX2F4T.mjs +55 -0
- package/dist/chunk-IFXRPGIJ.mjs +98 -0
- package/dist/chunk-JCV5SEKN.mjs +65 -0
- package/dist/chunk-LMCQMSW2.mjs +345 -0
- package/dist/chunk-N4CT5RNC.mjs +123 -0
- package/dist/{chunk-B2DHYFSH.mjs → chunk-NEHW62L7.mjs} +56 -3
- package/dist/chunk-NSYSECKW.mjs +53 -0
- package/dist/{chunk-3IKIIRV3.mjs → chunk-QAE2D4KV.mjs} +39 -16
- package/dist/chunk-TAM3VMJT.mjs +80 -0
- package/dist/chunk-UU6JK5HX.mjs +257 -0
- package/dist/chunk-UVHVCION.mjs +168 -0
- package/dist/chunk-VF3G2URZ.mjs +83 -0
- package/dist/chunk-VRQ6OSAZ.mjs +76 -0
- package/dist/chunk-WAAH3NLG.mjs +77 -0
- package/dist/chunk-XNDXYI2N.mjs +158 -0
- package/dist/context/editor-file-context.d.mts +70 -0
- package/dist/context/editor-file-context.d.ts +70 -0
- package/dist/context/editor-file-context.js +96 -0
- package/dist/context/editor-file-context.mjs +12 -0
- package/dist/extensions/callout/callout-settings.d.mts +13 -0
- package/dist/extensions/callout/callout-settings.d.ts +13 -0
- package/dist/extensions/callout/callout-settings.js +206 -0
- package/dist/extensions/callout/callout-settings.mjs +9 -0
- package/dist/extensions/callout/callout-view.d.mts +12 -0
- package/dist/extensions/callout/callout-view.d.ts +12 -0
- package/dist/extensions/callout/callout-view.js +273 -0
- package/dist/extensions/callout/callout-view.mjs +12 -0
- package/dist/extensions/callout/index.d.mts +44 -0
- package/dist/extensions/callout/index.d.ts +44 -0
- package/dist/extensions/callout/index.js +380 -0
- package/dist/extensions/callout/index.mjs +13 -0
- package/dist/extensions/callout/messages.d.mts +59 -0
- package/dist/extensions/callout/messages.d.ts +59 -0
- package/dist/extensions/callout/messages.js +88 -0
- package/dist/extensions/callout/messages.mjs +7 -0
- package/dist/extensions/image/image-view.d.mts +15 -0
- package/dist/extensions/image/image-view.d.ts +15 -0
- package/dist/extensions/image/image-view.js +423 -0
- package/dist/extensions/image/image-view.mjs +12 -0
- package/dist/extensions/image/index.d.mts +66 -0
- package/dist/extensions/image/index.d.ts +66 -0
- package/dist/extensions/image/index.js +495 -0
- package/dist/extensions/image/index.mjs +16 -0
- package/dist/extensions/image/messages.d.mts +56 -0
- package/dist/extensions/image/messages.d.ts +56 -0
- package/dist/extensions/image/messages.js +85 -0
- package/dist/extensions/image/messages.mjs +7 -0
- package/dist/extensions/math/index.d.mts +38 -0
- package/dist/extensions/math/index.d.ts +38 -0
- package/dist/extensions/math/index.js +544 -0
- package/dist/extensions/math/index.mjs +17 -0
- package/dist/extensions/math/inline-math-view.d.mts +12 -0
- package/dist/extensions/math/inline-math-view.d.ts +12 -0
- package/dist/extensions/math/inline-math-view.js +232 -0
- package/dist/extensions/math/inline-math-view.mjs +11 -0
- package/dist/extensions/math/inline-math.d.mts +32 -0
- package/dist/extensions/math/inline-math.d.ts +32 -0
- package/dist/extensions/math/inline-math.js +304 -0
- package/dist/extensions/math/inline-math.mjs +12 -0
- package/dist/extensions/math/math-block-view.d.mts +11 -0
- package/dist/extensions/math/math-block-view.d.ts +11 -0
- package/dist/extensions/math/math-block-view.js +248 -0
- package/dist/extensions/math/math-block-view.mjs +11 -0
- package/dist/extensions/math/messages.d.mts +49 -0
- package/dist/extensions/math/messages.d.ts +49 -0
- package/dist/extensions/math/messages.js +78 -0
- package/dist/extensions/math/messages.mjs +7 -0
- package/dist/extensions/toc/index.d.mts +53 -0
- package/dist/extensions/toc/index.d.ts +53 -0
- package/dist/extensions/toc/index.js +501 -0
- package/dist/extensions/toc/index.mjs +13 -0
- package/dist/extensions/toc/messages.d.mts +74 -0
- package/dist/extensions/toc/messages.d.ts +74 -0
- package/dist/extensions/toc/messages.js +103 -0
- package/dist/extensions/toc/messages.mjs +7 -0
- package/dist/extensions/toc/toc-settings.d.mts +13 -0
- package/dist/extensions/toc/toc-settings.d.ts +13 -0
- package/dist/extensions/toc/toc-settings.js +283 -0
- package/dist/extensions/toc/toc-settings.mjs +9 -0
- package/dist/extensions/toc/toc-view.d.mts +12 -0
- package/dist/extensions/toc/toc-view.d.ts +12 -0
- package/dist/extensions/toc/toc-view.js +411 -0
- package/dist/extensions/toc/toc-view.mjs +12 -0
- package/dist/hooks/use-create-editor.d.mts +20 -2
- package/dist/hooks/use-create-editor.d.ts +20 -2
- package/dist/hooks/use-create-editor.js +2020 -20
- package/dist/hooks/use-create-editor.mjs +20 -3
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +3948 -1563
- package/dist/index.mjs +64 -23
- package/dist/presets/basic/editor-header.d.mts +3 -2
- package/dist/presets/basic/editor-header.d.ts +3 -2
- package/dist/presets/basic/editor-header.js +91 -25
- package/dist/presets/basic/editor-header.mjs +14 -14
- package/dist/presets/basic/index.d.mts +3 -1
- package/dist/presets/basic/index.d.ts +3 -1
- package/dist/presets/basic/index.js +3833 -1517
- package/dist/presets/basic/index.mjs +41 -22
- package/dist/ui/bubble-menu/index.d.mts +13 -0
- package/dist/ui/bubble-menu/index.d.ts +13 -0
- package/dist/ui/bubble-menu/index.js +671 -0
- package/dist/ui/bubble-menu/index.mjs +16 -0
- package/dist/ui/color-highlight-popover/color-highlight-popover.mjs +2 -2
- package/dist/ui/color-highlight-popover/index.mjs +2 -2
- package/dist/ui/copy-anchor-link-button/use-scroll-to-hash.mjs +2 -2
- package/dist/ui/link-bubble/index.d.mts +13 -0
- package/dist/ui/link-bubble/index.d.ts +13 -0
- package/dist/ui/link-bubble/index.js +182 -0
- package/dist/ui/link-bubble/index.mjs +10 -0
- package/dist/ui/link-popover/index.js +66 -23
- package/dist/ui/link-popover/index.mjs +3 -3
- package/dist/ui/link-popover/link-popover.d.mts +7 -2
- package/dist/ui/link-popover/link-popover.d.ts +7 -2
- package/dist/ui/link-popover/link-popover.js +66 -23
- package/dist/ui/link-popover/link-popover.mjs +3 -3
- package/dist/ui/link-popover/use-link-popover.mjs +2 -2
- package/dist/ui/slash-dropdown-menu/index.js +53 -3
- package/dist/ui/slash-dropdown-menu/index.mjs +6 -6
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.js +53 -3
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.mjs +4 -4
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.d.mts +28 -0
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.d.ts +28 -0
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.js +53 -3
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.mjs +1 -1
- package/dist/ui/suggestion-menu/index.mjs +2 -2
- package/dist/ui/suggestion-menu/suggestion-menu.mjs +2 -2
- package/dist/utils/safe-parse.js +113 -4
- package/dist/utils/safe-parse.mjs +1 -1
- package/package.json +48 -39
- package/dist/chunk-7LHOYNVF.mjs +0 -60
- package/dist/chunk-LXOLVGLW.mjs +0 -131
- package/dist/{chunk-XL5FS7LN.mjs → chunk-C5RQWJKE.mjs} +3 -3
- package/dist/{chunk-JNL4KY45.mjs → chunk-DZLGLP7R.mjs} +3 -3
- package/dist/{chunk-LHXRE26G.mjs → chunk-VTKJPVNM.mjs} +3 -3
- package/dist/{chunk-XLSZK3WJ.mjs → chunk-ZYFCSR3E.mjs} +3 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface EditorFileHandler {
|
|
5
|
+
/**
|
|
6
|
+
* Upload a file and return a reference string.
|
|
7
|
+
* The reference format is determined by the backend (e.g., UUID, custom scheme).
|
|
8
|
+
* @param file The file to upload
|
|
9
|
+
* @param onProgress Optional progress callback (0-100)
|
|
10
|
+
* @returns Promise resolving to a reference string
|
|
11
|
+
*/
|
|
12
|
+
upload: (file: File, onProgress?: (percent: number) => void) => Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a reference to a displayable URL.
|
|
15
|
+
* Typically returns a signed URL from your storage backend.
|
|
16
|
+
* @param ref The reference string from upload
|
|
17
|
+
* @returns Promise resolving to a displayable URL
|
|
18
|
+
*/
|
|
19
|
+
resolve: (ref: string) => Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a src string is a reference that needs resolving.
|
|
22
|
+
* Returns false for already-valid URLs (https://, data:, etc.)
|
|
23
|
+
* @param src The src attribute value
|
|
24
|
+
* @returns true if this needs to be resolved
|
|
25
|
+
*/
|
|
26
|
+
isReference: (src: string) => boolean;
|
|
27
|
+
}
|
|
28
|
+
interface EditorFileContextValue extends EditorFileHandler {
|
|
29
|
+
/**
|
|
30
|
+
* Whether file handling is available
|
|
31
|
+
*/
|
|
32
|
+
isAvailable: true;
|
|
33
|
+
}
|
|
34
|
+
interface EditorFileProviderProps {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Upload handler - called when user pastes/drops a file
|
|
38
|
+
*/
|
|
39
|
+
onUpload: EditorFileHandler["upload"];
|
|
40
|
+
/**
|
|
41
|
+
* Resolve handler - called to get displayable URL from reference
|
|
42
|
+
*/
|
|
43
|
+
onResolve: EditorFileHandler["resolve"];
|
|
44
|
+
/**
|
|
45
|
+
* Check if src needs resolving (default: not starting with http/https/data)
|
|
46
|
+
*/
|
|
47
|
+
isReference?: EditorFileHandler["isReference"];
|
|
48
|
+
/**
|
|
49
|
+
* Cache TTL buffer in ms (default: 2 minutes)
|
|
50
|
+
* URLs are refreshed this much before actual expiry
|
|
51
|
+
*/
|
|
52
|
+
cacheBuffer?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Default cache TTL in ms if not determined from response (default: 10 minutes)
|
|
55
|
+
*/
|
|
56
|
+
defaultCacheTtl?: number;
|
|
57
|
+
}
|
|
58
|
+
declare function EditorFileProvider({ children, onUpload, onResolve, isReference, cacheBuffer, defaultCacheTtl, }: EditorFileProviderProps): react_jsx_runtime.JSX.Element;
|
|
59
|
+
/**
|
|
60
|
+
* Hook to access file handling capabilities.
|
|
61
|
+
* Returns null if no EditorFileProvider is present (files not supported).
|
|
62
|
+
*/
|
|
63
|
+
declare function useEditorFile(): EditorFileContextValue | null;
|
|
64
|
+
/**
|
|
65
|
+
* Hook that throws if file handling is not available.
|
|
66
|
+
* Use this in components that require file support.
|
|
67
|
+
*/
|
|
68
|
+
declare function useEditorFileRequired(): EditorFileContextValue;
|
|
69
|
+
|
|
70
|
+
export { type EditorFileHandler, EditorFileProvider, type EditorFileProviderProps, useEditorFile, useEditorFileRequired };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/context/editor-file-context.tsx
|
|
23
|
+
var editor_file_context_exports = {};
|
|
24
|
+
__export(editor_file_context_exports, {
|
|
25
|
+
EditorFileProvider: () => EditorFileProvider,
|
|
26
|
+
useEditorFile: () => useEditorFile,
|
|
27
|
+
useEditorFileRequired: () => useEditorFileRequired
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(editor_file_context_exports);
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var EditorFileContext = (0, import_react.createContext)(null);
|
|
33
|
+
var DEFAULT_CACHE_BUFFER = 2 * 60 * 1e3;
|
|
34
|
+
var DEFAULT_CACHE_TTL = 10 * 60 * 1e3;
|
|
35
|
+
var defaultIsReference = (src) => {
|
|
36
|
+
if (!src) return false;
|
|
37
|
+
if (src.startsWith("http://") || src.startsWith("https://")) return false;
|
|
38
|
+
if (src.startsWith("data:")) return false;
|
|
39
|
+
if (src.startsWith("blob:")) return false;
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
function EditorFileProvider({
|
|
43
|
+
children,
|
|
44
|
+
onUpload,
|
|
45
|
+
onResolve,
|
|
46
|
+
isReference = defaultIsReference,
|
|
47
|
+
cacheBuffer = DEFAULT_CACHE_BUFFER,
|
|
48
|
+
defaultCacheTtl = DEFAULT_CACHE_TTL
|
|
49
|
+
}) {
|
|
50
|
+
const cacheRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
51
|
+
const resolve = (0, import_react.useCallback)(
|
|
52
|
+
async (ref) => {
|
|
53
|
+
const cache = cacheRef.current;
|
|
54
|
+
const now = Date.now();
|
|
55
|
+
const cached = cache.get(ref);
|
|
56
|
+
if (cached && cached.expiresAt > now + cacheBuffer) {
|
|
57
|
+
return cached.url;
|
|
58
|
+
}
|
|
59
|
+
const url = await onResolve(ref);
|
|
60
|
+
cache.set(ref, {
|
|
61
|
+
url,
|
|
62
|
+
expiresAt: now + defaultCacheTtl
|
|
63
|
+
});
|
|
64
|
+
return url;
|
|
65
|
+
},
|
|
66
|
+
[onResolve, cacheBuffer, defaultCacheTtl]
|
|
67
|
+
);
|
|
68
|
+
const value = (0, import_react.useMemo)(
|
|
69
|
+
() => ({
|
|
70
|
+
isAvailable: true,
|
|
71
|
+
upload: onUpload,
|
|
72
|
+
resolve,
|
|
73
|
+
isReference
|
|
74
|
+
}),
|
|
75
|
+
[onUpload, resolve, isReference]
|
|
76
|
+
);
|
|
77
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditorFileContext.Provider, { value, children });
|
|
78
|
+
}
|
|
79
|
+
function useEditorFile() {
|
|
80
|
+
return (0, import_react.useContext)(EditorFileContext);
|
|
81
|
+
}
|
|
82
|
+
function useEditorFileRequired() {
|
|
83
|
+
const context = (0, import_react.useContext)(EditorFileContext);
|
|
84
|
+
if (!context) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
"useEditorFileRequired must be used within an EditorFileProvider"
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return context;
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
EditorFileProvider,
|
|
94
|
+
useEditorFile,
|
|
95
|
+
useEditorFileRequired
|
|
96
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
import { CalloutAttrs as CalloutNodeAttrs } from './index.mjs';
|
|
4
|
+
import '@tiptap/core';
|
|
5
|
+
|
|
6
|
+
interface CalloutSettingsProps {
|
|
7
|
+
editor: Editor;
|
|
8
|
+
attrs: CalloutNodeAttrs;
|
|
9
|
+
getPos: () => number | undefined;
|
|
10
|
+
}
|
|
11
|
+
declare function CalloutSettings({ editor, attrs, getPos, }: CalloutSettingsProps): react_jsx_runtime.JSX.Element | null;
|
|
12
|
+
|
|
13
|
+
export { CalloutSettings };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
import { CalloutAttrs as CalloutNodeAttrs } from './index.js';
|
|
4
|
+
import '@tiptap/core';
|
|
5
|
+
|
|
6
|
+
interface CalloutSettingsProps {
|
|
7
|
+
editor: Editor;
|
|
8
|
+
attrs: CalloutNodeAttrs;
|
|
9
|
+
getPos: () => number | undefined;
|
|
10
|
+
}
|
|
11
|
+
declare function CalloutSettings({ editor, attrs, getPos, }: CalloutSettingsProps): react_jsx_runtime.JSX.Element | null;
|
|
12
|
+
|
|
13
|
+
export { CalloutSettings };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/extensions/callout/callout-settings.tsx
|
|
23
|
+
var callout_settings_exports = {};
|
|
24
|
+
__export(callout_settings_exports, {
|
|
25
|
+
CalloutSettings: () => CalloutSettings
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(callout_settings_exports);
|
|
28
|
+
var import_button = require("@kopexa/button");
|
|
29
|
+
var import_dialog = require("@kopexa/dialog");
|
|
30
|
+
var import_icons = require("@kopexa/icons");
|
|
31
|
+
var import_input = require("@kopexa/input");
|
|
32
|
+
var import_label = require("@kopexa/label");
|
|
33
|
+
var import_select = require("@kopexa/select");
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var import_react_intl2 = require("react-intl");
|
|
36
|
+
|
|
37
|
+
// src/extensions/callout/messages.ts
|
|
38
|
+
var import_react_intl = require("react-intl");
|
|
39
|
+
var messages = (0, import_react_intl.defineMessages)({
|
|
40
|
+
settings: {
|
|
41
|
+
id: "editor.callout.settings",
|
|
42
|
+
defaultMessage: "Settings",
|
|
43
|
+
description: "Settings button label"
|
|
44
|
+
},
|
|
45
|
+
variant: {
|
|
46
|
+
id: "editor.callout.variant",
|
|
47
|
+
defaultMessage: "Variant",
|
|
48
|
+
description: "Variant setting label"
|
|
49
|
+
},
|
|
50
|
+
variant_default: {
|
|
51
|
+
id: "editor.callout.variant_default",
|
|
52
|
+
defaultMessage: "Default",
|
|
53
|
+
description: "Default variant option"
|
|
54
|
+
},
|
|
55
|
+
variant_info: {
|
|
56
|
+
id: "editor.callout.variant_info",
|
|
57
|
+
defaultMessage: "Info",
|
|
58
|
+
description: "Info variant option"
|
|
59
|
+
},
|
|
60
|
+
variant_success: {
|
|
61
|
+
id: "editor.callout.variant_success",
|
|
62
|
+
defaultMessage: "Success",
|
|
63
|
+
description: "Success variant option"
|
|
64
|
+
},
|
|
65
|
+
variant_warning: {
|
|
66
|
+
id: "editor.callout.variant_warning",
|
|
67
|
+
defaultMessage: "Warning",
|
|
68
|
+
description: "Warning variant option"
|
|
69
|
+
},
|
|
70
|
+
variant_destructive: {
|
|
71
|
+
id: "editor.callout.variant_destructive",
|
|
72
|
+
defaultMessage: "Error",
|
|
73
|
+
description: "Destructive/Error variant option"
|
|
74
|
+
},
|
|
75
|
+
title: {
|
|
76
|
+
id: "editor.callout.title",
|
|
77
|
+
defaultMessage: "Title",
|
|
78
|
+
description: "Title input label"
|
|
79
|
+
},
|
|
80
|
+
title_placeholder: {
|
|
81
|
+
id: "editor.callout.title_placeholder",
|
|
82
|
+
defaultMessage: "Optional title...",
|
|
83
|
+
description: "Title input placeholder"
|
|
84
|
+
},
|
|
85
|
+
save: {
|
|
86
|
+
id: "editor.callout.save",
|
|
87
|
+
defaultMessage: "Save",
|
|
88
|
+
description: "Save button label"
|
|
89
|
+
},
|
|
90
|
+
cancel: {
|
|
91
|
+
id: "editor.callout.cancel",
|
|
92
|
+
defaultMessage: "Cancel",
|
|
93
|
+
description: "Cancel button label"
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// src/extensions/callout/callout-settings.tsx
|
|
98
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
99
|
+
var VARIANTS = [
|
|
100
|
+
{ value: "default", messageKey: "variant_default" },
|
|
101
|
+
{ value: "info", messageKey: "variant_info" },
|
|
102
|
+
{ value: "success", messageKey: "variant_success" },
|
|
103
|
+
{ value: "warning", messageKey: "variant_warning" },
|
|
104
|
+
{ value: "destructive", messageKey: "variant_destructive" }
|
|
105
|
+
];
|
|
106
|
+
function CalloutSettings({
|
|
107
|
+
editor,
|
|
108
|
+
attrs,
|
|
109
|
+
getPos
|
|
110
|
+
}) {
|
|
111
|
+
const intl = (0, import_react_intl2.useIntl)();
|
|
112
|
+
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
|
113
|
+
const [localAttrs, setLocalAttrs] = (0, import_react.useState)(attrs);
|
|
114
|
+
(0, import_react.useEffect)(() => {
|
|
115
|
+
if (isOpen) {
|
|
116
|
+
setLocalAttrs(attrs);
|
|
117
|
+
}
|
|
118
|
+
}, [isOpen, attrs]);
|
|
119
|
+
const handleSave = (0, import_react.useCallback)(() => {
|
|
120
|
+
const pos = getPos();
|
|
121
|
+
if (pos === void 0) return;
|
|
122
|
+
editor.view.dispatch(
|
|
123
|
+
editor.state.tr.setNodeMarkup(pos, void 0, localAttrs)
|
|
124
|
+
);
|
|
125
|
+
setIsOpen(false);
|
|
126
|
+
}, [editor, localAttrs, getPos]);
|
|
127
|
+
const handleCancel = (0, import_react.useCallback)(() => {
|
|
128
|
+
setLocalAttrs(attrs);
|
|
129
|
+
setIsOpen(false);
|
|
130
|
+
}, [attrs]);
|
|
131
|
+
const handleVariantChange = (0, import_react.useCallback)((value) => {
|
|
132
|
+
setLocalAttrs((prev) => ({
|
|
133
|
+
...prev,
|
|
134
|
+
variant: String(value)
|
|
135
|
+
}));
|
|
136
|
+
}, []);
|
|
137
|
+
const handleTitleChange = (0, import_react.useCallback)(
|
|
138
|
+
(e) => {
|
|
139
|
+
const value = e.target.value;
|
|
140
|
+
setLocalAttrs((prev) => ({
|
|
141
|
+
...prev,
|
|
142
|
+
title: value || null
|
|
143
|
+
}));
|
|
144
|
+
},
|
|
145
|
+
[]
|
|
146
|
+
);
|
|
147
|
+
if (!editor.isEditable) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
+
import_button.IconButton,
|
|
153
|
+
{
|
|
154
|
+
size: "sm",
|
|
155
|
+
variant: "ghost",
|
|
156
|
+
"aria-label": intl.formatMessage(messages.settings),
|
|
157
|
+
onClick: (e) => {
|
|
158
|
+
e.stopPropagation();
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
setIsOpen(true);
|
|
161
|
+
},
|
|
162
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.SettingsIcon, { className: "size-3.5" })
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Root, { open: isOpen, onOpenChange: setIsOpen, size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Content, { children: [
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Title, { children: intl.formatMessage(messages.settings) }) }),
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-4", children: [
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1.5", children: [
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.Label, { className: "text-sm", children: intl.formatMessage(messages.variant) }),
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
171
|
+
import_select.Select,
|
|
172
|
+
{
|
|
173
|
+
size: "sm",
|
|
174
|
+
value: localAttrs.variant,
|
|
175
|
+
onValueChange: handleVariantChange,
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.Select.Trigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.Select.Value, {}) }),
|
|
178
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.Select.Content, { children: VARIANTS.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select.Select.Item, { value: v.value, children: intl.formatMessage(messages[v.messageKey]) }, v.value)) })
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
] }),
|
|
183
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1.5", children: [
|
|
184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.Label, { className: "text-sm", children: intl.formatMessage(messages.title) }),
|
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
186
|
+
import_input.Input,
|
|
187
|
+
{
|
|
188
|
+
size: "sm",
|
|
189
|
+
value: localAttrs.title || "",
|
|
190
|
+
onChange: handleTitleChange,
|
|
191
|
+
placeholder: intl.formatMessage(messages.title_placeholder)
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
] })
|
|
195
|
+
] }) }),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Footer, { children: [
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { variant: "ghost", onClick: handleCancel, children: intl.formatMessage(messages.cancel) }),
|
|
198
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { onClick: handleSave, children: intl.formatMessage(messages.save) })
|
|
199
|
+
] })
|
|
200
|
+
] }) })
|
|
201
|
+
] });
|
|
202
|
+
}
|
|
203
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
204
|
+
0 && (module.exports = {
|
|
205
|
+
CalloutSettings
|
|
206
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { NodeViewProps } from '@tiptap/react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Callout NodeView Component
|
|
6
|
+
*
|
|
7
|
+
* Renders a callout block with variant-specific styling.
|
|
8
|
+
* Supports editable content inside the callout.
|
|
9
|
+
*/
|
|
10
|
+
declare function CalloutNodeView({ editor, node, getPos }: NodeViewProps): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { CalloutNodeView, CalloutNodeView as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { NodeViewProps } from '@tiptap/react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Callout NodeView Component
|
|
6
|
+
*
|
|
7
|
+
* Renders a callout block with variant-specific styling.
|
|
8
|
+
* Supports editable content inside the callout.
|
|
9
|
+
*/
|
|
10
|
+
declare function CalloutNodeView({ editor, node, getPos }: NodeViewProps): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { CalloutNodeView, CalloutNodeView as default };
|