Begin prototyping a popout text editor for use across multiple sheet types
This commit is contained in:
parent
97af3801c4
commit
71684fcbe9
4 changed files with 64 additions and 0 deletions
51
module/dialogs/PopoutTextEditor.mjs
Normal file
51
module/dialogs/PopoutTextEditor.mjs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
export class PopoutTextEditor extends FormApplication {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a form
|
||||||
|
*/
|
||||||
|
static create(value) {};
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
constructor(actor, property, options = {}) {
|
||||||
|
super(actor, options);
|
||||||
|
this.property = property;
|
||||||
|
};
|
||||||
|
|
||||||
|
static get defaultOptions() {
|
||||||
|
const opts = mergeObject({
|
||||||
|
...super.defaultOptions,
|
||||||
|
title: `Rich Text Editor`,
|
||||||
|
template: `systems/dotdungeon/templates/dialogs/text-editor.hbs`,
|
||||||
|
width: 500,
|
||||||
|
height: 600,
|
||||||
|
submitOnClose: false,
|
||||||
|
resizable: true,
|
||||||
|
});
|
||||||
|
return opts;
|
||||||
|
};
|
||||||
|
|
||||||
|
async getData() {
|
||||||
|
const ctx = await super.getData();
|
||||||
|
|
||||||
|
ctx.editor = {
|
||||||
|
engine: `prosemirror`,
|
||||||
|
collaborate: true,
|
||||||
|
content: await TextEditor.enrichHTML(
|
||||||
|
await getProperty(this.document, this.property),
|
||||||
|
{
|
||||||
|
relativeTo: this.object,
|
||||||
|
secrets: this.object.isOwner,
|
||||||
|
async: true
|
||||||
|
}
|
||||||
|
),
|
||||||
|
target: this.property,
|
||||||
|
};
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
};
|
||||||
|
|
||||||
|
async _updateObject(_event, formData) {
|
||||||
|
console.log(formData);
|
||||||
|
this.document.update({ [this.property]: formData["text"] })
|
||||||
|
};
|
||||||
|
};
|
||||||
5
styles/dialog/text-editor.scss
Normal file
5
styles/dialog/text-editor.scss
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
.dialog--text-editor {
|
||||||
|
[role="application"] {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
@use "./global/design-v2.scss";
|
@use "./global/design-v2.scss";
|
||||||
|
|
||||||
@use "./dialog/DiceList.scss";
|
@use "./dialog/DiceList.scss";
|
||||||
|
@use "./dialog/text-editor.scss";
|
||||||
|
|
||||||
@use "./sheets/partials/stat.scss";
|
@use "./sheets/partials/stat.scss";
|
||||||
@use "./sheets/partials/skill.scss";
|
@use "./sheets/partials/skill.scss";
|
||||||
|
|
|
||||||
7
templates/dialogs/text-editor.hbs
Normal file
7
templates/dialogs/text-editor.hbs
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<form class="dialog--text-editor flexcol">
|
||||||
|
{{editor
|
||||||
|
editor.content
|
||||||
|
target=editor.target
|
||||||
|
collaborate=editor.collaborate
|
||||||
|
}}
|
||||||
|
</form>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue