js-draw 1.16.1 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundledStyles.js +1 -1
  3. package/dist/cjs/Editor.d.ts +76 -6
  4. package/dist/cjs/Editor.js +89 -89
  5. package/dist/cjs/Pointer.d.ts +2 -1
  6. package/dist/cjs/Pointer.js +9 -2
  7. package/dist/cjs/commands/localization.d.ts +1 -0
  8. package/dist/cjs/commands/localization.js +1 -0
  9. package/dist/cjs/commands/uniteCommands.d.ts +5 -1
  10. package/dist/cjs/commands/uniteCommands.js +33 -7
  11. package/dist/cjs/components/TextComponent.d.ts +36 -1
  12. package/dist/cjs/components/TextComponent.js +39 -1
  13. package/dist/cjs/components/builders/ArrowBuilder.js +1 -1
  14. package/dist/cjs/components/builders/PolylineBuilder.d.ts +35 -0
  15. package/dist/cjs/components/builders/PolylineBuilder.js +115 -0
  16. package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.js +1 -1
  17. package/dist/cjs/components/builders/autocorrect/makeShapeFitAutocorrect.js +1 -1
  18. package/dist/cjs/components/lib.d.ts +1 -0
  19. package/dist/cjs/components/lib.js +3 -1
  20. package/dist/cjs/components/util/StrokeSmoother.js +4 -4
  21. package/dist/cjs/image/EditorImage.d.ts +4 -1
  22. package/dist/cjs/image/EditorImage.js +4 -1
  23. package/dist/cjs/inputEvents.d.ts +11 -1
  24. package/dist/cjs/localizations/comments.d.ts +3 -0
  25. package/dist/cjs/localizations/comments.js +3 -0
  26. package/dist/cjs/localizations/de.js +0 -2
  27. package/dist/cjs/localizations/es.js +2 -2
  28. package/dist/cjs/rendering/renderers/CanvasRenderer.d.ts +7 -0
  29. package/dist/cjs/rendering/renderers/CanvasRenderer.js +16 -0
  30. package/dist/cjs/rendering/renderers/SVGRenderer.js +1 -1
  31. package/dist/cjs/toolbar/IconProvider.d.ts +6 -3
  32. package/dist/cjs/toolbar/IconProvider.js +6 -4
  33. package/dist/cjs/toolbar/widgets/DocumentPropertiesWidget.js +24 -1
  34. package/dist/cjs/toolbar/widgets/PenToolWidget.d.ts +1 -1
  35. package/dist/cjs/toolbar/widgets/PenToolWidget.js +7 -1
  36. package/dist/cjs/tools/Eraser.js +1 -1
  37. package/dist/cjs/tools/InputFilter/InputStabilizer.js +3 -3
  38. package/dist/cjs/tools/PasteHandler.js +36 -10
  39. package/dist/cjs/tools/Pen.js +2 -2
  40. package/dist/cjs/tools/SelectionTool/SelectionTool.js +23 -4
  41. package/dist/cjs/tools/SelectionTool/ToPointerAutoscroller.js +1 -1
  42. package/dist/cjs/tools/ToolController.d.ts +17 -1
  43. package/dist/cjs/tools/ToolController.js +21 -8
  44. package/dist/cjs/tools/localization.d.ts +2 -2
  45. package/dist/cjs/tools/localization.js +2 -2
  46. package/dist/cjs/util/ClipboardHandler.d.ts +27 -0
  47. package/dist/cjs/util/ClipboardHandler.js +205 -0
  48. package/dist/cjs/util/ClipboardHandler.test.d.ts +1 -0
  49. package/dist/cjs/version.d.ts +5 -0
  50. package/dist/cjs/version.js +6 -1
  51. package/dist/mjs/Editor.d.ts +76 -6
  52. package/dist/mjs/Editor.mjs +89 -89
  53. package/dist/mjs/Pointer.d.ts +2 -1
  54. package/dist/mjs/Pointer.mjs +9 -2
  55. package/dist/mjs/commands/localization.d.ts +1 -0
  56. package/dist/mjs/commands/localization.mjs +1 -0
  57. package/dist/mjs/commands/uniteCommands.d.ts +5 -1
  58. package/dist/mjs/commands/uniteCommands.mjs +33 -7
  59. package/dist/mjs/components/TextComponent.d.ts +36 -1
  60. package/dist/mjs/components/TextComponent.mjs +40 -2
  61. package/dist/mjs/components/builders/ArrowBuilder.mjs +1 -1
  62. package/dist/mjs/components/builders/PolylineBuilder.d.ts +35 -0
  63. package/dist/mjs/components/builders/PolylineBuilder.mjs +108 -0
  64. package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.mjs +1 -1
  65. package/dist/mjs/components/builders/autocorrect/makeShapeFitAutocorrect.mjs +1 -1
  66. package/dist/mjs/components/lib.d.ts +1 -0
  67. package/dist/mjs/components/lib.mjs +1 -0
  68. package/dist/mjs/components/util/StrokeSmoother.mjs +4 -4
  69. package/dist/mjs/image/EditorImage.d.ts +4 -1
  70. package/dist/mjs/image/EditorImage.mjs +4 -1
  71. package/dist/mjs/inputEvents.d.ts +11 -1
  72. package/dist/mjs/localizations/comments.d.ts +3 -0
  73. package/dist/mjs/localizations/comments.mjs +3 -0
  74. package/dist/mjs/localizations/de.mjs +0 -2
  75. package/dist/mjs/localizations/es.mjs +2 -2
  76. package/dist/mjs/rendering/renderers/CanvasRenderer.d.ts +7 -0
  77. package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +16 -0
  78. package/dist/mjs/rendering/renderers/SVGRenderer.mjs +1 -1
  79. package/dist/mjs/toolbar/IconProvider.d.ts +6 -3
  80. package/dist/mjs/toolbar/IconProvider.mjs +6 -4
  81. package/dist/mjs/toolbar/widgets/DocumentPropertiesWidget.mjs +24 -1
  82. package/dist/mjs/toolbar/widgets/PenToolWidget.d.ts +1 -1
  83. package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +7 -1
  84. package/dist/mjs/tools/Eraser.mjs +1 -1
  85. package/dist/mjs/tools/InputFilter/InputStabilizer.mjs +3 -3
  86. package/dist/mjs/tools/PasteHandler.mjs +36 -10
  87. package/dist/mjs/tools/Pen.mjs +2 -2
  88. package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +23 -4
  89. package/dist/mjs/tools/SelectionTool/ToPointerAutoscroller.mjs +1 -1
  90. package/dist/mjs/tools/ToolController.d.ts +17 -1
  91. package/dist/mjs/tools/ToolController.mjs +21 -8
  92. package/dist/mjs/tools/localization.d.ts +2 -2
  93. package/dist/mjs/tools/localization.mjs +2 -2
  94. package/dist/mjs/util/ClipboardHandler.d.ts +27 -0
  95. package/dist/mjs/util/ClipboardHandler.mjs +200 -0
  96. package/dist/mjs/util/ClipboardHandler.test.d.ts +1 -0
  97. package/dist/mjs/version.d.ts +5 -0
  98. package/dist/mjs/version.mjs +6 -1
  99. package/package.json +6 -6
@@ -12,6 +12,12 @@ export default class ToolController implements InputEventListener {
12
12
  private isEditorReadOnly;
13
13
  /** @internal */
14
14
  constructor(editor: Editor, localization: ToolLocalization);
15
+ /**
16
+ * Replaces the current set of tools with `tools`. This should only be done before
17
+ * the creation of the app's toolbar (if using `AbstractToolbar`).
18
+ *
19
+ * If no `primaryToolGroup` is given, an empty one will be created.
20
+ */
15
21
  setTools(tools: BaseTool[], primaryToolGroup?: ToolEnabledGroup): void;
16
22
  /**
17
23
  * Add a tool that acts like one of the primary tools (only one primary tool can be enabled at a time).
@@ -22,7 +28,17 @@ export default class ToolController implements InputEventListener {
22
28
  */
23
29
  addPrimaryTool(tool: BaseTool): void;
24
30
  getPrimaryTools(): BaseTool[];
25
- addTool(tool: BaseTool): void;
31
+ /**
32
+ * Add a tool to the end of this' tool list (the added tool receives events after tools already added to this).
33
+ * This should be called before creating the app's toolbar.
34
+ *
35
+ * If `options.addToFront`, the tool is added to the beginning of this' tool list.
36
+ *
37
+ * Does nothing if the tool is already present.
38
+ */
39
+ addTool(tool: BaseTool, options?: {
40
+ addToFront: boolean;
41
+ }): void;
26
42
  /**
27
43
  * Removes **and destroys** all tools in `tools` from this.
28
44
  */
@@ -109,8 +109,12 @@ class ToolController {
109
109
  });
110
110
  this.activeTool = null;
111
111
  }
112
- // Replaces the current set of tools with `tools`. This should only be done before
113
- // the creation of the app's toolbar (if using `AbstractToolbar`).
112
+ /**
113
+ * Replaces the current set of tools with `tools`. This should only be done before
114
+ * the creation of the app's toolbar (if using `AbstractToolbar`).
115
+ *
116
+ * If no `primaryToolGroup` is given, an empty one will be created.
117
+ */
114
118
  setTools(tools, primaryToolGroup) {
115
119
  this.tools = tools;
116
120
  this.primaryToolGroup = primaryToolGroup ?? new ToolEnabledGroup_1.default();
@@ -136,14 +140,23 @@ class ToolController {
136
140
  return tool.getToolGroup() === this.primaryToolGroup;
137
141
  });
138
142
  }
139
- // Add a tool to the end of this' tool list (the added tool receives events after tools already added to this).
140
- // This should be called before creating the app's toolbar.
141
- //
142
- // A tool should only be added once.
143
- addTool(tool) {
143
+ /**
144
+ * Add a tool to the end of this' tool list (the added tool receives events after tools already added to this).
145
+ * This should be called before creating the app's toolbar.
146
+ *
147
+ * If `options.addToFront`, the tool is added to the beginning of this' tool list.
148
+ *
149
+ * Does nothing if the tool is already present.
150
+ */
151
+ addTool(tool, options) {
144
152
  // Only add if not already present.
145
153
  if (!this.tools.includes(tool)) {
146
- this.tools.push(tool);
154
+ if (options?.addToFront) {
155
+ this.tools.splice(0, 0, tool);
156
+ }
157
+ else {
158
+ this.tools.push(tool);
159
+ }
147
160
  }
148
161
  }
149
162
  /**
@@ -26,8 +26,8 @@ export interface ToolLocalization {
26
26
  findDialogHidden: string;
27
27
  focusedFoundText: (currentMatchNumber: number, totalMatches: number) => string;
28
28
  anyDevicePanning: string;
29
- copied: (count: number, description: string) => string;
30
- pasted: (count: number, description: string) => string;
29
+ copied: (count: number) => string;
30
+ pasted: (count: number) => string;
31
31
  toolEnabledAnnouncement: (toolName: string) => string;
32
32
  toolDisabledAnnouncement: (toolName: string) => string;
33
33
  }
@@ -29,8 +29,8 @@ exports.defaultToolLocalization = {
29
29
  findDialogHidden: 'Find dialog hidden',
30
30
  focusedFoundText: (matchIdx, totalMatches) => `Viewing match ${matchIdx} of ${totalMatches}`,
31
31
  anyDevicePanning: 'Any device panning',
32
- copied: (count, description) => `Copied ${count} ${description}`,
33
- pasted: (count, description) => `Pasted ${count} ${description}`,
32
+ copied: (count) => `Copied ${count} item(s)`,
33
+ pasted: (count) => `Pasted ${count} item(s)`,
34
34
  toolEnabledAnnouncement: (toolName) => `${toolName} enabled`,
35
35
  toolDisabledAnnouncement: (toolName) => `${toolName} disabled`,
36
36
  };
@@ -0,0 +1,27 @@
1
+ import { Editor } from '../Editor';
2
+ /**
3
+ * Handles conversion between the browser clipboard APIs and internal
4
+ * js-draw clipboard events.
5
+ */
6
+ export default class ClipboardHandler {
7
+ #private;
8
+ private editor;
9
+ constructor(editor: Editor);
10
+ /**
11
+ * Pastes data from the clipboard into the editor associated with
12
+ * this handler.
13
+ *
14
+ * @param event Optional -- a clipboard/drag event. If not provided,
15
+ * `navigator.clipboard` will be used instead.
16
+ * @returns true if the paste event was handled by the editor.
17
+ */
18
+ paste(event?: DragEvent | ClipboardEvent): Promise<boolean>;
19
+ /**
20
+ * Copies text from the editor associated with this.
21
+ *
22
+ * Even if `event` is provided, the `navigator.clipboard` API may be used if image data
23
+ * is to be copied. This is done because `ClipboardEvent`s seem to not support attaching
24
+ * images.
25
+ */
26
+ copy(event?: ClipboardEvent): Promise<void>;
27
+ }
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _ClipboardHandler_preferClipboardEvents;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const inputEvents_1 = require("../inputEvents");
19
+ const fileToBase64Url_1 = __importDefault(require("./fileToBase64Url"));
20
+ const isTextMimeType = (mime) =>
21
+ // +xml: Handles image/svg+xml
22
+ mime.endsWith('+xml') || mime.startsWith('text/');
23
+ /**
24
+ * Handles conversion between the browser clipboard APIs and internal
25
+ * js-draw clipboard events.
26
+ */
27
+ class ClipboardHandler {
28
+ constructor(editor) {
29
+ this.editor = editor;
30
+ _ClipboardHandler_preferClipboardEvents.set(this, false);
31
+ }
32
+ /**
33
+ * Pastes data from the clipboard into the editor associated with
34
+ * this handler.
35
+ *
36
+ * @param event Optional -- a clipboard/drag event. If not provided,
37
+ * `navigator.clipboard` will be used instead.
38
+ * @returns true if the paste event was handled by the editor.
39
+ */
40
+ async paste(event) {
41
+ const editor = this.editor;
42
+ const clipboardData = event?.dataTransfer ?? event?.clipboardData ?? null;
43
+ const hasEvent = !!clipboardData;
44
+ const sendPasteEvent = (mime, data) => {
45
+ return data && editor.toolController.dispatchInputEvent({
46
+ kind: inputEvents_1.InputEvtType.PasteEvent,
47
+ mime,
48
+ data,
49
+ });
50
+ };
51
+ // Listed in order of precedence
52
+ const supportedMIMEs = [
53
+ 'image/svg+xml',
54
+ 'text/html',
55
+ 'image/png',
56
+ 'image/jpeg',
57
+ 'text/plain',
58
+ ];
59
+ let files = [];
60
+ const textData = new Map();
61
+ if (hasEvent) {
62
+ // NOTE: On some browsers, .getData and .files must be used before any async operations.
63
+ files = [...clipboardData.files];
64
+ for (const mime of supportedMIMEs) {
65
+ const data = clipboardData.getData(mime);
66
+ if (data) {
67
+ textData.set(mime, data);
68
+ }
69
+ }
70
+ }
71
+ else {
72
+ const clipboardData = await navigator.clipboard.read();
73
+ for (const item of clipboardData) {
74
+ for (const mime of item.types) {
75
+ if (supportedMIMEs.includes(mime)) {
76
+ files.push(await item.getType(mime));
77
+ }
78
+ }
79
+ }
80
+ }
81
+ // Returns true if handled
82
+ const handleMIME = async (mime) => {
83
+ const isTextFormat = isTextMimeType(mime);
84
+ if (isTextFormat) {
85
+ const data = textData.get(mime);
86
+ if (sendPasteEvent(mime, data)) {
87
+ event?.preventDefault();
88
+ return true;
89
+ }
90
+ }
91
+ for (const file of files) {
92
+ const fileType = file.type.toLowerCase();
93
+ if (fileType !== mime) {
94
+ continue;
95
+ }
96
+ if (isTextFormat) {
97
+ const text = await file.text();
98
+ if (sendPasteEvent(mime, text)) {
99
+ event?.preventDefault();
100
+ return true;
101
+ }
102
+ }
103
+ else {
104
+ editor.showLoadingWarning(0);
105
+ const onprogress = (evt) => {
106
+ editor.showLoadingWarning(evt.loaded / evt.total);
107
+ };
108
+ try {
109
+ const data = await (0, fileToBase64Url_1.default)(file, { onprogress });
110
+ if (sendPasteEvent(mime, data)) {
111
+ event?.preventDefault();
112
+ editor.hideLoadingWarning();
113
+ return true;
114
+ }
115
+ }
116
+ catch (e) {
117
+ console.error('Error reading image:', e);
118
+ }
119
+ editor.hideLoadingWarning();
120
+ }
121
+ }
122
+ return false;
123
+ };
124
+ for (const mime of supportedMIMEs) {
125
+ if (await handleMIME(mime)) {
126
+ return true;
127
+ }
128
+ }
129
+ return false;
130
+ }
131
+ /**
132
+ * Copies text from the editor associated with this.
133
+ *
134
+ * Even if `event` is provided, the `navigator.clipboard` API may be used if image data
135
+ * is to be copied. This is done because `ClipboardEvent`s seem to not support attaching
136
+ * images.
137
+ */
138
+ copy(event) {
139
+ const mimeToData = Object.create(null);
140
+ if (this.editor.toolController.dispatchInputEvent({
141
+ kind: inputEvents_1.InputEvtType.CopyEvent,
142
+ setData: (mime, data) => {
143
+ mimeToData[mime] = data;
144
+ },
145
+ })) {
146
+ event?.preventDefault();
147
+ }
148
+ const mimeTypes = Object.keys(mimeToData);
149
+ const hasNonTextMimeTypes = mimeTypes.some(mime => !isTextMimeType(mime));
150
+ const copyToEvent = () => {
151
+ if (!event) {
152
+ throw new Error('Unable to paste -- no event provided.');
153
+ }
154
+ for (const key in mimeToData) {
155
+ const value = mimeToData[key];
156
+ if (typeof value === 'string') {
157
+ event.clipboardData?.setData(key, value);
158
+ }
159
+ }
160
+ };
161
+ const copyToClipboardApi = () => {
162
+ const mappedMimeToData = Object.create(null);
163
+ const mimeMapping = {
164
+ // image/svg+xml is unsupported in Chrome.
165
+ 'image/svg+xml': 'text/html',
166
+ };
167
+ for (const key in mimeToData) {
168
+ const data = mimeToData[key];
169
+ const mappedKey = mimeMapping[key] || key;
170
+ if (typeof data === 'string') {
171
+ mappedMimeToData[mappedKey] = new Blob([new TextEncoder().encode(data)], { type: mappedKey });
172
+ }
173
+ else {
174
+ mappedMimeToData[mappedKey] = data;
175
+ }
176
+ }
177
+ return navigator.clipboard.write([new ClipboardItem(mappedMimeToData)]);
178
+ };
179
+ const supportsClipboardApi = (typeof ClipboardItem !== 'undefined'
180
+ && typeof navigator?.clipboard?.write !== 'undefined');
181
+ if (!__classPrivateFieldGet(this, _ClipboardHandler_preferClipboardEvents, "f") && supportsClipboardApi && (hasNonTextMimeTypes || !event)) {
182
+ let clipboardApiPromise = null;
183
+ const fallBackToCopyEvent = (reason) => {
184
+ console.warn('Unable to copy to the clipboard API. Future calls to .copy will use ClipboardEvents if possible.', reason);
185
+ __classPrivateFieldSet(this, _ClipboardHandler_preferClipboardEvents, true, "f");
186
+ copyToEvent();
187
+ };
188
+ try {
189
+ clipboardApiPromise = copyToClipboardApi();
190
+ }
191
+ catch (error) {
192
+ fallBackToCopyEvent(error);
193
+ }
194
+ if (clipboardApiPromise) {
195
+ return clipboardApiPromise.catch(fallBackToCopyEvent);
196
+ }
197
+ }
198
+ else {
199
+ copyToEvent();
200
+ }
201
+ return Promise.resolve();
202
+ }
203
+ }
204
+ _ClipboardHandler_preferClipboardEvents = new WeakMap();
205
+ exports.default = ClipboardHandler;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Contains the current version of the library -- used
3
+ * internaly (e.g. for documentation).
4
+ * @internal
5
+ */
1
6
  declare const _default: {
2
7
  number: string;
3
8
  };
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Contains the current version of the library -- used
5
+ * internaly (e.g. for documentation).
6
+ * @internal
7
+ */
3
8
  exports.default = {
4
- number: '1.16.1',
9
+ number: '1.17.0',
5
10
  };
@@ -11,12 +11,14 @@ import Pointer from './Pointer';
11
11
  import { EditorLocalization } from './localization';
12
12
  import IconProvider from './toolbar/IconProvider';
13
13
  import AbstractComponent from './components/AbstractComponent';
14
+ import { BackgroundType } from './components/BackgroundComponent';
14
15
  import KeyboardShortcutManager from './shortcuts/KeyboardShortcutManager';
15
16
  import KeyBinding from './shortcuts/KeyBinding';
16
17
  import AbstractToolbar from './toolbar/AbstractToolbar';
17
18
  import RenderablePathSpec from './rendering/RenderablePathSpec';
18
19
  import { AboutDialogEntry } from './dialogs/makeAboutDialog';
19
20
  import ReactiveValue, { MutableReactiveValue } from './util/ReactiveValue';
21
+ import { PenTypeRecord } from './toolbar/widgets/PenToolWidget';
20
22
  /**
21
23
  * Provides settings to an instance of an editor. See the Editor {@link Editor.constructor}.
22
24
  *
@@ -73,6 +75,35 @@ export interface EditorSettings {
73
75
  description?: string;
74
76
  version?: string;
75
77
  } | null;
78
+ /**
79
+ * Configures the default pen tools.
80
+ *
81
+ * **Example**:
82
+ * ```ts,runnable
83
+ * import { Editor, makePolylineBuilder } from 'js-draw';
84
+ *
85
+ * const editor = new Editor(document.body, {
86
+ * pens: {
87
+ * additionalPenTypes: [{
88
+ * name: 'Polyline (For debugging)',
89
+ * id: 'custom-polyline',
90
+ * factory: makePolylineBuilder,
91
+ *
92
+ * // The pen doesn't create fixed shapes (e.g. squares, rectangles, etc)
93
+ * // and so should go under the "pens" section.
94
+ * isShapeBuilder: false,
95
+ * }],
96
+ * },
97
+ * });
98
+ * editor.addToolbar();
99
+ * ```
100
+ */
101
+ pens: {
102
+ /**
103
+ * Additional pen types that can be selected in a toolbar.
104
+ */
105
+ additionalPenTypes: readonly Readonly<PenTypeRecord>[];
106
+ } | null;
76
107
  }
77
108
  /**
78
109
  * The main entrypoint for the full editor.
@@ -195,7 +226,7 @@ export declare class Editor {
195
226
  private accessibilityControlArea;
196
227
  private eventListenerTargets;
197
228
  private readOnly;
198
- private settings;
229
+ private readonly settings;
199
230
  /**
200
231
  * @example
201
232
  * ```ts,runnable
@@ -227,6 +258,12 @@ export declare class Editor {
227
258
  * ```
228
259
  */
229
260
  constructor(parent: HTMLElement, settings?: Partial<EditorSettings>);
261
+ /**
262
+ * @returns a shallow copy of the current settings of the editor.
263
+ *
264
+ * Do not modify.
265
+ */
266
+ getCurrentSettings(): Readonly<EditorSettings>;
230
267
  /**
231
268
  * @returns a reference to the editor's container.
232
269
  *
@@ -254,7 +291,7 @@ export declare class Editor {
254
291
  private registerListeners;
255
292
  private updateEditorSizeVariables;
256
293
  /** @internal */
257
- protected handleHTMLWheelEvent(event: WheelEvent): boolean | undefined;
294
+ handleHTMLWheelEvent(event: WheelEvent): boolean | undefined;
258
295
  private pointers;
259
296
  private getPointerList;
260
297
  /**
@@ -273,7 +310,7 @@ export declare class Editor {
273
310
  /** @internal */
