Skip to content

Commit

Permalink
Make compatible with Monk's Enhanced Journal
Browse files Browse the repository at this point in the history
  • Loading branch information
farling42 committed Feb 15, 2024
1 parent e5d2638 commit f5b027f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.51.0

- With Monk's Enhanced Journal module, support creation of `@PDF` links when dragging a PDF page title to a journal page.

## 0.50.0

- Only display "Data Inspector" and "Show PDF Fields" in the Actor/Item PDF sheet if the user is a GM.
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -15,6 +15,10 @@ It also generates reads the Outline from the PDF file to use as the Table of Con

The module option "Immediately Display PDF" will remove the "Load PDF" button from the PDF pages of journal and will instead immediately load the PDF into the window.

## Create links to sections within a PDF.

The page header or an individual section from the table of contents of a PDF journal page can be dragged to another journal page in order to create a `@PDF` link to that PDF document. When the page header is dragged from the TOC, then a link is created to the currently visible page within the PDF.

## PDF Character Sheets

This module will allow a fillable PDF document to be used as the Actor sheet for actors.
Expand Down
17 changes: 10 additions & 7 deletions scripts/pdf-linker.mjs
Expand Up @@ -134,13 +134,16 @@ function JournalEntryPage_createDocumentLink(wrapped, eventData, args) {
// Use page=xxx as slug
let pagenum=1;
let sheet = this.parent?.sheet; // JournalEntry
if (sheet && sheet._pages[sheet.pageIndex]._id == this.id)
{
let iframe = sheet.element?.find('iframe');
if (iframe?.length>0) {
// Read current page from PDF viewer, then remove the user-configured offset from that number.
pagenum = iframe[0].contentWindow.PDFViewerApplication.page - (this.getFlag(PDFCONFIG.MODULE_NAME, PDFCONFIG.FLAG_OFFSET) ?? 0);
}
let iframe;

if (game.MonksEnhancedJournal)
iframe = game.MonksEnhancedJournal.journal?.element?.find('iframe');
else if (sheet && sheet._pages && sheet._pages[sheet.pageIndex]._id == this.id)
iframe = sheet.element?.find('iframe');

if (iframe?.length>0) {
// Read current page from PDF viewer, then remove the user-configured offset from that number.
pagenum = iframe[0].contentWindow.PDFViewerApplication.page - (this.getFlag(PDFCONFIG.MODULE_NAME, PDFCONFIG.FLAG_OFFSET) ?? 0);
}
slug = `page=${pagenum}`
label = this.name;
Expand Down

0 comments on commit f5b027f

Please sign in to comment.