Added convertSymbol for item's desc and actor's notes

This commit is contained in:
Vlyan
2021-01-02 12:35:08 +01:00
parent 2ceb501543
commit 331872e84f
6 changed files with 71 additions and 36 deletions

View File

@@ -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;
}
}