[PR][Feature] Support multiline adversary and character names (#1437)

* Support multiline adversary names

* Create fake placeholder

* Also support multiline character names
This commit is contained in:
Carlos Fernandez 2025-12-19 16:57:15 -05:00 committed by GitHub
parent 5f6d08d8c2
commit 474cf28a53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 46 additions and 22 deletions

View file

@ -179,6 +179,7 @@ export default function DHApplicationMixin(Base) {
super._attachPartListeners(partId, htmlElement, options);
this._dragDrop.forEach(d => d.bind(htmlElement));
// Handle delta inputs
for (const deltaInput of htmlElement.querySelectorAll('input[data-allow-delta]')) {
deltaInput.dataset.numValue = deltaInput.value;
deltaInput.inputMode = 'numeric';
@ -232,6 +233,25 @@ export default function DHApplicationMixin(Base) {
handleUpdate();
});
}
// Handle contenteditable
for (const input of htmlElement.querySelectorAll('[contenteditable][data-property]')) {
const property = input.dataset.property;
input.addEventListener("blur", () => {
const selection = document.getSelection();
if (input.contains(selection.anchorNode)) {
selection.empty();
}
this.document.update({ [property]: input.textContent });
});
input.addEventListener("keydown", event => {
if (event.key === "Enter") input.blur();
});
// Chrome sometimes add <br>, which aren't a problem for the value but are for the placeholder
input.addEventListener("input", () => input.querySelectorAll("br").forEach((i) => i.remove()));
}
}
/**@inheritdoc */