mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Close open prosemirror documents during reset
This commit is contained in:
parent
e10dc83cd9
commit
25f87f1baa
1 changed files with 8 additions and 2 deletions
|
|
@ -134,17 +134,23 @@ const registerNonConfigSettings = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers a reset and non-forced re-render on all given actors (if given)
|
* Triggers a reset and non-forced re-render on all given actors (if given)
|
||||||
* or all world actors and actors in all scenes to show immediate results for a changed setting.
|
* or all world actors and actors in all scenes to show immediate results for a changed setting.
|
||||||
*/
|
*/
|
||||||
function resetActors(actors) {
|
function resetActors(actors) {
|
||||||
actors ??= [
|
actors ??= [
|
||||||
game.actors.contents,
|
game.actors.contents,
|
||||||
game.scenes.contents.flatMap((s) => s.tokens.contents).flatMap((t) => t.actor ?? []),
|
game.scenes.contents.flatMap(s => s.tokens.contents).flatMap(t => t.actor ?? [])
|
||||||
].flat();
|
].flat();
|
||||||
actors = new Set(actors);
|
actors = new Set(actors);
|
||||||
for (const actor of actors) {
|
for (const actor of actors) {
|
||||||
|
for (const app of Object.values(actor.apps)) {
|
||||||
|
for (const element of app.element?.querySelectorAll('prose-mirror.active')) {
|
||||||
|
element.open = false; // This triggers a save
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
actor.reset();
|
actor.reset();
|
||||||
actor.render();
|
actor.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue