Compare commits
1 Commits
92e15eff2e
...
e637d8e806
| Author | SHA1 | Date | |
|---|---|---|---|
|
e637d8e806
|
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"id": "asc-starwars-style-journal",
|
||||
"title": "Star Wars Style Journal",
|
||||
"version": "0.3.1",
|
||||
"version": "0.4",
|
||||
"download": "https://gitea.ascorrea.com/asc/asc-starwars-style-journal/releases/download/latest/module.zip",
|
||||
"manifest": "https://gitea.ascorrea.com/asc/asc-starwars-style-journal/releases/download/latest/module.json",
|
||||
"compatibility": {
|
||||
"minimum": "12",
|
||||
"verified": "12"
|
||||
},
|
||||
"scripts": ["scripts/vendor/turndown.js"],
|
||||
"esmodules": ["scripts/asc-starwars.js"],
|
||||
"styles": [
|
||||
"styles/asc-ffg-starwars.css",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var turndownService = new TurndownService()
|
||||
|
||||
export class StarWarsStyleJournalSheet extends JournalSheet {
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
@@ -7,6 +9,8 @@ export class StarWarsStyleJournalSheet extends JournalSheet {
|
||||
async _render(force, options) {
|
||||
await super._render(force, {...options, collapsed:true});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export class StarWarsTextPageSheet extends JournalTextPageSheet {
|
||||
@@ -18,4 +22,33 @@ export class StarWarsTextPageSheet extends JournalTextPageSheet {
|
||||
resizable: true,
|
||||
});
|
||||
}
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
// Ensure the button is not duplicated
|
||||
if (html.find(".asc-copy-button").length > 0) return;
|
||||
|
||||
// Create the button element
|
||||
const button = $(`<div class="asc-copy"><button><i class="fas fa-clipboard"></i>Copy</button></div>`);
|
||||
|
||||
// Insert it inside the .journal-header
|
||||
const journal_header = html.find(".journal-header aside")
|
||||
journal_header.append(button);
|
||||
|
||||
// Attach event listener
|
||||
button.click(this._onCopyButtonClick.bind(this));
|
||||
}
|
||||
|
||||
_onCopyButtonClick(event) {
|
||||
event.preventDefault();
|
||||
var editorContent = this.element.find(".editor-content").html();
|
||||
|
||||
// Replace linked items
|
||||
editorContent = editorContent.replace(/@\w+\[.+\]\{(.*?)\}/g,"$1")
|
||||
|
||||
const markdownContent = turndownService.turndown(editorContent)
|
||||
|
||||
// Copy to clipboard
|
||||
navigator.clipboard.writeText(markdownContent)
|
||||
.then(()=>ui.notifications.info("Journal content copied as Markdown!"));
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,13 @@
|
||||
src: url("../fonts/SWCrawlBody.ttf");
|
||||
}
|
||||
|
||||
.asc-starwars .asc-copy {
|
||||
width: 100%;
|
||||
button {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.asc-starwars .journal-entry-content, .asc-starwars .editor-container, .chat-message.asc-starwars .message-content {
|
||||
background-image:url(../artwork/stars.png) !important;
|
||||
background-repeat:repeat !important;
|
||||
|
||||
Reference in New Issue
Block a user