@cgboiler/biz-basic 1.0.39 → 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 CHANGED
@@ -5,6 +5,6 @@ declare namespace _default {
5
5
  }
6
6
  export default _default;
7
7
  export function install(app: any): void;
8
- export const version: "1.0.38";
8
+ export const version: "1.0.40";
9
9
  import RichTextEditor from './rich-text-editor';
10
10
  export { RichTextEditor };
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import RichTextEditor from "./rich-text-editor";
2
- const version = "1.0.38";
2
+ const version = "1.0.40";
3
3
  function install(app) {
4
4
  const components = [
5
5
  RichTextEditor
@@ -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" | "update:modelValue" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "update:modelValue" | "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" | "update:modelValue" | "mention-clicked" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "update:modelValue" | "mention-clicked" | "hashTag-clicked", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
20
  modelValue: {
21
21
  type: StringConstructor;
22
22
  default: string;
@@ -40,6 +40,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
40
40
  "onHashTag-exit"?: ((...args: any[]) => any) | undefined;
41
41
  "onMention-triggered"?: ((...args: any[]) => any) | undefined;
42
42
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
43
+ "onMention-clicked"?: ((...args: any[]) => any) | undefined;
43
44
  "onHashTag-clicked"?: ((...args: any[]) => any) | undefined;
44
45
  }>, {
45
46
  modelValue: 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", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
34
+ emits: ["update:modelValue", "mention-triggered", "mention-clicked", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
35
35
  setup(props, {
36
36
  emit,
37
37
  expose
@@ -166,6 +166,21 @@ var stdin_default = defineComponent({
166
166
  return;
167
167
  }
168
168
  };
169
+ const mentionClickHandler = (event) => {
170
+ const target = event.target;
171
+ const tagEl = target.closest(".mention") || null;
172
+ if (tagEl) {
173
+ const id = tagEl.getAttribute("data-id") || "";
174
+ const label = tagEl.getAttribute("data-label") || tagEl.textContent || "";
175
+ emit("mention-clicked", {
176
+ userId: id,
177
+ name: label
178
+ });
179
+ event.stopPropagation();
180
+ event.preventDefault();
181
+ return;
182
+ }
183
+ };
169
184
  const HISTORY_METADATA_KEY = "rich_text_editor_history_metadata";
170
185
  const MAX_HISTORY_ITEMS = 10;
171
186
  let saveTimeoutId = null;
@@ -218,6 +233,7 @@ var stdin_default = defineComponent({
218
233
  if (editorElement) {
219
234
  editorElement.addEventListener("click", imageClickHandler);
220
235
  editorElement.addEventListener("click", hashTagClickHandler);
236
+ editorElement.addEventListener("click", mentionClickHandler);
221
237
  }
222
238
  });
223
239
  });
@@ -230,6 +246,7 @@ var stdin_default = defineComponent({
230
246
  if (editorElement) {
231
247
  editorElement.removeEventListener("click", imageClickHandler);
232
248
  editorElement.removeEventListener("click", hashTagClickHandler);
249
+ editorElement.removeEventListener("click", mentionClickHandler);
233
250
  }
234
251
  (_c = editor.value) == null ? void 0 : _c.destroy();
235
252
  });
@@ -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
- emit("hashTag-exit");
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
@@ -5,6 +5,6 @@ declare namespace _default {
5
5
  }
6
6
  export default _default;
7
7
  export function install(app: any): void;
8
- export const version: "1.0.38";
8
+ export const version: "1.0.40";
9
9
  import RichTextEditor from './rich-text-editor';
10
10
  export { RichTextEditor };
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.38";
39
+ const version = "1.0.40";
40
40
  function install(app) {
41
41
  const components = [
42
42
  import_rich_text_editor.default
@@ -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" | "update:modelValue" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "update:modelValue" | "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" | "update:modelValue" | "mention-clicked" | "hashTag-clicked")[], "blur" | "focus" | "hashTag-triggered" | "hashTag-input" | "hashTag-exit" | "mention-triggered" | "update:modelValue" | "mention-clicked" | "hashTag-clicked", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
20
  modelValue: {
21
21
  type: StringConstructor;
22
22
  default: string;
@@ -40,6 +40,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
40
40
  "onHashTag-exit"?: ((...args: any[]) => any) | undefined;
41
41
  "onMention-triggered"?: ((...args: any[]) => any) | undefined;
42
42
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
43
+ "onMention-clicked"?: ((...args: any[]) => any) | undefined;
43
44
  "onHashTag-clicked"?: ((...args: any[]) => any) | undefined;
44
45
  }>, {
45
46
  modelValue: string;
@@ -63,7 +63,7 @@ var import_index = require("./index.css");
63
63
  var stdin_default = (0, import_vue2.defineComponent)({
64
64
  name: "RichTextEditor",
65
65
  props: import_types.richTextEditorProps,
66
- emits: ["update:modelValue", "mention-triggered", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
66
+ emits: ["update:modelValue", "mention-triggered", "mention-clicked", "hashTag-triggered", "hashTag-input", "hashTag-exit", "hashTag-clicked", "blur", "focus"],
67
67
  setup(props, {
68
68
  emit,
69
69
  expose
@@ -198,6 +198,21 @@ var stdin_default = (0, import_vue2.defineComponent)({
198
198
  return;
199
199
  }
200
200
  };
201
+ const mentionClickHandler = (event) => {
202
+ const target = event.target;
203
+ const tagEl = target.closest(".mention") || null;
204
+ if (tagEl) {
205
+ const id = tagEl.getAttribute("data-id") || "";
206
+ const label = tagEl.getAttribute("data-label") || tagEl.textContent || "";
207
+ emit("mention-clicked", {
208
+ userId: id,
209
+ name: label
210
+ });
211
+ event.stopPropagation();
212
+ event.preventDefault();
213
+ return;
214
+ }
215
+ };
201
216
  const HISTORY_METADATA_KEY = "rich_text_editor_history_metadata";
202
217
  const MAX_HISTORY_ITEMS = 10;
203
218
  let saveTimeoutId = null;
@@ -250,6 +265,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
250
265
  if (editorElement) {
251
266
  editorElement.addEventListener("click", imageClickHandler);
252
267
  editorElement.addEventListener("click", hashTagClickHandler);
268
+ editorElement.addEventListener("click", mentionClickHandler);
253
269
  }
254
270
  });
255
271
  });
@@ -262,6 +278,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
262
278
  if (editorElement) {
263
279
  editorElement.removeEventListener("click", imageClickHandler);
264
280
  editorElement.removeEventListener("click", hashTagClickHandler);
281
+ editorElement.removeEventListener("click", mentionClickHandler);
265
282
  }
266
283
  (_c = editor.value) == null ? void 0 : _c.destroy();
267
284
  });
@@ -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
- emit("hashTag-exit");
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-basic",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",