@hufe921/canvas-editor 0.9.72 → 0.9.73

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.
@@ -3,7 +3,7 @@ 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
- export declare type IDrawCursorOption = ICursorOption & {
6
+ export type IDrawCursorOption = ICursorOption & {
7
7
  isShow?: boolean;
8
8
  isBlink?: boolean;
9
9
  isFocus?: boolean;
@@ -1,4 +1,4 @@
1
- import { IAppendElementListOption, IDrawOption, IDrawRowPayload, IGetImageOption, IGetValueOption, IPainterOption } from '../../interface/Draw';
1
+ import { IAppendElementListOption, IComputeRowListPayload, IDrawOption, IDrawRowPayload, IGetImageOption, IGetValueOption, IPainterOption } from '../../interface/Draw';
2
2
  import { IEditorData, IEditorOption, IEditorResult } from '../../interface/Editor';
3
3
  import { IElement, IElementStyle } from '../../interface/Element';
4
4
  import { IRow } from '../../interface/Row';
@@ -196,7 +196,7 @@ export declare class Draw {
196
196
  private _initPageContext;
197
197
  getElementFont(el: IElement, scale?: number): string;
198
198
  getElementSize(el: IElement): number;
199
- computeRowList(innerWidth: number, elementList: IElement[]): IRow[];
199
+ computeRowList(payload: IComputeRowListPayload): IRow[];
200
200
  private _computePageList;
201
201
  private _drawHighlight;
202
202
  drawRow(ctx: CanvasRenderingContext2D, payload: IDrawRowPayload): void;
@@ -30,7 +30,7 @@ export declare class Control {
30
30
  getPosition(): IElementPosition | null;
31
31
  getPreY(): number;
32
32
  getRange(): IRange;
33
- shrinkBoundary(): void;
33
+ shrinkBoundary(context?: IControlContext): void;
34
34
  getActiveControl(): IControlInstance | null;
35
35
  initControl(): void;
36
36
  destroyControl(): void;
@@ -1,7 +1,7 @@
1
1
  import { IControlHighlight, IControlHighlightRule } from '../../../../interface/Control';
2
2
  import { ISearchResult } from '../../../../interface/Search';
3
3
  import { Control } from '../Control';
4
- declare type IHighlightMatchResult = (ISearchResult & IControlHighlightRule)[];
4
+ type IHighlightMatchResult = (ISearchResult & IControlHighlightRule)[];
5
5
  export declare class ControlSearch {
6
6
  private draw;
7
7
  private options;
@@ -1,5 +1,6 @@
1
+ import { IControlContext } from '../../interface/Control';
1
2
  import { IElement } from '../../interface/Element';
2
- import { IRange, RangeRowArray, RangeRowMap } from '../../interface/Range';
3
+ import { IRange, IRangeParagraphInfo, RangeRowArray, RangeRowMap } from '../../interface/Range';
3
4
  import { Draw } from '../draw/Draw';
4
5
  export declare class RangeManager {
5
6
  private draw;
@@ -20,6 +21,7 @@ export declare class RangeManager {
20
21
  getRangeRow(): RangeRowMap | null;
21
22
  getRangeRowElementList(): IElement[] | null;
22
23
  getRangeParagraph(): RangeRowArray | null;
24
+ getRangeParagraphInfo(): IRangeParagraphInfo | null;
23
25
  getRangeParagraphElementList(): IElement[] | null;
24
26
  getIsSelectAll(): boolean;
25
27
  getIsPointInRange(x: number, y: number): boolean;
@@ -29,7 +31,7 @@ export declare class RangeManager {
29
31
  replaceRange(range: IRange): void;
30
32
  setRangeStyle(): void;
31
33
  recoveryRangeStyle(): void;
32
- shrinkBoundary(): void;
34
+ shrinkBoundary(context?: IControlContext): void;
33
35
  render(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number): void;
34
36
  toString(): string;
35
37
  }
@@ -5,3 +5,4 @@ export declare const SURROGATE_PAIR_REG: RegExp;
5
5
  export declare const EMOJI_REG: RegExp;
6
6
  export declare const UNICODE_SYMBOL_REG: RegExp;
7
7
  export declare const PUNCTUATION_REG: RegExp;
8
+ export declare const START_LINE_BREAK_REG: RegExp;
@@ -5,7 +5,8 @@ export declare enum ListType {
5
5
  export declare enum UlStyle {
6
6
  DISC = "disc",
7
7
  CIRCLE = "circle",
8
- SQUARE = "square"
8
+ SQUARE = "square",
9
+ CHECKBOX = "checkbox"
9
10
  }
10
11
  export declare enum OlStyle {
11
12
  DECIMAL = "decimal"
@@ -14,5 +15,6 @@ export declare enum ListStyle {
14
15
  DISC = "disc",
15
16
  CIRCLE = "circle",
16
17
  SQUARE = "square",
17
- DECIMAL = "decimal"
18
+ DECIMAL = "decimal",
19
+ CHECKBOX = "checkbox"
18
20
  }
@@ -5,4 +5,4 @@ export interface ICatalogItem {
5
5
  level: TitleLevel;
6
6
  subCatalog: ICatalogItem[];
7
7
  }
8
- export declare type ICatalog = ICatalogItem[];
8
+ export type ICatalog = ICatalogItem[];
@@ -1,12 +1,12 @@
1
- export declare type Primitive = string | number | boolean | bigint | symbol | undefined | null;
2
- export declare type Builtin = Primitive | Function | Date | Error | RegExp;
3
- export declare type DeepRequired<T> = T extends Error ? Required<T> : T extends Builtin ? T : T extends Map<infer K, infer V> ? Map<DeepRequired<K>, DeepRequired<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepRequired<K>, DeepRequired<V>> : T extends WeakMap<infer K, infer V> ? WeakMap<DeepRequired<K>, DeepRequired<V>> : T extends Set<infer U> ? Set<DeepRequired<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepRequired<U>> : T extends WeakSet<infer U> ? WeakSet<DeepRequired<U>> : T extends Promise<infer U> ? Promise<DeepRequired<U>> : T extends {} ? {
1
+ export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
2
+ export type Builtin = Primitive | Function | Date | Error | RegExp;
3
+ export type DeepRequired<T> = T extends Error ? Required<T> : T extends Builtin ? T : T extends Map<infer K, infer V> ? Map<DeepRequired<K>, DeepRequired<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepRequired<K>, DeepRequired<V>> : T extends WeakMap<infer K, infer V> ? WeakMap<DeepRequired<K>, DeepRequired<V>> : T extends Set<infer U> ? Set<DeepRequired<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepRequired<U>> : T extends WeakSet<infer U> ? WeakSet<DeepRequired<U>> : T extends Promise<infer U> ? Promise<DeepRequired<U>> : T extends {} ? {
4
4
  [K in keyof T]-?: DeepRequired<T[K]>;
5
5
  } : Required<T>;
6
- export declare type DeepPartial<T> = {
6
+ export type DeepPartial<T> = {
7
7
  [P in keyof T]?: DeepPartial<T[P]>;
8
8
  };
9
- export declare type IPadding = [
9
+ export type IPadding = [
10
10
  top: number,
11
11
  right: number,
12
12
  bottom: number,
@@ -43,7 +43,7 @@ export interface IControlBasic {
43
43
  extension?: unknown;
44
44
  indentation?: ControlIndentation;
45
45
  }
46
- export declare type IControl = IControlBasic & IControlRule & Partial<IControlSelect> & Partial<IControlCheckbox>;
46
+ export type IControl = IControlBasic & IControlRule & Partial<IControlSelect> & Partial<IControlCheckbox>;
47
47
  export interface IControlOption {
48
48
  placeholderColor?: string;
49
49
  bracketColor?: string;
@@ -77,7 +77,7 @@ export interface IControlRuleOption {
77
77
  export interface IGetControlValueOption {
78
78
  conceptId: string;
79
79
  }
80
- export declare type IGetControlValueResult = (Omit<IControl, 'value'> & {
80
+ export type IGetControlValueResult = (Omit<IControl, 'value'> & {
81
81
  value: string | null;
82
82
  innerText: string | null;
83
83
  zone: EditorZone;
@@ -90,8 +90,8 @@ export interface ISetControlExtensionOption {
90
90
  conceptId: string;
91
91
  extension: unknown;
92
92
  }
93
- export declare type ISetControlHighlightOption = IControlHighlight[];
94
- export declare type ISetControlProperties = {
93
+ export type ISetControlHighlightOption = IControlHighlight[];
94
+ export type ISetControlProperties = {
95
95
  conceptId: string;
96
96
  properties: Partial<Omit<IControl, 'value'>>;
97
97
  };
@@ -51,3 +51,8 @@ export interface IGetImageOption {
51
51
  pixelRatio?: number;
52
52
  mode?: EditorMode;
53
53
  }
54
+ export interface IComputeRowListPayload {
55
+ innerWidth: number;
56
+ elementList: IElement[];
57
+ isPagingMode?: boolean;
58
+ }
@@ -90,4 +90,4 @@ export interface IEditorHTML {
90
90
  main: string;
91
91
  footer: string;
92
92
  }
93
- export declare type IEditorText = IEditorHTML;
93
+ export type IEditorText = IEditorHTML;
@@ -59,7 +59,7 @@ export interface ITableElement {
59
59
  conceptId?: string;
60
60
  pagingId?: string;
61
61
  }
62
- export declare type ITable = ITableAttr & ITableElement;
62
+ export type ITable = ITableAttr & ITableElement;
63
63
  export interface IHyperlinkElement {
64
64
  valueList?: IElement[];
65
65
  url?: string;
@@ -96,7 +96,7 @@ export interface IImageElement {
96
96
  export interface IBlockElement {
97
97
  block?: IBlock;
98
98
  }
99
- export declare type IElement = IElementBasic & IElementStyle & IElementGroup & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement & IListElement;
99
+ export type IElement = IElementBasic & IElementStyle & IElementGroup & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement & IListElement;
100
100
  export interface IElementMetrics {
101
101
  width: number;
102
102
  height: number;
@@ -25,13 +25,13 @@ export interface IRangeStyle {
25
25
  groupIds: string[] | null;
26
26
  textDecoration: ITextDecoration | null;
27
27
  }
28
- export declare type IRangeStyleChange = (payload: IRangeStyle) => void;
29
- export declare type IVisiblePageNoListChange = (payload: number[]) => void;
30
- export declare type IIntersectionPageNoChange = (payload: number) => void;
31
- export declare type IPageSizeChange = (payload: number) => void;
32
- export declare type IPageScaleChange = (payload: number) => void;
33
- export declare type ISaved = (payload: IEditorResult) => void;
34
- export declare type IContentChange = () => void;
35
- export declare type IControlChange = (payload: IControl | null) => void;
36
- export declare type IPageModeChange = (payload: PageMode) => void;
37
- export declare type IZoneChange = (payload: EditorZone) => void;
28
+ export type IRangeStyleChange = (payload: IRangeStyle) => void;
29
+ export type IVisiblePageNoListChange = (payload: number[]) => void;
30
+ export type IIntersectionPageNoChange = (payload: number) => void;
31
+ export type IPageSizeChange = (payload: number) => void;
32
+ export type IPageScaleChange = (payload: number) => void;
33
+ export type ISaved = (payload: IEditorResult) => void;
34
+ export type IContentChange = () => void;
35
+ export type IControlChange = (payload: IControl | null) => void;
36
+ export type IPageModeChange = (payload: PageMode) => void;
37
+ export type IZoneChange = (payload: EditorZone) => void;
@@ -1 +1 @@
1
- export declare type IMargin = [top: number, right: number, bottom: number, left: number];
1
+ export type IMargin = [top: number, right: number, bottom: number, left: number];
@@ -1,3 +1,3 @@
1
1
  import Editor from '..';
2
- export declare type PluginFunction<Options> = (editor: Editor, options?: Options) => any;
3
- export declare type UsePlugin = <Options>(pluginFunction: PluginFunction<Options>, options?: Options) => void;
2
+ export type PluginFunction<Options> = (editor: Editor, options?: Options) => any;
3
+ export type UsePlugin = <Options>(pluginFunction: PluginFunction<Options>, options?: Options) => void;
@@ -31,7 +31,7 @@ export interface IGetPositionByXYPayload {
31
31
  elementList?: IElement[];
32
32
  positionList?: IElementPosition[];
33
33
  }
34
- export declare type IGetFloatPositionByXYPayload = IGetPositionByXYPayload & {
34
+ export type IGetFloatPositionByXYPayload = IGetPositionByXYPayload & {
35
35
  imgDisplay: ImageDisplay;
36
36
  };
37
37
  export interface IPositionContext {
@@ -11,10 +11,10 @@ export interface IRange {
11
11
  endTrIndex?: number;
12
12
  zone?: EditorZone;
13
13
  }
14
- export declare type RangeRowArray = Map<number, number[]>;
15
- export declare type RangeRowMap = Map<number, Set<number>>;
16
- export declare type RangeRect = IElementFillRect;
17
- export declare type RangeContext = {
14
+ export type RangeRowArray = Map<number, number[]>;
15
+ export type RangeRowMap = Map<number, Set<number>>;
16
+ export type RangeRect = IElementFillRect;
17
+ export type RangeContext = {
18
18
  isCollapsed: boolean;
19
19
  startElement: IElement;
20
20
  endElement: IElement;
@@ -24,3 +24,7 @@ export declare type RangeContext = {
24
24
  zone: EditorZone;
25
25
  isTable: boolean;
26
26
  };
27
+ export interface IRangeParagraphInfo {
28
+ elementList: IElement[];
29
+ startIndex: number;
30
+ }
@@ -1,6 +1,6 @@
1
1
  import { RowFlex } from '../dataset/enum/Row';
2
2
  import { IElement, IElementMetrics } from './Element';
3
- export declare type IRowElement = IElement & {
3
+ export type IRowElement = IElement & {
4
4
  metrics: IElementMetrics;
5
5
  style: string;
6
6
  left?: number;
@@ -12,4 +12,4 @@ export interface ISearchResultRestArgs {
12
12
  tdId?: string;
13
13
  startIndex?: number;
14
14
  }
15
- export declare type ISearchResult = ISearchResultBasic & ISearchResultRestArgs;
15
+ export type ISearchResult = ISearchResultBasic & ISearchResultRestArgs;
@@ -6,4 +6,4 @@ export interface ITitleSizeOption {
6
6
  defaultFifthSize?: number;
7
7
  defaultSixthSize?: number;
8
8
  }
9
- export declare type ITitleOption = ITitleSizeOption & {};
9
+ export type ITitleOption = ITitleSizeOption & {};
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.72",
5
+ "version": "0.9.73",
6
6
  "description": "rich text editor by canvas/svg",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/",
@@ -30,7 +30,7 @@
30
30
  "emr"
31
31
  ],
32
32
  "engines": {
33
- "node": ">=12.0.0"
33
+ "node": ">=16.9.1"
34
34
  },
35
35
  "type": "module",
36
36
  "scripts": {
@@ -49,15 +49,15 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@rollup/plugin-typescript": "^10.0.1",
52
- "@types/node": "^16.11.12",
52
+ "@types/node": "16.18.96",
53
53
  "@types/prismjs": "^1.26.0",
54
- "@typescript-eslint/eslint-plugin": "4.33.0",
55
- "@typescript-eslint/parser": "4.33.0",
54
+ "@typescript-eslint/eslint-plugin": "5.62.0",
55
+ "@typescript-eslint/parser": "5.62.0",
56
56
  "cypress": "13.6.0",
57
57
  "cypress-file-upload": "^5.0.8",
58
58
  "eslint": "7.32.0",
59
59
  "simple-git-hooks": "^2.8.1",
60
- "typescript": "^4.3.2",
60
+ "typescript": "4.9.5",
61
61
  "vite": "^2.4.2",
62
62
  "vite-plugin-css-injected-by-js": "^2.1.1",
63
63
  "vitepress": "1.0.0-beta.6",