Skip to content

Commit

Permalink
Merge pull request #2571 from Azmoria/Fix---issue-with-send-to-game-l…
Browse files Browse the repository at this point in the history
…og-for-spells/new-entries-that-have-stat-blocks

Fix - issue with send to game log for spells/new entries that have 2024 stat blocks
  • Loading branch information
Azmoria authored Oct 16, 2024
2 parents 98025d8 + 9d2d089 commit 098d041
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CoreFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ function inject_sidebar_send_to_gamelog_button(sidebarPaneContent) {
// make sure the button grabs dynamically. Don't hold HTML in the button click block because clicking on items back to back will fuck that up

let sidebar = sidebarPaneContent.closest(".ct-sidebar__portal");
let toInject = $(`<div></div>`);
let toInject = $(`<div style='width: 100%;'></div>`);
toInject.attr("class", sidebarPaneContent.attr("class")); // set the class on our new element
// required
toInject.append(sidebar.find(".ct-sidebar__header").clone());
Expand Down
3 changes: 3 additions & 0 deletions Journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,8 @@ class JournalManager{
// replace all "to hit" and "damage" rolls

let currentElement = $(target).clone()
const dashToMinus = /([\s>])−(\d)/gi


// apply most specific regex first matching all possible ways to write a dice notation
// to account for all the nuances of DNDB dice notation.
Expand All @@ -1370,6 +1372,7 @@ class JournalManager{
const actionType = "roll"
const rollType = "AboveVTT"
const updated = currentElement.html()
.replaceAll(dashToMinus, `$1-$2`)
.replaceAll(damageRollRegexBracket, `<button data-exp='$3' data-mod='$4' data-rolltype='damage' data-actiontype='${actionType}' class='avtt-roll-button' title='${actionType}'> $1$2$5</button>`)
.replaceAll(damageRollRegex, `$1<button data-exp='$3' data-mod='$4' data-rolltype='damage' data-actiontype='${actionType}' class='avtt-roll-button' title='${actionType}'> $2</button>$5`)
.replaceAll(hitRollRegexBracket, `<button data-exp='1d20' data-mod='$2' data-rolltype='to hit' data-actiontype=${actionType} class='avtt-roll-button' title='${actionType}'> $1$2$3</button>`)
Expand Down
2 changes: 1 addition & 1 deletion MessageBroker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ class MessageBroker {
//Security logic to prevent content being sent which can execute JavaScript.
data.player = DOMPurify.sanitize( data.player,{ALLOWED_TAGS: []});
data.img = DOMPurify.sanitize( data.img,{ALLOWED_TAGS: []});
data.text = DOMPurify.sanitize( data.text,{ALLOWED_TAGS: ['video','img','div','p', 'b', 'button', 'span', 'style', 'path', 'svg', 'a', 'hr', 'ul', 'li', 'h3', 'h2', 'h4', 'h1'], ADD_ATTR: ['target']}); //This array needs to include all HTML elements the extension sends via chat.
data.text = DOMPurify.sanitize( data.text,{ALLOWED_TAGS: ['video','img','div','p', 'b', 'button', 'span', 'style', 'path', 'svg', 'a', 'hr', 'ul', 'li', 'h3', 'h2', 'h4', 'h1', 'table', 'tr', 'td', 'th'], ADD_ATTR: ['target']}); //This array needs to include all HTML elements the extension sends via chat.

if(data.dmonly && !(window.DM) && !local) // /dmroll only for DM of or the user who initiated it
return $("<div/>");
Expand Down
7 changes: 6 additions & 1 deletion abovevtt.css
Original file line number Diff line number Diff line change
Expand Up @@ -10636,7 +10636,12 @@ div#playlistFields {
display: flex;
gap: 10px
}

.glc-game-log .stat-block .stats{
flex-direction:column;
}
.glc-game-log .stat-block .stats>table{
margin:0px;
}
.stat-block .stats+p {
margin-top: 10px
}
Expand Down

0 comments on commit 098d041

Please sign in to comment.