ht-emr 0.6.2 → 0.6.3

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.
@@ -163,5 +163,8 @@ export declare class Command {
163
163
  expandSubTemplate: CommandAdapt['expandSubTemplate'];
164
164
  collapseSubTemplate: CommandAdapt['collapseSubTemplate'];
165
165
  toggleSubTemplate: CommandAdapt['toggleSubTemplate'];
166
+ insertLogicTemplate: CommandAdapt['insertLogicTemplate'];
167
+ updateLogicTemplate: CommandAdapt['updateLogicTemplate'];
168
+ getLogicTemplateList: CommandAdapt['getLogicTemplateList'];
166
169
  constructor(adapt: CommandAdapt);
167
170
  }
@@ -13,7 +13,7 @@ import { DeepRequired } from '../../interface/Common';
13
13
  import { IGetControlValueOption, IGetControlValueResult, ILocationControlOption, IRemoveControlOption, ISetControlExtensionOption, ISetControlHighlightOption, ISetControlProperties, ISetControlValueOption } from '../../interface/Control';
14
14
  import { IAppendElementListOption, IDrawImagePayload, IForceUpdateOption, IGetImageOption, IGetValueOption, IPainterOption } from '../../interface/Draw';
15
15
  import { IEditorData, IEditorHTML, IEditorOption, IFormModeTraceOption, IEditorResult, IEditorText, IFocusOption, ISetValueOption, IUpdateOption } from '../../interface/Editor';
16
- import { IDeleteElementByIdOption, IElement, IElementPosition, IGetElementByIdOption, IGetMacroValueOption, IImageCaption, IImageCrop, IInsertElementListOption, IMacroValueResult, ISetMacroValueOption, IUpdateElementByIdOption, IUpdateMacroPropertiesOption } from '../../interface/Element';
16
+ import { IDeleteElementByIdOption, IElement, IElementPosition, IGetElementByIdOption, ILogicTemplateDisplayRule, ILogicTemplateElement, IGetMacroValueOption, IImageCaption, IImageCrop, IInsertElementListOption, IMacroValueResult, ISetMacroValueOption, IUpdateElementByIdOption, IUpdateMacroPropertiesOption } from '../../interface/Element';
17
17
  import { ICopyOption, IPasteOption, IPositionContextByEventOption, IPositionContextByEventResult } from '../../interface/Event';
18
18
  import { IMargin } from '../../interface/Margin';
19
19
  import { IRange, RangeContext } from '../../interface/Range';
@@ -298,4 +298,39 @@ export declare class CommandAdapt {
298
298
  /** 是否提交历史 */
299
299
  isSubmitHistory?: boolean;
300
300
  }): void;
301
+ /**
302
+ * 插入逻辑模板
303
+ * Insert logic template content directly with display rule metadata
304
+ */
305
+ insertLogicTemplate(payload: {
306
+ /** 逻辑模板名称 */
307
+ label: string;
308
+ /** 逻辑模板引用的模板 ID */
309
+ templateId: string;
310
+ /** 模板内容 */
311
+ content: IElement[];
312
+ /** 显示规则 */
313
+ displayRule?: ILogicTemplateDisplayRule;
314
+ /** 是否提交历史 */
315
+ isSubmitHistory?: boolean;
316
+ }): string | null;
317
+ /**
318
+ * 更新逻辑模板元数据
319
+ * Update logic template metadata for the whole group
320
+ */
321
+ updateLogicTemplate(payload: {
322
+ /** 逻辑模板 ID */
323
+ logicTemplateId?: string;
324
+ /** 逻辑模板内任意元素 ID */
325
+ id?: string;
326
+ /** 要更新的属性 */
327
+ properties: Partial<Omit<ILogicTemplateElement, 'logicTemplateId' | 'logicTemplateHidden'>>;
328
+ /** 是否提交历史 */
329
+ isSubmitHistory?: boolean;
330
+ }): void;
331
+ /**
332
+ * 获取逻辑模板列表
333
+ * Get all logic template groups
334
+ */
335
+ getLogicTemplateList(): ILogicTemplateElement[];
301
336
  }
@@ -3,39 +3,139 @@ import { ICursorOption } from '../../interface/Cursor';
3
3
  import { IElementPosition } from '../../interface/Element';
4
4
  import { Draw } from '../draw/Draw';
5
5
  import { CanvasEvent } from '../event/CanvasEvent';
