Added convertSymbol for item's desc and actor's notes
This commit is contained in:
@@ -42,12 +42,31 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the actor.
|
||||
* @param event
|
||||
* @param formData
|
||||
* Activate a named TinyMCE text editor
|
||||
* @param {string} name The named data field which the editor modifies.
|
||||
* @param {object} options TinyMCE initialization options passed to TextEditor.create
|
||||
* @param {string} initialContent Initial text content for the editor area.
|
||||
* @override
|
||||
*/
|
||||
_updateObject(event, formData) {
|
||||
return this.object.update(formData);
|
||||
activateEditor(name, options = {}, initialContent = "") {
|
||||
if (name === "data.notes.value" && initialContent) {
|
||||
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
|
||||
}
|
||||
super.activateEditor(name, options, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called upon form submission after form data is validated
|
||||
* @param event {Event} The initial triggering submission event
|
||||
* @param formData {Object} The object of validated form data with which to update the object
|
||||
* @returns {Promise} A Promise which resolves once the update operation has completed
|
||||
* @override
|
||||
*/
|
||||
async _updateObject(event, formData) {
|
||||
if (formData["data.notes.value"]) {
|
||||
formData["data.notes.value"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.notes.value"], true);
|
||||
}
|
||||
return super._updateObject(event, formData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { HelpersL5r5e } from "../helpers.js";
|
||||
import { TwentyQuestions } from "./twenty-questions.js";
|
||||
import { RollL5r5e } from "../dice/roll.js";
|
||||
|
||||
@@ -320,7 +319,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
if (!id) {
|
||||
continue;
|
||||
}
|
||||
const item = await HelpersL5r5e.getObjectGameOrPack(id, "Item");
|
||||
const item = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack(id, "Item");
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { L5R5E } from "./config.js";
|
||||
import { ItemL5r5e } from "./item.js";
|
||||
|
||||
/**
|
||||
@@ -21,7 +20,7 @@ export class HelpersL5r5e {
|
||||
*/
|
||||
static getSkillsList(useGroup = false) {
|
||||
if (!useGroup) {
|
||||
return Array.from(L5R5E.skills).map(([id, cat]) => ({
|
||||
return Array.from(CONFIG.l5r5e.skills).map(([id, cat]) => ({
|
||||
id: id,
|
||||
cat: cat,
|
||||
label: game.i18n.localize(`l5r5e.skills.${cat}.${id}`),
|
||||
@@ -139,4 +138,18 @@ export class HelpersL5r5e {
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert (op), (ex)... to associated symbols for content/descriptions
|
||||
*/
|
||||
static convertSymbols(text, toSymbol) {
|
||||
CONFIG.l5r5e.symbols.forEach((cfg, tag) => {
|
||||
if (toSymbol) {
|
||||
text = text.replace(tag, `<i class="${cfg.class}" title="${game.i18n.localize(cfg.label)}"></i>`);
|
||||
} else {
|
||||
text = text.replace(new RegExp(`<i class="${cfg.class}" title="[^"]*"></i>`, "gi"), tag);
|
||||
}
|
||||
});
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,34 @@ export class ItemSheetL5r5e extends ItemSheet {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate a named TinyMCE text editor
|
||||
* @param {string} name The named data field which the editor modifies.
|
||||
* @param {object} options TinyMCE initialization options passed to TextEditor.create
|
||||
* @param {string} initialContent Initial text content for the editor area.
|
||||
* @override
|
||||
*/
|
||||
activateEditor(name, options = {}, initialContent = "") {
|
||||
if (name === "data.description" && initialContent) {
|
||||
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
|
||||
}
|
||||
super.activateEditor(name, options, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called upon form submission after form data is validated
|
||||
* @param event {Event} The initial triggering submission event
|
||||
* @param formData {Object} The object of validated form data with which to update the object
|
||||
* @returns {Promise} A Promise which resolves once the update operation has completed
|
||||
* @override
|
||||
*/
|
||||
async _updateObject(event, formData) {
|
||||
if (formData["data.description"]) {
|
||||
formData["data.description"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.description"], true);
|
||||
}
|
||||
return super._updateObject(event, formData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to events from the sheet.
|
||||
* @param html HTML content of the sheet.
|
||||
@@ -79,15 +107,6 @@ export class ItemSheetL5r5e extends ItemSheet {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the item with data from the sheet.
|
||||
* @param event
|
||||
* @param formData
|
||||
*/
|
||||
_updateObject(event, formData) {
|
||||
return this.object.update(formData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create drag-and-drop workflow handlers for this Application
|
||||
* @return An array of DragDrop handlers
|
||||
|
||||
@@ -12,7 +12,7 @@ export class BaseJournalSheetL5r5e extends JournalSheet {
|
||||
*/
|
||||
activateEditor(name, options = {}, initialContent = "") {
|
||||
if (initialContent) {
|
||||
initialContent = this._convertSymbols(initialContent, false);
|
||||
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
|
||||
}
|
||||
super.activateEditor(name, options, initialContent);
|
||||
}
|
||||
@@ -27,23 +27,8 @@ export class BaseJournalSheetL5r5e extends JournalSheet {
|
||||
async _updateObject(event, formData) {
|
||||
// event.type = mcesave / submit
|
||||
if (formData.content) {
|
||||
formData.content = this._convertSymbols(formData.content, true);
|
||||
formData.content = game.l5r5e.HelpersL5r5e.convertSymbols(formData.content, true);
|
||||
}
|
||||
return super._updateObject(event, formData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert (op), (ex)... to associated symbols
|
||||
* @private
|
||||
*/
|
||||
_convertSymbols(text, toSymbol) {
|
||||
CONFIG.l5r5e.symbols.forEach((cfg, tag) => {
|
||||
if (toSymbol) {
|
||||
text = text.replace(tag, `<i class="${cfg.class}" title="${game.i18n.localize(cfg.label)}"></i>`);
|
||||
} else {
|
||||
text = text.replace(new RegExp(`<i class="${cfg.class}" title="[^"]*"></i>`, "gi"), tag);
|
||||
}
|
||||
});
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user