@cgboiler/biz-basic 1.0.67 → 1.0.68
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/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/rich-text-editor/RichTextEditor.js +3 -0
- package/es/rich-text-editor/index.css +1 -1
- package/es/rich-text-editor/index.less +437 -436
- package/es/rich-text-editor/lib/utils.d.ts +123 -0
- package/es/rich-text-editor/lib/utils.js +244 -0
- package/es/rich-text-editor/menu-system/components/_atomic.css +2 -0
- package/es/rich-text-editor/menu-system/components/table-dropdown-menu.d.ts +25 -0
- package/es/rich-text-editor/menu-system/components/table-dropdown-menu.js +167 -0
- package/es/rich-text-editor/menu-system/icons/index.d.ts +13 -0
- package/es/rich-text-editor/menu-system/icons/index.js +26 -0
- package/es/rich-text-editor/menu-system/styles/animations.less +91 -91
- package/es/rich-text-editor/menu-system/styles/button-colors.less +142 -142
- package/es/rich-text-editor/menu-system/styles/button-group.less +23 -23
- package/es/rich-text-editor/menu-system/styles/button.less +322 -322
- package/es/rich-text-editor/menu-system/styles/card.less +78 -78
- package/es/rich-text-editor/menu-system/styles/color-highlight-button.less +57 -57
- package/es/rich-text-editor/menu-system/styles/color-highlight-popover.less +51 -51
- package/es/rich-text-editor/menu-system/styles/dropdown-menu.less +40 -40
- package/es/rich-text-editor/menu-system/styles/image-upload-node.less +240 -240
- package/es/rich-text-editor/menu-system/styles/input.less +53 -53
- package/es/rich-text-editor/menu-system/styles/link-popover.less +32 -32
- package/es/rich-text-editor/menu-system/styles/separator.less +26 -26
- package/es/rich-text-editor/menu-system/styles/simple-editor.less +39 -39
- package/es/rich-text-editor/menu-system/styles/toolbar.less +87 -87
- package/es/rich-text-editor/menu-system/styles/variables.less +294 -294
- package/es/vue-sfc-shim.d.ts +6 -6
- package/es/vue-tsx-shim.d.ts +24 -24
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/rich-text-editor/RichTextEditor.js +3 -0
- package/lib/rich-text-editor/index.css +1 -1
- package/lib/rich-text-editor/index.less +437 -436
- package/lib/rich-text-editor/lib/utils.d.ts +123 -0
- package/lib/rich-text-editor/lib/utils.js +263 -0
- package/lib/rich-text-editor/menu-system/components/_atomic.css +2 -0
- package/lib/rich-text-editor/menu-system/components/table-dropdown-menu.d.ts +25 -0
- package/lib/rich-text-editor/menu-system/components/table-dropdown-menu.js +186 -0
- package/lib/rich-text-editor/menu-system/icons/index.d.ts +13 -0
- package/lib/rich-text-editor/menu-system/icons/index.js +26 -0
- package/lib/rich-text-editor/menu-system/styles/animations.less +91 -91
- package/lib/rich-text-editor/menu-system/styles/button-colors.less +142 -142
- package/lib/rich-text-editor/menu-system/styles/button-group.less +23 -23
- package/lib/rich-text-editor/menu-system/styles/button.less +322 -322
- package/lib/rich-text-editor/menu-system/styles/card.less +78 -78
- package/lib/rich-text-editor/menu-system/styles/color-highlight-button.less +57 -57
- package/lib/rich-text-editor/menu-system/styles/color-highlight-popover.less +51 -51
- package/lib/rich-text-editor/menu-system/styles/dropdown-menu.less +40 -40
- package/lib/rich-text-editor/menu-system/styles/image-upload-node.less +240 -240
- package/lib/rich-text-editor/menu-system/styles/input.less +53 -53
- package/lib/rich-text-editor/menu-system/styles/link-popover.less +32 -32
- package/lib/rich-text-editor/menu-system/styles/separator.less +26 -26
- package/lib/rich-text-editor/menu-system/styles/simple-editor.less +39 -39
- package/lib/rich-text-editor/menu-system/styles/toolbar.less +87 -87
- package/lib/rich-text-editor/menu-system/styles/variables.less +294 -294
- package/lib/vue-sfc-shim.d.ts +6 -6
- package/lib/vue-tsx-shim.d.ts +24 -24
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { Node as TiptapNode } from '@tiptap/pm/model';
|
|
2
|
+
import type { Editor } from '@tiptap/core';
|
|
3
|
+
import { type ClassValue } from 'clsx';
|
|
4
|
+
export declare const MAX_FILE_SIZE: number;
|
|
5
|
+
export declare const MAC_SYMBOLS: Record<string, string>;
|
|
6
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
7
|
+
/**
|
|
8
|
+
* Determines if the current platform is macOS
|
|
9
|
+
* @returns boolean indicating if the current platform is Mac
|
|
10
|
+
*/
|
|
11
|
+
export declare function isMac(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a shortcut key based on the platform (Mac or non-Mac)
|
|
14
|
+
* @param key - The key to format (e.g., "ctrl", "alt", "shift")
|
|
15
|
+
* @param isMac - Boolean indicating if the platform is Mac
|
|
16
|
+
* @param capitalize - Whether to capitalize the key (default: true)
|
|
17
|
+
* @returns Formatted shortcut key symbol
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatShortcutKey: (key: string, isMac: boolean, capitalize?: boolean) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Parses a shortcut key string into an array of formatted key symbols
|
|
22
|
+
* @param shortcutKeys - The string of shortcut keys (e.g., "ctrl-alt-shift")
|
|
23
|
+
* @param delimiter - The delimiter used to split the keys (default: "-")
|
|
24
|
+
* @param capitalize - Whether to capitalize the keys (default: true)
|
|
25
|
+
* @returns Array of formatted shortcut key symbols
|
|
26
|
+
*/
|
|
27
|
+
export declare const parseShortcutKeys: (props: {
|
|
28
|
+
shortcutKeys: string | undefined;
|
|
29
|
+
delimiter?: string;
|
|
30
|
+
capitalize?: boolean;
|
|
31
|
+
}) => string[];
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a mark exists in the editor schema
|
|
34
|
+
* @param markName - The name of the mark to check
|
|
35
|
+
* @param editor - The editor instance
|
|
36
|
+
* @returns boolean indicating if the mark exists in the schema
|
|
37
|
+
*/
|
|
38
|
+
export declare const isMarkInSchema: (markName: string, editor: Editor | null) => boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if a node exists in the editor schema
|
|
41
|
+
* @param nodeName - The name of the node to check
|
|
42
|
+
* @param editor - The editor instance
|
|
43
|
+
* @returns boolean indicating if the node exists in the schema
|
|
44
|
+
*/
|
|
45
|
+
export declare const isNodeInSchema: (nodeName: string, editor: Editor | null) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Moves the focus to the next node in the editor
|
|
48
|
+
* @param editor - The editor instance
|
|
49
|
+
* @returns boolean indicating if the focus was moved
|
|
50
|
+
*/
|
|
51
|
+
export declare function focusNextNode(editor: Editor): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a value is a valid number (not null, undefined, or NaN)
|
|
54
|
+
* @param value - The value to check
|
|
55
|
+
* @returns boolean indicating if the value is a valid number
|
|
56
|
+
*/
|
|
57
|
+
export declare function isValidPosition(pos: number | null | undefined): pos is number;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if one or more extensions are registered in the Tiptap editor.
|
|
60
|
+
* @param editor - The Tiptap editor instance
|
|
61
|
+
* @param extensionNames - A single extension name or an array of names to check
|
|
62
|
+
* @returns True if at least one of the extensions is available, false otherwise
|
|
63
|
+
*/
|
|
64
|
+
export declare function isExtensionAvailable(editor: Editor | null, extensionNames: string | string[]): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Finds a node at the specified position with error handling
|
|
67
|
+
* @param editor The Tiptap editor instance
|
|
68
|
+
* @param position The position in the document to find the node
|
|
69
|
+
* @returns The node at the specified position, or null if not found
|
|
70
|
+
*/
|
|
71
|
+
export declare function findNodeAtPosition(editor: Editor, position: number): TiptapNode | null;
|
|
72
|
+
/**
|
|
73
|
+
* Finds the position and instance of a node in the document
|
|
74
|
+
* @param props Object containing editor, node (optional), and nodePos (optional)
|
|
75
|
+
* @param props.editor The Tiptap editor instance
|
|
76
|
+
* @param props.node The node to find (optional if nodePos is provided)
|
|
77
|
+
* @param props.nodePos The position of the node to find (optional if node is provided)
|
|
78
|
+
* @returns An object with the position and node, or null if not found
|
|
79
|
+
*/
|
|
80
|
+
export declare function findNodePosition(props: {
|
|
81
|
+
editor: Editor | null;
|
|
82
|
+
node?: TiptapNode | null;
|
|
83
|
+
nodePos?: number | null;
|
|
84
|
+
}): {
|
|
85
|
+
pos: number;
|
|
86
|
+
node: TiptapNode;
|
|
87
|
+
} | null;
|
|
88
|
+
/**
|
|
89
|
+
* Checks if the current selection in the editor is a node selection of specified types
|
|
90
|
+
* @param editor The Tiptap editor instance
|
|
91
|
+
* @param types An array of node type names to check against
|
|
92
|
+
* @returns boolean indicating if the selected node matches any of the specified types
|
|
93
|
+
*/
|
|
94
|
+
export declare function isNodeTypeSelected(editor: Editor | null, types?: string[]): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Handles image upload with progress tracking and abort capability
|
|
97
|
+
* @param file The file to upload
|
|
98
|
+
* @param onProgress Optional callback for tracking upload progress
|
|
99
|
+
* @param abortSignal Optional AbortSignal for cancelling the upload
|
|
100
|
+
* @returns Promise resolving to the URL of the uploaded image
|
|
101
|
+
*/
|
|
102
|
+
export declare const handleImageUpload: (file: File, onProgress?: (event: {
|
|
103
|
+
progress: number;
|
|
104
|
+
}) => void, abortSignal?: AbortSignal) => Promise<string>;
|
|
105
|
+
type ProtocolOptions = {
|
|
106
|
+
/**
|
|
107
|
+
* The protocol scheme to be registered.
|
|
108
|
+
* @default '''
|
|
109
|
+
* @example 'ftp'
|
|
110
|
+
* @example 'git'
|
|
111
|
+
*/
|
|
112
|
+
scheme: string;
|
|
113
|
+
/**
|
|
114
|
+
* If enabled, it allows optional slashes after the protocol.
|
|
115
|
+
* @default false
|
|
116
|
+
* @example true
|
|
117
|
+
*/
|
|
118
|
+
optionalSlashes?: boolean;
|
|
119
|
+
};
|
|
120
|
+
type ProtocolConfig = Array<ProtocolOptions | string>;
|
|
121
|
+
export declare function isAllowedUri(uri: string | undefined, protocols?: ProtocolConfig): true | RegExpMatchArray | null;
|
|
122
|
+
export declare function sanitizeUrl(inputUrl: string, baseUrl: string, protocols?: ProtocolConfig): string;
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __async = (__this, __arguments, generator) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
var fulfilled = (value) => {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var rejected = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.throw(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var stdin_exports = {};
|
|
39
|
+
__export(stdin_exports, {
|
|
40
|
+
MAC_SYMBOLS: () => MAC_SYMBOLS,
|
|
41
|
+
MAX_FILE_SIZE: () => MAX_FILE_SIZE,
|
|
42
|
+
cn: () => cn,
|
|
43
|
+
findNodeAtPosition: () => findNodeAtPosition,
|
|
44
|
+
findNodePosition: () => findNodePosition,
|
|
45
|
+
focusNextNode: () => focusNextNode,
|
|
46
|
+
formatShortcutKey: () => formatShortcutKey,
|
|
47
|
+
handleImageUpload: () => handleImageUpload,
|
|
48
|
+
isAllowedUri: () => isAllowedUri,
|
|
49
|
+
isExtensionAvailable: () => isExtensionAvailable,
|
|
50
|
+
isMac: () => isMac,
|
|
51
|
+
isMarkInSchema: () => isMarkInSchema,
|
|
52
|
+
isNodeInSchema: () => isNodeInSchema,
|
|
53
|
+
isNodeTypeSelected: () => isNodeTypeSelected,
|
|
54
|
+
isValidPosition: () => isValidPosition,
|
|
55
|
+
parseShortcutKeys: () => parseShortcutKeys,
|
|
56
|
+
sanitizeUrl: () => sanitizeUrl
|
|
57
|
+
});
|
|
58
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
59
|
+
var import_state = require("@tiptap/pm/state");
|
|
60
|
+
var import_clsx = require("clsx");
|
|
61
|
+
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
62
|
+
const MAC_SYMBOLS = {
|
|
63
|
+
mod: "\u2318",
|
|
64
|
+
command: "\u2318",
|
|
65
|
+
meta: "\u2318",
|
|
66
|
+
ctrl: "\u2303",
|
|
67
|
+
control: "\u2303",
|
|
68
|
+
alt: "\u2325",
|
|
69
|
+
option: "\u2325",
|
|
70
|
+
shift: "\u21E7",
|
|
71
|
+
backspace: "Del",
|
|
72
|
+
delete: "\u2326",
|
|
73
|
+
enter: "\u23CE",
|
|
74
|
+
escape: "\u238B",
|
|
75
|
+
capslock: "\u21EA"
|
|
76
|
+
};
|
|
77
|
+
function cn(...inputs) {
|
|
78
|
+
return (0, import_clsx.clsx)(inputs);
|
|
79
|
+
}
|
|
80
|
+
function isMac() {
|
|
81
|
+
return typeof navigator !== "undefined" && navigator.platform.toLowerCase().includes("mac");
|
|
82
|
+
}
|
|
83
|
+
const formatShortcutKey = (key, isMac2, capitalize = true) => {
|
|
84
|
+
if (isMac2) {
|
|
85
|
+
const lowerKey = key.toLowerCase();
|
|
86
|
+
return MAC_SYMBOLS[lowerKey] || (capitalize ? key.toUpperCase() : key);
|
|
87
|
+
}
|
|
88
|
+
return capitalize ? key.charAt(0).toUpperCase() + key.slice(1) : key;
|
|
89
|
+
};
|
|
90
|
+
const parseShortcutKeys = (props) => {
|
|
91
|
+
const { shortcutKeys, delimiter = "+", capitalize = true } = props;
|
|
92
|
+
if (!shortcutKeys)
|
|
93
|
+
return [];
|
|
94
|
+
return shortcutKeys.split(delimiter).map((key) => key.trim()).map((key) => formatShortcutKey(key, isMac(), capitalize));
|
|
95
|
+
};
|
|
96
|
+
const isMarkInSchema = (markName, editor) => {
|
|
97
|
+
if (!(editor == null ? void 0 : editor.schema))
|
|
98
|
+
return false;
|
|
99
|
+
return editor.schema.spec.marks.get(markName) !== void 0;
|
|
100
|
+
};
|
|
101
|
+
const isNodeInSchema = (nodeName, editor) => {
|
|
102
|
+
if (!(editor == null ? void 0 : editor.schema))
|
|
103
|
+
return false;
|
|
104
|
+
return editor.schema.spec.nodes.get(nodeName) !== void 0;
|
|
105
|
+
};
|
|
106
|
+
function focusNextNode(editor) {
|
|
107
|
+
const { state, view } = editor;
|
|
108
|
+
const { doc, selection } = state;
|
|
109
|
+
const nextSel = import_state.Selection.findFrom(selection.$to, 1, true);
|
|
110
|
+
if (nextSel) {
|
|
111
|
+
view.dispatch(state.tr.setSelection(nextSel).scrollIntoView());
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const paragraphType = state.schema.nodes.paragraph;
|
|
115
|
+
if (!paragraphType) {
|
|
116
|
+
console.warn("No paragraph node type found in schema.");
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const end = doc.content.size;
|
|
120
|
+
const para = paragraphType.create();
|
|
121
|
+
let tr = state.tr.insert(end, para);
|
|
122
|
+
const $inside = tr.doc.resolve(end + 1);
|
|
123
|
+
tr = tr.setSelection(import_state.TextSelection.near($inside)).scrollIntoView();
|
|
124
|
+
view.dispatch(tr);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
function isValidPosition(pos) {
|
|
128
|
+
return typeof pos === "number" && pos >= 0;
|
|
129
|
+
}
|
|
130
|
+
function isExtensionAvailable(editor, extensionNames) {
|
|
131
|
+
if (!editor)
|
|
132
|
+
return false;
|
|
133
|
+
const names = Array.isArray(extensionNames) ? extensionNames : [extensionNames];
|
|
134
|
+
const found = names.some(
|
|
135
|
+
(name) => editor.extensionManager.extensions.some((ext) => ext.name === name)
|
|
136
|
+
);
|
|
137
|
+
if (!found) {
|
|
138
|
+
console.warn(
|
|
139
|
+
`None of the extensions [${names.join(
|
|
140
|
+
", "
|
|
141
|
+
)}] were found in the editor schema. Ensure they are included in the editor configuration.`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
return found;
|
|
145
|
+
}
|
|
146
|
+
function findNodeAtPosition(editor, position) {
|
|
147
|
+
try {
|
|
148
|
+
const node = editor.state.doc.nodeAt(position);
|
|
149
|
+
if (!node) {
|
|
150
|
+
console.warn(`No node found at position ${position}`);
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
return node;
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.error(`Error getting node at position ${position}:`, error);
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function findNodePosition(props) {
|
|
160
|
+
var _a;
|
|
161
|
+
const { editor, node, nodePos } = props;
|
|
162
|
+
if (!editor || !((_a = editor.state) == null ? void 0 : _a.doc))
|
|
163
|
+
return null;
|
|
164
|
+
const hasValidNode = node !== void 0 && node !== null;
|
|
165
|
+
const hasValidPos = isValidPosition(nodePos);
|
|
166
|
+
if (!hasValidNode && !hasValidPos) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
if (hasValidNode) {
|
|
170
|
+
let foundPos = -1;
|
|
171
|
+
let foundNode = null;
|
|
172
|
+
editor.state.doc.descendants((currentNode, pos) => {
|
|
173
|
+
if (currentNode === node) {
|
|
174
|
+
foundPos = pos;
|
|
175
|
+
foundNode = currentNode;
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
});
|
|
180
|
+
if (foundPos !== -1 && foundNode !== null) {
|
|
181
|
+
return { pos: foundPos, node: foundNode };
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (hasValidPos) {
|
|
185
|
+
const nodeAtPos = findNodeAtPosition(editor, nodePos);
|
|
186
|
+
if (nodeAtPos) {
|
|
187
|
+
return { pos: nodePos, node: nodeAtPos };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
function isNodeTypeSelected(editor, types = []) {
|
|
193
|
+
if (!editor || !editor.state.selection)
|
|
194
|
+
return false;
|
|
195
|
+
const { state } = editor;
|
|
196
|
+
const { selection } = state;
|
|
197
|
+
if (selection.empty)
|
|
198
|
+
return false;
|
|
199
|
+
if (selection instanceof import_state.NodeSelection) {
|
|
200
|
+
const node = selection.node;
|
|
201
|
+
return node ? types.includes(node.type.name) : false;
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
const handleImageUpload = (file, onProgress, abortSignal) => __async(void 0, null, function* () {
|
|
206
|
+
if (!file) {
|
|
207
|
+
throw new Error("No file provided");
|
|
208
|
+
}
|
|
209
|
+
if (file.size > MAX_FILE_SIZE) {
|
|
210
|
+
throw new Error(`File size exceeds maximum allowed (${MAX_FILE_SIZE / (1024 * 1024)}MB)`);
|
|
211
|
+
}
|
|
212
|
+
for (let progress = 0; progress <= 100; progress += 10) {
|
|
213
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
214
|
+
throw new Error("Upload cancelled");
|
|
215
|
+
}
|
|
216
|
+
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
217
|
+
onProgress == null ? void 0 : onProgress({ progress });
|
|
218
|
+
}
|
|
219
|
+
return "/images/tiptap-ui-placeholder-image.jpg";
|
|
220
|
+
});
|
|
221
|
+
const ATTR_WHITESPACE = (
|
|
222
|
+
// eslint-disable-next-line no-control-regex
|
|
223
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
224
|
+
);
|
|
225
|
+
function isAllowedUri(uri, protocols) {
|
|
226
|
+
const allowedProtocols = [
|
|
227
|
+
"http",
|
|
228
|
+
"https",
|
|
229
|
+
"ftp",
|
|
230
|
+
"ftps",
|
|
231
|
+
"mailto",
|
|
232
|
+
"tel",
|
|
233
|
+
"callto",
|
|
234
|
+
"sms",
|
|
235
|
+
"cid",
|
|
236
|
+
"xmpp"
|
|
237
|
+
];
|
|
238
|
+
if (protocols) {
|
|
239
|
+
protocols.forEach((protocol) => {
|
|
240
|
+
const nextProtocol = typeof protocol === "string" ? protocol : protocol.scheme;
|
|
241
|
+
if (nextProtocol) {
|
|
242
|
+
allowedProtocols.push(nextProtocol);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return !uri || uri.replace(ATTR_WHITESPACE, "").match(
|
|
247
|
+
new RegExp(
|
|
248
|
+
// eslint-disable-next-line no-useless-escape
|
|
249
|
+
`^(?:(?:${allowedProtocols.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,
|
|
250
|
+
"i"
|
|
251
|
+
)
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
function sanitizeUrl(inputUrl, baseUrl, protocols) {
|
|
255
|
+
try {
|
|
256
|
+
const url = new URL(inputUrl, baseUrl);
|
|
257
|
+
if (isAllowedUri(url.href, protocols)) {
|
|
258
|
+
return url.href;
|
|
259
|
+
}
|
|
260
|
+
} catch (e) {
|
|
261
|
+
}
|
|
262
|
+
return "#";
|
|
263
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import 'element-plus/es/components/dropdown/style/css';
|
|
3
|
+
import 'element-plus/es/components/dropdown-menu/style/css';
|
|
4
|
+
import 'element-plus/es/components/dropdown-item/style/css';
|
|
5
|
+
export declare const TableDropdownMenu: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
6
|
+
editor: {
|
|
7
|
+
type: PropType<any>;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
className: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
15
|
+
editor: {
|
|
16
|
+
type: PropType<any>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
className: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
}>> & Readonly<{}>, {
|
|
24
|
+
className: string;
|
|
25
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
TableDropdownMenu: () => TableDropdownMenu
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
+
var import_vue = require("vue");
|
|
24
|
+
var import_atomic = require("./_atomic.css");
|
|
25
|
+
var import_vue2 = require("vue");
|
|
26
|
+
var import_button = require("../primitives/button");
|
|
27
|
+
var import_tiptap_utils = require("../utils/tiptap-utils");
|
|
28
|
+
var import_element_plus = require("element-plus");
|
|
29
|
+
var import_icons = require("../icons");
|
|
30
|
+
var import_css = require("element-plus/es/components/dropdown/style/css");
|
|
31
|
+
var import_css2 = require("element-plus/es/components/dropdown-menu/style/css");
|
|
32
|
+
var import_css3 = require("element-plus/es/components/dropdown-item/style/css");
|
|
33
|
+
const TableDropdownMenu = (0, import_vue2.defineComponent)({
|
|
34
|
+
name: "TableDropdownMenu",
|
|
35
|
+
props: {
|
|
36
|
+
editor: {
|
|
37
|
+
type: Object,
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
className: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: ""
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
setup(props, {
|
|
46
|
+
attrs
|
|
47
|
+
}) {
|
|
48
|
+
const handleCommand = (command) => {
|
|
49
|
+
const editor = props.editor && "value" in props.editor ? props.editor.value : props.editor;
|
|
50
|
+
if (!editor)
|
|
51
|
+
return;
|
|
52
|
+
switch (command) {
|
|
53
|
+
case "insertTable":
|
|
54
|
+
editor.commands.insertTable({
|
|
55
|
+
rows: 3,
|
|
56
|
+
cols: 3,
|
|
57
|
+
withHeaderRow: true
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case "addColumnBefore":
|
|
61
|
+
editor.commands.addColumnBefore();
|
|
62
|
+
break;
|
|
63
|
+
case "addColumnAfter":
|
|
64
|
+
editor.commands.addColumnAfter();
|
|
65
|
+
break;
|
|
66
|
+
case "deleteColumn":
|
|
67
|
+
editor.commands.deleteColumn();
|
|
68
|
+
break;
|
|
69
|
+
case "addRowBefore":
|
|
70
|
+
editor.commands.addRowBefore();
|
|
71
|
+
break;
|
|
72
|
+
case "addRowAfter":
|
|
73
|
+
editor.commands.addRowAfter();
|
|
74
|
+
break;
|
|
75
|
+
case "deleteRow":
|
|
76
|
+
editor.commands.deleteRow();
|
|
77
|
+
break;
|
|
78
|
+
case "deleteTable":
|
|
79
|
+
editor.commands.deleteTable();
|
|
80
|
+
break;
|
|
81
|
+
case "mergeCells":
|
|
82
|
+
editor.commands.mergeCells();
|
|
83
|
+
break;
|
|
84
|
+
case "splitCell":
|
|
85
|
+
editor.commands.splitCell();
|
|
86
|
+
break;
|
|
87
|
+
case "toggleHeaderRow":
|
|
88
|
+
editor.commands.toggleHeaderRow();
|
|
89
|
+
break;
|
|
90
|
+
case "toggleHeaderColumn":
|
|
91
|
+
editor.commands.toggleHeaderColumn();
|
|
92
|
+
break;
|
|
93
|
+
case "toggleHeaderCell":
|
|
94
|
+
editor.commands.toggleHeaderCell();
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const isInTable = () => {
|
|
101
|
+
const editor = props.editor && "value" in props.editor ? props.editor.value : props.editor;
|
|
102
|
+
return editor == null ? void 0 : editor.isActive("table");
|
|
103
|
+
};
|
|
104
|
+
return () => {
|
|
105
|
+
const trigger = (0, import_vue.createVNode)(import_button.Button, (0, import_vue.mergeProps)({
|
|
106
|
+
"type": "button",
|
|
107
|
+
"data-style": "ghost",
|
|
108
|
+
"data-active-state": isInTable() ? "on" : "off",
|
|
109
|
+
"role": "button",
|
|
110
|
+
"tooltip": "\u8868\u683C\u64CD\u4F5C",
|
|
111
|
+
"class": (0, import_tiptap_utils.cn)(props.className, "tiptap-table-dropdown-trigger")
|
|
112
|
+
}, attrs), {
|
|
113
|
+
default: () => [(0, import_vue.createVNode)(import_icons.TableIcon, {
|
|
114
|
+
"class": "tiptap-button-icon"
|
|
115
|
+
}, null), (0, import_vue.createVNode)(import_icons.ChevronDownIcon, {
|
|
116
|
+
"class": "tiptap-button-icon-chevron"
|
|
117
|
+
}, null)]
|
|
118
|
+
});
|
|
119
|
+
return (0, import_vue.createVNode)(import_element_plus.ElDropdown, {
|
|
120
|
+
"trigger": "click",
|
|
121
|
+
"onCommand": handleCommand,
|
|
122
|
+
"popper-class": "tiptap-dropdown-menu"
|
|
123
|
+
}, {
|
|
124
|
+
default: () => trigger,
|
|
125
|
+
dropdown: () => (0, import_vue.createVNode)(import_element_plus.ElDropdownMenu, null, {
|
|
126
|
+
default: () => [!isInTable() ? (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
127
|
+
"command": "insertTable"
|
|
128
|
+
}, {
|
|
129
|
+
default: () => [(0, import_vue.createTextVNode)("\u63D2\u5165\u8868\u683C")]
|
|
130
|
+
}) : (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
131
|
+
"command": "addColumnBefore"
|
|
132
|
+
}, {
|
|
133
|
+
default: () => [(0, import_vue.createTextVNode)("\u5728\u524D\u65B9\u63D2\u5165\u5217")]
|
|
134
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
135
|
+
"command": "addColumnAfter"
|
|
136
|
+
}, {
|
|
137
|
+
default: () => [(0, import_vue.createTextVNode)("\u5728\u540E\u65B9\u63D2\u5165\u5217")]
|
|
138
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
139
|
+
"command": "deleteColumn"
|
|
140
|
+
}, {
|
|
141
|
+
default: () => [(0, import_vue.createTextVNode)("\u5220\u9664\u5F53\u524D\u5217")]
|
|
142
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
143
|
+
"divided": true,
|
|
144
|
+
"command": "addRowBefore"
|
|
145
|
+
}, {
|
|
146
|
+
default: () => [(0, import_vue.createTextVNode)("\u5728\u4E0A\u65B9\u63D2\u5165\u884C")]
|
|
147
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
148
|
+
"command": "addRowAfter"
|
|
149
|
+
}, {
|
|
150
|
+
default: () => [(0, import_vue.createTextVNode)("\u5728\u4E0B\u65B9\u63D2\u5165\u884C")]
|
|
151
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
152
|
+
"command": "deleteRow"
|
|
153
|
+
}, {
|
|
154
|
+
default: () => [(0, import_vue.createTextVNode)("\u5220\u9664\u5F53\u524D\u884C")]
|
|
155
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
156
|
+
"divided": true,
|
|
157
|
+
"command": "mergeCells"
|
|
158
|
+
}, {
|
|
159
|
+
default: () => [(0, import_vue.createTextVNode)("\u5408\u5E76\u5355\u5143\u683C")]
|
|
160
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
161
|
+
"command": "splitCell"
|
|
162
|
+
}, {
|
|
163
|
+
default: () => [(0, import_vue.createTextVNode)("\u62C6\u5206\u5355\u5143\u683C")]
|
|
164
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
165
|
+
"divided": true,
|
|
166
|
+
"command": "toggleHeaderRow"
|
|
167
|
+
}, {
|
|
168
|
+
default: () => [(0, import_vue.createTextVNode)("\u5207\u6362\u8868\u5934\u884C")]
|
|
169
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
170
|
+
"command": "toggleHeaderColumn"
|
|
171
|
+
}, {
|
|
172
|
+
default: () => [(0, import_vue.createTextVNode)("\u5207\u6362\u8868\u5934\u5217")]
|
|
173
|
+
}), (0, import_vue.createVNode)(import_element_plus.ElDropdownItem, {
|
|
174
|
+
"divided": true,
|
|
175
|
+
"command": "deleteTable",
|
|
176
|
+
"style": {
|
|
177
|
+
color: "var(--red)"
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
default: () => [(0, import_vue.createTextVNode)("\u5220\u9664\u8868\u683C")]
|
|
181
|
+
})])]
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
});
|
|
@@ -544,3 +544,16 @@ export declare const DivideIcon: import("vue").DefineComponent<import("vue").Ext
|
|
|
544
544
|
}>> & Readonly<{}>, {
|
|
545
545
|
className: string;
|
|
546
546
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
547
|
+
export declare const TableIcon: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
548
|
+
className: {
|
|
549
|
+
type: StringConstructor;
|
|
550
|
+
default: string;
|
|
551
|
+
};
|
|
552
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
553
|
+
className: {
|
|
554
|
+
type: StringConstructor;
|
|
555
|
+
default: string;
|
|
556
|
+
};
|
|
557
|
+
}>> & Readonly<{}>, {
|
|
558
|
+
className: string;
|
|
559
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -56,6 +56,7 @@ __export(stdin_exports, {
|
|
|
56
56
|
StrikeIcon: () => StrikeIcon,
|
|
57
57
|
SubscriptIcon: () => SubscriptIcon,
|
|
58
58
|
SuperscriptIcon: () => SuperscriptIcon,
|
|
59
|
+
TableIcon: () => TableIcon,
|
|
59
60
|
TrashIcon: () => TrashIcon,
|
|
60
61
|
UnderlineIcon: () => UnderlineIcon,
|
|
61
62
|
Undo2Icon: () => Undo2Icon
|
|
@@ -504,3 +505,28 @@ const DivideIcon = createIcon("DivideIcon", (0, import_vue.createVNode)("path",
|
|
|
504
505
|
"stroke-width": "2",
|
|
505
506
|
"stroke-linecap": "round"
|
|
506
507
|
}, null));
|
|
508
|
+
const TableIcon = createIcon("TableIcon", (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)("rect", {
|
|
509
|
+
"x": "3",
|
|
510
|
+
"y": "3",
|
|
511
|
+
"width": "18",
|
|
512
|
+
"height": "18",
|
|
513
|
+
"rx": "2",
|
|
514
|
+
"stroke": "currentColor",
|
|
515
|
+
"stroke-width": "2"
|
|
516
|
+
}, null), (0, import_vue.createVNode)("path", {
|
|
517
|
+
"d": "M3 9H21",
|
|
518
|
+
"stroke": "currentColor",
|
|
519
|
+
"stroke-width": "2"
|
|
520
|
+
}, null), (0, import_vue.createVNode)("path", {
|
|
521
|
+
"d": "M3 15H21",
|
|
522
|
+
"stroke": "currentColor",
|
|
523
|
+
"stroke-width": "2"
|
|
524
|
+
}, null), (0, import_vue.createVNode)("path", {
|
|
525
|
+
"d": "M9 3V21",
|
|
526
|
+
"stroke": "currentColor",
|
|
527
|
+
"stroke-width": "2"
|
|
528
|
+
}, null), (0, import_vue.createVNode)("path", {
|
|
529
|
+
"d": "M15 3V21",
|
|
530
|
+
"stroke": "currentColor",
|
|
531
|
+
"stroke-width": "2"
|
|
532
|
+
}, null)]));
|