@cgboiler/biz-basic 1.0.41 → 1.0.43

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.40";
8
+ export const version: "1.0.42";
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.40";
2
+ const version = "1.0.42";
3
3
  function install(app) {
4
4
  const components = [
5
5
  RichTextEditor
@@ -30,11 +30,11 @@ export interface HashTagData {
30
30
  * HashTagExitEvent
31
31
  * - 功能:在 `hashTag-exit` 事件中传递退出原因与是否为非连续输入。
32
32
  * - 字段说明:
33
- * - reason: 退出原因;可取值 'space' | 'enter' | 'tab' | 'escape' | 'unknown'。
34
- * - nonContiguous: 是否属于“非连续输入”导致的退出(如空格、回车、Tab)。
33
+ * - reason: 退出原因;可取值 'space' | 'unknown'。
34
+ * - nonContiguous: 是否属于“非连续输入”导致的退出(如空格)。
35
35
  */
36
36
  export interface HashTagExitEvent {
37
- reason: 'space' | 'enter' | 'tab' | 'escape' | 'unknown';
37
+ reason: 'space' | 'unknown';
38
38
  nonContiguous: boolean;
39
39
  }
40
40
  export declare const richTextEditorProps: {
@@ -70,30 +70,43 @@ function useExtensions({ props, emit }) {
70
70
  * - 异常:无。
71
71
  */
72
72
  onKeyDown({ event }) {
73
- if (event.key === "Enter") {
74
- exitCause = "enter";
75
- return false;
76
- }
77
- if (event.key === " ") {
73
+ const isSpaceKey = event.key === " " || event.key === "Space" || event.key === "Spacebar" || // @ts-ignore 兼容旧浏览器/环境的数值键码
74
+ event.keyCode === 32 || // 兼容部分环境的 event.code 标识
75
+ event.code === "Space";
76
+ if (isSpaceKey) {
78
77
  exitCause = "space";
79
78
  return false;
80
79
  }
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
80
  return false;
90
81
  },
82
+ /**
83
+ * onExit
84
+ * - 功能:建议态结束时向外部发送退出事件,并尽可能准确地判断退出原因。
85
+ * - 设计考量:
86
+ * - 安卓设备上软键盘可能不触发标准 keydown 空格;此时通过检查当前选择位置前一个字符是否为空格来回溯判断。
87
+ * - 参数:无。
88
+ * - 返回值:无(通过 emit 派发事件)。
89
+ * - 异常:内部读取选择/文档时若发生异常,捕获后保持原有退出原因,不影响外部流程。
90
+ */
91
91
  onExit() {
92
+ var _a, _b, _c, _d, _e;
93
+ try {
94
+ const editorRef = activeEditor;
95
+ if (editorRef) {
96
+ const sel = (_a = editorRef.state) == null ? void 0 : _a.selection;
97
+ const from = (_b = sel == null ? void 0 : sel.from) != null ? _b : 0;
98
+ const prevChar = (_e = (_d = (_c = editorRef.state) == null ? void 0 : _c.doc) == null ? void 0 : _d.textBetween(Math.max(from - 1, 0), from, "\0", "\0")) != null ? _e : "";
99
+ if (prevChar === " ") {
100
+ exitCause = "space";
101
+ }
102
+ }
103
+ } catch (e) {
104
+ }
92
105
  activeRange = null;
93
106
  activeEditor = null;
94
107
  const payload = {
95
108
  reason: exitCause,
96
- nonContiguous: exitCause === "space" || exitCause === "enter" || exitCause === "tab"
109
+ nonContiguous: exitCause === "space"
97
110
  };
98
111
  emit("hashTag-exit", payload);
99
112
  }
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.40";
8
+ export const version: "1.0.42";
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.40";
39
+ const version = "1.0.42";
40
40
  function install(app) {
41
41
  const components = [
42
42
  import_rich_text_editor.default
@@ -30,11 +30,11 @@ export interface HashTagData {
30
30
  * HashTagExitEvent
31
31
  * - 功能:在 `hashTag-exit` 事件中传递退出原因与是否为非连续输入。
32
32
  * - 字段说明:
33
- * - reason: 退出原因;可取值 'space' | 'enter' | 'tab' | 'escape' | 'unknown'。
34
- * - nonContiguous: 是否属于“非连续输入”导致的退出(如空格、回车、Tab)。
33
+ * - reason: 退出原因;可取值 'space' | 'unknown'。
34
+ * - nonContiguous: 是否属于“非连续输入”导致的退出(如空格)。
35
35
  */
36
36
  export interface HashTagExitEvent {
37
- reason: 'space' | 'enter' | 'tab' | 'escape' | 'unknown';
37
+ reason: 'space' | 'unknown';
38
38
  nonContiguous: boolean;
39
39
  }
40
40
  export declare const richTextEditorProps: {
@@ -102,30 +102,43 @@ function useExtensions({ props, emit }) {
102
102
  * - 异常:无。
103
103
  */
104
104
  onKeyDown({ event }) {
105
- if (event.key === "Enter") {
106
- exitCause = "enter";
107
- return false;
108
- }
109
- if (event.key === " ") {
105
+ const isSpaceKey = event.key === " " || event.key === "Space" || event.key === "Spacebar" || // @ts-ignore 兼容旧浏览器/环境的数值键码
106
+ event.keyCode === 32 || // 兼容部分环境的 event.code 标识
107
+ event.code === "Space";
108
+ if (isSpaceKey) {
110
109
  exitCause = "space";
111
110
  return false;
112
111
  }
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
112
  return false;
122
113
  },
114
+ /**
115
+ * onExit
116
+ * - 功能:建议态结束时向外部发送退出事件,并尽可能准确地判断退出原因。
117
+ * - 设计考量:
118
+ * - 安卓设备上软键盘可能不触发标准 keydown 空格;此时通过检查当前选择位置前一个字符是否为空格来回溯判断。
119
+ * - 参数:无。
120
+ * - 返回值:无(通过 emit 派发事件)。
121
+ * - 异常:内部读取选择/文档时若发生异常,捕获后保持原有退出原因,不影响外部流程。
122
+ */
123
123
  onExit() {
124
+ var _a, _b, _c, _d, _e;
125
+ try {
126
+ const editorRef = activeEditor;
127
+ if (editorRef) {
128
+ const sel = (_a = editorRef.state) == null ? void 0 : _a.selection;
129
+ const from = (_b = sel == null ? void 0 : sel.from) != null ? _b : 0;
130
+ const prevChar = (_e = (_d = (_c = editorRef.state) == null ? void 0 : _c.doc) == null ? void 0 : _d.textBetween(Math.max(from - 1, 0), from, "\0", "\0")) != null ? _e : "";
131
+ if (prevChar === " ") {
132
+ exitCause = "space";
133
+ }
134
+ }
135
+ } catch (e) {
136
+ }
124
137
  activeRange = null;
125
138
  activeEditor = null;
126
139
  const payload = {
127
140
  reason: exitCause,
128
- nonContiguous: exitCause === "space" || exitCause === "enter" || exitCause === "tab"
141
+ nonContiguous: exitCause === "space"
129
142
  };
130
143
  emit("hashTag-exit", payload);
131
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgboiler/biz-basic",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",