generated from League-of-Foundry-Developers/FoundryVTT-Module-Template
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added clear all items, better handling of image, added text editor fo…
…r description
- Loading branch information
Showing
16 changed files
with
260 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/applications/dialogs/text-editor-dialog/text-editor-dialog-shell.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<script> | ||
import { localize } from '@typhonjs-fvtt/runtime/svelte/helper'; | ||
import { getContext } from "svelte"; | ||
import { ApplicationShell } from "@typhonjs-fvtt/runtime/svelte/component/core"; | ||
const { application } = getContext('external'); | ||
export let text; | ||
export let elementRoot; | ||
let form; | ||
function requestSubmit() { | ||
form.requestSubmit(); | ||
} | ||
function submit() { | ||
application.options.resolve(text); | ||
application.close(); | ||
} | ||
</script> | ||
|
||
<svelte:options accessors={true}/> | ||
|
||
<ApplicationShell bind:elementRoot> | ||
<form class="item-piles-flexcol" bind:this={form} on:submit|once|preventDefault={submit} style="padding:0.5rem;" | ||
autocomplete="off"> | ||
|
||
<textarea style="flex:1; resize: none;" bind:value={text}></textarea> | ||
|
||
<footer class="sheet-footer item-piles-flexrow" style="margin-top: 1rem; flex: 0;"> | ||
<button type="button" on:click|once={requestSubmit}> | ||
<i class="fas fa-check"></i> | ||
{localize("Okay")} | ||
</button> | ||
<button type="button" on:click={() => { application.close() }}> | ||
<i class="fas fa-times"></i> | ||
{localize("Cancel")} | ||
</button> | ||
</footer> | ||
|
||
</form> | ||
|
||
</ApplicationShell> |
56 changes: 56 additions & 0 deletions
56
src/applications/dialogs/text-editor-dialog/text-editor-dialog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import CONSTANTS from "../../../constants/constants.js"; | ||
|
||
export default class TextEditorDialog extends FormApplication { | ||
|
||
constructor(text, options) { | ||
super(); | ||
this.text = text; | ||
this.resolve = options.resolve; | ||
} | ||
|
||
static get defaultOptions() { | ||
return foundry.utils.mergeObject(super.defaultOptions, { | ||
title: game.i18n.localize("ITEM-PILES.Applications.DropItem.Title"), | ||
template: `${CONSTANTS.PATH}templates/text-editor.html`, | ||
width: 430, | ||
height: 350, | ||
classes: ["item-piles-app"], | ||
resizable: true | ||
}) | ||
} | ||
|
||
async getData(options) { | ||
const data = super.getData(options); | ||
data.text = this.text; | ||
return data; | ||
} | ||
|
||
static getActiveApps(id) { | ||
return Object.values(ui.windows).filter(app => app.id === `item-pile-text-editor-${id}`); | ||
} | ||
|
||
async _updateObject(event, formData) { | ||
this.resolve(formData.text); | ||
return this.close(); | ||
} | ||
|
||
async close(options) { | ||
this.resolve(null); | ||
return super.close(options); | ||
} | ||
|
||
static async show(text, options = {}) { | ||
const apps = options.id ? this.getActiveApps(options.id) : []; | ||
if (apps.length) { | ||
for (let app of apps) { | ||
app.render(false, { focus: true }); | ||
} | ||
return; | ||
} | ||
return new Promise((resolve) => { | ||
options.resolve = resolve; | ||
new this(text, options).render(true, { focus: true }); | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.