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

When a post is saved, check for tinymce and save any editors. #12568

Merged
merged 8 commits into from
Dec 9, 2018
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/edit-post/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.1.5 (Unreleased)

### Bug Fixes
- Fix saving WYSIWYG Meta Boxes

## 3.1.4 (2018-11-30)

## 3.1.3 (2018-11-30)
Expand Down
5 changes: 3 additions & 2 deletions packages/edit-post/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/edit-post",
"version": "3.1.4",
"version": "3.1.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"version": "3.1.5",
"version": "3.1.4",

The versions are actually changed automatically when we publish the packages. So we should keep it as is and only update the change log for now

"description": "Edit Post module for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down Expand Up @@ -40,7 +40,8 @@
"@wordpress/viewport": "file:../viewport",
"classnames": "^2.2.5",
"lodash": "^4.17.10",
"refx": "^3.0.0"
"refx": "^3.0.0",
"tinymce": "^4.7.2"
},
"devDependencies": {
"deep-freeze": "^0.0.1",
Expand Down
6 changes: 6 additions & 0 deletions packages/edit-post/src/store/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { reduce } from 'lodash';
import tinymce from 'tinymce';

/**
* WordPress dependencies
Expand Down Expand Up @@ -72,6 +73,11 @@ const effects = {
} );
},
REQUEST_META_BOX_UPDATES( action, store ) {
// Saves the wp_editor fields
for ( var i = 0; i < tinyMCE.editors.length; i++ ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

so this means you're loading the tinymce variable but using the tinyMCE global? seems to me like we should replace this with tinymce to use the imported variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can use the global tinyMCE without importing tinymce at the top.

If we import tinymce and call tinymce.triggerSave or tinymce.editors, they don't work as we would expect to save the extra editors.

Thanks again for the time on this. We're going to fix this issue, which is important for plugins. I'm getting an education in Gutenberg, node, and JS here. I apologize for the confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for your help here :). That's interesting though, now I'm curious. What is the difference between window.tinymce and window.tinyMCE?

Copy link
Contributor Author

@ideadude ideadude Dec 4, 2018

Choose a reason for hiding this comment

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

window.tinymce and window.tinyMCE seem to be the same object in my console (or 2 copies of the same object in sync). TinyMCE might setup both???

tinyMCE.editors[i].save();
}

const state = store.getState();

// Additional data needed for backwards compatibility.
Expand Down