mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 20:46:37 +02:00
✨ Import text-editor code into the repository
This commit is contained in:
parent
68397edd4d
commit
04a0d867b0
65 changed files with 11112 additions and 7 deletions
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright (c) KALEIDOS INC
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used for handling debugging.
|
||||
*/
|
||||
export class SelectionControllerDebug {
|
||||
/**
|
||||
* @type {Object.<string, HTMLElement>}
|
||||
*/
|
||||
#elements = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param {Object.<string, HTMLElement>} elements List of elements used to debug the SelectionController
|
||||
*/
|
||||
constructor(elements) {
|
||||
this.#elements = elements;
|
||||
}
|
||||
|
||||
getNodeDescription(node, offset) {
|
||||
if (!node) return "null";
|
||||
return `${node.nodeName} ${
|
||||
node.nodeType === Node.TEXT_NODE
|
||||
? node.nodeValue + (typeof offset === "number" ? `(${offset})` : "")
|
||||
: node.dataset.itype
|
||||
}`;
|
||||
}
|
||||
|
||||
update(selectionController) {
|
||||
this.#elements.direction.value = selectionController.direction;
|
||||
this.#elements.multiElement.checked = selectionController.isMulti;
|
||||
this.#elements.multiInlineElement.checked =
|
||||
selectionController.isMultiInline;
|
||||
this.#elements.multiParagraphElement.checked =
|
||||
selectionController.isMultiParagraph;
|
||||
this.#elements.isParagraphStart.checked =
|
||||
selectionController.isParagraphStart;
|
||||
this.#elements.isParagraphEnd.checked = selectionController.isParagraphEnd;
|
||||
this.#elements.isInlineStart.checked = selectionController.isInlineStart;
|
||||
this.#elements.isInlineEnd.checked = selectionController.isInlineEnd;
|
||||
this.#elements.isTextAnchor.checked = selectionController.isTextAnchor;
|
||||
this.#elements.isTextFocus.checked = selectionController.isTextFocus;
|
||||
this.#elements.focusNode.value = this.getNodeDescription(
|
||||
selectionController.focusNode,
|
||||
selectionController.focusOffset
|
||||
);
|
||||
this.#elements.focusOffset.value = selectionController.focusOffset;
|
||||
this.#elements.anchorNode.value = this.getNodeDescription(
|
||||
selectionController.anchorNode,
|
||||
selectionController.anchorOffset
|
||||
);
|
||||
this.#elements.anchorOffset.value = selectionController.anchorOffset;
|
||||
this.#elements.focusInline.value = this.getNodeDescription(
|
||||
selectionController.focusInline
|
||||
);
|
||||
this.#elements.anchorInline.value = this.getNodeDescription(
|
||||
selectionController.anchorInline
|
||||
);
|
||||
this.#elements.focusParagraph.value = this.getNodeDescription(
|
||||
selectionController.focusParagraph
|
||||
);
|
||||
this.#elements.anchorParagraph.value = this.getNodeDescription(
|
||||
selectionController.anchorParagraph
|
||||
);
|
||||
this.#elements.startContainer.value = this.getNodeDescription(selectionController.startContainer);
|
||||
this.#elements.endContainer.value = this.getNodeDescription(selectionController.endContainer);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue