@hufe921/canvas-editor 0.9.131 → 0.9.133

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.
@@ -41,6 +41,7 @@ import { TableOperate } from './particle/table/TableOperate';
41
41
  import { Area } from './interactive/Area';
42
42
  import { Badge } from './frame/Badge';
43
43
  import { Graffiti } from './graffiti/Graffiti';
44
+ import { Magnifier } from './interactive/Magnifier';
44
45
  export declare class Draw {
45
46
  private container;
46
47
  private pageContainer;
@@ -65,6 +66,7 @@ export declare class Draw {
65
66
  private margin;
66
67
  private background;
67
68
  private badge;
69
+ private magnifier;
68
70
  private search;
69
71
  private group;
70
72
  private area;
@@ -168,6 +170,7 @@ export declare class Draw {
168
170
  getGroup(): Group;
169
171
  getArea(): Area;
170
172
  getBadge(): Badge;
173
+ getMagnifier(): Magnifier;
171
174
  getHistoryManager(): HistoryManager;
172
175
  getPosition(): Position;
173
176
  getZone(): Zone;
@@ -0,0 +1,19 @@
1
+ import { Draw } from '../Draw';
2
+ export declare class Magnifier {
3
+ private draw;
4
+ private options;
5
+ private canvas;
6
+ private isActive;
7
+ private container;
8
+ constructor(draw: Draw);
9
+ private _createMagnifierCanvas;
10
+ private _addEvent;
11
+ private _removeEvent;
12
+ private _handleKeyDown;
13
+ private _handleKeyUp;
14
+ private _mousemove;
15
+ show(): void;
16
+ hide(): void;
17
+ private _update;
18
+ destroy(): void;
19
+ }
@@ -10,6 +10,7 @@ export declare class GlobalEvent {
10
10
  private tableTool;
11
11
  private hyperlinkParticle;
12
12
  private control;
13
+ private magnifier;
13
14
  private dateParticle;
14
15
  private imageParticle;
15
16
  private dprMediaQueryList;
@@ -10,6 +10,7 @@ export declare class SelectionObserver {
10
10
  private clientWidth;
11
11
  private clientHeight;
12
12
  private containerRect;
13
+ private pageContainer;
13
14
  constructor(draw: Draw);
14
15
  private _addEvent;
15
16
  removeEvent(): void;
@@ -2,5 +2,5 @@ import { DeepRequired } from '../../interface/Common';
2
2
  import { IModeRule } from '../../interface/Editor';
3
3
  export declare const EDITOR_COMPONENT = "editor-component";
4
4
  export declare const EDITOR_PREFIX = "ce";
5
- export declare const EDITOR_CLIPBOARD: string;
5
+ export declare const EDITOR_CLIPBOARD = "ce-clipboard";
6
6
  export declare const defaultModeRuleOption: Readonly<DeepRequired<IModeRule>>;
@@ -0,0 +1,2 @@
1
+ import { IMagnifierOption } from '../../interface/Magnifier';
2
+ export declare const defaultMagnifierOption: Readonly<Required<IMagnifierOption>>;
@@ -1,5 +1,5 @@
1
1
  export declare enum AreaMode {
2
- EDIT = "edit",
3
- READONLY = "readonly",
2
+ EDIT = "edit",// 编辑模式(文档可编辑、辅助元素均存在)
3
+ READONLY = "readonly",// 只读模式(文档不可编辑)
4
4
  FORM = "form"
5
5
  }
@@ -17,7 +17,7 @@ export declare enum ControlComponent {
17
17
  RADIO = "radio"
18
18
  }
19
19
  export declare enum ControlIndentation {
20
- ROW_START = "rowStart",
20
+ ROW_START = "rowStart",// 从行起始位置缩进
21
21
  VALUE_START = "valueStart"
22
22
  }
23
23
  export declare enum ControlState {
@@ -13,12 +13,12 @@ export declare enum EditorContext {
13
13
  TABLE = "table"
14
14
  }
15
15
  export declare enum EditorMode {
16
- EDIT = "edit",
17
- CLEAN = "clean",
18
- READONLY = "readonly",
19
- FORM = "form",
20
- PRINT = "print",
21
- DESIGN = "design",
16
+ EDIT = "edit",// 编辑模式(文档可编辑、辅助元素均存在)
17
+ CLEAN = "clean",// 清洁模式(隐藏辅助元素)
18
+ READONLY = "readonly",// 只读模式(文档不可编辑)
19
+ FORM = "form",// 表单模式(仅控件内可编辑)
20
+ PRINT = "print",// 打印模式(文档不可编辑、隐藏辅助元素、选区、未书写控件及边框)
21
+ DESIGN = "design",// 设计模式(不可删除、只读等配置不控制)
22
22
  GRAFFITI = "graffiti"
23
23
  }
24
24
  export declare enum EditorZone {
@@ -1,6 +1,7 @@
1
1
  export declare enum KeyMap {
2
2
  Delete = "Delete",
3
3
  Backspace = "Backspace",
4
+ ALT = "Alt",
4
5
  Enter = "Enter",
5
6
  Left = "ArrowLeft",
6
7
  Right = "ArrowRight",
@@ -3,9 +3,9 @@ export declare enum ListType {
3
3
  OL = "ol"
4
4
  }
5
5
  export declare enum UlStyle {
6
- DISC = "disc",
7
- CIRCLE = "circle",
8
- SQUARE = "square",
6
+ DISC = "disc",// 实心圆点
7
+ CIRCLE = "circle",// 空心圆点
8
+ SQUARE = "square",// 实心方块
9
9
  CHECKBOX = "checkbox"
10
10
  }
11
11
  export declare enum OlStyle {
@@ -12,6 +12,6 @@ export declare enum TdBorder {
12
12
  LEFT = "left"
13
13
  }
14
14
  export declare enum TdSlash {
15
- FORWARD = "forward",
15
+ FORWARD = "forward",// 正斜线 /
16
16
  BACK = "back"
17
17
  }
@@ -27,6 +27,7 @@ import { LocationPosition } from '../dataset/enum/Common';
27
27
  import { IRange } from './Range';
28
28
  import { IGraffitiData, IGraffitiOption } from './Graffiti';
29
29
  import { IWhiteSpaceOption } from './WhiteSpace';
30
+ import { IMagnifierOption } from './Magnifier';
30
31
  export interface IEditorData {
31
32
  header?: IElement[];
32
33
  main: IElement[];
@@ -104,6 +105,7 @@ export interface IEditorOption {
104
105
  label?: ILabelOption;
105
106
  imgCaption?: IImgCaptionOption;
106
107
  list?: IListOption;
108
+ magnifier?: IMagnifierOption;
107
109
  }
108
110
  export interface IEditorResult {
109
111
  version: string;
@@ -0,0 +1,6 @@
1
+ export interface IMagnifierOption {
2
+ disabled?: boolean;
3
+ size?: number;
4
+ zoom?: number;
5
+ borderColor?: string;
6
+ }
@@ -22,7 +22,7 @@ interface IZipElementListOption {
22
22
  }
23
23
  export declare function zipElementList(payload: IElement[], options?: IZipElementListOption): IElement[];
24
24
  export declare function convertTextAlignToRowFlex(node: HTMLElement): RowFlex;
25
- export declare function convertRowFlexToTextAlign(rowFlex: RowFlex): RowFlex.LEFT | RowFlex.CENTER | RowFlex.RIGHT | RowFlex.JUSTIFY | "justify";
25
+ export declare function convertRowFlexToTextAlign(rowFlex: RowFlex): "justify" | RowFlex.LEFT | RowFlex.CENTER | RowFlex.RIGHT | RowFlex.JUSTIFY;
26
26
  export declare function convertRowFlexToJustifyContent(rowFlex: RowFlex): "center" | "flex-start" | "flex-end" | "space-between";
27
27
  export declare function isTextLikeElement(element: IElement): boolean;
28
28
  export declare function isTextElement(element: IElement): boolean;
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.131",
5
+ "version": "0.9.133",
6
6
  "description": "rich text editor by canvas/svg",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org/",
@@ -16,8 +16,8 @@
16
16
  "package.json"
17
17
  ],
18
18
  "typings": "./dist/src/editor/index.d.ts",
19
- "main": "./dist/canvas-editor.umd.js",
20
- "module": "./dist/canvas-editor.es.js",
19
+ "main": "./dist/canvas-editor.umd.cjs",
20
+ "module": "./dist/canvas-editor.js",
21
21
  "homepage": "https://github.com/Hufe921/canvas-editor",
22
22
  "repository": {
23
23
  "type": "git",
@@ -29,42 +29,51 @@
29
29
  "wysiwyg",
30
30
  "emr"
31
31
  ],
32
- "engines": {
33
- "node": ">=16.9.1"
34
- },
35
32
  "type": "module",
36
33
  "scripts": {
37
34
  "dev": "vite",
38
- "lib": "npm run lint && tsc && vite build --mode lib",
39
- "build": "npm run lint && tsc && vite build --mode app",
35
+ "lib": "eslint . && tsc && vitest run && vite build --mode lib",
36
+ "build": "eslint . && tsc && vitest run && vite build --mode app",
40
37
  "serve": "vite preview",
41
- "lint": "eslint .",
38
+ "lint": "eslint . && tsc --noEmit && vitest run",
42
39
  "cypress:open": "cypress open",
43
40
  "cypress:run": "cypress run",
41
+ "test:unit": "vitest run",
42
+ "test:unit:watch": "vitest",
43
+ "test:coverage": "vitest run --coverage",
44
44
  "type:check": "tsc --noEmit",
45
45
  "docs:dev": "vitepress dev docs",
46
46
  "docs:build": "vitepress build docs",
47
47
  "docs:preview": "vitepress preview docs",
48
- "release": "node scripts/release.js"
48
+ "pre-release": "node scripts/pre-release.js"
49
49
  },
50
50
  "devDependencies": {
51
- "@rollup/plugin-typescript": "^10.0.1",
52
- "@types/node": "16.18.96",
53
- "@types/prismjs": "^1.26.0",
54
- "@typescript-eslint/eslint-plugin": "5.62.0",
55
- "@typescript-eslint/parser": "5.62.0",
56
- "cypress": "13.6.0",
51
+ "@eslint/js": "^10.0.1",
52
+ "@rollup/plugin-typescript": "^12.3.0",
53
+ "@types/jsdom": "^28.0.1",
54
+ "@types/node": "^24.0.0",
55
+ "@types/prismjs": "^1.26.6",
56
+ "@typescript-eslint/eslint-plugin": "^8.59.1",
57
+ "@typescript-eslint/parser": "^8.59.1",
58
+ "@vitest/coverage-v8": "^4.1.5",
59
+ "cypress": "^15.14.2",
57
60
  "cypress-file-upload": "^5.0.8",
58
- "eslint": "7.32.0",
59
- "simple-git-hooks": "^2.8.1",
60
- "typescript": "4.9.5",
61
- "vite": "^2.4.2",
62
- "vite-plugin-css-injected-by-js": "^2.1.1",
63
- "vitepress": "1.0.0-beta.6",
64
- "vue": "^3.2.45"
61
+ "eslint": "^10.3.0",
62
+ "globals": "^17.6.0",
63
+ "jsdom": "^29.1.1",
64
+ "simple-git-hooks": "^2.13.1",
65
+ "tslib": "^2.8.1",
66
+ "typescript": "^6.0.3",
67
+ "typescript-eslint": "^8.59.1",
68
+ "vite": "^8.0.10",
69
+ "vite-plugin-css-injected-by-js": "^5.0.1",
70
+ "vitepress": "^1.6.4",
71
+ "vitest": "^4.1.5",
72
+ "vitest-canvas-mock": "^1.1.4",
73
+ "vue": "^3.5.33"
65
74
  },
66
75
  "simple-git-hooks": {
67
76
  "pre-commit": "npm run lint && npm run type:check",
68
77
  "commit-msg": "node scripts/verifyCommit.js"
69
78
  }
70
- }
79
+ }