Fix export/print when Preview Pane is hidden#274
Merged
Conversation
Implements a general performAfterRender: mechanism that defers operations until the WebView finishes rendering. This fixes issue #16 where PDF export, HTML export, printing, and copy operations would use stale content when the preview pane was hidden. Changes: - Add renderCompletionHandlers array property for queued operations - Add performAfterRender: method to defer operations when preview hidden - Add invokeRenderCompletionHandlers method called after WebView loads - Update copyHtml: to use performAfterRender: (replaces copying flag) - Update exportHtml: to defer HTML generation until after render - Update printDocumentWithSettings: to defer print until after render - Remove obsolete copying property and related code - Add MPRenderDeferralTests.m with 17 tests for the mechanism Related to #16
The method needs to be visible to the static function MPGetPreviewLoadingCompletionHandler which is defined before the @implementation block. Related to #16
Add graceful skip logic when WebView doesn't render in headless CI environment. The test now skips early if no display is available or if handlers aren't invoked after toggling preview visibility. Related to #16
- Fix methodSignatureForSelector: call to use printDelegate instead of NSMethodSignature class (was incorrect) - Add weak-strong pattern to copyHtml: and exportHtml: blocks to prevent retain cycles when document is deallocated before render completes Related to #16
Contributor
Code Coverage ReportCurrent Coverage: 52.77% Coverage Details (Summary) |
Owner
Author
|
Closes #16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
performAfterRender:mechanism to defer operations until WebView renders when preview pane is hiddencopyHtml:fix to use the new general mechanismDetails
When the preview pane is hidden,
needsHtmlreturns NO and the WebView doesn't render markdown changes. This caused export/print operations to output stale HTML. The fix queues operations inrenderCompletionHandlersand triggers a render cycle, then invokes handlers whenwebView:didFinishLoadForFrame:or MathJax completion fires.Test plan
Related to #16