Commit Graph
1 Commits
Author SHA1 Message Date
David Richardson 5a1845957e AppKit: Implement CPOpenPanel for the browser
* CPItemProvider.j: Introduce CPItemProvider, modelled on NSItemProvider.
  - Register data representations keyed by MIME type, with wildcard matching.
  - Load representations asynchronously, completing inside a run loop pass.
  - Read browser File objects with FileReader.
  - Document remaining NSItemProvider compatibility gaps via TODO comments.

* Foundation.j: Import CPItemProvider.j.

* CPPlatformFilePanel.j: Introduce the DOM platform class that runs the browser's file dialog through a hidden file input.

* CPOpenPanel.j: Replace the NativeHost implementation with a browser implementation.
  - Implement -beginWithCompletionHandler: and -beginSheetModalForWindow:completionHandler:.
  - Add allowed file types, message, prompt, and an accessory view behind an Options button.
  - Validate chosen files through the window delegate's panel:validateURL:error:.
  - Add -itemProviders, and -URLs holding file names.
  - Raise an exception from -runModal.
  - Document remaining NSOpenPanel compatibility gaps via TODO comments.

* CPTextView.j: Insert images through CPOpenPanel and CPItemProvider, for both -insertImage: and paste.

* CPItemProviderTest.j, CPOpenPanelTest.j: Add unit tests covering registration, loading, type matching, panel results, and cancelled runs.
2026-11-02 14:52:41 -06:00