diff --git a/module/dialogs/PopoutTextEditor.mjs b/module/dialogs/PopoutTextEditor.mjs new file mode 100644 index 0000000..fc74b62 --- /dev/null +++ b/module/dialogs/PopoutTextEditor.mjs @@ -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"] }) + }; +}; diff --git a/styles/dialog/text-editor.scss b/styles/dialog/text-editor.scss new file mode 100644 index 0000000..1c581c6 --- /dev/null +++ b/styles/dialog/text-editor.scss @@ -0,0 +1,5 @@ +.dialog--text-editor { + [role="application"] { + height: 100%; + } +} \ No newline at end of file diff --git a/styles/root.scss b/styles/root.scss index 2d2dd72..65c8cd5 100644 --- a/styles/root.scss +++ b/styles/root.scss @@ -9,6 +9,7 @@ @use "./global/design-v2.scss"; @use "./dialog/DiceList.scss"; +@use "./dialog/text-editor.scss"; @use "./sheets/partials/stat.scss"; @use "./sheets/partials/skill.scss"; diff --git a/templates/dialogs/text-editor.hbs b/templates/dialogs/text-editor.hbs new file mode 100644 index 0000000..77e2c21 --- /dev/null +++ b/templates/dialogs/text-editor.hbs @@ -0,0 +1,7 @@ +
\ No newline at end of file