From d351ee6367c1a5b35fb8299d0786c16f64f803f6 Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 5 Mar 2021 13:40:52 +0100 Subject: [PATCH] Updated Squire to v1.11.1 --- vendors/squire/README.md | 6 ++---- vendors/squire/build/squire-raw.js | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/vendors/squire/README.md b/vendors/squire/README.md index 5c11d5beb..2ce7b803d 100644 --- a/vendors/squire/README.md +++ b/vendors/squire/README.md @@ -9,7 +9,7 @@ Squire was designed to be integrated with your own UI framework, and so does not Squire supports all reasonably recent, and even moderately old, browsers (even IE11, although this is not tested much these days). -In addition to its use at [Fastmail](https://www.fastmail.com), it is also currently used in production at [ProtonMail](https://protonmail.com/), [StartMail](https://startmail.com/), [Tutanota](https://tutanota.com), [Zoho Mail](https://www.zoho.com/mail/) and [Superhuman](https://superhuman.com/), as well as other non-mail apps (drop me a line if you're using Squire elsewhere, I'm always interested to hear about it!). +In addition to its use at [Fastmail](https://www.fastmail.com), it is also currently used in production at [ProtonMail](https://protonmail.com/), [SnappyMail](https://github.com/the-djmaze/snappymail), [StartMail](https://startmail.com/), [Tutanota](https://tutanota.com), [Zoho Mail](https://www.zoho.com/mail/) and [Superhuman](https://superhuman.com/), as well as other non-mail apps including [Google Earth](https://www.google.com/earth/) (drop me a line if you're using Squire elsewhere, I'm always interested to hear about it!). An example UI integration can be tried at http://neilj.github.io/Squire/. Please note though, this is an out-of-date version of Squire and a slightly buggy implementation written by an intern many years ago. For a demo of the latest version with a production-level UI integration, [sign up for a free Fastmail trial](https://www.fastmail.com/signup/) :). There's also a very bare-bones integration in the repo; just clone it and open `Demo.html`. If you are reporting a bug, please report the steps to reproduce using `Demo.html`, to make sure it's not a bug in your integration. @@ -128,7 +128,7 @@ Returns self (the Squire instance). ### setKeyHandler -Adds or removes a keyboard shortcut. You can use this to override the default keyboard shortcuts (e.g. Ctrl-B for bold – see the bottom of KeyHandlers.js for the list). +Adds or removes a keyboard shortcut. You can use this to override the default keyboard shortcuts (e.g. Ctrl-B for bold – see the bottom of KeyHandlers.js for the list). This method takes two arguments: @@ -499,5 +499,3 @@ This is useful when the document needs to be changed programmatically, but those ### linkRegExp This is the regular expression used to automatically mark up links when inserting HTML or after pressing space. You can change it if you want to use a custom regular expression for detecting links, or set to `null` to turn off link detection. - - diff --git a/vendors/squire/build/squire-raw.js b/vendors/squire/build/squire-raw.js index bdca2d074..0f8c7a09a 100644 --- a/vendors/squire/build/squire-raw.js +++ b/vendors/squire/build/squire-raw.js @@ -2562,10 +2562,13 @@ class Squire documentSizeThreshold: -1, // -1 means no threshold undoLimit: -1 // -1 means no limit }, - sanitizeToDOMFragment: null, addLinks: true }, config, true ); + if ( typeof config.sanitizeToDOMFragment !== 'function' ) { + config.sanitizeToDOMFragment = null; + } + // Users may specify block tag in lower case config.blockTag = config.blockTag.toUpperCase(); @@ -3683,7 +3686,13 @@ class Squire _setHTML ( html ) { let root = this._root; let node = root; - node.innerHTML = html; + let sanitizeToDOMFragment = this._config.sanitizeToDOMFragment; + if ( sanitizeToDOMFragment ) { + empty( node ); + node.appendChild( sanitizeToDOMFragment( html, false, this ) ); + } else { + node.innerHTML = html; + } do { fixCursor( node, root ); } while ( node = getNextBlock( node, root ) ); @@ -3709,7 +3718,7 @@ class Squire let div, frag, child; // Parse HTML into DOM tree - if ( typeof sanitizeToDOMFragment === 'function' ) { + if ( sanitizeToDOMFragment ) { frag = sanitizeToDOMFragment( html, false, this ); } else { div = createElement( 'DIV' ); @@ -3830,7 +3839,7 @@ class Squire html = html.slice( startFragmentIndex + 20, endFragmentIndex ); } } - if ( typeof sanitizeToDOMFragment === 'function' ) { + if ( sanitizeToDOMFragment ) { frag = sanitizeToDOMFragment( html, isPaste, this ); } else { // Wrap with if html contains dangling tags