tools.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2022 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.KeyboardManager = exports.CommandManager = exports.ColorManager = exports.AnnotationEditorUIManager = void 0;
  27. exports.bindEvents = bindEvents;
  28. exports.opacityToHex = opacityToHex;
  29. var _util = require("../../shared/util.js");
  30. var _display_utils = require("../display_utils.js");
  31. function bindEvents(obj, element, names) {
  32. for (const name of names) {
  33. element.addEventListener(name, obj[name].bind(obj));
  34. }
  35. }
  36. function opacityToHex(opacity) {
  37. return Math.round(Math.min(255, Math.max(1, 255 * opacity))).toString(16).padStart(2, "0");
  38. }
  39. class IdManager {
  40. #id = 0;
  41. getId() {
  42. return `${_util.AnnotationEditorPrefix}${this.#id++}`;
  43. }
  44. }
  45. class CommandManager {
  46. #commands = [];
  47. #locked = false;
  48. #maxSize;
  49. #position = -1;
  50. constructor(maxSize = 128) {
  51. this.#maxSize = maxSize;
  52. }
  53. add({
  54. cmd,
  55. undo,
  56. mustExec,
  57. type = NaN,
  58. overwriteIfSameType = false,
  59. keepUndo = false
  60. }) {
  61. if (mustExec) {
  62. cmd();
  63. }
  64. if (this.#locked) {
  65. return;
  66. }
  67. const save = {
  68. cmd,
  69. undo,
  70. type
  71. };
  72. if (this.#position === -1) {
  73. if (this.#commands.length > 0) {
  74. this.#commands.length = 0;
  75. }
  76. this.#position = 0;
  77. this.#commands.push(save);
  78. return;
  79. }
  80. if (overwriteIfSameType && this.#commands[this.#position].type === type) {
  81. if (keepUndo) {
  82. save.undo = this.#commands[this.#position].undo;
  83. }
  84. this.#commands[this.#position] = save;
  85. return;
  86. }
  87. const next = this.#position + 1;
  88. if (next === this.#maxSize) {
  89. this.#commands.splice(0, 1);
  90. } else {
  91. this.#position = next;
  92. if (next < this.#commands.length) {
  93. this.#commands.splice(next);
  94. }
  95. }
  96. this.#commands.push(save);
  97. }
  98. undo() {
  99. if (this.#position === -1) {
  100. return;
  101. }
  102. this.#locked = true;
  103. this.#commands[this.#position].undo();
  104. this.#locked = false;
  105. this.#position -= 1;
  106. }
  107. redo() {
  108. if (this.#position < this.#commands.length - 1) {
  109. this.#position += 1;
  110. this.#locked = true;
  111. this.#commands[this.#position].cmd();
  112. this.#locked = false;
  113. }
  114. }
  115. hasSomethingToUndo() {
  116. return this.#position !== -1;
  117. }
  118. hasSomethingToRedo() {
  119. return this.#position < this.#commands.length - 1;
  120. }
  121. destroy() {
  122. this.#commands = null;
  123. }
  124. }
  125. exports.CommandManager = CommandManager;
  126. class KeyboardManager {
  127. constructor(callbacks) {
  128. this.buffer = [];
  129. this.callbacks = new Map();
  130. this.allKeys = new Set();
  131. const {
  132. isMac
  133. } = _util.FeatureTest.platform;
  134. for (const [keys, callback] of callbacks) {
  135. for (const key of keys) {
  136. const isMacKey = key.startsWith("mac+");
  137. if (isMac && isMacKey) {
  138. this.callbacks.set(key.slice(4), callback);
  139. this.allKeys.add(key.split("+").at(-1));
  140. } else if (!isMac && !isMacKey) {
  141. this.callbacks.set(key, callback);
  142. this.allKeys.add(key.split("+").at(-1));
  143. }
  144. }
  145. }
  146. }
  147. #serialize(event) {
  148. if (event.altKey) {
  149. this.buffer.push("alt");
  150. }
  151. if (event.ctrlKey) {
  152. this.buffer.push("ctrl");
  153. }
  154. if (event.metaKey) {
  155. this.buffer.push("meta");
  156. }
  157. if (event.shiftKey) {
  158. this.buffer.push("shift");
  159. }
  160. this.buffer.push(event.key);
  161. const str = this.buffer.join("+");
  162. this.buffer.length = 0;
  163. return str;
  164. }
  165. exec(self, event) {
  166. if (!this.allKeys.has(event.key)) {
  167. return;
  168. }
  169. const callback = this.callbacks.get(this.#serialize(event));
  170. if (!callback) {
  171. return;
  172. }
  173. callback.bind(self)();
  174. event.stopPropagation();
  175. event.preventDefault();
  176. }
  177. }
  178. exports.KeyboardManager = KeyboardManager;
  179. class ColorManager {
  180. static _colorsMapping = new Map([["CanvasText", [0, 0, 0]], ["Canvas", [255, 255, 255]]]);
  181. get _colors() {
  182. if (typeof document === "undefined") {
  183. return (0, _util.shadow)(this, "_colors", ColorManager._colorsMapping);
  184. }
  185. const colors = new Map([["CanvasText", null], ["Canvas", null]]);
  186. (0, _display_utils.getColorValues)(colors);
  187. return (0, _util.shadow)(this, "_colors", colors);
  188. }
  189. convert(color) {
  190. const rgb = (0, _display_utils.getRGB)(color);
  191. if (!window.matchMedia("(forced-colors: active)").matches) {
  192. return rgb;
  193. }
  194. for (const [name, RGB] of this._colors) {
  195. if (RGB.every((x, i) => x === rgb[i])) {
  196. return ColorManager._colorsMapping.get(name);
  197. }
  198. }
  199. return rgb;
  200. }
  201. getHexCode(name) {
  202. const rgb = this._colors.get(name);
  203. if (!rgb) {
  204. return name;
  205. }
  206. return _util.Util.makeHexColor(...rgb);
  207. }
  208. }
  209. exports.ColorManager = ColorManager;
  210. class AnnotationEditorUIManager {
  211. #activeEditor = null;
  212. #allEditors = new Map();
  213. #allLayers = new Map();
  214. #annotationStorage = null;
  215. #commandManager = new CommandManager();
  216. #currentPageIndex = 0;
  217. #editorTypes = null;
  218. #editorsToRescale = new Set();
  219. #eventBus = null;
  220. #idManager = new IdManager();
  221. #isEnabled = false;
  222. #mode = _util.AnnotationEditorType.NONE;
  223. #selectedEditors = new Set();
  224. #boundCopy = this.copy.bind(this);
  225. #boundCut = this.cut.bind(this);
  226. #boundPaste = this.paste.bind(this);
  227. #boundKeydown = this.keydown.bind(this);
  228. #boundOnEditingAction = this.onEditingAction.bind(this);
  229. #boundOnPageChanging = this.onPageChanging.bind(this);
  230. #boundOnScaleChanging = this.onScaleChanging.bind(this);
  231. #boundOnRotationChanging = this.onRotationChanging.bind(this);
  232. #previousStates = {
  233. isEditing: false,
  234. isEmpty: true,
  235. hasSomethingToUndo: false,
  236. hasSomethingToRedo: false,
  237. hasSelectedEditor: false
  238. };
  239. #container = null;
  240. static _keyboardManager = new KeyboardManager([[["ctrl+a", "mac+meta+a"], AnnotationEditorUIManager.prototype.selectAll], [["ctrl+z", "mac+meta+z"], AnnotationEditorUIManager.prototype.undo], [["ctrl+y", "ctrl+shift+Z", "mac+meta+shift+Z"], AnnotationEditorUIManager.prototype.redo], [["Backspace", "alt+Backspace", "ctrl+Backspace", "shift+Backspace", "mac+Backspace", "mac+alt+Backspace", "mac+ctrl+Backspace", "Delete", "ctrl+Delete", "shift+Delete"], AnnotationEditorUIManager.prototype.delete], [["Escape", "mac+Escape"], AnnotationEditorUIManager.prototype.unselectAll]]);
  241. constructor(container, eventBus, annotationStorage) {
  242. this.#container = container;
  243. this.#eventBus = eventBus;
  244. this.#eventBus._on("editingaction", this.#boundOnEditingAction);
  245. this.#eventBus._on("pagechanging", this.#boundOnPageChanging);
  246. this.#eventBus._on("scalechanging", this.#boundOnScaleChanging);
  247. this.#eventBus._on("rotationchanging", this.#boundOnRotationChanging);
  248. this.#annotationStorage = annotationStorage;
  249. this.viewParameters = {
  250. realScale: _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS,
  251. rotation: 0
  252. };
  253. }
  254. destroy() {
  255. this.#removeKeyboardManager();
  256. this.#eventBus._off("editingaction", this.#boundOnEditingAction);
  257. this.#eventBus._off("pagechanging", this.#boundOnPageChanging);
  258. this.#eventBus._off("scalechanging", this.#boundOnScaleChanging);
  259. this.#eventBus._off("rotationchanging", this.#boundOnRotationChanging);
  260. for (const layer of this.#allLayers.values()) {
  261. layer.destroy();
  262. }
  263. this.#allLayers.clear();
  264. this.#allEditors.clear();
  265. this.#editorsToRescale.clear();
  266. this.#activeEditor = null;
  267. this.#selectedEditors.clear();
  268. this.#commandManager.destroy();
  269. }
  270. onPageChanging({
  271. pageNumber
  272. }) {
  273. this.#currentPageIndex = pageNumber - 1;
  274. }
  275. focusMainContainer() {
  276. this.#container.focus();
  277. }
  278. addShouldRescale(editor) {
  279. this.#editorsToRescale.add(editor);
  280. }
  281. removeShouldRescale(editor) {
  282. this.#editorsToRescale.delete(editor);
  283. }
  284. onScaleChanging({
  285. scale
  286. }) {
  287. this.commitOrRemove();
  288. this.viewParameters.realScale = scale * _display_utils.PixelsPerInch.PDF_TO_CSS_UNITS;
  289. for (const editor of this.#editorsToRescale) {
  290. editor.onScaleChanging();
  291. }
  292. }
  293. onRotationChanging({
  294. pagesRotation
  295. }) {
  296. this.commitOrRemove();
  297. this.viewParameters.rotation = pagesRotation;
  298. }
  299. addToAnnotationStorage(editor) {
  300. if (!editor.isEmpty() && this.#annotationStorage && !this.#annotationStorage.has(editor.id)) {
  301. this.#annotationStorage.setValue(editor.id, editor);
  302. }
  303. }
  304. #addKeyboardManager() {
  305. this.#container.addEventListener("keydown", this.#boundKeydown);
  306. }
  307. #removeKeyboardManager() {
  308. this.#container.removeEventListener("keydown", this.#boundKeydown);
  309. }
  310. #addCopyPasteListeners() {
  311. document.addEventListener("copy", this.#boundCopy);
  312. document.addEventListener("cut", this.#boundCut);
  313. document.addEventListener("paste", this.#boundPaste);
  314. }
  315. #removeCopyPasteListeners() {
  316. document.removeEventListener("copy", this.#boundCopy);
  317. document.removeEventListener("cut", this.#boundCut);
  318. document.removeEventListener("paste", this.#boundPaste);
  319. }
  320. copy(event) {
  321. event.preventDefault();
  322. if (this.#activeEditor) {
  323. this.#activeEditor.commitOrRemove();
  324. }
  325. if (!this.hasSelection) {
  326. return;
  327. }
  328. const editors = [];
  329. for (const editor of this.#selectedEditors) {
  330. if (!editor.isEmpty()) {
  331. editors.push(editor.serialize());
  332. }
  333. }
  334. if (editors.length === 0) {
  335. return;
  336. }
  337. event.clipboardData.setData("application/pdfjs", JSON.stringify(editors));
  338. }
  339. cut(event) {
  340. this.copy(event);
  341. this.delete();
  342. }
  343. paste(event) {
  344. event.preventDefault();
  345. let data = event.clipboardData.getData("application/pdfjs");
  346. if (!data) {
  347. return;
  348. }
  349. try {
  350. data = JSON.parse(data);
  351. } catch (ex) {
  352. (0, _util.warn)(`paste: "${ex.message}".`);
  353. return;
  354. }
  355. if (!Array.isArray(data)) {
  356. return;
  357. }
  358. this.unselectAll();
  359. const layer = this.#allLayers.get(this.#currentPageIndex);
  360. try {
  361. const newEditors = [];
  362. for (const editor of data) {
  363. const deserializedEditor = layer.deserialize(editor);
  364. if (!deserializedEditor) {
  365. return;
  366. }
  367. newEditors.push(deserializedEditor);
  368. }
  369. const cmd = () => {
  370. for (const editor of newEditors) {
  371. this.#addEditorToLayer(editor);
  372. }
  373. this.#selectEditors(newEditors);
  374. };
  375. const undo = () => {
  376. for (const editor of newEditors) {
  377. editor.remove();
  378. }
  379. };
  380. this.addCommands({
  381. cmd,
  382. undo,
  383. mustExec: true
  384. });
  385. } catch (ex) {
  386. (0, _util.warn)(`paste: "${ex.message}".`);
  387. }
  388. }
  389. keydown(event) {
  390. if (!this.getActive()?.shouldGetKeyboardEvents()) {
  391. AnnotationEditorUIManager._keyboardManager.exec(this, event);
  392. }
  393. }
  394. onEditingAction(details) {
  395. if (["undo", "redo", "delete", "selectAll"].includes(details.name)) {
  396. this[details.name]();
  397. }
  398. }
  399. #dispatchUpdateStates(details) {
  400. const hasChanged = Object.entries(details).some(([key, value]) => this.#previousStates[key] !== value);
  401. if (hasChanged) {
  402. this.#eventBus.dispatch("annotationeditorstateschanged", {
  403. source: this,
  404. details: Object.assign(this.#previousStates, details)
  405. });
  406. }
  407. }
  408. #dispatchUpdateUI(details) {
  409. this.#eventBus.dispatch("annotationeditorparamschanged", {
  410. source: this,
  411. details
  412. });
  413. }
  414. setEditingState(isEditing) {
  415. if (isEditing) {
  416. this.#addKeyboardManager();
  417. this.#addCopyPasteListeners();
  418. this.#dispatchUpdateStates({
  419. isEditing: this.#mode !== _util.AnnotationEditorType.NONE,
  420. isEmpty: this.#isEmpty(),
  421. hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),
  422. hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),
  423. hasSelectedEditor: false
  424. });
  425. } else {
  426. this.#removeKeyboardManager();
  427. this.#removeCopyPasteListeners();
  428. this.#dispatchUpdateStates({
  429. isEditing: false
  430. });
  431. }
  432. }
  433. registerEditorTypes(types) {
  434. if (this.#editorTypes) {
  435. return;
  436. }
  437. this.#editorTypes = types;
  438. for (const editorType of this.#editorTypes) {
  439. this.#dispatchUpdateUI(editorType.defaultPropertiesToUpdate);
  440. }
  441. }
  442. getId() {
  443. return this.#idManager.getId();
  444. }
  445. get currentLayer() {
  446. return this.#allLayers.get(this.#currentPageIndex);
  447. }
  448. get currentPageIndex() {
  449. return this.#currentPageIndex;
  450. }
  451. addLayer(layer) {
  452. this.#allLayers.set(layer.pageIndex, layer);
  453. if (this.#isEnabled) {
  454. layer.enable();
  455. } else {
  456. layer.disable();
  457. }
  458. }
  459. removeLayer(layer) {
  460. this.#allLayers.delete(layer.pageIndex);
  461. }
  462. updateMode(mode) {
  463. this.#mode = mode;
  464. if (mode === _util.AnnotationEditorType.NONE) {
  465. this.setEditingState(false);
  466. this.#disableAll();
  467. } else {
  468. this.setEditingState(true);
  469. this.#enableAll();
  470. for (const layer of this.#allLayers.values()) {
  471. layer.updateMode(mode);
  472. }
  473. }
  474. }
  475. updateToolbar(mode) {
  476. if (mode === this.#mode) {
  477. return;
  478. }
  479. this.#eventBus.dispatch("switchannotationeditormode", {
  480. source: this,
  481. mode
  482. });
  483. }
  484. updateParams(type, value) {
  485. if (!this.#editorTypes) {
  486. return;
  487. }
  488. for (const editor of this.#selectedEditors) {
  489. editor.updateParams(type, value);
  490. }
  491. for (const editorType of this.#editorTypes) {
  492. editorType.updateDefaultParams(type, value);
  493. }
  494. }
  495. #enableAll() {
  496. if (!this.#isEnabled) {
  497. this.#isEnabled = true;
  498. for (const layer of this.#allLayers.values()) {
  499. layer.enable();
  500. }
  501. }
  502. }
  503. #disableAll() {
  504. this.unselectAll();
  505. if (this.#isEnabled) {
  506. this.#isEnabled = false;
  507. for (const layer of this.#allLayers.values()) {
  508. layer.disable();
  509. }
  510. }
  511. }
  512. getEditors(pageIndex) {
  513. const editors = [];
  514. for (const editor of this.#allEditors.values()) {
  515. if (editor.pageIndex === pageIndex) {
  516. editors.push(editor);
  517. }
  518. }
  519. return editors;
  520. }
  521. getEditor(id) {
  522. return this.#allEditors.get(id);
  523. }
  524. addEditor(editor) {
  525. this.#allEditors.set(editor.id, editor);
  526. }
  527. removeEditor(editor) {
  528. this.#allEditors.delete(editor.id);
  529. this.unselect(editor);
  530. this.#annotationStorage?.remove(editor.id);
  531. }
  532. #addEditorToLayer(editor) {
  533. const layer = this.#allLayers.get(editor.pageIndex);
  534. if (layer) {
  535. layer.addOrRebuild(editor);
  536. } else {
  537. this.addEditor(editor);
  538. }
  539. }
  540. setActiveEditor(editor) {
  541. if (this.#activeEditor === editor) {
  542. return;
  543. }
  544. this.#activeEditor = editor;
  545. if (editor) {
  546. this.#dispatchUpdateUI(editor.propertiesToUpdate);
  547. }
  548. }
  549. toggleSelected(editor) {
  550. if (this.#selectedEditors.has(editor)) {
  551. this.#selectedEditors.delete(editor);
  552. editor.unselect();
  553. this.#dispatchUpdateStates({
  554. hasSelectedEditor: this.hasSelection
  555. });
  556. return;
  557. }
  558. this.#selectedEditors.add(editor);
  559. editor.select();
  560. this.#dispatchUpdateUI(editor.propertiesToUpdate);
  561. this.#dispatchUpdateStates({
  562. hasSelectedEditor: true
  563. });
  564. }
  565. setSelected(editor) {
  566. for (const ed of this.#selectedEditors) {
  567. if (ed !== editor) {
  568. ed.unselect();
  569. }
  570. }
  571. this.#selectedEditors.clear();
  572. this.#selectedEditors.add(editor);
  573. editor.select();
  574. this.#dispatchUpdateUI(editor.propertiesToUpdate);
  575. this.#dispatchUpdateStates({
  576. hasSelectedEditor: true
  577. });
  578. }
  579. isSelected(editor) {
  580. return this.#selectedEditors.has(editor);
  581. }
  582. unselect(editor) {
  583. editor.unselect();
  584. this.#selectedEditors.delete(editor);
  585. this.#dispatchUpdateStates({
  586. hasSelectedEditor: this.hasSelection
  587. });
  588. }
  589. get hasSelection() {
  590. return this.#selectedEditors.size !== 0;
  591. }
  592. undo() {
  593. this.#commandManager.undo();
  594. this.#dispatchUpdateStates({
  595. hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),
  596. hasSomethingToRedo: true,
  597. isEmpty: this.#isEmpty()
  598. });
  599. }
  600. redo() {
  601. this.#commandManager.redo();
  602. this.#dispatchUpdateStates({
  603. hasSomethingToUndo: true,
  604. hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),
  605. isEmpty: this.#isEmpty()
  606. });
  607. }
  608. addCommands(params) {
  609. this.#commandManager.add(params);
  610. this.#dispatchUpdateStates({
  611. hasSomethingToUndo: true,
  612. hasSomethingToRedo: false,
  613. isEmpty: this.#isEmpty()
  614. });
  615. }
  616. #isEmpty() {
  617. if (this.#allEditors.size === 0) {
  618. return true;
  619. }
  620. if (this.#allEditors.size === 1) {
  621. for (const editor of this.#allEditors.values()) {
  622. return editor.isEmpty();
  623. }
  624. }
  625. return false;
  626. }
  627. delete() {
  628. this.commitOrRemove();
  629. if (!this.hasSelection) {
  630. return;
  631. }
  632. const editors = [...this.#selectedEditors];
  633. const cmd = () => {
  634. for (const editor of editors) {
  635. editor.remove();
  636. }
  637. };
  638. const undo = () => {
  639. for (const editor of editors) {
  640. this.#addEditorToLayer(editor);
  641. }
  642. };
  643. this.addCommands({
  644. cmd,
  645. undo,
  646. mustExec: true
  647. });
  648. }
  649. commitOrRemove() {
  650. this.#activeEditor?.commitOrRemove();
  651. }
  652. #selectEditors(editors) {
  653. this.#selectedEditors.clear();
  654. for (const editor of editors) {
  655. if (editor.isEmpty()) {
  656. continue;
  657. }
  658. this.#selectedEditors.add(editor);
  659. editor.select();
  660. }
  661. this.#dispatchUpdateStates({
  662. hasSelectedEditor: true
  663. });
  664. }
  665. selectAll() {
  666. for (const editor of this.#selectedEditors) {
  667. editor.commit();
  668. }
  669. this.#selectEditors(this.#allEditors.values());
  670. }
  671. unselectAll() {
  672. if (this.#activeEditor) {
  673. this.#activeEditor.commitOrRemove();
  674. return;
  675. }
  676. if (this.#selectedEditors.size === 0) {
  677. return;
  678. }
  679. for (const editor of this.#selectedEditors) {
  680. editor.unselect();
  681. }
  682. this.#selectedEditors.clear();
  683. this.#dispatchUpdateStates({
  684. hasSelectedEditor: false
  685. });
  686. }
  687. isActive(editor) {
  688. return this.#activeEditor === editor;
  689. }
  690. getActive() {
  691. return this.#activeEditor;
  692. }
  693. getMode() {
  694. return this.#mode;
  695. }
  696. }
  697. exports.AnnotationEditorUIManager = AnnotationEditorUIManager;