Skip to content

Commit

Permalink
Squashed 'libs/editor/' changes from 0f6fba8..41a1010
Browse files Browse the repository at this point in the history
41a1010 Merge pull request #337 from wordpress-mobile/issue/336-media-insert-paragraph-fix
767f36f Added comment for API<19 media insertion newline hack
1678bd1 Updating to gradle 2.0
c7a583d Fixed adding newline after media insertion for API<19
2e12295 Corrected some variable names in media insertion methods
200c8d5 Modified paragraph tag wrapping for media insertion to handle div tags correctly
94aa080 Updating to rc3
19cfc2e Merge commit 'c5b98a88c01551e8dbf44366072607d364ec01dd' into develop
64a065f Updating the rest of the modules to buildToolsVersion 23.0.3
f2c8351 Merge commit '4c9324cf1eee00b66c76e0d5a917c86e1293a845' into develop
3878f51 Add missing classes for images inserted from media library - also fix a bug with undefined alt text
3a4fe83 Add missing attributes for uploaded images
61f219e update to android-gradle-2.0.0-rc1
29e1264 Merge commit 'c6efe0a9190244d40e64300efc9cca56ae5acd5c' into develop
a061001 Merge branch 'develop' into issue/120editor-initial-focus
0aa44f3 Merge commit '9b0b5fab24db9f435b278ad0b9e77d5895135700' into develop
0e8a35f Merge pull request #3897 from wordpress-mobile/issue/260editor-clear-failed-images-on-upload
85e19fb Null check getParentRangeOfFocusedNode/setRange in onMutationObserved - in case editor is not in focus
778bc7a Show the software keyboard once the DOM has loaded
e0b6c72 Focus on the title field when opening posts
58c156b New EditorFragment method to removeAllFailedMediaUploads()
533abee New JS function ZSSEditor.removeAllFailedMediaUploads
29db13e Merge pull request #3896 from wordpress-mobile/issue/300editor-broken-images-after-upload-2
c53cb9d remove debug logs
a29070e Use remoteurl in the link wrapper
9abfb9d Merge branch 'develop' into issue/300editor-broken-images-after-upload-2
964938e Merge branch 'develop' into issue/297editor-backspace-media
f6acb17 update to com.android.tools.build:gradle:2.0.0-beta7
e71320e Merge branch 'develop' into issue/297editor-backspace-media
2ff37a5 Merge commit '8db246f15ce6f4d2c7f7f7ec51c68b87e9a66c2f' into develop
7c57f6f Changed MutationObserver handling to check if the WebView supports it, rather than rely on API levels
256916c Refactor: grouped mutation observation methods together
c129a3b Refactored DOM element mutation listening, delegating everything to one trackNodeForMutation method
3df3bbd Changed MutationObserver behavior to track individual media nodes instead of each contenteditable div
f096312 Moved failed media methods to the generic media method group
b13515d Parse for failed media when returning from HTML to visual mode
f193d88 Track DOMNodeRemoved events when parsing for failed media
44b4e92 Fixed a variable name error in ZSSEditor.removeImage
b2342da On API<19, use DOMNodeRemoved events to track media deletions (instead of the unsupported MutationObserver used for newer APIs)
e5e7693 Merge branch 'develop' into issue/297editor-backspace-media
06b252d Merge pull request #3804 from wordpress-mobile/issue/enable-editor-debug-mode
2daf87e Consume KEYCODE_VOLUME_UP event when debug print is called
8519f0d broken retries
8bd6476 Merge branch 'issue/enable-editor-debug-mode' into issue/300editor-broken-images-after-upload-2
06d70f9 use a remoteUrl attribute to avoid seeing broken image if download failed
e5c9d8a remove debug action bar button and log raw html when volume up button is pressed
19f7043 fix function call errors
dae02b2 Add back image swapping onError
515e508 fix wordpress-mobile/WordPress-Editor-Android#300: Retry download onError after an upload
05936de add missing comment
316f566 Updated gradle to 2.0.0-beta6
d6871e8 Fixes an issue where manually deleting uploading/failed media will cause the caret to disappear
eb05458 Notify native through a callback whenever uploading/failed media are manually deleted
4fe64ad catch a common JS exception
3d45aff Merge branch 'develop' into issue/288editor-log-js-errors-in-crashlytics
8db4d8c fix wordpress-mobile/WordPress-Editor-Android#288: new EditorWebViewAbstract.ErrorListener used to forward JS errors to Crashlytics
f2ba93d Keep the format bar disabled on rotation when the title field is in focus
f2f6c0f Rely on ZSSEditor to flag uploads as completed in native-side checks
1fc3ed1 Added null checking for MediaType onMediaUploadFailed
223c7f0 Wait until the ZSSEditor has replaced the local media with remote before marking it as completed
4ff61f7 Strip any trailing &nbsp; when returning the title

git-subtree-dir: libs/editor
git-subtree-split: 41a1010939cb0af0cc43672558265000623aefd2
  • Loading branch information
