@agile_jy/word-editor 0.0.1-beta.21 → 0.0.1-beta.23
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/dist/canvas-editor.es.js +179 -43
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +35 -32
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +6 -1
- package/dist/src/editor/index.d.ts +4 -3
- package/dist/src/editor/interface/Editor.d.ts +18 -0
- package/dist/src/editor/utils/rowMargin.d.ts +13 -0
- package/dist/src/plugins/docx/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -120,6 +120,7 @@ export declare class Command {
|
|
|
120
120
|
getCatalog: CommandAdapt['getCatalog'];
|
|
121
121
|
getImage: CommandAdapt['getImage'];
|
|
122
122
|
getOptions: CommandAdapt['getOptions'];
|
|
123
|
+
getDefaultLineHeight: CommandAdapt['getDefaultLineHeight'];
|
|
123
124
|
getValue: CommandAdapt['getValue'];
|
|
124
125
|
getValueAsync: CommandAdapt['getValueAsync'];
|
|
125
126
|
getAreaValue: CommandAdapt['getAreaValue'];
|
|
@@ -10,7 +10,7 @@ import { ICatalog } from '../../interface/Catalog';
|
|
|
10
10
|
import { DeepRequired } from '../../interface/Common';
|
|
11
11
|
import { IGetControlValueOption, IGetControlValueResult, ILocationControlOption, IRemoveControlOption, ISetControlExtensionOption, ISetControlHighlightOption, ISetControlProperties, ISetControlValueOption } from '../../interface/Control';
|
|
12
12
|
import { IAppendElementListOption, IDrawImagePayload, IForceUpdateOption, IGetImageOption, IGetValueOption, IPainterOption } from '../../interface/Draw';
|
|
13
|
-
import { IEditorData, IEditorHTML, IEditorOption, IEditorResult, IEditorText, IFocusOption, IImportDocxOption, ISetHtmlDocxOption, ISetValueOption, IUpdateOption } from '../../interface/Editor';
|
|
13
|
+
import { IEditorData, IEditorHTML, IEditorOption, IEditorResult, IEditorText, IFocusOption, IGetDefaultLineHeightOption, IDefaultLineHeightResult, IImportDocxOption, ISetHtmlDocxOption, ISetValueOption, IUpdateOption } from '../../interface/Editor';
|
|
14
14
|
import { IDeleteElementByIdOption, IElement, IElementPosition, IGetElementByIdOption, IImageCaption, IImageCrop, IInsertElementListOption, IUpdateElementByIdOption } from '../../interface/Element';
|
|
15
15
|
import { ICopyOption, IPasteOption, IPositionContextByEventOption, IPositionContextByEventResult } from '../../interface/Event';
|
|
16
16
|
import { IMargin } from '../../interface/Margin';
|
|
@@ -116,6 +116,11 @@ export declare class CommandAdapt {
|
|
|
116
116
|
changeImageDisplay(element: IElement, display: ImageDisplay): void;
|
|
117
117
|
getImage(payload?: IGetImageOption): Promise<string[]>;
|
|
118
118
|
getOptions(): DeepRequired<IEditorOption>;
|
|
119
|
+
/**
|
|
120
|
+
* 获取默认行高(与 canvas 排版 / 导出 HTML 一致)
|
|
121
|
+
* 可传入 size、rowMargin 覆盖默认值
|
|
122
|
+
*/
|
|
123
|
+
getDefaultLineHeight(payload?: IGetDefaultLineHeightOption): IDefaultLineHeightResult;
|
|
119
124
|
getValue(options?: IGetValueOption): IEditorResult;
|
|
120
125
|
getValueAsync(options?: IGetValueOption): Promise<IEditorResult>;
|
|
121
126
|
getAreaValue(options?: IGetAreaValueOption): IGetAreaValueResult | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './assets/css/index.css';
|
|
2
|
-
import { IEditorData, IEditorOption, IEditorResult, IImportDocxOption } from './interface/Editor';
|
|
2
|
+
import { IEditorData, IEditorOption, IEditorResult, IImportDocxOption, IGetDefaultLineHeightOption, IDefaultLineHeightResult } from './interface/Editor';
|
|
3
3
|
import { IElement, IFormInputImage, IUpdateElementByIdOption } from './interface/Element';
|
|
4
4
|
import { IFormImageProperties, ISignatureImage, ISealImage, IRiskCopyImage } from '../utils';
|
|
5
5
|
import { Command } from './core/command/Command';
|
|
@@ -44,6 +44,7 @@ import { INTERNAL_SHORTCUT_KEY } from './dataset/constant/Shortcut';
|
|
|
44
44
|
import { formInputPropertiesConfigDialog, formCheckboxPropertiesConfigDialog, formRadioPropertiesConfigDialog, formImagePropertiesConfigDialog, formSignatureConfigDialog, formSealConfigDialog, formRiskCopyConfigDialog } from '../utils';
|
|
45
45
|
import { Dialog, type IDialogData, type IDialogConfirm, type IDialogOptions } from '../components/dialog/Dialog';
|
|
46
46
|
import docxPlugin from '../plugins/docx';
|
|
47
|
+
import { computeElementLineHeightPx, computeElementRowMarginPx } from './utils/rowMargin';
|
|
47
48
|
export default class Editor {
|
|
48
49
|
command: Command;
|
|
49
50
|
version: string;
|
|
@@ -98,5 +99,5 @@ export default class Editor {
|
|
|
98
99
|
export { splitText, createDomFromElementList, getElementListByHTML, getTextFromElementList };
|
|
99
100
|
export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY, INTERNAL_SHORTCUT_KEY, EDITOR_CLIPBOARD };
|
|
100
101
|
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, RenderMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, ControlComponent, BackgroundRepeat, BackgroundSize, TextDecorationStyle, LineNumberType, LocationPosition, AreaMode, ControlState, FlexDirection, WatermarkType };
|
|
101
|
-
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle, IBadge, IGetElementListByHTMLOption, IFormInputImage, IUpdateElementByIdOption, IFormImageProperties, ISignatureImage, ISealImage, IRiskCopyImage, IDialogData, IDialogConfirm, IDialogOptions, IImportDocxOption };
|
|
102
|
-
export { Dialog, docxPlugin, formInputPropertiesConfigDialog, formCheckboxPropertiesConfigDialog, formRadioPropertiesConfigDialog, formImagePropertiesConfigDialog, formSignatureConfigDialog, formSealConfigDialog, formRiskCopyConfigDialog };
|
|
102
|
+
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle, IBadge, IGetElementListByHTMLOption, IFormInputImage, IUpdateElementByIdOption, IFormImageProperties, ISignatureImage, ISealImage, IRiskCopyImage, IDialogData, IDialogConfirm, IDialogOptions, IImportDocxOption, IGetDefaultLineHeightOption, IDefaultLineHeightResult };
|
|
103
|
+
export { Dialog, docxPlugin, computeElementRowMarginPx, computeElementLineHeightPx, formInputPropertiesConfigDialog, formCheckboxPropertiesConfigDialog, formRadioPropertiesConfigDialog, formImagePropertiesConfigDialog, formSignatureConfigDialog, formSealConfigDialog, formRiskCopyConfigDialog };
|
|
@@ -128,6 +128,24 @@ export interface IImportDocxOption {
|
|
|
128
128
|
/** 页边距 [上, 右, 下, 左],传入则覆盖 DOM 解析结果 */
|
|
129
129
|
margins?: IMargin;
|
|
130
130
|
}
|
|
131
|
+
/** getDefaultLineHeight 可选覆盖项 */
|
|
132
|
+
export interface IGetDefaultLineHeightOption {
|
|
133
|
+
/** 覆盖默认字号 */
|
|
134
|
+
size?: number;
|
|
135
|
+
/** 覆盖默认行距倍数 */
|
|
136
|
+
rowMargin?: number;
|
|
137
|
+
}
|
|
138
|
+
/** 默认行高计算结果(与 canvas / 导出 HTML 公式一致) */
|
|
139
|
+
export interface IDefaultLineHeightResult {
|
|
140
|
+
/** 行距倍数 */
|
|
141
|
+
rowMargin: number;
|
|
142
|
+
/** 单侧行距 px */
|
|
143
|
+
rowMarginPx: number;
|
|
144
|
+
/** 整行高近似 px:字号 + 2×单侧行距 */
|
|
145
|
+
lineHeightPx: number;
|
|
146
|
+
/** 参与计算的字号 */
|
|
147
|
+
size: number;
|
|
148
|
+
}
|
|
131
149
|
export type IEditorText = IEditorHTML;
|
|
132
150
|
export type IUpdateOption = Omit<IEditorOption, 'mode' | 'width' | 'height' | 'scale' | 'pageGap' | 'pageMode' | 'paperDirection' | 'historyMaxRecordCount' | 'scrollContainerSelector'>;
|
|
133
151
|
export interface ISetValueOption {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DeepRequired } from '../interface/Common';
|
|
2
|
+
import { IEditorOption } from '../interface/Editor';
|
|
3
|
+
import { IElement } from '../interface/Element';
|
|
4
|
+
/**
|
|
5
|
+
* 计算元素单侧行距(px),与 Draw.getElementRowMargin 公式一致:
|
|
6
|
+
* defaultBasicRowMarginHeight × ratio × (rowMargin ?? defaultRowMargin) × scale
|
|
7
|
+
*/
|
|
8
|
+
export declare function computeElementRowMarginPx(el: IElement, options: DeepRequired<IEditorOption> | IEditorOption): number;
|
|
9
|
+
/**
|
|
10
|
+
* 导出 HTML 用的整行高近似(px):
|
|
11
|
+
* 字号 + 2 × 单侧行距(对应 canvas:ascent+descent+2×rowMargin)
|
|
12
|
+
*/
|
|
13
|
+
export declare function computeElementLineHeightPx(el: IElement, options: DeepRequired<IEditorOption> | IEditorOption): number;
|
|
@@ -4,5 +4,5 @@ export type { IImportDocxOption } from '../../editor/interface/Editor';
|
|
|
4
4
|
* 兼容旧用法:executeImportDocx 已内置到 Command,无需再挂载。
|
|
5
5
|
* 保留插件导出,避免旧代码 instance.use(docxPlugin) 报错。
|
|
6
6
|
*/
|
|
7
|
-
export default function docxPlugin(_editor
|
|
7
|
+
export default function docxPlugin(_editor?: Editor): void;
|
|
8
8
|
export { docxPlugin };
|
package/package.json
CHANGED