Skip to content

Commit

Permalink
Fix scrambleSpans error
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed May 12, 2024
1 parent 94b6337 commit cd8cca6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/module/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,13 @@ export default class PolyglotHooks {
const isOwnerOrGM = sheet.document?.isOwner || game.user.isGM;
const isEditable = data.editable;
const isTextSheet = sheet instanceof JournalTextPageSheet;
const [header, text, section] = html;

if (isTextSheet && !(sheet.object.parent.isOwner || isOwnerOrGM || isEditable)) {
if (sheet.document.isOwner) game.polyglot.insertHeaderButton(sheet.object.parent.sheet, html);
else game.polyglot.scrambleSpans();
else game.polyglot.scrambleSpans(sheet, html);
} else if (html.find(".polyglot-journal").length) {
if (isOwnerOrGM && html.find('[data-engine="prosemirror"]').length) game.polyglot.insertHeaderButton(sheet, html);
else if (!(isOwnerOrGM || isEditable)) game.polyglot.scrambleSpans();
else if (!(isOwnerOrGM || isEditable)) game.polyglot.scrambleSpans(sheet, html);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/module/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ export class Polyglot {
* @param {HTMLElement} html
*/
scrambleSpans(document, html) {
// eslint-disable-next-line no-unused-vars
const [header, text, section] = html;
const spans = section ? section.querySelectorAll("span.polyglot-journal") : header.querySelectorAll("span.polyglot-journal");
spans.forEach((e) => {
Expand Down

0 comments on commit cd8cca6

Please sign in to comment.