diff --git a/MarkEditKit/Sources/EditorMessageHandler.swift b/MarkEditKit/Sources/EditorMessageHandler.swift index a3eee7b23..3f1362023 100644 --- a/MarkEditKit/Sources/EditorMessageHandler.swift +++ b/MarkEditKit/Sources/EditorMessageHandler.swift @@ -22,6 +22,10 @@ public final class EditorMessageHandler: NSObject, Sendable, WKScriptMessageHand return (nil, message) } + guard message.frameInfo.isMainFrame else { + return reportError("Native bridge is unavailable to subframes") + } + guard message.name == "bridge", let body = message.body as? [String: Any] else { return reportError("Invalid message payload: \(message.name), \(message.body)") } diff --git a/MarkEditMac/Sources/Editor/Controllers/EditorViewController.swift b/MarkEditMac/Sources/Editor/Controllers/EditorViewController.swift index 55ef735ad..aab37b80a 100644 --- a/MarkEditMac/Sources/Editor/Controllers/EditorViewController.swift +++ b/MarkEditMac/Sources/Editor/Controllers/EditorViewController.swift @@ -148,7 +148,7 @@ final class EditorViewController: NSViewController { controller.addUserScript(WKUserScript( source: $0, injectionTime: .atDocumentEnd, - forMainFrameOnly: false + forMainFrameOnly: true )) } diff --git a/QuickLookMac/QuickLookConfig.swift b/QuickLookMac/QuickLookConfig.swift index 982df663f..dcace03f6 100644 --- a/QuickLookMac/QuickLookConfig.swift +++ b/QuickLookMac/QuickLookConfig.swift @@ -28,7 +28,7 @@ extension QuickLookViewController { WKUserScript( source: EditorUserAsset.script(for: url, contents: contents), injectionTime: .atDocumentEnd, - forMainFrameOnly: false + forMainFrameOnly: true ) } }