amis-editor-core 6.11.0-beta.4 → 6.11.0-beta.5

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.
@@ -0,0 +1,28 @@
1
+ import { InlineEditableElement } from './plugin';
2
+ import { EditorNodeType } from './store/node';
3
+ /**
4
+ * 内联编辑上下文接口定义
5
+ * @interface InlineEditContext
6
+ * @property {EditorNodeType} node - 当前编辑器节点实例
7
+ * @property {HTMLElement} elem - 需要编辑的DOM元素
8
+ * @property {InlineEditableElement} config - 内联编辑的配置信息
9
+ * @property {MouseEvent} [event] - 触发编辑的鼠标事件对象
10
+ * @property {Function} onConfirm - 编辑确认后的回调函数,参数为编辑后的内容
11
+ * @property {Function} onCancel - 取消编辑的回调函数
12
+ */
13
+ export interface InlineEditContext {
14
+ node: EditorNodeType;
15
+ elem: HTMLElement;
16
+ config: InlineEditableElement;
17
+ event?: MouseEvent;
18
+ onConfirm: (value: string) => void;
19
+ onCancel: () => void;
20
+ richTextToken?: string;
21
+ richTextOptions?: any;
22
+ }
23
+ /**
24
+ * 启动内联编辑
25
+ * 根据配置的mode选择对应的编辑模式
26
+ * @param {InlineEditContext} context - 编辑上下文
27
+ */
28
+ export declare function startInlineEdit(context: InlineEditContext): void;
package/lib/manager.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  /// <reference types="lodash" />
3
3
  import { DataSchema } from 'amis';
4
4
  import { RenderOptions, GlobalVariableItem } from 'amis-core';
5
- import { PluginInterface, BasicPanelItem, RendererInfo, SubRendererInfo, PluginEvent, RegionConfig, ContextMenuItem, ContextMenuEventContext, EventContext, PluginEventFn, ScaffoldForm, RendererPluginEvent, PluginEvents, PluginActions } from './plugin';
5
+ import { PluginInterface, BasicPanelItem, RendererInfo, SubRendererInfo, PluginEvent, RegionConfig, ContextMenuItem, ContextMenuEventContext, EventContext, PluginEventFn, ScaffoldForm, RendererPluginEvent, PluginEvents, PluginActions, InlineEditableElement } from './plugin';
6
6
  import { EditorStoreType, SubEditorContext } from './store/editor';
7
7
  import { EditorNodeType } from './store/node';
8
8
  import { EditorProps } from './component/Editor';
