When pasting in BBCode format, the first and last blocks were sometimes
being removed, such as:
[center]test[/center][center]test[/center][center]test[/center]
This also caused extra newlines to sometimes be added when pasting.
* Removes `rimraf` dependency and updates dependencies to latest versions
* Fix auto focus issue with manual test caused by Less.js, fixes `autofocus` is unreliable in Firefox with manual test #912.
* Waits for Less.js to load before running tests (prevent any issues like `autofocus` is unreliable in Firefox with manual test #912)
* Fixes autoYoutube tests in FF due to changed parameter ordering
* Updates the `nodesEqual()` and `nodesNotEqual()` assertions to give better diffs.
Improves the special case handling for code tags so they only include text content.
This stops code tags including styles from block elements and makes BBCode paste not handle styles in code tags
Also tidies code a little:
* vChildren will either be an array or undefined so no need to check type.
* Adding text node check to if statement removes need for early return nodeType check.
Fixes#915
* Update dependencies
* Move test libs into devDependencies.
This moves the the dev dependencies into a more appropriate place and
should make keeping the updated easier.
The sinon-qunit library was completely removed as not needed.
* Add wildcard BBCode tag matching.
Adds ability to use wildcards to match tags and combines moves styles to
the style attribute.
This also renames the attrMatch property to strictMatching.
Fixes#589
* Improve JSDoc for strictMatch
* Update src/formats/bbcode.js
Co-authored-by: John Rayes <live627@gmail.com>
* Fix going back in the browser causes content to be lost
If you use the back button in your browser then go forward, all the content is lost. This is because the information is not sent back to the original prior to unloading the page. This change simply attaches a event to the unload for window and triggers the base update to occur. The browser handles the rest if it supports remembering what was entered into the textarea.
Signed-off-by: jdarwood007 <unmonitored+github@sleepycode.com>
* Use page events instead of unload for back fix.
Using the unload event can cause the browser not to use the bfcache:
https://web.dev/bfcache/https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/1.5/Using_Firefox_1.5_caching
Co-authored-by: jdarwood007 <unmonitored+github@sleepycode.com>
Converts all <div> tags that are in a <code> tag to <span> tagsin the
XHTML format.
<div> tags are invalid children of inline tags but are common when
pasted.
Currently <code> tags are split to fix this which isn't a good UX
so this fixes that.
* Remove MatchingMode enum
See comments in PR. This is harder to type and has no benefits in JS.
Aiming to remove them in next others in next release so not adding new ones.
* Remove 2 from being a value for matchAttrs
2 is not a vlaid option for matchAttrs .
* Remove isObject function
Handler attributes should be an object or falsey
so no need to check if plain object.
* Allow chaning BBCode format after editor creation
Maintains backwards compatibility until next breaking release
LGTM complains about prototype pollution event though it is prevented.
It seems to not recognise the combined if statment.
Also makes it a little easier to
read and slightly reduces the code size.
Plugins should be initialized before the formatters since they may wish to add or change formatting handlers and since the bbcode format caches its handlers, such changes must be done first.
* Make fixNesting split <p> tags containing <blockquotes>
* Prevent fixNesting from creating empty nodes
* Fix nesting after inserting HTML
* Update fixNesting to copy inline styling
* Don't remove empty node that contain <br /> tags
* Prevent empty nodes being created when inserting
* Remove dev comments
New option added `instance.opts.parserOptions.matchAttrs`
New enumerable added: `sceditor.BBCodeParser.MatchingMode`
The enum has two values:
- `sceditor.BBCodeParser.MatchingMode.all`
- `sceditor.BBCodeParser.MatchingMode.any`—this is the value which will be used if left blank, ie, not set. This way, any existing code will still work exactly as before.
Each individual format option will have the opportunity to specify its own `matchAttrs` and override the global option.