@hufe921/canvas-editor 0.9.66 → 0.9.68

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.
@@ -14,6 +14,7 @@ import { IElement } from '../../interface/Element';
14
14
  import { IPasteOption } from '../../interface/Event';
15
15
  import { IMargin } from '../../interface/Margin';
16
16
  import { IRange, RangeContext } from '../../interface/Range';
17
+ import { ITextDecoration } from '../../interface/Text';
17
18
  import { IWatermark } from '../../interface/Watermark';
18
19
  import { Draw } from '../draw/Draw';
19
20
  import { INavigateInfo } from '../draw/interactive/Search';
@@ -52,7 +53,7 @@ export declare class CommandAdapt {
52
53
  sizeMinus(): void;
53
54
  bold(): void;
54
55
  italic(): void;
55
- underline(): void;
56
+ underline(textDecoration?: ITextDecoration): void;
56
57
  strikeout(): void;
57
58
  superscript(): void;
58
59
  subscript(): void;
@@ -6,7 +6,7 @@ export declare class TextControl implements IControlInstance {
6
6
  private control;
7
7
  constructor(element: IElement, control: Control);
8
8
  getElement(): IElement;
9
- getValue(): IElement[];
9
+ getValue(context?: IControlContext): IElement[];
10
10
  setValue(data: IElement[], context?: IControlContext, options?: IControlRuleOption): number;
11
11
  clearValue(context?: IControlContext, options?: IControlRuleOption): number;
12
12
  keydown(evt: KeyboardEvent): number | null;
@@ -1,5 +1,6 @@
1
1
  import { IElement } from '../../..';
2
2
  import { IRowElement } from '../../../interface/Row';
3
+ import { ITextMetrics } from '../../../interface/Text';
3
4
  import { Draw } from '../Draw';
4
5
  export interface IMeasureWordResult {
5
6
  width: number;
@@ -18,7 +19,7 @@ export declare class TextParticle {
18
19
  constructor(draw: Draw);
19
20
  measureWord(ctx: CanvasRenderingContext2D, elementList: IElement[], curIndex: number): IMeasureWordResult;
20
21
  measurePunctuationWidth(ctx: CanvasRenderingContext2D, element: IElement): number;
21
- measureText(ctx: CanvasRenderingContext2D, element: IElement): TextMetrics;
22
+ measureText(ctx: CanvasRenderingContext2D, element: IElement): ITextMetrics;
22
23
  complete(): void;
23
24
  record(ctx: CanvasRenderingContext2D, element: IRowElement, x: number, y: number): void;
24
25
  private _setCurXY;
@@ -1,9 +1,11 @@
1
+ import { TextDecorationStyle } from '../../../dataset/enum/Text';
1
2
  import { IElementFillRect } from '../../../interface/Element';
2
3
  export declare abstract class AbstractRichText {
3
- fillRect: IElementFillRect;
4
- fillColor?: string;
4
+ protected fillRect: IElementFillRect;
5
+ protected fillColor?: string;
6
+ protected fillDecorationStyle?: TextDecorationStyle;
5
7
  constructor();
6
8
  clearFillInfo(): IElementFillRect;
7
- recordFillInfo(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height?: number, color?: string): void;
9
+ recordFillInfo(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height?: number, color?: string, decorationStyle?: TextDecorationStyle): void;
8
10
  abstract render(ctx: CanvasRenderingContext2D): void;
9
11
  }
@@ -3,5 +3,8 @@ import { Draw } from '../Draw';
3
3
  export declare class Underline extends AbstractRichText {
4
4
  private options;
5
5
  constructor(draw: Draw);
6
+ private _drawLine;
7
+ private _drawDouble;
8
+ private _drawWave;
6
9
  render(ctx: CanvasRenderingContext2D): void;
7
10
  }
@@ -1,5 +1,5 @@
1
1
  import { IElement, IElementPosition } from '../../interface/Element';
2
- import { ICurrentPosition } from '../../interface/Position';
2
+ import { ICurrentPosition, IPositionContext } from '../../interface/Position';
3
3
  import { Draw } from '../draw/Draw';
4
4
  import { IRange } from '../../interface/Range';
5
5
  export interface ICompositionInfo {
@@ -17,6 +17,7 @@ export declare class CanvasEvent {
17
17
  cacheRange: IRange | null;
18
18
  cacheElementList: IElement[] | null;
19
19
  cachePositionList: IElementPosition[] | null;
20
+ cachePositionContext: IPositionContext | null;
20
21
  mouseDownStartPosition: ICurrentPosition | null;
21
22
  private draw;
22
23
  private pageContainer;
@@ -9,6 +9,7 @@ export declare const TABLE_TD_ZIP_ATTR: Array<keyof ITd>;
9
9
  export declare const TABLE_CONTEXT_ATTR: Array<keyof IElement>;
10
10
  export declare const TITLE_CONTEXT_ATTR: Array<keyof IElement>;
11
11
  export declare const LIST_CONTEXT_ATTR: Array<keyof IElement>;
12
+ export declare const CONTROL_CONTEXT_ATTR: Array<keyof IElement>;
12
13
  export declare const EDITOR_ELEMENT_CONTEXT_ATTR: Array<keyof IElement>;
13
14
  export declare const TEXTLIKE_ELEMENT_TYPE: ElementType[];
14
15
  export declare const INLINE_ELEMENT_TYPE: ElementType[];
@@ -0,0 +1,12 @@
1
+ export declare enum TextDecorationStyle {
2
+ SOLID = "solid",
3
+ DOUBLE = "double",
4
+ DASHED = "dashed",
5
+ DOTTED = "dotted",
6
+ WAVY = "wavy"
7
+ }
8
+ export declare enum DashType {
9
+ SOLID = "solid",
10
+ DASHED = "dashed",
11
+ DOTTED = "dotted"
12
+ }
@@ -33,6 +33,7 @@ import { INTERNAL_CONTEXT_MENU_KEY } from './dataset/constant/ContextMenu';
33
33
  import { IRange } from './interface/Range';
34
34
  import { splitText } from './utils';
35
35
  import { BackgroundRepeat, BackgroundSize } from './dataset/enum/Background';
36
+ import { TextDecorationStyle } from './dataset/enum/Text';
36
37
  export default class Editor {
37
38
  command: Command;
38
39
  listener: Listener;
@@ -45,5 +46,5 @@ export default class Editor {
45
46
  }
46
47
  export { splitText };
47
48
  export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY };
48
- export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, BackgroundRepeat, BackgroundSize };
49
+ export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, BackgroundRepeat, BackgroundSize, TextDecorationStyle };
49
50
  export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle };
@@ -8,6 +8,7 @@ import { TableBorder } from '../dataset/enum/table/Table';
8
8
  import { IBlock } from './Block';
9
9
  import { ICheckbox } from './Checkbox';
10
10
  import { IControl } from './Control';
11
+ import { ITextDecoration } from './Text';
11
12
  import { IColgroup } from './table/Colgroup';
12
13
  import { ITr } from './table/Tr';
13
14
  export interface IElementBasic {
@@ -29,6 +30,7 @@ export interface IElementStyle {
29
30
  rowFlex?: RowFlex;
30
31
  rowMargin?: number;
31
32
  letterSpacing?: number;
33
+ textDecoration?: ITextDecoration;
32
34
  }
33
35
  export interface IElementGroup {
34
36
  groupIds?: string[];
@@ -2,6 +2,7 @@ import { EditorZone, ElementType, ListStyle, ListType, PageMode, TitleLevel } fr
2
2
  import { RowFlex } from '../dataset/enum/Row';
3
3
  import { IControl } from './Control';
4
4
  import { IEditorResult } from './Editor';
5
+ import { ITextDecoration } from './Text';
5
6
  export interface IRangeStyle {
6
7
  type: ElementType | null;
7
8
  undo: boolean;
@@ -22,6 +23,7 @@ export interface IRangeStyle {
22
23
  listType: ListType | null;
23
24
  listStyle: ListStyle | null;
24
25
  groupIds: string[] | null;
26
+ textDecoration: ITextDecoration | null;
25
27
  }
26
28
  export declare type IRangeStyleChange = (payload: IRangeStyle) => void;
27
29
  export declare type IVisiblePageNoListChange = (payload: number[]) => void;
@@ -0,0 +1,13 @@
1
+ import { TextDecorationStyle } from '../dataset/enum/Text';
2
+ export interface ITextMetrics {
3
+ width: number;
4
+ actualBoundingBoxAscent: number;
5
+ actualBoundingBoxDescent: number;
6
+ actualBoundingBoxLeft: number;
7
+ actualBoundingBoxRight: number;
8
+ fontBoundingBoxAscent: number;
9
+ fontBoundingBoxDescent: number;
10
+ }
11
+ export interface ITextDecoration {
12
+ style?: TextDecorationStyle;
13
+ }
@@ -25,4 +25,5 @@ interface IGetElementListByHTMLOption {
25
25
  }
26
26
  export declare function getElementListByHTML(htmlText: string, options: IGetElementListByHTMLOption): IElement[];
27
27
  export declare function getTextFromElementList(elementList: IElement[]): string;
28
+ export declare function getSlimCloneElementList(elementList: IElement[]): IElement[];
28
29
  export {};
@@ -1,5 +1,6 @@
1
1
  export declare function debounce(func: Function, delay: number): (this: any, ...args: any[]) => void;
2
2
  export declare function throttle(func: Function, delay: number): (this: any, ...args: any[]) => void;
3
+ export declare function deepCloneOmitKeys<T, K>(obj: T, omitKeys: (keyof K)[]): T;
3
4
  export declare function deepClone<T>(obj: T): T;
4
5
  export declare function isBody(node: Element): boolean;
5
6
  export declare function findParent(node: Element, filterFn: Function, includeSelf: boolean): Element | null;
@@ -18,3 +19,4 @@ export declare function omitObject<T>(object: T, omitKeys: (keyof T)[]): T;
18
19
  export declare function convertStringToBase64(input: string): string;
19
20
  export declare function findScrollContainer(element: HTMLElement): HTMLElement;
20
21
  export declare function isArrayEqual(arr1: unknown[], arr2: unknown[]): boolean;
22
+ export declare function isObjectEqual(obj1: unknown, obj2: unknown): boolean;
@@ -1 +1,7 @@
1
- export declare function printImageBase64(base64List: string[], width: number, height: number): void;
1
+ import { PaperDirection } from '../dataset/enum/Editor';
2
+ export interface IPrintImageBase64Option {
3
+ width: number;
4
+ height: number;
5
+ direction?: PaperDirection;
6
+ }
7
+ export declare function printImageBase64(base64List: string[], options: IPrintImageBase64Option): void;
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.66",
5
+ "version": "0.9.68",
6
6
  "description": "rich text editor by canvas/svg",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/",