@hufe921/canvas-editor 0.9.29 → 0.9.31

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.
@@ -1,4 +1,4 @@
1
- import { IElement, ImageDisplay, INavigateInfo, TableBorder, VerticalAlign } from '../..';
1
+ import { IElement, ImageDisplay, INavigateInfo, TableBorder, TitleLevel, VerticalAlign } from '../..';
2
2
  import { EditorMode, PageMode, PaperDirection } from '../../dataset/enum/Editor';
3
3
  import { IDrawImagePayload, IPainterOptions } from '../../interface/Draw';
4
4
  import { IEditorResult } from '../../interface/Editor';
@@ -30,6 +30,7 @@ export declare class Command {
30
30
  private static subscript;
31
31
  private static color;
32
32
  private static highlight;
33
+ private static title;
33
34
  private static left;
34
35
  private static center;
35
36
  private static right;
@@ -105,6 +106,7 @@ export declare class Command {
105
106
  executeSubscript(): void;
106
107
  executeColor(payload: string): void;
107
108
  executeHighlight(payload: string): void;
109
+ executeTitle(payload: TitleLevel | null): void;
108
110
  executeLeft(): void;
109
111
  executeCenter(): void;
110
112
  executeRight(): void;
@@ -2,6 +2,7 @@ import { ImageDisplay } from '../../dataset/enum/Control';
2
2
  import { EditorMode, PageMode, PaperDirection } from '../../dataset/enum/Editor';
3
3
  import { RowFlex } from '../../dataset/enum/Row';
4
4
  import { TableBorder } from '../../dataset/enum/table/Table';
5
+ import { TitleLevel } from '../../dataset/enum/Title';
5
6
  import { VerticalAlign } from '../../dataset/enum/VerticalAlign';
6
7
  import { IDrawImagePayload, IPainterOptions } from '../../interface/Draw';
7
8
  import { IEditorResult } from '../../interface/Editor';
@@ -48,6 +49,7 @@ export declare class CommandAdapt {
48
49
  subscript(): void;
49
50
  color(payload: string): void;
50
51
  highlight(payload: string): void;
52
+ title(payload: TitleLevel | null): void;
51
53
  rowFlex(payload: RowFlex): void;
52
54
  rowMargin(payload: number): void;
53
55
  insertTable(row: number, col: number): void;
@@ -111,6 +111,7 @@ export declare class Draw {
111
111
  setPageNo(payload: number): void;
112
112
  getPage(pageNo?: number): HTMLCanvasElement;
113
113
  getPageList(): HTMLCanvasElement[];
114
+ getPageCount(): number;
114
115
  getTableRowList(sourceElementList: IElement[]): IRow[];
115
116
  getOriginalRowList(): IRow[];
116
117
  getRowList(): IRow[];
@@ -1,4 +1,4 @@
1
- import { IContentChange, IControlChange, IIntersectionPageNoChange, IPageModeChange, IPageScaleChange, IPageSizeChange, IRangeStyleChange, ISaved, IVisiblePageNoListChange } from '../../interface/Listener';
1
+ import { IContentChange, IControlChange, IIntersectionPageNoChange, IPageModeChange, IPageScaleChange, IPageSizeChange, IRangeStyleChange, ISaved, IVisiblePageNoListChange, IZoneChange } from '../../interface/Listener';
2
2
  export declare class Listener {
3
3
  rangeStyleChange: IRangeStyleChange | null;
4
4
  visiblePageNoListChange: IVisiblePageNoListChange | null;
@@ -9,5 +9,6 @@ export declare class Listener {
9
9
  contentChange: IContentChange | null;
10
10
  controlChange: IControlChange | null;
11
11
  pageModeChange: IPageModeChange | null;
12
+ zoneChange: IZoneChange | null;
12
13
  constructor();
13
14
  }
@@ -5,3 +5,4 @@ export declare const EDITOR_ELEMENT_COPY_ATTR: Array<keyof IElement>;
5
5
  export declare const EDITOR_ELEMENT_ZIP_ATTR: Array<keyof IElement>;
6
6
  export declare const TEXTLIKE_ELEMENT_TYPE: ElementType[];
7
7
  export declare const INLINE_ELEMENT_TYPE: ElementType[];
8
+ export declare const INLINE_NODE_NAME: string[];
@@ -1,2 +1,6 @@
1
1
  import { IPageNumber } from '../../interface/PageNumber';
2
+ export declare const FORMAT_PLACEHOLDER: {
3
+ PAGE_NO: string;
4
+ PAGE_COUNT: string;
5
+ };
2
6
  export declare const defaultPageNumberOption: Readonly<Required<IPageNumber>>;
@@ -0,0 +1,6 @@
1
+ import { ITitleOption, ITitleSizeOption } from '../../interface/Title';
2
+ import { TitleLevel } from '../enum/Title';
3
+ export declare const defaultTitleOption: Readonly<Required<ITitleOption>>;
4
+ export declare const titleSizeMapping: Record<TitleLevel, keyof ITitleSizeOption>;
5
+ export declare const titleOrderNumberMapping: Record<TitleLevel, number>;
6
+ export declare const titleNodeNameMapping: Record<string, TitleLevel>;
@@ -3,3 +3,7 @@ export declare enum MaxHeightRatio {
3
3
  ONE_THIRD = "one-third",
4
4
  QUARTER = "quarter"
5
5
  }
6
+ export declare enum NumberType {
7
+ ARABIC = "arabic",
8
+ CHINESE = "chinese"
9
+ }
@@ -12,5 +12,6 @@ export declare enum ElementType {
12
12
  LATEX = "latex",
13
13
  TAB = "tab",
14
14
  DATE = "date",
15
- BLOCK = "block"
15
+ BLOCK = "block",
16
+ TITLE = "title"
16
17
  }
@@ -0,0 +1,8 @@
1
+ export declare enum TitleLevel {
2
+ FIRST = "first",
3
+ SECOND = "second",
4
+ THIRD = "third",
5
+ FOURTH = "fourth",
6
+ FIFTH = "fifth",
7
+ SIXTH = "sixth"
8
+ }
@@ -18,7 +18,8 @@ import { IBlock } from './interface/Block';
18
18
  import { ILang } from './interface/i18n/I18n';
19
19
  import { VerticalAlign } from './dataset/enum/VerticalAlign';
20
20
  import { TableBorder } from './dataset/enum/table/Table';
21
- import { MaxHeightRatio } from './dataset/enum/Common';
21
+ import { MaxHeightRatio, NumberType } from './dataset/enum/Common';
22
+ import { TitleLevel } from './dataset/enum/Title';
22
23
  export default class Editor {
23
24
  command: Command;
24
25
  listener: Listener;
@@ -26,5 +27,5 @@ export default class Editor {
26
27
  destroy: Function;
27
28
  constructor(container: HTMLDivElement, data: IEditorData | IElement[], options?: IEditorOption);
28
29
  }
29
- export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, EDITOR_COMPONENT, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, MaxHeightRatio };
30
+ export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, EDITOR_COMPONENT, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, MaxHeightRatio, NumberType, TitleLevel };
30
31
  export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang };
@@ -7,6 +7,7 @@ import { IFooter } from './Footer';
7
7
  import { IHeader } from './Header';
8
8
  import { IMargin } from './Margin';
9
9
  import { IPageNumber } from './PageNumber';
10
+ import { ITitleOption } from './Title';
10
11
  import { IWatermark } from './Watermark';
11
12
  export interface IEditorData {
12
13
  header?: IElement[];
@@ -54,6 +55,7 @@ export interface IEditorOption {
54
55
  control?: IControlOption;
55
56
  checkbox?: ICheckboxOption;
56
57
  cursor?: ICursorOption;
58
+ title?: ITitleOption;
57
59
  }
58
60
  export interface IEditorResult {
59
61
  version: string;
@@ -1,6 +1,7 @@
1
1
  import { ControlComponent, ImageDisplay } from '../dataset/enum/Control';
2
2
  import { ElementType } from '../dataset/enum/Element';
3
3
  import { RowFlex } from '../dataset/enum/Row';
4
+ import { TitleLevel } from '../dataset/enum/Title';
4
5
  import { TableBorder } from '../dataset/enum/table/Table';
5
6
  import { IBlock } from './Block';
6
7
  import { ICheckbox } from './Checkbox';
@@ -27,6 +28,11 @@ export interface IElementStyle {
27
28
  rowMargin?: number;
28
29
  letterSpacing?: number;
29
30
  }
31
+ export interface ITitleElement {
32
+ valueList?: IElement[];
33
+ level?: TitleLevel;
34
+ titleId?: string;
35
+ }
30
36
  export interface ITableAttr {
31
37
  colgroup?: IColgroup[];
32
38
  trList?: ITr[];
@@ -70,7 +76,7 @@ export interface IImageElement {
70
76
  export interface IBlockElement {
71
77
  block?: IBlock;
72
78
  }
73
- export declare type IElement = IElementBasic & IElementStyle & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & ILaTexElement & IDateElement & IImageElement & IBlockElement;
79
+ export declare type IElement = IElementBasic & IElementStyle & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement;
74
80
  export interface IElementMetrics {
75
81
  width: number;
76
82
  height: number;
@@ -1,4 +1,4 @@
1
- import { ElementType, PageMode } from '..';
1
+ import { EditorZone, ElementType, PageMode, TitleLevel } from '..';
2
2
  import { RowFlex } from '../dataset/enum/Row';
3
3
  import { IControl } from './Control';
4
4
  import { IEditorResult } from './Editor';
@@ -18,6 +18,7 @@ export interface IRangeStyle {
18
18
  rowFlex: RowFlex | null;
19
19
  rowMargin: number;
20
20
  dashArray: number[];
21
+ level: TitleLevel | null;
21
22
  }
22
23
  export declare type IRangeStyleChange = (payload: IRangeStyle) => void;
23
24
  export declare type IVisiblePageNoListChange = (payload: number[]) => void;
@@ -28,3 +29,4 @@ export declare type ISaved = (payload: IEditorResult) => void;
28
29
  export declare type IContentChange = () => void;
29
30
  export declare type IControlChange = (payload: IControl | null) => void;
30
31
  export declare type IPageModeChange = (payload: PageMode) => void;
32
+ export declare type IZoneChange = (payload: EditorZone) => void;
@@ -1,3 +1,4 @@
1
+ import { NumberType } from '../dataset/enum/Common';
1
2
  import { RowFlex } from '../dataset/enum/Row';
2
3
  export interface IPageNumber {
3
4
  bottom?: number;
@@ -5,4 +6,6 @@ export interface IPageNumber {
5
6
  font?: string;
6
7
  color?: string;
7
8
  rowFlex?: RowFlex;
9
+ format?: string;
10
+ numberType?: NumberType;
8
11
  }
@@ -0,0 +1,9 @@
1
+ export interface ITitleSizeOption {
2
+ defaultFirstSize?: number;
3
+ defaultSecondSize?: number;
4
+ defaultThirdSize?: number;
5
+ defaultFourthSize?: number;
6
+ defaultFifthSize?: number;
7
+ defaultSixthSize?: number;
8
+ }
9
+ export declare type ITitleOption = ITitleSizeOption & {};
@@ -1,6 +1,7 @@
1
1
  import { IEditorOption, IElement } from '..';
2
2
  import { DeepRequired } from '../interface/Common';
3
3
  export declare function writeClipboardItem(text: string, html: string): void;
4
+ export declare function convertElementToDom(element: IElement, options: DeepRequired<IEditorOption>): HTMLElement;
4
5
  export declare function writeElementList(elementList: IElement[], options: DeepRequired<IEditorOption>): void;
5
6
  interface IGetElementListByHTMLOption {
6
7
  innerWidth: number;
@@ -1,4 +1,5 @@
1
1
  import { IEditorOption, IElement, RowFlex } from '..';
2
+ export declare function unzipElementList(elementList: IElement[]): IElement[];
2
3
  interface IFormatElementListOption {
3
4
  isHandleFirstElement?: boolean;
4
5
  editorOptions: Required<IEditorOption>;
@@ -8,4 +9,5 @@ export declare function isSameElementExceptValue(source: IElement, target: IElem
8
9
  export declare function pickElementAttr(payload: IElement): IElement;
9
10
  export declare function zipElementList(payload: IElement[]): IElement[];
10
11
  export declare function getElementRowFlex(node: HTMLElement): RowFlex;
12
+ export declare function isTextLikeElement(element: IElement): boolean;
11
13
  export {};
@@ -10,3 +10,4 @@ export declare function isObject(type: unknown): type is Record<string, unknown>
10
10
  export declare function isArray(type: unknown): type is Array<unknown>;
11
11
  export declare function mergeObject<T>(source: T, target: T): T;
12
12
  export declare function nextTick(fn: Function): void;
13
+ export declare function convertNumberToChinese(num: number): string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@hufe921/canvas-editor",
3
3
  "author": "Hufe",
4
4
  "license": "MIT",
5
- "version": "0.9.29",
5
+ "version": "0.9.31",
6
6
  "description": "rich text editor by canvas/svg",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/",