274
311
  protected handleDrop(evt: DragEvent | ClipboardEvent): Promise<void>;
275
312
  /** @internal */
276
- protected handlePaste(evt: DragEvent | ClipboardEvent): Promise<void>;
313
+ protected handlePaste(evt: DragEvent | ClipboardEvent): Promise<boolean | undefined>;
277
314
  /**
278
315
  * Forward pointer events from `elem` to this editor. Such that right-click/right-click drag
279
316
  * events are also forwarded, `elem`'s contextmenu is disabled.
@@ -317,9 +354,9 @@ export declare class Editor {
317
354
  remove: () => void;
318
355
  };
319
356
  /** @internal */
320
- protected handleHTMLKeyDownEvent(htmlEvent: KeyboardEvent): boolean;
357
+ handleHTMLKeyDownEvent(htmlEvent: KeyboardEvent): boolean;
321
358
  /** @internal */
322
- protected handleHTMLKeyUpEvent(htmlEvent: KeyboardEvent): boolean;
359
+ handleHTMLKeyUpEvent(htmlEvent: KeyboardEvent): boolean;
323
360
  /**
324
361
  * Adds event listners for keypresses (and drop events) on `elem` and forwards those
325
362
  * events to the editor.
@@ -444,8 +481,11 @@ export declare class Editor {
444
481
  * This is a convenience method that creates **and applies** a single command.
445
482
  *
446
483
  * If `selectComponents` is true (the default), the components are selected.
484
+ *
485
+ * `actionDescription`, if given, should be a screenreader-friendly description of the
486
+ * reason components were added (e.g. "pasted").
447
487
  */