6
+ /**
7
+ * 绘制光标的配置选项
8
+ * @extends ICursorOption
9
+ */
6
10
  export type IDrawCursorOption = ICursorOption & {
11
+ /** 是否显示光标 */
7
12
  isShow?: boolean;
13
+ /** 是否启用闪烁动画 */
8
14
  isBlink?: boolean;
15
+ /** 是否聚焦到代理输入框 */
9
16
  isFocus?: boolean;
17
+ /** 点击行首时的起始索引 */
10
18
  hitLineStartIndex?: number;
11
19
  };
20
+ /**
21
+ * 移动光标到可视区域的配置选项
22
+ */
12
23
  export interface IMoveCursorToVisibleOption {
24
+ /** 移动方向 */
13
25
  direction: MoveDirection;
26
+ /** 光标位置信息 */
14
27
  cursorPosition: IElementPosition;
15
28
  }
29
+ /**
30
+ * 光标管理类
31
+ *
32
+ * 负责编辑器中光标的绘制、显示和位置管理。
33
+ * 光标是文本编辑器中指示当前输入位置的视觉元素,支持闪烁动画、
34
+ * 自动滚动到可视区域等功能。
35
+ */
16
36
  export declare class Cursor {
37
+ /** 光标闪烁动画的CSS类名 */
17
38
  private readonly ANIMATION_CLASS;
39
+ /** Draw实例,用于获取渲染上下文和状态 */
18
40
  private draw;
41
+ /** 编辑器容器元素 */
19
42
  private container;
43
+ /** 编辑器配置选项 */
20
44
  private options;
45
+ /** 位置管理器,用于获取光标位置 */
21
46
  private position;
47
+ /** 光标DOM元素 */
22
48
  private cursorDom;
49
+ /** 光标代理,用于处理输入事件 */
23
50
  private cursorAgent;
51
+ /** 闪烁定时器ID */
24
52
  private blinkTimeout;
53
+ /** 点击行首时的起始索引 */
25
54
  private hitLineStartIndex;
55
+ /**
56
+ * 创建光标管理器实例
57
+ * @param draw - Draw实例,用于获取渲染上下文
58
+ * @param canvasEvent - CanvasEvent实例,用于处理事件
59
+ */
26
60
  constructor(draw: Draw, canvasEvent: CanvasEvent);
61
+ /**
62
+ * 获取光标DOM元素
63
+ * @returns 光标的DOM元素
64
+ */
27
65
  getCursorDom(): HTMLDivElement;
66
+ /**
67
+ * 获取代理输入框DOM元素
68
+ * @returns 代理输入框的textarea元素
69
+ */
28
70
  getAgentDom(): HTMLTextAreaElement;
71
+ /**
72
+ * 检查代理输入框是否处于激活状态
73
+ * @returns 如果代理输入框是当前激活元素则返回true
74
+ */
29
75
  getAgentIsActive(): boolean;
76
+ /**
77
+ * 获取代理输入框的值
78
+ * @returns 代理输入框中的文本内容
79
+ */
30
80
  getAgentDomValue(): string;
81
+ /**
82
+ * 清空代理输入框的值
83
+ */
31
84
  clearAgentDomValue(): void;
85
+ /**
86
+ * 获取点击行首时的起始索引
87
+ * @returns 行首索引,如果未设置则返回undefined
88
+ */
32
89
  getHitLineStartIndex(): number | undefined;
90
+ /**
91
+ * 开始光标闪烁动画
92
+ * @private
93
+ */
33
94
  private _blinkStart;
95
+ /**
96
+ * 停止光标闪烁动画
97
+ * @private
98
+ */
34
99
  private _blinkStop;
100
+ /**
101
+ * 设置闪烁定时器
102
+ * @private
103
+ */
35
104
  private _setBlinkTimeout;
105
+ /**
106
+ * 清除闪烁定时器
107
+ * @private
108
+ */
36
109
  private _clearBlinkTimeout;
110
+ /**
111
+ * 聚焦到代理输入框
112
+ *
113
+ * 在移动端只读模式下禁用聚焦以避免唤起输入法,
114
+ * 在web端允许聚焦以确保键盘事件能够被捕获。
115
+ */
37
116
  focus(): void;
117
+ /**
118
+ * 绘制光标
119
+ *
120
+ * 根据当前光标位置绘制光标,支持自定义光标样式和动画。
121
+ * 光标会自动调整位置和大小以适应当前字体。
122
+ *
123
+ * @param payload - 绘制光标的配置选项
124
+ */
38
125
  drawCursor(payload?: IDrawCursorOption): void;
126
+ /**
127
+ * 隐藏光标
128
+ *
129
+ * 将光标从视图中移除并停止闪烁动画
130
+ */
39
131
  recoveryCursor(): void;
132
+ /**
133
+ * 将光标移动到可视区域
134
+ *
135
+ * 当光标位置超出当前可视区域时,自动滚动页面以确保光标可见。
136
+ * 支持向上和向下两种滚动方向。
137
+ *
138
+ * @param payload - 移动配置选项
139
+ */
40
140
  moveCursorToVisible(payload: IMoveCursorToVisibleOption): void;
41
141
  }
