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

Extend/Refactor plugin.js & Add More Settings #87

Merged
merged 3 commits into from
Jul 8, 2017

Conversation

dhaupin
Copy link
Contributor

@dhaupin dhaupin commented Jul 5, 2017

Helps AutoSave become more flexible to config, more accurate when it saves, and less bossy when loading. Solves #86

Needed a quick URL mitigator. This is needed to use new `saveKeyIgnoreParams` config. I dont know who the original author is, but we can update when found.
The way autosave was constructing `SaveKey` wasnt very dynamic, and was too specific to be useful on pages with URLs that contain un-needed querystrings (params). This commit introduces more flexibility as well as an option to make autosave url (for SaveKey name) more flexible. In addition there are new configs available to allow an OP to adjust things such as input target identifier right from config.js (without requiring a plugin shim init for editor object). New settings available are:

 - `saveKeyPrefix: 'localstore_prefix',` <-- Optional `SaveKey` prefix, defaults to "autosave" for backwards compatibility
 - `saveKeyIgnoreParams: ['querystring_to_ignore', 'something_else', 'gclid'],` <-- Querystrings to scrub out of `SaveKey` URL
 - `saveKeyIgnoreProtocol: true,` <-- Whether or not to include the https:// in `SaveKey` name, defaults to false for backwards compatibility
 - `saveKeyDelimiter: ' | ',` <-- Optional `SaveKey` URL delimiter, defaults to "_" for backwards compatibility
 - `saveKeyAttribute: 'id'` <-- The unique attribute to target for `SaveKey` name, defaults to element "name" for backwards compatibility

The `SaveKey` is then constructed using those settings and pushed to config.
I may have missed something here, but loadPlugin() is constructing its own config defaults for no good reason. It pulls from 2nd arg what is constructed on init, so we can eliminate all the if checks.
@dhaupin dhaupin changed the title Extend/Refactor plugin.js & Add More Settings https://github.com/w8tcha/CKEditor-AutoSave-Plugin/issues/86 Extend/Refactor plugin.js & Add More Settings Jul 5, 2017
dhaupin added a commit to dhaupin/cs-cart-lib_ckeditor_full that referenced this pull request Jul 5, 2017
dhaupin added a commit to dhaupin/cs-cart-lib_ckeditor_full that referenced this pull request Jul 5, 2017
@w8tcha
Copy link
Owner

w8tcha commented Jul 8, 2017

thanks

@w8tcha w8tcha merged commit 87037d0 into w8tcha:master Jul 8, 2017
dhaupin added a commit to dhaupin/CKEditor-AutoSave-Plugin that referenced this pull request Jul 21, 2017
Merge pull request w8tcha#87 from dhaupin/master
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.

2 participants