@@ -10,7 +10,7 @@ import {isMobile} from "../../util/functions";
1010import { Constants } from "../../constants" ;
1111import { highlightRender , lineNumberRender } from "../render/highlightRender" ;
1212import { processRender } from "../util/processCode" ;
13- import { isIPhone , isSafari , saveExportFile , setStorageVal } from "../util/compatibility" ;
13+ import { saveExportFile , setStorageVal } from "../util/compatibility" ;
1414import { useShell } from "../../util/pathName" ;
1515
1616export const afterExport = ( exportPath : string , msgId : string ) => {
@@ -90,14 +90,13 @@ export const exportImage = (id: string) => {
9090 item . textContent = ( index + 1 ) . toString ( ) ;
9191 } ) ;
9292 setTimeout ( ( ) => {
93- addScript ( `${ Constants . PROTYLE_CDN } /js/html-to-image.min.js?v=1.11.13` , "protyleHtml2image" ) . then ( async ( ) => {
94- let blob = await window . htmlToImage . toBlob ( exportDialog . element . querySelector ( ".b3-dialog__content" ) ) ;
95- if ( isIPhone ( ) || isSafari ( ) ) {
96- await window . htmlToImage . toBlob ( contentElement ) ;
97- await window . htmlToImage . toBlob ( contentElement ) ;
98- await window . htmlToImage . toBlob ( contentElement ) ;
99- blob = await window . htmlToImage . toBlob ( contentElement ) ;
100- }
93+ // modern-screenshot is used instead of html-to-image because the latter clones every
94+ // node and copies its full computed style one property at a time, which is O(nodes) with
95+ // a huge constant on WebKit/WKWebView (~15s for a mid-size doc on iOS vs ~3s on desktop).
96+ // modern-screenshot caches default styles per tag and only writes differing properties,
97+ // and it renders correctly in a single pass, so the old 3x Safari re-render hack is gone.
98+ addScript ( `${ Constants . PROTYLE_CDN } /js/modern-screenshot.min.js` , "protyleModernScreenshot" ) . then ( async ( ) => {
99+ const blob = await window . modernScreenshot . domToBlob ( contentElement , { type : "image/png" } ) ;
101100 const formData = new FormData ( ) ;
102101 formData . append ( "file" , blob , btnsElement [ 1 ] . getAttribute ( "data-title" ) ) ;
103102 formData . append ( "type" , "image/png" ) ;
0 commit comments