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

Expose TinyMCE editor content manipulation APIs in Gutenberg #3688

Closed
pavelthq opened this issue Nov 28, 2017 · 14 comments
Closed

Expose TinyMCE editor content manipulation APIs in Gutenberg #3688

pavelthq opened this issue Nov 28, 2017 · 14 comments
Assignees
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Extensibility The ability to extend blocks or the editing experience Needs Technical Feedback Needs testing from a developer perspective. [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.
Milestone

Comments

@pavelthq
Copy link

Please make sure that there is same api for setContent, getContent and getting the editor wrapper as in current version of tinymce.

Many compatibility issues can be solved if there will be same api for settings the content.

wp.tinymce.get('content').setContent('something').

@jaswrks
Copy link
Contributor

jaswrks commented Dec 5, 2017

@danielbachhuber
Copy link
Member

Hi @AngeIII,

Thanks for the report. Can you document what does and doesn't currently work?

@danielbachhuber danielbachhuber added [Status] Needs More Info Follow-up required in order to be actionable. [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes. labels Jan 19, 2018
@pavelthq
Copy link
Author

@danielbachhuber Hello, I already wrote in ticket start:

  • wp.tinymce.get('content') - getting the "Editor" instance
  • wp.tinymce.get('content').setContent('customContent')

also, there was some twinks and abilities to show source/html mode API.

@danielbachhuber danielbachhuber added the Backwards Compatibility Issues or PRs that impact backwards compatability label May 14, 2018
@danielbachhuber
Copy link
Member

Related #6648

@danielbachhuber danielbachhuber changed the title Unify the API for old version of wordpress Expose TinyMCE editor content manipulation APIs in Gutenberg May 14, 2018
@danielbachhuber danielbachhuber removed the [Status] Needs More Info Follow-up required in order to be actionable. label May 14, 2018
@danielbachhuber danielbachhuber added this to the Merge Proposal: Back Compat milestone May 21, 2018
@mtias mtias added [Component] TinyMCE [Feature] Extensibility The ability to extend blocks or the editing experience labels Jun 22, 2018
@gziolo
Copy link
Member

gziolo commented Jul 10, 2018

@iseulde, what's your opinion on this one? I don't think we want to expose internal TinyMCE API for every RichText component. What would be the alternative?

@adamsilverstein
Copy link
Member

adamsilverstein commented Jul 11, 2018

I don't think we want to expose internal TinyMCE API for every RichText component.

Maybe not every API? Why not expose common TinyMCE API points like getContent and setContent which could be extremely useful/required for certain extension use cases?

@danielbachhuber
Copy link
Member

Why not expose common TinyMCE API points like getContent and setContent which could be extremely useful/required for certain extension use cases?

And if we don't want to expose these directly, their equivalents would be just as helpful.

@simondowdles
Copy link

simondowdles commented Jul 11, 2018

I feel that some of the important TinyMCE API points (like getContent and setContent as other have pointed out) should be a baseline requirement here.

We've experienced a bug when using custom formatters, where the value of the RichText component is not passed to the onChange event when content is pasted. This ultimately resulted in attributes that relied on the onChange callback to have their value(s) set, not receiving the expected value. (This is an issue I shall soon open)

I would like to believe that had we had the getContent API point exposed, we could have reverted to that and hopefully gotten the content we expected.

Furthermore, having the getContent and setContent API points exposed, we would not have to convert from a ReactDOM object to an HTML string (using renderToString() for example) had we had more native API's exposed. We'd also not have to rely on third party libraries to get HTML strings back into ReactDOM arrays when setting the (HTML) value of a RichText component from an attribute that may have been saved as a string value.

@ellatrix
Copy link
Member

The shape of the content of RichText is being revised in #7890. That PR will hopefully partly address the issues mentioned here.

Please make sure that there is same api for setContent, getContent and getting the editor wrapper as in current version of tinymce.

Could you elaborate on what you need those for? In what way are you trying to extend the editor. Maybe with that knowledge we can provide more suitable APIs.

@gziolo gziolo mentioned this issue Aug 6, 2018
4 tasks
@mtias mtias removed this from the Merge: Back Compat milestone Oct 3, 2018
@mtias mtias added the Needs Technical Feedback Needs testing from a developer perspective. label Oct 3, 2018
@aaronjorbin aaronjorbin added this to the API Freeze milestone Oct 8, 2018
@aaronjorbin
Copy link
Member

This may be completed after #7890, milestoning to make sure it is

@ellatrix
Copy link
Member

ellatrix commented Oct 8, 2018

#3688 (comment) would need a reply in order to know what is needed.

@danielbachhuber
Copy link
Member

@iseulde I documented some TinyMCE API usage in #6648

@gziolo
Copy link
Member

gziolo commented Oct 8, 2018

By the way, @iseulde proposed Formatting API which is going to play a role of TinyMCE editor content manipulation APIs in Gutenberg. Let's close this issue, and move the discussion to #10068 to ensure that all requirements shared above are included in the final version.

@gziolo gziolo closed this as completed Oct 8, 2018
@gziolo
Copy link
Member

gziolo commented Oct 26, 2018

We have just landed Format API with #10068. It allows registering any format you need. We are still working on a way to give better control which control can be displayed for a given block and documentation. It should be all ready early next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Extensibility The ability to extend blocks or the editing experience Needs Technical Feedback Needs testing from a developer perspective. [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.
Projects
None yet
Development

No branches or pull requests

9 participants