BowPad icon indicating copy to clipboard operation
BowPad copied to clipboard

Plugin with UI

Open wmjordan opened this issue 4 years ago • 2 comments

Is it possible to present some UI to the user from the plugin?

For instance, the plugin can be an HTML page, whereas scripts in that page can access functions provided by BowPad. When that plugin is executed, a modal dialog presents with HTML content rendered inside will be displayed. When the user clicks the Close button on the top-right corner of the dialog box, the control switches back to BowPad.

For security concerns, the HTML plugin can only access local files (other scripts, images or CSS files). Files from the Internet are prohibited.

wmjordan avatar Oct 28 '20 07:10 wmjordan

it's possible, yes. You can do that in jscript or vbscript without having BP to provide additional APIs. Here's an example I found using vbscript: https://gist.github.com/simply-coded/4a3a2c2227af61e2d4c5639fa791d08a

stefankueng avatar Oct 28 '20 18:10 stefankueng

Thank you for providing the code snippet.

The above solution calls mshta.exe to present an HTA to the user. The HTA has higher execution privilege than ordinary HTML pages, which may expose security issues. However, it may not be a big concern from the good-will aspect :)

The most important missing feature in the above solution is that the HTA could not communicate with the existing BowPad instance and the underlying Scintilla control, which has considerably limited its usage.

For instance, a typical usage of plugins with UI may be the following:

  1. User select something in the document window, and execute the plugin.
  2. The plugin does some pre-processing then call a function, like BowPad.OpenHtmlDialog('index.html'), to present an HTML page. The page should be hosted by BowPad, ideally with security constraints. The page may also contain or reference some scripts within the plugin folder.
  3. The script within (or referenced by) the html reads the selected content by calling the BowPad scripting object there and fills the text into a text box.
  4. The user interact with controls in the page.
  5. The script does some processing after user clicking an "Ok" button in the page.
  6. The script overwrites the selection with the output.

Without the ability of intercommunication between the page and BowPad, the above will be impossible.

wmjordan avatar Oct 29 '20 01:10 wmjordan