@@ -112,10 +112,6 @@ export declare class EditorManager {
112
112
  readonly removable: boolean;
113
113
  readonly duplicatable: boolean;
114
114
  readonly replaceable: boolean;
115
- /**
116
- * 在 component/Editor.tsx 里面实例化的。
117
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
118
- */
119
115
  memberImmutable(region: string): boolean;
120
116
  readonly isRegion: boolean;
121
117
  readonly childRegions: any[];
@@ -180,10 +176,6 @@ export declare class EditorManager {
180
176
  readonly removable: boolean;
181
177
  readonly duplicatable: boolean;
182
178
  readonly replaceable: boolean;
183
- /**
184
- * 在 component/Editor.tsx 里面实例化的。
185
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
186
- */
187
179
  memberImmutable(region: string): boolean;
188
180
  readonly isRegion: boolean;
189
181
  readonly childRegions: any[];
@@ -247,10 +239,6 @@ export declare class EditorManager {
247
239
  readonly removable: boolean;
248
240
  readonly duplicatable: boolean;
249
241
  readonly replaceable: boolean;
250
- /**
251
- * 在 component/Editor.tsx 里面实例化的。
252
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
253
- */
254
242
  memberImmutable(region: string): boolean;
255
243
  readonly isRegion: boolean;
256
244
  readonly childRegions: any[];
@@ -341,10 +329,6 @@ export declare class EditorManager {
341
329
  readonly removable: boolean;
342
330
  readonly duplicatable: boolean;
343
331
  readonly replaceable: boolean;
344
- /**
345
- * 在 component/Editor.tsx 里面实例化的。
346
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
347
- */
348
332
  memberImmutable(region: string): boolean;
349
333
  readonly isRegion: boolean;
350
334
  readonly childRegions: any[];
@@ -408,10 +392,6 @@ export declare class EditorManager {
408
392
  readonly removable: boolean;
409
393
  readonly duplicatable: boolean;
410
394
  readonly replaceable: boolean;
411
- /**
412
- * 在 component/Editor.tsx 里面实例化的。
413
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
414
- */
415
395
  memberImmutable(region: string): boolean;
416
396
  readonly isRegion: boolean;
417
397
  readonly childRegions: any[];
@@ -509,10 +489,6 @@ export declare class EditorManager {
509
489
  readonly removable: boolean;
510
490
  readonly duplicatable: boolean;
511
491
  readonly replaceable: boolean;
512
- /**
513
- * 在 component/Editor.tsx 里面实例化的。
514
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
515
- */
516
492
  memberImmutable(region: string): boolean;
517
493
  readonly isRegion: boolean;
518
494
  readonly childRegions: any[];
@@ -577,10 +553,6 @@ export declare class EditorManager {
577
553
  readonly removable: boolean;
578
554
  readonly duplicatable: boolean;
579
555
  readonly replaceable: boolean;
580
- /**
581
- * 在 component/Editor.tsx 里面实例化的。
582
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
583
- */
584
556
  memberImmutable(region: string): boolean;
585
557
  readonly isRegion: boolean;
586
558
  readonly childRegions: any[];
@@ -644,10 +616,6 @@ export declare class EditorManager {
644
616
  readonly removable: boolean;
645
617
  readonly duplicatable: boolean;
646
618
  readonly replaceable: boolean;
647
- /**
648
- * 在 component/Editor.tsx 里面实例化的。
649
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
650
- */
651
619
  memberImmutable(region: string): boolean;
652
620
  readonly isRegion: boolean;
653
621
  readonly childRegions: any[];
@@ -738,10 +706,6 @@ export declare class EditorManager {
738
706
  readonly removable: boolean;
739
707
  readonly duplicatable: boolean;
740
708
  readonly replaceable: boolean;
741
- /**
742
- * 在 component/Editor.tsx 里面实例化的。
743
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
744
- */
745
709
  memberImmutable(region: string): boolean;
746
710
  readonly isRegion: boolean;
747
711
  readonly childRegions: any[];
@@ -805,10 +769,6 @@ export declare class EditorManager {
805
769
  readonly removable: boolean;
806
770
  readonly duplicatable: boolean;
807
771
  readonly replaceable: boolean;
808
- /**
809
- * 在 component/Editor.tsx 里面实例化的。
810
- * 辅助 component/Editor.tsx 实现一些非 UI 相关的功能。
811
- */
812
772
  memberImmutable(region: string): boolean;
813
773
  readonly isRegion: boolean;
814
774
  readonly childRegions: any[];
@@ -1178,6 +1138,7 @@ export declare class EditorManager {
1178
1138
  * 获取可用上下文待绑定字段
1179
1139
  */
1180
1140
  getAvailableContextFields(node: EditorNodeType): Promise<any>;
1141
+ startInlineEdit(node: EditorNodeType, elem: HTMLElement, config: InlineEditableElement, event?: MouseEvent): void;
1181
1142
  /**
1182
1143
  * 初始化全局变量
1183
1144
  */
package/lib/plugin.d.ts CHANGED
@@ -127,6 +127,11 @@ export interface RendererScaffoldInfo {
127
127
  type?: string;
128
128
  scaffold?: any;
129
129
  }
130
+ export interface InlineEditableElement {
131
+ match: string;
132
+ mode?: 'plain-text' | 'rich-text';
133
+ key: string;
134
+ }
130
135
  /**
131
136
  * 渲染器信息。
132
137
  */
@@ -148,6 +153,10 @@ export interface RendererInfo extends RendererScaffoldInfo {
148
153
  * 配置区域。
149
154
  */
150
155
  regions?: Array<RegionConfig>;
156
+ /**
157
+ * 支持内联编辑的元素集合
158
+ */
159
+ inlineEditableElements?: Array<InlineEditableElement>;
151
160
  /**
152
161
  * 选中不需要高亮
153
162
  */
@@ -347,9 +356,10 @@ export interface PanelProps {
347
356
  export interface PanelItem {
348
357
  nodeId?: string;
349
358
  key: string;
350
- icon: string;
359
+ icon: React.ReactNode;
360
+ tooltip?: string;
351
361
  pluginIcon?: string;
352
- title: string | JSX.Element;
362
+ title?: React.ReactNode;
353
363
  component?: React.ComponentType<PanelProps | any>;
354
364
  order: number;
355
365
  position?: 'left' | 'right';
@@ -463,6 +463,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
463
463
  hoverRegion: import("mobx-state-tree").IType<string | undefined, string, string>;
464
464
  activeId: import("mobx-state-tree").IType<string | undefined, string, string>;
465
465
  activeRegion: import("mobx-state-tree").IType<string | undefined, string, string>;
466
+ activeElement: import("mobx-state-tree").IType<string | undefined, string, string>;
466
467
  mouseMoveRegion: import("mobx-state-tree").IType<string | undefined, string, string>;
467
468
  selections: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<string[], string[], string[]>, [undefined]>;
468
469
  contextId: import("mobx-state-tree").IType<string | undefined, string, string>;
@@ -3661,6 +3662,7 @@ export declare const MainStore: import("mobx-state-tree").IModelType<{
3661
3662
  moveSchema(event: PluginEvent<MoveEventContext>): void;
3662
3663
  setActiveId(id: string, region?: string, selections?: Array<string>, onEditorActive?: boolean): void;
3663
3664
  setActiveIdByComponentId(id: string): void;
3665
+ setActiveElement(selector: string): void;
3664
3666
  setSelections(ids: Array<string>): void;
3665
3667
  clearSelection(): void;
3666
3668
  setHoverId(id: string, region?: string): void;