From c9d47a567bc95f3d2c6b6e20414796486d4108c0 Mon Sep 17 00:00:00 2001 From: Ying Zhong <0x00eeee@gmail.com> Date: Tue, 16 Jun 2026 17:44:45 +0800 Subject: [PATCH] Consolidate Writing Tools definition --- .../Sources/Main/AppWritingTools.swift | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/MarkEditMac/Sources/Main/AppWritingTools.swift b/MarkEditMac/Sources/Main/AppWritingTools.swift index dca3aad2b..3d1ed9803 100644 --- a/MarkEditMac/Sources/Main/AppWritingTools.swift +++ b/MarkEditMac/Sources/Main/AppWritingTools.swift @@ -10,17 +10,26 @@ import MarkEditKit @available(macOS 15.1, *) enum AppWritingTools { + // Source/WebKit/Platform/spi/Cocoa/Modules/WritingTools_SPI/WritingToolsSPI.h enum Tool: Int { - case panel = 0 + case index = 0 + case proofread = 1 case rewrite = 2 - case makeFriendly = 11 - case makeProfessional = 12 - case makeConcise = 13 - case summarize = 21 - case createKeyPoints = 22 - case makeList = 23 - case makeTable = 24 + case rewriteProofread = 3 + + case rewriteFriendly = 11 + case rewriteProfessional = 12 + case rewriteConcise = 13 + case rewriteOpenEnded = 19 + + case transformSummarize = 21 + case transformKeyPoints = 22 + case transformList = 23 + case transformTable = 24 + + case smartReply = 101 + case compose = 201 } @@ -28,15 +37,15 @@ enum AppWritingTools { guard let controller = NSApp.windows .compactMap(\.contentViewController) .first(where: { $0.className == "WTWritingToolsViewController" }) else { - return .panel + return .index } // WTWritingToolsConfiguration guard let target = invokeObject(controller, selector: "writingToolsConfiguration") else { - return .panel + return .index } - return .init(rawValue: invokeInt(target, selector: "requestedTool")) ?? .panel + return .init(rawValue: invokeInt(target, selector: "requestedTool")) ?? .index } static var affordanceIcon: NSImage? { @@ -70,12 +79,12 @@ enum AppWritingTools { return false } - return shouldReselect(with: .init(rawValue: menuItem.tag) ?? .panel) + return shouldReselect(with: .init(rawValue: menuItem.tag) ?? .index) } static func shouldReselect(with tool: Tool) -> Bool { - // Compose mode can start without text selections - tool != .compose + // These tools can start without text selections + tool != .smartReply && tool != .compose } }