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

Add support for Monaco Editor #239

Merged
merged 10 commits into from
Mar 11, 2023
Merged

Add support for Monaco Editor #239

merged 10 commits into from
Mar 11, 2023

Conversation

ryan6416
Copy link
Contributor

This pull request adds support for the Monaco Editor. This resolves issue #140, which requested the ability to use GhostText with the Monaco Editor.

The changes include a new condition in the unsafe-messenger.js file that checks for the existence of the monaco object, and a new function monacoEditor(target) that handles the events and value transfer for the Monaco Editor.

This has been tested and confirmed to work with the Monaco Editor, and should not affect the existing support for CodeMirror and Ace.

Here's a demo of the update:

vehLTicnh4.mp4

Copy link
Owner

@fregante fregante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Can you add a Monaco editor to the demo page on the demo/testing page?

https://ghosttext.fregante.com/test/

The "edit" link is at the bottom

source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/ghost-text.js Outdated Show resolved Hide resolved
source/ghost-text.js Outdated Show resolved Hide resolved
source/ghost-text.js Outdated Show resolved Hide resolved
@ryan6416
Copy link
Contributor Author

ryan6416 commented Jan 24, 2023

Thank you for the PR! Can you add a Monaco editor to the demo page on the demo/testing page?
ghosttext.fregante.com/test
The "edit" link is at the bottom

Done @fregante fregante/ghosttext.fregante.com#10

@fregante
Copy link
Owner

fregante commented Jan 26, 2023

Refer to https://github.com/fregante/GhostText/blob/main/contributing.md#adding-support-for-more-editors for more information if you haven't.

Linting is still failing here as well and it should pass for this PR to be merged

@fregante
Copy link
Owner

You marked some of my comments as resolved but you did not address them. Please review again

source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/unsafe-messenger.js Outdated Show resolved Hide resolved
source/unsafe-messenger.js Outdated Show resolved Hide resolved
@fregante fregante linked an issue Jan 27, 2023 that may be closed by this pull request
const monaco = field.closest('.monaco-editor');
if (monaco) {
const visualElement = monaco.querySelector('.monaco-editor-background');
return new AdvancedTextWrapper(monaco, visualElement);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works now

Screenshot 3

@fregante
Copy link
Owner

fregante commented Jan 27, 2023

Fixed:

  • multiple field support
  • selector/lint/syntax errors

Not fixed:

  • see unresolved reviews, the most important broken part is that it only works "one way" (editor -> browser)

@fregante
Copy link
Owner

fregante commented Mar 2, 2023

@ryan-efendy are you able to finish this soon? I'd love to include it in this week’s release, otherwise it'll have to wait longer

@fregante fregante merged commit da7c48f into fregante:main Mar 11, 2023
@fregante fregante added the new site support Requests of support for new sites and fields label Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new site support Requests of support for new sites and fields
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Monaco Editor (Freecodecamp, Repl.it, Google Colab)
2 participants