Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Resolves #8931: Improve support for plugins in the Rich Text Editor (implement webviewApi.postMesage) #10158

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Mar 19, 2024

Summary

This pull request makes it possible for a plugin's content scripts to communicate with its background script, without using internal Joplin APIs (e.g. through parent.require). Specifically, it

  1. Allows renderer plugins to access webviewApi when running in the rich text editor. This is the same API as is used in the markdown preview pane.
  2. Updates tests/support/plugins/content_script/ to support the rich text editor.

Testing

  1. Build the content_script example plugin and add it as a development plugin to Joplin.
    • It may be necessary to upgrade its version of TypeScript and Webpack to do this.
  2. Create a note with the following content:
    Test
    ```justtesting
    foo
    bar
    baz
    ```
  3. Switch to the Rich Text Editor.
  4. Click on the generated link and check the console for a Got response in content script: justtesting+response message.
  5. Make a change to the text just above the rendered block.
  6. Switch back to the markdown editor
  7. Verify that the original markup for the justtesting block is still present.

@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Fixes #8931: Better support plugins in the Rich Text Editor (implement webviewApi.postMesage) Desktop: Resolves #8931: Improve support for plugins in the Rich Text Editor (implement webviewApi.postMesage) Mar 19, 2024
@laurent22 laurent22 merged commit eecad1a into laurent22:dev Mar 20, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants