@cgboiler/biz-basic 1.0.47 → 1.0.49
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.d.ts +5 -1
- package/es/rich-text-editor/RichTextEditor.js +37 -2
- package/es/rich-text-editor/index.css +1 -1
- package/es/rich-text-editor/index.less +12 -1
- package/es/rich-text-editor/types.d.ts +15 -0
- package/es/rich-text-editor/useExtensions.d.ts +2 -7
- package/es/rich-text-editor/useExtensions.js +177 -150
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/rich-text-editor/RichTextEditor.d.ts +5 -1
- package/lib/rich-text-editor/RichTextEditor.js +37 -2
- package/lib/rich-text-editor/index.css +1 -1
- package/lib/rich-text-editor/index.less +12 -1
- package/lib/rich-text-editor/types.d.ts +15 -0
- package/lib/rich-text-editor/useExtensions.d.ts +2 -7
- package/lib/rich-text-editor/useExtensions.js +176 -149
- package/package.json +1 -1
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -16,7 +16,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
16
16
|
type: BooleanConstructor;
|
|
17
17
|
default: boolean;
|
|
18
18
|
};
|
|
19
|
-
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "mention-input" | "mention-exit" | "update:modelValue" | "mention-clicked" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "mention-input" | "mention-exit" | "update:modelValue" | "mention-clicked" | "hashTag-clicked", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "mention-input" | "mention-exit" | "update:modelValue" | "mention-clicked" | "hashTag-clicked" | "customContent-triggered" | "customContent-input" | "customContent-exit" | "customContent-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "mention-input" | "mention-exit" | "update:modelValue" | "mention-clicked" | "hashTag-clicked" | "customContent-triggered" | "customContent-input" | "customContent-exit" | "customContent-clicked", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
20
20
|
modelValue: {
|
|
21
21
|
type: StringConstructor;
|
|
22
22
|
default: string;
|
|
@@ -44,6 +44,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
44
44
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
45
45
|
"onMention-clicked"?: ((...args: any[]) => any) | undefined;
|
|
46
46
|
"onHashTag-clicked"?: ((...args: any[]) => any) | undefined;
|
|
47
|
+
"onCustomContent-triggered"?: ((...args: any[]) => any) | undefined;
|
|
48
|
+
"onCustomContent-input"?: ((...args: any[]) => any) | undefined;
|
|
49
|
+
"onCustomContent-exit"?: ((...args: any[]) => any) | undefined;
|
|
50
|
+
"onCustomContent-clicked"?: ((...args: any[]) => any) | undefined;
|
|
47
51
|
}>, {
|
|
48
52
|
modelValue: string;
|
|
49
53
|
placeholder: string;
|
|
@@ -31,7 +31,7 @@ import "./index.css";
|
|
|
31
31
|
var stdin_default = defineComponent({
|
|
32
32
|
name: "RichTextEditor",
|
|
33
33
|
props: richTextEditorProps,
|
|
34
|
-
emits: ["update:modelValue", "mention-triggered", "mention-input", "mention-exit", "mention-clicked", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
|
|
34
|
+
emits: ["update:modelValue", "mention-triggered", "mention-input", "mention-exit", "mention-clicked", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "customContent-triggered", "customContent-input", "customContent-exit", "customContent-clicked", "blur", "focus"],
|
|
35
35
|
setup(props, {
|
|
36
36
|
emit,
|
|
37
37
|
expose
|
|
@@ -99,10 +99,23 @@ var stdin_default = defineComponent({
|
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
|
+
const insertCustomContent = (data) => {
|
|
103
|
+
editor.value.commands.insertContent({
|
|
104
|
+
type: "customContent",
|
|
105
|
+
attrs: {
|
|
106
|
+
id: data.id || `custom-${Date.now()}`,
|
|
107
|
+
label: data.label,
|
|
108
|
+
obj: data.obj,
|
|
109
|
+
color: data.color,
|
|
110
|
+
hoverColor: data.hoverColor
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
102
114
|
expose({
|
|
103
115
|
getEditor: () => editor.value,
|
|
104
116
|
insertMention,
|
|
105
|
-
insertHashTag
|
|
117
|
+
insertHashTag,
|
|
118
|
+
insertCustomContent
|
|
106
119
|
});
|
|
107
120
|
watch(() => props.modelValue, (newValue) => {
|
|
108
121
|
var _a, _b;
|
|
@@ -185,6 +198,26 @@ var stdin_default = defineComponent({
|
|
|
185
198
|
return;
|
|
186
199
|
}
|
|
187
200
|
};
|
|
201
|
+
const customContentClickHandler = (event) => {
|
|
202
|
+
const target = event.target;
|
|
203
|
+
const tagEl = target.closest(".custom-content") || null;
|
|
204
|
+
if (tagEl) {
|
|
205
|
+
const objStr = tagEl.getAttribute("obj") || "{}";
|
|
206
|
+
const label = tagEl.getAttribute("file-label") || "";
|
|
207
|
+
try {
|
|
208
|
+
const obj = JSON.parse(objStr);
|
|
209
|
+
emit("customContent-clicked", {
|
|
210
|
+
obj,
|
|
211
|
+
label
|
|
212
|
+
});
|
|
213
|
+
} catch (e) {
|
|
214
|
+
console.error("Failed to parse custom content obj:", e);
|
|
215
|
+
}
|
|
216
|
+
event.stopPropagation();
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
188
221
|
const HISTORY_METADATA_KEY = "rich_text_editor_history_metadata";
|
|
189
222
|
const MAX_HISTORY_ITEMS = 10;
|
|
190
223
|
let saveTimeoutId = null;
|
|
@@ -238,6 +271,7 @@ var stdin_default = defineComponent({
|
|
|
238
271
|
editorElement.addEventListener("click", imageClickHandler);
|
|
239
272
|
editorElement.addEventListener("click", hashTagClickHandler);
|
|
240
273
|
editorElement.addEventListener("click", mentionClickHandler);
|
|
274
|
+
editorElement.addEventListener("click", customContentClickHandler);
|
|
241
275
|
}
|
|
242
276
|
});
|
|
243
277
|
});
|
|
@@ -251,6 +285,7 @@ var stdin_default = defineComponent({
|
|
|
251
285
|
editorElement.removeEventListener("click", imageClickHandler);
|
|
252
286
|
editorElement.removeEventListener("click", hashTagClickHandler);
|
|
253
287
|
editorElement.removeEventListener("click", mentionClickHandler);
|
|
288
|
+
editorElement.removeEventListener("click", customContentClickHandler);
|
|
254
289
|
}
|
|
255
290
|
(_c = editor.value) == null ? void 0 : _c.destroy();
|
|
256
291
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
body .ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}body .ProseMirror :first-child{margin-top:0}body .ProseMirror video{width:100%}body .ProseMirror ol{list-style:auto}body .ProseMirror ol ol,body .ProseMirror ul{list-style:disc}body .ProseMirror ol,body .ProseMirror ul{padding-left:1.5em;margin:0 0 12px}body .ProseMirror ol li p,body .ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}body .ProseMirror li::marker{text-align:start!important}body .ProseMirror h1,body .ProseMirror h2,body .ProseMirror h3,body .ProseMirror h4,body .ProseMirror h5,body .ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}body .ProseMirror h1,body .ProseMirror h2{margin-top:1rem;margin-bottom:1rem}body .ProseMirror h1{font-size:1.4rem}body .ProseMirror h2{font-size:1.2rem}body .ProseMirror h3{font-size:1.1rem}body .ProseMirror h4,body .ProseMirror h5,body .ProseMirror h6{font-size:1rem}body .ProseMirror a,body .ProseMirror .editor-link{color:var(--purple);text-decoration:underline;cursor:pointer;transition:color .2s ease}body .ProseMirror a:hover,body .ProseMirror .editor-link:hover{color:var(--purple-contrast);text-decoration:underline}body .ProseMirror code{background-color:#ffe5e8;border-radius:.4rem;color:#c02537;padding:2px 4px}body .ProseMirror pre{border-radius:.5rem;font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}body .ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}body .ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}body .ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}body .ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}body .ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}body .ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}body .ProseMirror table td,body .ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}body .ProseMirror table td>*,body .ProseMirror table th>*{margin-bottom:0}body .ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}body .ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}body .ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}body .ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}body .ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}body .ProseMirror img{max-width:100%}body .ProseMirror .mention,body .ProseMirror .hash-tag{color:#c02537;padding:0 .3em}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
|
|
1
|
+
body .ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}body .ProseMirror :first-child{margin-top:0}body .ProseMirror video{width:100%}body .ProseMirror ol{list-style:auto}body .ProseMirror ol ol,body .ProseMirror ul{list-style:disc}body .ProseMirror ol,body .ProseMirror ul{padding-left:1.5em;margin:0 0 12px}body .ProseMirror ol li p,body .ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}body .ProseMirror li::marker{text-align:start!important}body .ProseMirror h1,body .ProseMirror h2,body .ProseMirror h3,body .ProseMirror h4,body .ProseMirror h5,body .ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}body .ProseMirror h1,body .ProseMirror h2{margin-top:1rem;margin-bottom:1rem}body .ProseMirror h1{font-size:1.4rem}body .ProseMirror h2{font-size:1.2rem}body .ProseMirror h3{font-size:1.1rem}body .ProseMirror h4,body .ProseMirror h5,body .ProseMirror h6{font-size:1rem}body .ProseMirror a,body .ProseMirror .editor-link{color:var(--purple);text-decoration:underline;cursor:pointer;transition:color .2s ease}body .ProseMirror a:hover,body .ProseMirror .editor-link:hover{color:var(--purple-contrast);text-decoration:underline}body .ProseMirror code{background-color:#ffe5e8;border-radius:.4rem;color:#c02537;padding:2px 4px}body .ProseMirror pre{border-radius:.5rem;font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}body .ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}body .ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}body .ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}body .ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}body .ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}body .ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}body .ProseMirror table td,body .ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}body .ProseMirror table td>*,body .ProseMirror table th>*{margin-bottom:0}body .ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}body .ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}body .ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}body .ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}body .ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}body .ProseMirror img{max-width:100%}body .ProseMirror .mention,body .ProseMirror .hash-tag{color:#c02537;padding:0 .3em}body .ProseMirror .custom-content{color:var(--custom-content-color, #000);padding:0 .3em;cursor:pointer;transition:color .2s ease}body .ProseMirror .custom-content:hover{color:var(--custom-content-hover-color, #c02537)}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
|
|
@@ -218,11 +218,22 @@ body .ProseMirror {
|
|
|
218
218
|
img {
|
|
219
219
|
max-width: 100%;
|
|
220
220
|
}
|
|
221
|
-
// @人的样式 #话题的样式
|
|
221
|
+
// @人的样式 #话题的样式 自定义内容的样式
|
|
222
222
|
.mention, .hash-tag {
|
|
223
223
|
color: #c02537;
|
|
224
224
|
padding: 0 0.3em;
|
|
225
225
|
}
|
|
226
|
+
|
|
227
|
+
.custom-content {
|
|
228
|
+
color: var(--custom-content-color, #000);
|
|
229
|
+
padding: 0 0.3em;
|
|
230
|
+
cursor: pointer;
|
|
231
|
+
transition: color 0.2s ease;
|
|
232
|
+
|
|
233
|
+
&:hover {
|
|
234
|
+
color: var(--custom-content-hover-color, #c02537);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
226
237
|
}
|
|
227
238
|
|
|
228
239
|
// animation
|
|
@@ -26,6 +26,21 @@ export interface HashTagData {
|
|
|
26
26
|
hashTagId: string;
|
|
27
27
|
name: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* CustomContentData
|
|
31
|
+
* - 功能:自定义内容的数据结构。
|
|
32
|
+
* - 字段说明:
|
|
33
|
+
* - label: string 显示标签(如 )。
|
|
34
|
+
* - obj: 任意JSON对象,内容由用户自定义。
|
|
35
|
+
* - id: 可选及其他扩展字段。
|
|
36
|
+
*/
|
|
37
|
+
export interface CustomContentData {
|
|
38
|
+
label: string;
|
|
39
|
+
obj: Record<string, any>;
|
|
40
|
+
color?: string;
|
|
41
|
+
hoverColor?: string;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
29
44
|
/**
|
|
30
45
|
* HashTagExitEvent
|
|
31
46
|
* - 功能:在 `hashTag-exit` 事件中传递退出原因与是否为非连续输入。
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
1
|
+
import { Extension, Mark } from '@tiptap/core';
|
|
2
2
|
/**
|
|
3
3
|
* useExtensions
|
|
4
4
|
* - 功能:构建并返回 TipTap 编辑器使用的扩展集合。
|
|
5
|
-
* - 参数说明:
|
|
6
|
-
* - props: 组件属性对象,至少应包含占位符 `placeholder` 等。
|
|
7
|
-
* - emit: 事件发送函数,用于向父组件触发富文本相关事件(如 hashTag-triggered / hashTag-input / hashTag-exit)。
|
|
8
|
-
* - 返回值:Extension[] 扩展数组,用于初始化 TipTap 编辑器。
|
|
9
|
-
* - 异常:无显式抛出;若内部命令执行失败(例如插入内容时)可能由 TipTap 抛出异常,应在上层统一处理。
|
|
10
5
|
*/
|
|
11
|
-
export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | Extension<
|
|
6
|
+
export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Node<any, any> | Mark<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | Extension<import("@tiptap/extension-table").TableKitOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extension-list").ListKitOptions, any>)[];
|