448
- addAndCenterComponents(components: AbstractComponent[], selectComponents?: boolean): Promise<void>;
488
+ addAndCenterComponents(components: AbstractComponent[], selectComponents?: boolean, actionDescription?: string): Promise<void>;
449
489
  /**
450
490
  * Get a data URL (e.g. as produced by `HTMLCanvasElement::toDataURL`).
451
491
  * If `format` is not `image/png`, a PNG image URL may still be returned (as in the
@@ -493,8 +533,38 @@ export declare class Editor {
493
533
  */
494
534
  loadFrom(loader: ImageLoader): Promise<void>;
495
535
  private getTopmostBackgroundComponent;
536
+ /**
537
+ * This is a convenience method for adding or updating the {@link BackgroundComponent}
538
+ * and {@link EditorImage.setAutoresizeEnabled} for the current image.
539
+ *
540
+ * If there are multiple {@link BackgroundComponent}s in the image, this only modifies
541
+ * the topmost such element.
542
+ *
543
+ * **Example**:
544
+ * ```ts,runnable
545
+ * import { Editor, Color4, BackgroundComponentBackgroundType } from 'js-draw';
546
+ * const editor = new Editor(document.body);
547
+ * editor.dispatch(editor.setBackgroundStyle({
548
+ * color: Color4.orange,
549
+ * type: BackgroundComponentBackgroundType.Grid,
550
+ * autoresize: true,
551
+ * }));
552
+ * ```
553
+ *
554
+ * To change the background size, see {@link EditorImage.setImportExportRect}.
555
+ */
556
+ setBackgroundStyle(style: {
557
+ color?: Color4;
558
+ type?: BackgroundType;
559
+ autoresize?: boolean;
560
+ }): Command;
496
561
  /**
497
562
  * Set the background color of the image.
563
+ *
564
+ * This is a convenience method for adding or updating the {@link BackgroundComponent}
565
+ * for the current image.
566
+ *
567
+ * @see {@link setBackgroundStyle}
498
568
  */
499
569
  setBackgroundColor(color: Color4): Command;
500
570
  /**