From e9fe7ed190e4d1444c3b9e74cbcb719e6a862d01 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 11 Jun 2022 16:43:36 -0400 Subject: [PATCH] Bug fix for WA API change as 1.3.3 release --- module.json | 4 ++-- module/framework.js | 18 +++++++++++++----- module/journal.js | 16 ++++++++-------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/module.json b/module.json index 9a1fe03..28af77d 100644 --- a/module.json +++ b/module.json @@ -5,7 +5,7 @@ "author": "Atropos", "authors": [], "url": "https://github.com/foundryvtt/world-anvil", - "version": "1.3.2", + "version": "1.3.3", "minimumCoreVersion": "0.7.6", "compatibleCoreVersion": "9", "scripts": [], @@ -26,5 +26,5 @@ "system": [], "dependencies": [], "manifest": "https://raw.githubusercontent.com/foundryvtt/world-anvil/master/module.json", - "download": "https://github.com/foundryvtt/world-anvil/archive/refs/tags/release-1.3.2.zip" + "download": "https://github.com/foundryvtt/world-anvil/archive/refs/tags/release-1.3.3.zip" } diff --git a/module/framework.js b/module/framework.js index ebd1f1b..e89d98a 100644 --- a/module/framework.js +++ b/module/framework.js @@ -55,12 +55,20 @@ export const ARTICLE_CSS_CLASSES = { * @property {Category} [category] A parent category to which this article belongs * @property {object[]} sections Sections of the Article * @property {object[]} relations Relations to the Article - * @property {string} content_parsed Parsed HTML content for the article + * @property {string} contentParsed Parsed HTML content for the article * @property {string} portrait A portrait image URL * @property {string} cover A cover image URL * @property {JournalEntry} [entry] A linked JournalEntry document for this article */ +/** + * @typedef {Object} ArticleSection + * @property {string} title The section title + * @property {string} position A special positional assignment for the section + * @property {string} content The original WorldAnvil content in bbCode format + * @property {string} contentParsed The HTML parsed content of the section + */ + /** * @typedef {Object} ParsedArticleResult Used by the hook WAParseArticle. It contains primary data which could be altered by additional modules * @property {string} html What will become the journal entry content. Is in html format @@ -215,7 +223,7 @@ export function getArticleContent(article) { const includeSidebars = sectionEntries.some(s => { const [id, section] = s; if ( id !== DISPLAY_SIDEBAR_SECTION_ID ) return false; - return section.content_parsed === "1" + return section.contentParsed === "1" }); // Determine whether there are secrets inside this article @@ -252,13 +260,13 @@ export function getArticleContent(article) { const isLongContent = section.content.length > 100; if( isLongContent ) { sections += `

${title}

`; - sections += `\n

${section.content_parsed}


`; + sections += `\n

${section.contentParsed}


`; } // Display short-format content as a details list else { sections += `
${title}
`; - sections += `
${section.content_parsed}
`; + sections += `
${section.contentParsed}
`; } // End main section div @@ -281,7 +289,7 @@ export function getArticleContent(article) { // Combine content sections let content = `
`; - content += `

${article.content_parsed}

`; + content += `

${article.contentParsed}

`; content += "

"; content += aside; content += sections; diff --git a/module/journal.js b/module/journal.js index e2e0062..1c497bf 100644 --- a/module/journal.js +++ b/module/journal.js @@ -105,8 +105,8 @@ export default class WorldAnvilBrowser extends Application { // Check linked entry permissions article.entry = entries.find(e => e.getFlag("world-anvil", "articleId") === article.id); - article.visibleByPlayers = article.entry?.data.permission.default >= CONST.ENTITY_PERMISSIONS.OBSERVER; - + article.visibleByPlayers = article.entry?.data.permission.default >= CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER; + // Get the category to which the article belongs const category = categories.get(article.category?.id) || uncategorized; category.articles.push(article); @@ -243,11 +243,11 @@ export default class WorldAnvilBrowser extends Application { const category = this.categories.get(categoryId); const articles = category?.articles ?? []; const updates = articles.filter( a => { - return !a.entry?.data.permission.default < CONST.ENTITY_PERMISSIONS.OBSERVER; + return !a.entry?.data.permission.default < CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER; }).map( a => { return { _id: a.entry.id, - permission: { default: CONST.ENTITY_PERMISSIONS.OBSERVER } + permission: { default: CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER } } }); @@ -267,11 +267,11 @@ export default class WorldAnvilBrowser extends Application { const category = this.categories.get(categoryId); const articles = category?.articles ?? []; const updates = articles.filter( a => { - return a.entry?.data.permission.default >= CONST.ENTITY_PERMISSIONS.OBSERVER; + return a.entry?.data.permission.default >= CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER; }).map( a => { return { _id: a.entry.id, - permission: { default: CONST.ENTITY_PERMISSIONS.NONE } + permission: { default: CONST.DOCUMENT_PERMISSION_LEVELS.NONE } } }); @@ -292,7 +292,7 @@ export default class WorldAnvilBrowser extends Application { if( !entry ) { throw 'Can\'t find journal entry with id : ' + entryId; } const perms = { - default: CONST.ENTITY_PERMISSIONS.OBSERVER + default: CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER }; await entry.update({permission: perms}, {diff: false, recursive: false, noHook: true}); @@ -310,7 +310,7 @@ export default class WorldAnvilBrowser extends Application { if( !entry ) { throw 'Can\'t find journal entry with id : ' + entryId; } const perms = { - default: CONST.ENTITY_PERMISSIONS.NONE + default: CONST.DOCUMENT_PERMISSION_LEVELS.NONE }; await entry.update({permission: perms}, {diff: false, recursive: false, noHook: true});