Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/200487
Change subject: Make internal paste actually work in IE ...................................................................... Make internal paste actually work in IE Ever since context markers (the sunshine and umbrella characters) were added, the default code path for internal paste detection has been broken because it didn't take these into account. However, Chrome uses an optimized path where the clipboard ID is put in a special MIME type, so that kept working, and Firefox used a different optimized path where we looked at the pasted HTML in beforePaste, so that just left IE where the fallback strategy of looking at $pasteTarget was used. Comparing clipboardHashes more liberally allows internal pastes to be detected even when we can't use the clipboardData API. Change-Id: I898d91ec331bfb26d47940c5e8b75c8b1f872493 --- M src/ce/ve.ce.Surface.js 1 file changed, 19 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor refs/changes/87/200487/1 diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js index 6cb99d5..1ee670a 100644 --- a/src/ce/ve.ce.Surface.js +++ b/src/ce/ve.ce.Surface.js @@ -271,6 +271,21 @@ return hash.replace( /\s/gm, '' ); }; +/** + * Compare two clipboard hashes. + * + * This comparison is tolerant of context markers appearing in actual but not in expected. + * + * @param {string} actual Hash of the pasted content + * @param {string} expected Hash of the copied content + * @return {boolean} The hashes are equivalent + */ +ve.ce.Surface.static.compareClipboardHashes = function ( actual, expected ) { + return actual === expected || + // Try stripping paste context markers, if present + actual.replace( /^<[A-Z]+>☀/, '' ).replace( /☂$/, '' ) === expected; +}; + /* Methods */ /** @@ -1895,8 +1910,10 @@ // equal to the hash of the pasted HTML to assert that the HTML // hasn't been modified in another editor before being pasted back. if ( beforePasteData.custom || - this.clipboard[clipboardIndex].hash === - this.constructor.static.getClipboardHash( $elements.toArray() ) + this.constructor.static.compareClipboardHashes( + this.constructor.static.getClipboardHash( $elements.toArray() ), + this.clipboard[clipboardIndex].hash + ) ) { slice = this.clipboard[clipboardIndex].slice; } -- To view, visit https://gerrit.wikimedia.org/r/200487 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I898d91ec331bfb26d47940c5e8b75c8b1f872493 Gerrit-PatchSet: 1 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Catrope <roan.katt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits