fix(superdoc): expose header/footer edits in update callbacks#2368
fix(superdoc): expose header/footer edits in update callbacks#2368luccas-harbour wants to merge 5 commits intomainfrom
Conversation
caio-pizzol
left a comment
There was a problem hiding this comment.
@luccas-harbour clean approach, event listeners are set up and cleaned up in all the right places. no correctness blockers.
left three small inline comments — one consistency fix and two simplification ideas.
on tests: the happy path is covered well. three gaps worth considering: (1) no test that events stop firing after leaving header/footer mode, (2) no test for the body-editor path through the new payload builders, (3) footer surface isn't tested end-to-end (only header).
| * Clean up all resources. | ||
| */ | ||
| destroy(): void { | ||
| this.#teardownActiveEditorEventBridge(); |
There was a problem hiding this comment.
the resetSession callback in initialize() sets #activeEditor = null without calling #teardownActiveEditorEventBridge() first. every other place that clears #activeEditor does the teardown. not a bug since the editor is already destroyed, but the leftover cleanup ref could log a warning next time around. worth adding for consistency?
There was a problem hiding this comment.
sounds good, done
| this.#activeEditorEventCleanup = () => { | ||
| try { | ||
| editor.off?.('update', emitSurfaceUpdate); | ||
| } catch (error) { |
There was a problem hiding this comment.
the individual try/catch blocks around each editor.off() are heavier than anywhere else in the codebase — other spots just call editor.off() directly. the outer try/catch in #teardownActiveEditorEventBridge already covers this. ok to simplify?
There was a problem hiding this comment.
done, I simplified this
packages/superdoc/src/SuperDoc.vue
Outdated
|
|
||
| const onEditorUpdate = ({ editor }) => { | ||
| proxy.$superdoc.emit('editor-update', { editor }); | ||
| const buildEditorUpdatePayload = ({ |
There was a problem hiding this comment.
these two builder functions (buildEditorUpdatePayload and buildEditorTransactionPayload) do the same thing for the first 5 fields — only transaction and duration differ. could pull the shared part into one helper to keep them in sync.
There was a problem hiding this comment.
done, I refactored this to use a common helper
Summary
This PR makes header and footer edits observable through the same public callback surface as body edits.
Before this change, typing in header/footer child editors updated internal state, but those edits were not propagated through the public
onEditorUpdateandonTransactionhooks with the same immediacy as body edits. This caused integrations that rely on those callbacks for dirty-state tracking, autosave, and other live reactions to miss header/footer changes until blur.What Changed
updateandtransactionevents through the header/footer session flow.PresentationEditoras header/footer-specific presentation events.sourceEditorsurface(body,header, orfooter)headerIdsectionTypeTesting
PresentationEditortest that verifies live header/footer child-editor updates and transactions are re-emitted immediately.SuperDoc.vuetest that verifies header/footer presentation events are forwarded intoeditor-updateandonTransaction.