Close open prosemirror documents during reset

This commit is contained in:
Carlos Fernandez 2025-12-21 22:26:19 -05:00
parent e10dc83cd9
commit 25f87f1baa

View file

@ -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();
} }