@cgboiler/biz-basic 1.0.40 → 1.0.41
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/types.d.ts +30 -0
- package/es/rich-text-editor/useExtensions.d.ts +9 -0
- package/es/rich-text-editor/useExtensions.js +34 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/rich-text-editor/types.d.ts +30 -0
- package/lib/rich-text-editor/useExtensions.d.ts +9 -0
- package/lib/rich-text-editor/useExtensions.js +34 -1
- package/package.json +1 -1
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件说明:
|
|
3
|
+
* - 定义富文本编辑器相关的类型声明(Mention/HashTag 数据结构、事件负载等)。
|
|
4
|
+
* - 新增:`HashTagExitEvent` 用于在 `hashTag-exit` 事件中传递“退出原因(空格/换行等)”与是否为非连续输入。
|
|
5
|
+
*/
|
|
1
6
|
import { ExtractPropTypes } from 'vue';
|
|
7
|
+
/**
|
|
8
|
+
* MentionData
|
|
9
|
+
* - 功能:@ 提及的数据结构。
|
|
10
|
+
* - 字段说明:
|
|
11
|
+
* - userId: string 用户唯一标识。
|
|
12
|
+
* - name: string 显示名称。
|
|
13
|
+
*/
|
|
2
14
|
export interface MentionData {
|
|
3
15
|
userId: string;
|
|
4
16
|
name: string;
|
|
5
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* HashTagData
|
|
20
|
+
* - 功能:# 标签的数据结构。
|
|
21
|
+
* - 字段说明:
|
|
22
|
+
* - hashTagId: string 标签唯一标识。
|
|
23
|
+
* - name: string 标签显示名称。
|
|
24
|
+
*/
|
|
6
25
|
export interface HashTagData {
|
|
7
26
|
hashTagId: string;
|
|
8
27
|
name: string;
|
|
9
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* HashTagExitEvent
|
|
31
|
+
* - 功能:在 `hashTag-exit` 事件中传递退出原因与是否为非连续输入。
|
|
32
|
+
* - 字段说明:
|
|
33
|
+
* - reason: 退出原因;可取值 'space' | 'enter' | 'tab' | 'escape' | 'unknown'。
|
|
34
|
+
* - nonContiguous: 是否属于“非连续输入”导致的退出(如空格、回车、Tab)。
|
|
35
|
+
*/
|
|
36
|
+
export interface HashTagExitEvent {
|
|
37
|
+
reason: 'space' | 'enter' | 'tab' | 'escape' | 'unknown';
|
|
38
|
+
nonContiguous: boolean;
|
|
39
|
+
}
|
|
10
40
|
export declare const richTextEditorProps: {
|
|
11
41
|
modelValue: {
|
|
12
42
|
type: StringConstructor;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/core';
|
|
2
|
+
/**
|
|
3
|
+
* useExtensions
|
|
4
|
+
* - 功能:构建并返回 TipTap 编辑器使用的扩展集合。
|
|
5
|
+
* - 参数说明:
|
|
6
|
+
* - props: 组件属性对象,至少应包含占位符 `placeholder` 等。
|
|
7
|
+
* - emit: 事件发送函数,用于向父组件触发富文本相关事件(如 hashTag-triggered / hashTag-input / hashTag-exit)。
|
|
8
|
+
* - 返回值:Extension[] 扩展数组,用于初始化 TipTap 编辑器。
|
|
9
|
+
* - 异常:无显式抛出;若内部命令执行失败(例如插入内容时)可能由 TipTap 抛出异常,应在上层统一处理。
|
|
10
|
+
*/
|
|
2
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<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | import("@tiptap/core").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>)[];
|
|
@@ -37,10 +37,12 @@ function useExtensions({ props, emit }) {
|
|
|
37
37
|
render() {
|
|
38
38
|
let activeRange = null;
|
|
39
39
|
let activeEditor = null;
|
|
40
|
+
let exitCause = "unknown";
|
|
40
41
|
return {
|
|
41
42
|
onStart({ editor, range, command, query }) {
|
|
42
43
|
activeRange = range;
|
|
43
44
|
activeEditor = editor;
|
|
45
|
+
exitCause = "unknown";
|
|
44
46
|
emit("hashTag-triggered", (data) => {
|
|
45
47
|
try {
|
|
46
48
|
(activeEditor || editor).chain().focus().deleteRange(activeRange || range).insertContentAt((activeRange || range).from, {
|
|
@@ -59,10 +61,41 @@ function useExtensions({ props, emit }) {
|
|
|
59
61
|
activeEditor = editor || activeEditor;
|
|
60
62
|
emit("hashTag-input", query != null ? query : "");
|
|
61
63
|
},
|
|
64
|
+
/**
|
|
65
|
+
* onKeyDown
|
|
66
|
+
* - 功能:在建议态期间侦测用户键盘行为并记录“非连续输入”的退出原因。
|
|
67
|
+
* - 参数说明:
|
|
68
|
+
* - event: KeyboardEvent 当前键盘事件对象。
|
|
69
|
+
* - 返回值:boolean 始终返回 false,交由默认逻辑处理(从而触发 onExit)。
|
|
70
|
+
* - 异常:无。
|
|
71
|
+
*/
|
|
72
|
+
onKeyDown({ event }) {
|
|
73
|
+
if (event.key === "Enter") {
|
|
74
|
+
exitCause = "enter";
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (event.key === " ") {
|
|
78
|
+
exitCause = "space";
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (event.key === "Tab") {
|
|
82
|
+
exitCause = "tab";
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (event.key === "Escape") {
|
|
86
|
+
exitCause = "escape";
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
},
|
|
62
91
|
onExit() {
|
|
63
92
|
activeRange = null;
|
|
64
93
|
activeEditor = null;
|
|
65
|
-
|
|
94
|
+
const payload = {
|
|
95
|
+
reason: exitCause,
|
|
96
|
+
nonContiguous: exitCause === "space" || exitCause === "enter" || exitCause === "tab"
|
|
97
|
+
};
|
|
98
|
+
emit("hashTag-exit", payload);
|
|
66
99
|
}
|
|
67
100
|
};
|
|
68
101
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(stdin_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(stdin_exports);
|
|
37
37
|
var import_rich_text_editor = __toESM(require("./rich-text-editor"));
|
|
38
38
|
__reExport(stdin_exports, require("./rich-text-editor"), module.exports);
|
|
39
|
-
const version = "1.0.
|
|
39
|
+
const version = "1.0.40";
|
|
40
40
|
function install(app) {
|
|
41
41
|
const components = [
|
|
42
42
|
import_rich_text_editor.default
|
|
@@ -1,12 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件说明:
|
|
3
|
+
* - 定义富文本编辑器相关的类型声明(Mention/HashTag 数据结构、事件负载等)。
|
|
4
|
+
* - 新增:`HashTagExitEvent` 用于在 `hashTag-exit` 事件中传递“退出原因(空格/换行等)”与是否为非连续输入。
|
|
5
|
+
*/
|
|
1
6
|
import { ExtractPropTypes } from 'vue';
|
|
7
|
+
/**
|
|
8
|
+
* MentionData
|
|
9
|
+
* - 功能:@ 提及的数据结构。
|
|
10
|
+
* - 字段说明:
|
|
11
|
+
* - userId: string 用户唯一标识。
|
|
12
|
+
* - name: string 显示名称。
|
|
13
|
+
*/
|
|
2
14
|
export interface MentionData {
|
|
3
15
|
userId: string;
|
|
4
16
|
name: string;
|
|
5
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* HashTagData
|
|
20
|
+
* - 功能:# 标签的数据结构。
|
|
21
|
+
* - 字段说明:
|
|
22
|
+
* - hashTagId: string 标签唯一标识。
|
|
23
|
+
* - name: string 标签显示名称。
|
|
24
|
+
*/
|
|
6
25
|
export interface HashTagData {
|
|
7
26
|
hashTagId: string;
|
|
8
27
|
name: string;
|
|
9
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* HashTagExitEvent
|
|
31
|
+
* - 功能:在 `hashTag-exit` 事件中传递退出原因与是否为非连续输入。
|
|
32
|
+
* - 字段说明:
|
|
33
|
+
* - reason: 退出原因;可取值 'space' | 'enter' | 'tab' | 'escape' | 'unknown'。
|
|
34
|
+
* - nonContiguous: 是否属于“非连续输入”导致的退出(如空格、回车、Tab)。
|
|
35
|
+
*/
|
|
36
|
+
export interface HashTagExitEvent {
|
|
37
|
+
reason: 'space' | 'enter' | 'tab' | 'escape' | 'unknown';
|
|
38
|
+
nonContiguous: boolean;
|
|
39
|
+
}
|
|
10
40
|
export declare const richTextEditorProps: {
|
|
11
41
|
modelValue: {
|
|
12
42
|
type: StringConstructor;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/core';
|
|
2
|
+
/**
|
|
3
|
+
* useExtensions
|
|
4
|
+
* - 功能:构建并返回 TipTap 编辑器使用的扩展集合。
|
|
5
|
+
* - 参数说明:
|
|
6
|
+
* - props: 组件属性对象,至少应包含占位符 `placeholder` 等。
|
|
7
|
+
* - emit: 事件发送函数,用于向父组件触发富文本相关事件(如 hashTag-triggered / hashTag-input / hashTag-exit)。
|
|
8
|
+
* - 返回值:Extension[] 扩展数组,用于初始化 TipTap 编辑器。
|
|
9
|
+
* - 异常:无显式抛出;若内部命令执行失败(例如插入内容时)可能由 TipTap 抛出异常,应在上层统一处理。
|
|
10
|
+
*/
|
|
2
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<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | import("@tiptap/core").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>)[];
|
|
@@ -69,10 +69,12 @@ function useExtensions({ props, emit }) {
|
|
|
69
69
|
render() {
|
|
70
70
|
let activeRange = null;
|
|
71
71
|
let activeEditor = null;
|
|
72
|
+
let exitCause = "unknown";
|
|
72
73
|
return {
|
|
73
74
|
onStart({ editor, range, command, query }) {
|
|
74
75
|
activeRange = range;
|
|
75
76
|
activeEditor = editor;
|
|
77
|
+
exitCause = "unknown";
|
|
76
78
|
emit("hashTag-triggered", (data) => {
|
|
77
79
|
try {
|
|
78
80
|
(activeEditor || editor).chain().focus().deleteRange(activeRange || range).insertContentAt((activeRange || range).from, {
|
|
@@ -91,10 +93,41 @@ function useExtensions({ props, emit }) {
|
|
|
91
93
|
activeEditor = editor || activeEditor;
|
|
92
94
|
emit("hashTag-input", query != null ? query : "");
|
|
93
95
|
},
|
|
96
|
+
/**
|
|
97
|
+
* onKeyDown
|
|
98
|
+
* - 功能:在建议态期间侦测用户键盘行为并记录“非连续输入”的退出原因。
|
|
99
|
+
* - 参数说明:
|
|
100
|
+
* - event: KeyboardEvent 当前键盘事件对象。
|
|
101
|
+
* - 返回值:boolean 始终返回 false,交由默认逻辑处理(从而触发 onExit)。
|
|
102
|
+
* - 异常:无。
|
|
103
|
+
*/
|
|
104
|
+
onKeyDown({ event }) {
|
|
105
|
+
if (event.key === "Enter") {
|
|
106
|
+
exitCause = "enter";
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
if (event.key === " ") {
|
|
110
|
+
exitCause = "space";
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (event.key === "Tab") {
|
|
114
|
+
exitCause = "tab";
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (event.key === "Escape") {
|
|
118
|
+
exitCause = "escape";
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
},
|
|
94
123
|
onExit() {
|
|
95
124
|
activeRange = null;
|
|
96
125
|
activeEditor = null;
|
|
97
|
-
|
|
126
|
+
const payload = {
|
|
127
|
+
reason: exitCause,
|
|
128
|
+
nonContiguous: exitCause === "space" || exitCause === "enter" || exitCause === "tab"
|
|
129
|
+
};
|
|
130
|
+
emit("hashTag-exit", payload);
|
|
98
131
|
}
|
|
99
132
|
};
|
|
100
133
|
}
|