maxme committed Apr 8, 2016
1 parent c5b98a8 commit d2f7ed4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
4 changes: 2 additions & 2 deletions WordPressEditor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-rc1'
classpath 'com.android.tools.build:gradle:2.0.0'
}
}

Expand All @@ -20,7 +20,7 @@ android {
publishNonDefault true

compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"

defaultConfig {
versionCode 8
Expand Down
4 changes: 2 additions & 2 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-rc1'
classpath 'com.android.tools.build:gradle:2.0.0'
}
}

Expand All @@ -15,7 +15,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "org.wordpress.editorexample"
Expand Down
36 changes: 24 additions & 12 deletions libs/editor-common/assets/ZSSRichTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,22 +740,31 @@ ZSSEditor.setBackgroundColor = function(color) {
};

/**
* @brief Wraps given HTML in paragraph tags and appends a new line
* @brief Wraps given HTML in paragraph tags, appends a new line, and inserts it into the field
* @details This method makes sure that passed HTML is wrapped in a separate paragraph.
* It also appends a new opening paragraph tag and a space. This step is necessary to keep any spans or
* divs in the HTML from being read by the WebView as a style and applied to all future paragraphs.
*/
ZSSEditor.wrapInParagraphTags = function(html) {
ZSSEditor.insertHTMLWrappedInParagraphTags = function(html) {
var space = '<br>';
var paragraphOpenTag = '<' + this.defaultParagraphSeparator + '>';
var paragraphCloseTag = '</' + this.defaultParagraphSeparator + '>';

if (this.getFocusedField().getHTML().length == 0) {
html = paragraphOpenTag + html;
}
html = html + paragraphCloseTag + paragraphOpenTag + space;

return html;
// Without this line, API<19 WebView will reset the caret to the start of the document, inserting the new line
// there instead of under the newly added media item
if (nativeState.androidApiLevel < 19) {
html = html + '&#x200b;';
}

// Due to the way the WebView handles divs, we need to add a new paragraph in a separate insertion - otherwise,
// the new paragraph will be nested within the existing paragraph.
this.insertHTML(html);

this.insertHTML(paragraphOpenTag + space + paragraphCloseTag);
};

// Needs addClass method
Expand Down Expand Up @@ -1024,10 +1033,12 @@ ZSSEditor.updateImage = function(url, alt) {
ZSSEditor.insertImage = function(url, remoteId, alt) {
var html = '<img src="' + url + '" class="wp-image-' + remoteId + ' alignnone size-full';
if (alt) {
html += '" alt="' + alt
html += '" alt="' + alt;
}
html += '"/>'
this.insertHTML(this.wrapInParagraphTags(html));
html += '"/>';

this.insertHTMLWrappedInParagraphTags(html);

this.sendEnabledStyles();
};

Expand Down Expand Up @@ -1064,7 +1075,7 @@ ZSSEditor.insertLocalImage = function(imageNodeIdentifier, localImageUrl) {
var image = '<img data-wpid="' + imageNodeIdentifier + '" src="' + localImageUrl + '" alt="" />';
var html = imgContainerStart + progressElement + image + imgContainerEnd;

this.insertHTML(this.wrapInParagraphTags(html));
this.insertHTMLWrappedInParagraphTags(html);

ZSSEditor.trackNodeForMutation(this.getImageContainerNodeWithIdentifier(imageNodeIdentifier));

Expand Down Expand Up @@ -1352,7 +1363,8 @@ ZSSEditor.insertVideo = function(videoURL, posterURL, videopressID) {

html += '></video>';

this.insertHTML(this.wrapInParagraphTags(html));
this.insertHTMLWrappedInParagraphTags(html);

this.sendEnabledStyles();
};

Expand Down Expand Up @@ -1394,7 +1406,7 @@ ZSSEditor.insertLocalVideo = function(videoNodeIdentifier, posterURL) {
var image = '<img data-video_wpid="' + videoNodeIdentifier + '" src="' + posterURL + '" alt="" />';
var html = videoContainerStart + progressElement + image + videoContainerEnd;

this.insertHTML(this.wrapInParagraphTags(html));
this.insertHTMLWrappedInParagraphTags(html);

ZSSEditor.trackNodeForMutation(this.getVideoContainerNodeWithIdentifier(videoNodeIdentifier));

Expand Down Expand Up @@ -2235,13 +2247,13 @@ ZSSEditor.insertGallery = function( imageIds, type, columns ) {
shortcode = '[gallery columns="' + columns + '" ids="' + imageIds + '"]';
}

this.insertHTML(this.wrapInParagraphTags(shortcode));
this.insertHTMLWrappedInParagraphTags(shortcode);
}

ZSSEditor.insertLocalGallery = function( placeholderId ) {
var container = '<span id="' + placeholderId + '" class="gallery_container">['
+ nativeState.localizedStringUploadingGallery + ']</span>';
this.insertHTML(this.wrapInParagraphTags(container));
this.insertHTMLWrappedInParagraphTags(container);
}

ZSSEditor.replacePlaceholderGallery = function( placeholderId, imageIds, type, columns ) {
Expand Down

0 comments on commit d2f7ed4

Please sign in to comment.