2022-06-01 17:38:08 +09:00
|
|
|
/* Copyright 2022 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// eslint-disable-next-line max-len
|
|
|
|
/** @typedef {import("./annotation_editor_layer.js").AnnotationEditorLayer} AnnotationEditorLayer */
|
|
|
|
|
2022-07-24 23:52:18 +09:00
|
|
|
import { bindEvents, ColorManager, KeyboardManager } from "./tools.js";
|
2022-07-21 17:42:15 +09:00
|
|
|
import { shadow, unreachable } from "../../shared/util.js";
|
2022-06-01 17:38:08 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {Object} AnnotationEditorParameters
|
|
|
|
* @property {AnnotationEditorLayer} parent - the layer containing this editor
|
|
|
|
* @property {string} id - editor id
|
|
|
|
* @property {number} x - x-coordinate
|
|
|
|
* @property {number} y - y-coordinate
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for editors.
|
|
|
|
*/
|
|
|
|
class AnnotationEditor {
|
2022-07-21 17:42:15 +09:00
|
|
|
#boundFocusin = this.focusin.bind(this);
|
|
|
|
|
|
|
|
#boundFocusout = this.focusout.bind(this);
|
|
|
|
|
2022-07-22 22:49:42 +09:00
|
|
|
#hasBeenSelected = false;
|
2022-07-21 17:42:15 +09:00
|
|
|
|
2022-07-22 22:49:42 +09:00
|
|
|
#isEditing = false;
|
2022-07-21 17:42:15 +09:00
|
|
|
|
2022-06-01 17:38:08 +09:00
|
|
|
#isInEditMode = false;
|
|
|
|
|
2022-07-20 21:21:30 +09:00
|
|
|
#zIndex = AnnotationEditor._zIndex++;
|
|
|
|
|
2022-06-29 22:39:02 +09:00
|
|
|
static _colorManager = new ColorManager();
|
|
|
|
|
2022-07-20 21:21:30 +09:00
|
|
|
static _zIndex = 1;
|
|
|
|
|
2022-06-01 17:38:08 +09:00
|
|
|
/**
|
|
|
|
* @param {AnnotationEditorParameters} parameters
|
|
|
|
*/
|
|
|
|
constructor(parameters) {
|
|
|
|
if (this.constructor === AnnotationEditor) {
|
|
|
|
unreachable("Cannot initialize AnnotationEditor.");
|
|
|
|
}
|
|
|
|
|
|
|
|
this.parent = parameters.parent;
|
|
|
|
this.id = parameters.id;
|
|
|
|
this.width = this.height = null;
|
|
|
|
this.pageIndex = parameters.parent.pageIndex;
|
|
|
|
this.name = parameters.name;
|
|
|
|
this.div = null;
|
2022-06-23 22:47:45 +09:00
|
|
|
|
|
|
|
const [width, height] = this.parent.viewportBaseDimensions;
|
|
|
|
this.x = parameters.x / width;
|
|
|
|
this.y = parameters.y / height;
|
|
|
|
this.rotation = this.parent.viewport.rotation;
|
2022-06-01 17:38:08 +09:00
|
|
|
|
|
|
|
this.isAttachedToDOM = false;
|
|
|
|
}
|
|
|
|
|
2022-06-29 22:39:02 +09:00
|
|
|
static get _defaultLineColor() {
|
|
|
|
return shadow(
|
|
|
|
this,
|
|
|
|
"_defaultLineColor",
|
|
|
|
this._colorManager.getHexCode("CanvasText")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-06-17 01:16:49 +09:00
|
|
|
/**
|
|
|
|
* This editor will be behind the others.
|
|
|
|
*/
|
|
|
|
setInBackground() {
|
2022-07-20 21:21:30 +09:00
|
|
|
this.div.style.zIndex = 0;
|
2022-06-17 01:16:49 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This editor will be in the foreground.
|
|
|
|
*/
|
|
|
|
setInForeground() {
|
2022-07-20 21:21:30 +09:00
|
|
|
this.div.style.zIndex = this.#zIndex;
|
2022-06-17 01:16:49 +09:00
|
|
|
}
|
|
|
|
|
2022-06-01 17:38:08 +09:00
|
|
|
/**
|
|
|
|
* onfocus callback.
|
|
|
|
*/
|
2022-07-21 17:42:15 +09:00
|
|
|
focusin(event) {
|
2022-07-22 22:49:42 +09:00
|
|
|
if (!this.#hasBeenSelected) {
|
|
|
|
this.parent.setSelected(this);
|
|
|
|
} else {
|
|
|
|
this.#hasBeenSelected = false;
|
2022-07-21 17:42:15 +09:00
|
|
|
}
|
2022-06-01 17:38:08 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* onblur callback.
|
|
|
|
* @param {FocusEvent} event
|
|
|
|
*/
|
|
|
|
focusout(event) {
|
|
|
|
if (!this.isAttachedToDOM) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In case of focusout, the relatedTarget is the element which
|
|
|
|
// is grabbing the focus.
|
|
|
|
// So if the related target is an element under the div for this
|
|
|
|
// editor, then the editor isn't unactive.
|
|
|
|
const target = event.relatedTarget;
|
|
|
|
if (target?.closest(`#${this.id}`)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
2022-07-21 17:42:15 +09:00
|
|
|
if (!this.parent.isMultipleSelection) {
|
|
|
|
this.commitOrRemove();
|
2022-07-13 00:32:14 +09:00
|
|
|
}
|
2022-06-17 01:16:49 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
commitOrRemove() {
|
2022-06-01 17:38:08 +09:00
|
|
|
if (this.isEmpty()) {
|
|
|
|
this.remove();
|
|
|
|
} else {
|
|
|
|
this.commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We use drag-and-drop in order to move an editor on a page.
|
|
|
|
* @param {DragEvent} event
|
|
|
|
*/
|
|
|
|
dragstart(event) {
|
2022-06-23 22:47:45 +09:00
|
|
|
const rect = this.parent.div.getBoundingClientRect();
|
|
|
|
this.startX = event.clientX - rect.x;
|
|
|
|
this.startY = event.clientY - rect.y;
|
2022-06-01 17:38:08 +09:00
|
|
|
event.dataTransfer.setData("text/plain", this.id);
|
|
|
|
event.dataTransfer.effectAllowed = "move";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the editor position within its parent.
|
|
|
|
* @param {number} x
|
|
|
|
* @param {number} y
|
2022-06-23 22:47:45 +09:00
|
|
|
* @param {number} tx - x-translation in screen coordinates.
|
|
|
|
* @param {number} ty - y-translation in screen coordinates.
|
2022-06-01 17:38:08 +09:00
|
|
|
*/
|
2022-06-23 22:47:45 +09:00
|
|
|
setAt(x, y, tx, ty) {
|
|
|
|
const [width, height] = this.parent.viewportBaseDimensions;
|
|
|
|
[tx, ty] = this.screenToPageTranslation(tx, ty);
|
|
|
|
|
|
|
|
this.x = (x + tx) / width;
|
|
|
|
this.y = (y + ty) / height;
|
2022-06-01 17:38:08 +09:00
|
|
|
|
2022-06-23 22:47:45 +09:00
|
|
|
this.div.style.left = `${100 * this.x}%`;
|
|
|
|
this.div.style.top = `${100 * this.y}%`;
|
2022-06-01 17:38:08 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translate the editor position within its parent.
|
2022-06-23 22:47:45 +09:00
|
|
|
* @param {number} x - x-translation in screen coordinates.
|
|
|
|
* @param {number} y - y-translation in screen coordinates.
|
|
|
|
*/
|
|
|
|
translate(x, y) {
|
|
|
|
const [width, height] = this.parent.viewportBaseDimensions;
|
|
|
|
[x, y] = this.screenToPageTranslation(x, y);
|
|
|
|
|
|
|
|
this.x += x / width;
|
|
|
|
this.y += y / height;
|
|
|
|
|
|
|
|
this.div.style.left = `${100 * this.x}%`;
|
|
|
|
this.div.style.top = `${100 * this.y}%`;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a screen translation into a page one.
|
2022-06-01 17:38:08 +09:00
|
|
|
* @param {number} x
|
|
|
|
* @param {number} y
|
|
|
|
*/
|
2022-06-23 22:47:45 +09:00
|
|
|
screenToPageTranslation(x, y) {
|
|
|
|
const { rotation } = this.parent.viewport;
|
|
|
|
switch (rotation) {
|
|
|
|
case 90:
|
|
|
|
return [y, -x];
|
|
|
|
case 180:
|
|
|
|
return [-x, -y];
|
|
|
|
case 270:
|
|
|
|
return [-y, x];
|
|
|
|
default:
|
|
|
|
return [x, y];
|
|
|
|
}
|
2022-06-01 17:38:08 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the dimensions of this editor.
|
|
|
|
* @param {number} width
|
|
|
|
* @param {number} height
|
|
|
|
*/
|
|
|
|
setDims(width, height) {
|
2022-06-23 22:47:45 +09:00
|
|
|
const [parentWidth, parentHeight] = this.parent.viewportBaseDimensions;
|
|
|
|
this.div.style.width = `${(100 * width) / parentWidth}%`;
|
|
|
|
this.div.style.height = `${(100 * height) / parentHeight}%`;
|
2022-06-01 17:38:08 +09:00
|
|
|
}
|
|
|
|
|
2022-06-01 22:42:46 +09:00
|
|
|
/**
|
|
|
|
* Get the translation used to position this editor when it's created.
|
|
|
|
* @returns {Array<number>}
|
|
|
|
*/
|
|
|
|
getInitialTranslation() {
|
|
|
|
return [0, 0];
|
|
|
|
}
|
|
|
|
|
2022-06-01 17:38:08 +09:00
|
|
|
/**
|
|
|
|
* Render this editor in a div.
|
|
|
|
* @returns {HTMLDivElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
this.div = document.createElement("div");
|
2022-06-23 22:47:45 +09:00
|
|
|
this.div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360);
|
2022-06-01 17:38:08 +09:00
|
|
|
this.div.className = this.name;
|
|
|
|
this.div.setAttribute("id", this.id);
|
2022-07-20 01:20:56 +09:00
|
|
|
this.div.setAttribute("tabIndex", 0);
|
2022-06-01 22:42:46 +09:00
|
|
|
|
2022-07-20 21:21:30 +09:00
|
|
|
this.setInForeground();
|
|
|
|
|
2022-07-21 17:42:15 +09:00
|
|
|
this.div.addEventListener("focusin", this.#boundFocusin);
|
|
|
|
this.div.addEventListener("focusout", this.#boundFocusout);
|
|
|
|
|
2022-06-01 22:42:46 +09:00
|
|
|
const [tx, ty] = this.getInitialTranslation();
|
2022-06-23 22:47:45 +09:00
|
|
|
this.translate(tx, ty);
|
2022-06-01 17:38:08 +09:00
|
|
|
|
2022-07-22 22:49:42 +09:00
|
|
|
bindEvents(this, this.div, ["dragstart", "pointerdown"]);
|
2022-06-01 17:38:08 +09:00
|
|
|
|
|
|
|
return this.div;
|
|
|
|
}
|
|
|
|
|
2022-07-05 01:04:32 +09:00
|
|
|
/**
|
2022-07-20 01:20:56 +09:00
|
|
|
* Onpointerdown callback.
|
|
|
|
* @param {PointerEvent} event
|
2022-07-05 01:04:32 +09:00
|
|
|
*/
|
2022-07-20 01:20:56 +09:00
|
|
|
pointerdown(event) {
|
2022-07-24 23:52:18 +09:00
|
|
|
const isMac = KeyboardManager.platform.isMac;
|
|
|
|
if (event.button !== 0 || (event.ctrlKey && isMac)) {
|
2022-07-05 01:04:32 +09:00
|
|
|
// Avoid to focus this editor because of a non-left click.
|
|
|
|
event.preventDefault();
|
2022-07-27 21:11:29 +09:00
|
|
|
return;
|
2022-07-05 01:04:32 +09:00
|
|
|
}
|
2022-07-21 17:42:15 +09:00
|
|
|
|
2022-07-24 23:52:18 +09:00
|
|
|
if (
|
|
|
|
(event.ctrlKey && !isMac) ||
|
|
|
|
event.shiftKey ||
|
|
|
|
(event.metaKey && isMac)
|
|
|
|
) {
|
2022-07-22 22:49:42 +09:00
|
|
|
this.parent.toggleSelected(this);
|
|
|
|
} else {
|
|
|
|
this.parent.setSelected(this);
|
2022-07-21 17:42:15 +09:00
|
|
|
}
|
2022-07-22 22:49:42 +09:00
|
|
|
|
|
|
|
this.#hasBeenSelected = true;
|
2022-07-05 01:04:32 +09:00
|
|
|
}
|
|
|
|
|
2022-06-23 22:47:45 +09:00
|
|
|
getRect(tx, ty) {
|
|
|
|
const [parentWidth, parentHeight] = this.parent.viewportBaseDimensions;
|
|
|
|
const [pageWidth, pageHeight] = this.parent.pageDimensions;
|
|
|
|
const shiftX = (pageWidth * tx) / parentWidth;
|
|
|
|
const shiftY = (pageHeight * ty) / parentHeight;
|
|
|
|
const x = this.x * pageWidth;
|
|
|
|
const y = this.y * pageHeight;
|
|
|
|
const width = this.width * pageWidth;
|
|
|
|
const height = this.height * pageHeight;
|
|
|
|
|
|
|
|
switch (this.rotation) {
|
|
|
|
case 0:
|
|
|
|
return [
|
|
|
|
x + shiftX,
|
|
|
|
pageHeight - y - shiftY - height,
|
|
|
|
x + shiftX + width,
|
|
|
|
pageHeight - y - shiftY,
|
|
|
|
];
|
|
|
|
case 90:
|
|
|
|
return [
|
|
|
|
x + shiftY,
|
|
|
|
pageHeight - y + shiftX,
|
|
|
|
x + shiftY + height,
|
|
|
|
pageHeight - y + shiftX + width,
|
|
|
|
];
|
|
|
|
case 180:
|
|
|
|
return [
|
|
|
|
x - shiftX - width,
|
|
|
|
pageHeight - y + shiftY,
|
|
|
|
x - shiftX,
|
|
|
|
pageHeight - y + shiftY + height,
|
|
|
|
];
|
|
|
|
case 270:
|
|
|
|
return [
|
|
|
|
x - shiftY - height,
|
|
|
|
pageHeight - y - shiftX - width,
|
|
|
|
x - shiftY,
|
|
|
|
pageHeight - y - shiftX,
|
|
|
|
];
|
|
|
|
default:
|
|
|
|
throw new Error("Invalid rotation");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-18 21:47:09 +09:00
|
|
|
getRectInCurrentCoords(rect, pageHeight) {
|
|
|
|
const [x1, y1, x2, y2] = rect;
|
|
|
|
|
|
|
|
const width = x2 - x1;
|
|
|
|
const height = y2 - y1;
|
|
|
|
|
|
|
|
switch (this.rotation) {
|
|
|
|
case 0:
|
|
|
|
return [x1, pageHeight - y2, width, height];
|
|
|
|
case 90:
|
|
|
|
return [x1, pageHeight - y1, height, width];
|
|
|
|
case 180:
|
|
|
|
return [x2, pageHeight - y1, width, height];
|
|
|
|
case 270:
|
|
|
|
return [x2, pageHeight - y2, height, width];
|
|
|
|
default:
|
|
|
|
throw new Error("Invalid rotation");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-01 17:38:08 +09:00
|
|
|
/**
|
|
|
|
* Executed once this editor has been rendered.
|
|
|
|
*/
|
|
|
|
onceAdded() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the editor contains something.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isEmpty() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable edit mode.
|
|
|
|
*/
|
|
|
|
enableEditMode() {
|
|
|
|
this.#isInEditMode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable edit mode.
|
|
|
|
*/
|
|
|
|
disableEditMode() {
|
|
|
|
this.#isInEditMode = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the editor is edited.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
isInEditMode() {
|
|
|
|
return this.#isInEditMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If it returns true, then this editor handle the keyboard
|
|
|
|
* events itself.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
shouldGetKeyboardEvents() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if this editor needs to be rebuilt or not.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
needsToBeRebuilt() {
|
|
|
|
return this.div && !this.isAttachedToDOM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rebuild the editor in case it has been removed on undo.
|
|
|
|
*
|
|
|
|
* To implement in subclasses.
|
|
|
|
*/
|
|
|
|
rebuild() {
|
2022-07-21 17:42:15 +09:00
|
|
|
this.div?.addEventListener("focusin", this.#boundFocusin);
|
2022-06-01 17:38:08 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Serialize the editor.
|
|
|
|
* The result of the serialization will be used to construct a
|
|
|
|
* new annotation to add to the pdf document.
|
|
|
|
*
|
|
|
|
* To implement in subclasses.
|
|
|
|
*/
|
|
|
|
serialize() {
|
|
|
|
unreachable("An editor must be serializable");
|
|
|
|
}
|
|
|
|
|
2022-07-18 21:47:09 +09:00
|
|
|
/**
|
|
|
|
* Deserialize the editor.
|
|
|
|
* The result of the deserialization is a new editor.
|
|
|
|
*
|
|
|
|
* @param {Object} data
|
|
|
|
* @param {AnnotationEditorLayer} parent
|
|
|
|
* @returns {AnnotationEditor}
|
|
|
|
*/
|
|
|
|
static deserialize(data, parent) {
|
|
|
|
const editor = new this.prototype.constructor({
|
|
|
|
parent,
|
|
|
|
id: parent.getNextId(),
|
|
|
|
});
|
|
|
|
editor.rotation = data.rotation;
|
|
|
|
|
|
|
|
const [pageWidth, pageHeight] = parent.pageDimensions;
|
|
|
|
const [x, y, width, height] = editor.getRectInCurrentCoords(
|
|
|
|
data.rect,
|
|
|
|
pageHeight
|
|
|
|
);
|
|
|
|
editor.x = x / pageWidth;
|
|
|
|
editor.y = y / pageHeight;
|
|
|
|
editor.width = width / pageWidth;
|
|
|
|
editor.height = height / pageHeight;
|
|
|
|
|
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
|
2022-06-01 17:38:08 +09:00
|
|
|
/**
|
|
|
|
* Remove this editor.
|
|
|
|
* It's used on ctrl+backspace action.
|
|
|
|
*/
|
|
|
|
remove() {
|
2022-07-21 17:42:15 +09:00
|
|
|
this.div.removeEventListener("focusin", this.#boundFocusin);
|
|
|
|
this.div.removeEventListener("focusout", this.#boundFocusout);
|
|
|
|
|
2022-07-05 01:04:32 +09:00
|
|
|
if (!this.isEmpty()) {
|
|
|
|
// The editor is removed but it can be back at some point thanks to
|
|
|
|
// undo/redo so we must commit it before.
|
|
|
|
this.commit();
|
|
|
|
}
|
2022-06-01 17:38:08 +09:00
|
|
|
this.parent.remove(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select this editor.
|
|
|
|
*/
|
|
|
|
select() {
|
2022-07-21 17:42:15 +09:00
|
|
|
this.div?.classList.add("selectedEditor");
|
2022-06-01 17:38:08 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unselect this editor.
|
|
|
|
*/
|
|
|
|
unselect() {
|
2022-07-21 17:42:15 +09:00
|
|
|
this.div?.classList.remove("selectedEditor");
|
2022-06-01 17:38:08 +09:00
|
|
|
}
|
2022-06-14 01:23:10 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update some parameters which have been changed through the UI.
|
|
|
|
* @param {number} type
|
|
|
|
* @param {*} value
|
|
|
|
*/
|
|
|
|
updateParams(type, value) {}
|
|
|
|
|
2022-06-29 01:21:32 +09:00
|
|
|
/**
|
|
|
|
* When the user disables the editing mode some editors can change some of
|
|
|
|
* their properties.
|
|
|
|
*/
|
|
|
|
disableEditing() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When the user enables the editing mode some editors can change some of
|
|
|
|
* their properties.
|
|
|
|
*/
|
|
|
|
enableEditing() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the id to use in aria-owns when a link is done in the text layer.
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
getIdForTextLayer() {
|
|
|
|
return this.id;
|
|
|
|
}
|
|
|
|
|
2022-06-14 01:23:10 +09:00
|
|
|
/**
|
|
|
|
* Get some properties to update in the UI.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
get propertiesToUpdate() {
|
|
|
|
return {};
|
|
|
|
}
|
2022-06-29 01:21:32 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the div which really contains the displayed content.
|
|
|
|
*/
|
|
|
|
get contentDiv() {
|
|
|
|
return this.div;
|
|
|
|
}
|
2022-07-21 17:42:15 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true then the editor is currently edited.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
get isEditing() {
|
|
|
|
return this.#isEditing;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When set to true, it means that this editor is currently edited.
|
|
|
|
* @param {boolean} value
|
|
|
|
*/
|
|
|
|
set isEditing(value) {
|
|
|
|
this.#isEditing = value;
|
|
|
|
if (value) {
|
|
|
|
this.parent.setSelected(this);
|
|
|
|
this.parent.setActiveEditor(this);
|
|
|
|
} else {
|
|
|
|
this.parent.setActiveEditor(null);
|
|
|
|
}
|
|
|
|
}
|
2022-06-01 17:38:08 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
export { AnnotationEditor };
|