@@ -1,18 +1,97 @@
1
1
  import { Draw } from '../draw/Draw';
2
2
  import { CanvasEvent } from '../event/CanvasEvent';
3
+ /**
4
+ * 光标代理类
5
+ *
6
+ * 光标代理是一个隐藏的textarea元素,用于捕获用户输入事件。
7
+ * 由于Canvas无法直接接收文本输入,需要通过代理元素来处理:
8
+ * - 键盘输入事件
9
+ * - 输入法组合事件(中文输入等)
10
+ * - 粘贴事件
11
+ */
3
12
  export declare class CursorAgent {
13
+ /** Draw实例,用于获取渲染上下文和状态 */
4
14
  private draw;
15
+ /** 编辑器容器元素 */
5
16
  private container;
17
+ /** 代理输入框DOM元素 */
6
18
  private agentCursorDom;
19
+ /** Canvas事件处理器 */
7
20
  private canvasEvent;
21
+ /** 事件总线,用于发布/订阅事件 */
8
22
  private eventBus;
23
+ /**
24
+ * 创建光标代理实例
25
+ * @param draw - Draw实例,用于获取渲染上下文
26
+ * @param canvasEvent - CanvasEvent实例,用于处理事件
27
+ */
9
28
  constructor(draw: Draw, canvasEvent: CanvasEvent);
29
+ /**
30
+ * 获取代理输入框DOM元素
31
+ * @returns 代理输入框的textarea元素
32
+ */
10
33
  getAgentCursorDom(): HTMLTextAreaElement;
34
+ /**
35
+ * 处理键盘按下事件
36
+ * @param evt - 键盘事件对象
37
+ * @private
38
+ */
11
39
  private _keyDown;
40
+ /**
41
+ * 处理输入事件
42
+ *
43
+ * 当用户输入文本时触发,将输入数据传递给CanvasEvent处理。
44
+ * 同时发布input事件到事件总线。
45
+ *
46
+ * @param evt - 输入事件对象
47
+ * @private
48
+ */
12
49
  private _input;
50
+ /**
51
+ * 处理粘贴事件
52
+ *
53
+ * 当用户粘贴内容时触发,将粘贴操作委托给pasteByEvent处理函数。
54
+ * 在只读模式下忽略粘贴操作。
55
+ *
56
+ * @param evt - 剪贴板事件对象
57
+ * @private
58
+ */
13
59
  private _paste;
60
+ /**
61
+ * 处理输入法组合开始事件
62
+ *
63
+ * 当用户开始使用输入法(如中文输入法)时触发。
64
+ * 此时会调整代理输入框的样式以显示输入法候选词。
65
+ *
66
+ * @private
67
+ */
14
68
  private _compositionstart;
69
+ /**
70
+ * 处理输入法组合更新事件
71
+ *
72
+ * 当输入法组合内容发生变化时触发。
73
+ * 动态调整代理输入框宽度以适应输入内容。
74
+ *
75
+ * @private
76
+ */
15
77
  private _compositionupdate;
78
+ /**
79
+ * 处理输入法组合结束事件
80
+ *
81
+ * 当输入法组合完成时触发,将最终文本插入到文档中。
82
+ * 恢复代理输入框的样式。
83
+ *
84
+ * @param evt - 组合事件对象
85
+ * @private
86
+ */
16
87
  private _compositionend;
88
+ /**
89
+ * 处理键盘按下事件(用于取消输入法组合)
90
+ *
91
+ * 当用户按下Escape键时,取消当前的输入法组合。
92
+ *
93
+ * @param evt - 键盘事件对象
94
+ * @private
95
+ */
17
96
  private _keydown;
18
97
  }