From 2fc5d53d4ba45ed45c806a5ac0772458a4ef403e Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Mon, 20 Jun 2016 15:45:26 +0200 Subject: [PATCH] Squashed 'libs/editor/' changes from b207f3f..5ee37c8 5ee37c8 Merge pull request #419 from wordpress-mobile/js-tests 3c6a922 s/functional/unit/ 04b81e3 Updated README with Mocha test instructions 4d75715 Comment cleanup ef276fc Merge branch 'develop' into js-tests 8f06353 Added mocha tests for HTML to visual conversion d03ea19 Merge pull request #418 from wordpress-mobile/issue/415-media-delete-paragraphs 30a3c66 Exported some Visual -> HTML conversion methods to editor-utils-formatter for testability a53706d Merge pull request #414 from wordpress-mobile/issue/411-edit-overlay-stuck 8f3f816 Added editor-utils-formatter.js file and exported HTML->Visual formatting methods from the ZSSEditor JS aa4bb12 Don't add extraneous break tag after videos when converting from HTML dcbdbf1 Fix paragraph wrapping around media items when loading from HTML 7948e95 Fix duplicate src tag for videos 6470a4e Don't delete the paragraph div when deleting a media item d189b09 Merge pull request #410 from wordpress-mobile/issue/377-video-remove-button e13f5fc Fixed edit containers not being cleared when switching to HTML mode eff160c Fixed #408 0acaa82 Extend contenteditable=false to the entire edit container for videos 9774ef0 Merge pull request #404 from wordpress-mobile/issue/update-html-toolbar-icon 531f368 When adding edit containers for videos in ZSSEditor.applyVisualFormatting, track them for mutation 5f0444c Add edit containers to videos when applying visual formatting 9c89dfc Remove edit containers wrapping videos when stripping visual formatting b91317f Fixed trackNodeForMutation usage when video upload completes 3c6f61f Added a null check to ZSSEditor.sendEnabledStyles 86923d2 Track video edit containers for mutation 1a07cbf Fixed paragraph issues when adding remote videos at the start of a post 0917a1b Add delete button overlay for videos added directly (without being uploaded) d370041 Show delete button overlay for videos that have finished uploading 546d4c6 update with new HTML icons / using a solid background on highlighted version git-subtree-dir: libs/editor git-subtree-split: 5ee37c8c995994edeb87651efebce57b870ff3b7 --- .gitignore | 4 + README.md | 12 + .../res/drawable/format_bar_button_html.xml | 29 ++- .../format_bar_button_html_disabled.xml | 31 +-- .../format_bar_button_html_highlighted.xml | 32 +-- .../editor-common/assets/ZSSRichTextEditor.js | 219 +++++++----------- libs/editor-common/assets/android-editor.html | 1 + .../assets/editor-utils-formatter.js | 147 ++++++++++++ libs/editor-common/assets/editor.css | 5 +- .../assets/test/test-formatter.js | 122 ++++++++++ 10 files changed, 415 insertions(+), 187 deletions(-) create mode 100644 libs/editor-common/assets/editor-utils-formatter.js create mode 100644 libs/editor-common/assets/test/test-formatter.js diff --git a/.gitignore b/.gitignore index 1cbbb457376f..c73b540485b2 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ WordPress/src/main/res/values/com_crashlytics_export_strings.xml # libs libs/utils + +# Node-based JS Tests +node_modules +npm-debug.log* \ No newline at end of file diff --git a/README.md b/README.md index 35c05f08a273..eccadbbfbfbe 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,18 @@ Integration testing is done with the [Android testing framework](http://develope Add new unit tests to `src/test/java/` and integration tests to `stc/androidTest/java/`. +### JavaScript Tests ### + +This project also has unit tests for the JS part of the editor using [Mocha](https://mochajs.org/). + +To be able to run the tests, [npm](https://www.npmjs.com/) and Mocha (`npm install -g mocha`) are required. + +With npm and Mocha installed, from within `libs/editor-common/assets/test`, run: + + npm install chai + +It should now be possible to run the tests using `mocha` inside `libs/editor-common/assets`. + ## LICENSE ## WordPress-Editor-Android is an Open Source project covered by the [GNU General Public License version 2](LICENSE.md). diff --git a/WordPressEditor/src/main/res/drawable/format_bar_button_html.xml b/WordPressEditor/src/main/res/drawable/format_bar_button_html.xml index a17d37c9eb1b..96b241307005 100755 --- a/WordPressEditor/src/main/res/drawable/format_bar_button_html.xml +++ b/WordPressEditor/src/main/res/drawable/format_bar_button_html.xml @@ -1,21 +1,18 @@ - - + android:width="44dp" + android:height="44dp" + android:viewportWidth="44.0" + android:viewportHeight="44.0"> + android:pathData="M13.93,26H12.79v-4.16H9.17V26H8.04v-9h1.13v3.87h3.62V17h1.14V26z" + android:fillColor="#A6BCCC"/> + android:pathData="M20.97,17.97H18.6V26h-1.13v-8.03h-2.36V17h5.86V17.97z" + android:fillColor="#A6BCCC"/> + android:pathData="M23.75,17l2.35,7.34L28.45,17h1.46v9h-1.13v-3.51l0.1,-3.51L26.53,26h-0.87l-2.34,-6.99l0.1,3.49V26h-1.13v-9H23.75z" + android:fillColor="#A6BCCC"/> - \ No newline at end of file + android:pathData="M33,25.03h3.53V26h-4.67v-9h1.14V25.03z" + android:fillColor="#A6BCCC"/> + diff --git a/WordPressEditor/src/main/res/drawable/format_bar_button_html_disabled.xml b/WordPressEditor/src/main/res/drawable/format_bar_button_html_disabled.xml index b82938df0878..6e5b8074e234 100755 --- a/WordPressEditor/src/main/res/drawable/format_bar_button_html_disabled.xml +++ b/WordPressEditor/src/main/res/drawable/format_bar_button_html_disabled.xml @@ -1,15 +1,18 @@ - - - - \ No newline at end of file + android:width="44dp" + android:height="44dp" + android:viewportWidth="44.0" + android:viewportHeight="44.0"> + + + + + diff --git a/WordPressEditor/src/main/res/drawable/format_bar_button_html_highlighted.xml b/WordPressEditor/src/main/res/drawable/format_bar_button_html_highlighted.xml index 1497cf2b596f..331d9a8f98ab 100755 --- a/WordPressEditor/src/main/res/drawable/format_bar_button_html_highlighted.xml +++ b/WordPressEditor/src/main/res/drawable/format_bar_button_html_highlighted.xml @@ -1,15 +1,19 @@ - - - - \ No newline at end of file + android:width="44dp" + android:height="44dp" + android:viewportWidth="44.0" + android:viewportHeight="44.0"> + + + + + + diff --git a/libs/editor-common/assets/ZSSRichTextEditor.js b/libs/editor-common/assets/ZSSRichTextEditor.js index de5370727d44..d6a412fd6a72 100755 --- a/libs/editor-common/assets/ZSSRichTextEditor.js +++ b/libs/editor-common/assets/ZSSRichTextEditor.js @@ -67,10 +67,6 @@ ZSSEditor.lastTappedNode = null; // The default paragraph separator ZSSEditor.defaultParagraphSeparator = 'div'; -// Video format tags supported by the [video] shortcode: https://codex.wordpress.org/Video_Shortcode -// mp4, m4v and webm prioritized since they're supported by the stock player as of Android API 23 -ZSSEditor.videoShortcodeFormats = ["mp4", "m4v", "webm", "ogv", "wmv", "flv"]; - // We use a MutationObserver to catch user deletions of uploading or failed media // This is only officially supported on API>18; when the WebView doesn't recognize the MutationObserver, // we fall back to the deprecated DOMNodeRemoved event @@ -1536,7 +1532,8 @@ ZSSEditor.removeAllFailedMediaUploads = function() { * */ ZSSEditor.insertVideo = function(videoURL, posterURL, videopressID) { - var html = '