Skip to content

Add openFile hook to AttachesTool to support custom file opening logic #81

@pasichDev

Description

@pasichDev

This update introduces a new openFile hook to the AttachesTool config.
It allows custom file-opening logic beyond the default browser behavior.

This is especially useful for:

  • WebView environments (Android/iOS apps)
  • Desktop applications that embed Editor.js
  • Custom file viewers / sandboxed environments

When the hook is present, openFile(fileData) is executed instead of opening file.url in a new tab.
If the hook is missing or throws an error — the fallback browser action is triggered.

📌 Why this is useful
✔ Works in Android WebView

Browser links (target=_blank) do not work in WebView — but you can call the Android method.

🧩 Short PR Example Description
Added a new config option openFile to AttachesTool.
If provided, it overrides the default action when the user clicks the file icon.
Useful for WebView apps (Android/iOS), desktop clients, and custom environments where
opening external URLs is restricted. Falls back to the standard browser behavior
when not defined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions