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

Edit HTML Source not Saving HTML #45

Open
prazvan opened this issue Nov 7, 2016 · 7 comments
Open

Edit HTML Source not Saving HTML #45

prazvan opened this issue Nov 7, 2016 · 7 comments

Comments

@prazvan
Copy link

prazvan commented Nov 7, 2016

Hey,

So i found a weird bug when using the module with HTML Edit source.

Lets say that after you add a shortcode from the module our you want to add it manually when editing the html source, when you try to save the page as draft or published the content won't be save.

After a bit of debugging found a solution

in the shortcodable.js file

under the onbeforesubmitform callback i found out the the Editor save method wasn't called at all.

            /**
             * Make sure the editor has flushed all it's buffers before the form is submitted.
             */
            'from .cms-edit-form': {
                onbeforesubmitform: function(e) {
                    var shortcodable = tinyMCE.activeEditor.plugins.shortcodable;
                    var ed = this.getEditor();
                    var newContent = shortcodable.replacePlaceholdersWithShortcodes($(this).val(), ed);
                    $(this).val(newContent);

                    // save html - FIX
                    ed.save();

                }
            },

Thanks,
Razvan

@sheadawson
Copy link
Owner

sheadawson commented Nov 7, 2016

Great! Thanks Razvan. I had noticed that bug on a recent project but not investigated it.

Would you like to make a pull request to commit that change? If you are not experienced with this, this might be a good opportunity to have a go

@prazvan
Copy link
Author

prazvan commented Nov 9, 2016

@sheadawson will do that asap :)

@tomstgeorge
Copy link

tomstgeorge commented Nov 18, 2016

I just made this edit to shortcodable.js and it does fix the 'edit HTML source not saving' issue but breaks the saving of the inserted shortcode dataobject.

Now when I publish the page the embeded shortocde dataobject shows on the frontend as an image i.e. they are no longer being converted into shortcodes on save.

When I look in the database they are stored as the image and not being saved as e.g [myObject id="2"]

@tardinha
Copy link

Same for me.

@jonom jonom mentioned this issue Dec 1, 2016
@sheadawson sheadawson reopened this Dec 1, 2016
MrJamesEllis pushed a commit to MrJamesEllis/silverstripe-shortcodable that referenced this issue Feb 23, 2017
…ontent using setContent, call _super for saving of HTMLEditorField content
@jules0x
Copy link

jules0x commented Mar 1, 2017

The fix @MrJamesEllis pushed does not fix #52 or #49 for me.
A shortcode does not even need to be present on the page for the HTML Source editor to ignore the changes made. I rolled back to version ^2.0 and noted that I was able to edit the content via the HTML Source editor if I finish my edits, then open and close the HTML source editor again before attempting to save. This doesn't appear to work for ^3.0

@MrJamesEllis
Copy link

@jules0x I only applied the change to the 2.0 branch as that satisfies my SS version requirement.
Does the change fix the issues referenced for you in 2.0 ?

The only side-effect I've had reported is that navigating away from an admin form including the HTMLEditorField with a shortcode, causes the "Changes that you made, may not be saved" alert.. when no changes were made to the field.

@jules0x
Copy link

jules0x commented Mar 9, 2017

@MrJamesEllis I just tried adding the changes in f9466d8 to the 2.0.9 branch and no, I get the same behaviour. Edits to the htmlsource editor are lost on save, and when switching between pages, content is transferred between the two. My solution is likely to be removing the default html source editor button and implementing a separate html editor at a later date.

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

No branches or pull requests

6 participants