Skip to content
This repository was archived by the owner on Dec 13, 2017. It is now read-only.

Commit 4ee5c83

Browse files
committed
Merge branch 'develop' into feature/ios_10_fixes
2 parents 7283de5 + f6fa879 commit 4ee5c83

12 files changed

Lines changed: 125 additions & 87 deletions

File tree

Assets/ZSSRichTextEditor.js

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,12 @@ ZSSEditor.setBlockquote = function() {
457457
var sendStyles = false;
458458

459459
var ancestorElement = this.getAncestorElementForSettingBlockquote(range);
460-
460+
var focusedField = this.getFocusedField();
461+
462+
if (ancestorElement == focusedField.wrappedDomNode()) {
463+
focusedField.wrapCaretInParagraphIfNecessary()
464+
}
465+
461466
if (ancestorElement) {
462467
sendStyles = true;
463468

@@ -801,16 +806,35 @@ ZSSEditor.insertImage = function(url, alt) {
801806
* does not check for that. It would be a mistake.
802807
*/
803808
ZSSEditor.insertLocalImage = function(imageNodeIdentifier, localImageUrl) {
804-
var progressIdentifier = this.getImageProgressIdentifier(imageNodeIdentifier);
805-
var imageContainerIdentifier = this.getImageContainerIdentifier(imageNodeIdentifier);
806-
var imgContainerStart = '<span id="' + imageContainerIdentifier+'" class="img_container">';
807-
var imgContainerEnd = '</span>';
808-
var progress = '<progress id="' + progressIdentifier+'" value=0 class="wp_media_indicator"></progress>';
809-
var image = '<img data-wpid="' + imageNodeIdentifier + '" src="' + localImageUrl + '" alt="" />';
810-
var html = imgContainerStart + progress+image + imgContainerEnd;
811-
812-
this.insertHTML(html);
813-
this.sendEnabledStyles();
809+
810+
if (window.getSelection) {
811+
sel = window.getSelection();
812+
if (sel.getRangeAt && sel.rangeCount) {
813+
var progressIdentifier = this.getImageProgressIdentifier(imageNodeIdentifier);
814+
815+
var span = document.createElement("span");
816+
span.id = this.getImageContainerIdentifier(imageNodeIdentifier);
817+
span.className = "img_container";
818+
819+
var progress = document.createElement("progress");
820+
progress.id = progressIdentifier;
821+
progress.value = 0;
822+
progress.className = "wp_media_indicator";
823+
824+
var image = document.createElement("img");
825+
image.setAttribute("data-wpid", imageNodeIdentifier);
826+
image.src = localImageUrl;
827+
image.alt = "";
828+
829+
span.appendChild(progress);
830+
span.appendChild(image);
831+
832+
range = sel.getRangeAt(0);
833+
range.insertNode(span);
834+
835+
this.sendEnabledStyles();
836+
}
837+
}
814838
};
815839

816840
ZSSEditor.getImageNodeWithIdentifier = function(imageNodeIdentifier) {
@@ -927,36 +951,35 @@ ZSSEditor.setProgressOnImage = function(imageNodeIdentifier, progress) {
927951
* @brief Notifies that the image upload as finished
928952
*
929953
* @param imageNodeIdentifier The unique image ID for the uploaded image
930-
* @param image The image to be replaces
954+
* @param image The image to be replaced.
931955
* @param mediaID An integer that is the mediaID of the image on the server
932956
*/
933957
ZSSEditor.markImageUploadDone = function(imageNodeIdentifier, image, mediaID) {
958+
959+
var progressId = this.getImageProgressIdentifier(imageNodeIdentifier);
960+
var container = this.getImageContainerNodeWithIdentifier(imageNodeIdentifier)
961+
962+
this.log("Completing image: " + imageNodeIdentifier);
963+
this.log("Removing progress: " + progressId);
964+
965+
// Remove the progress bar from the DOM.
966+
$("#" + progressId).remove();
967+
968+
// Unwrap the image from the image container, leaving it wrapped inside a link
934969
var imageNode = this.getImageNodeWithIdentifier(imageNodeIdentifier);
935-
if (imageNode.length > 0){
936-
// remove identifier attributed from image
937-
imageNode.removeAttr('data-wpid');
938-
939-
// remove uploading style
970+
971+
if (imageNode.length > 0) {
972+
imageNode.unwrap();
973+
imageNode.wrap("<a href='" + image.src + "'></a>");
940974
imageNode.removeClass("uploading");
975+
imageNode.removeAttr('data-wpid');
941976
imageNode.removeAttr("class");
942-
943-
// set remote source
944977
imageNode.attr('src', image.src);
945-
// set attributes
946978
imageNode.attr({'width':image.width, 'height':image.height, 'class':'alignnone size-full'});
979+
947980
if (mediaID >= 0) {
948981
imageNode.addClass('wp-image-' + mediaID);
949982
}
950-
951-
// Remove all extra formatting nodes for progress
952-
if (imageNode.parent().attr("id") == this.getImageContainerIdentifier(imageNodeIdentifier)) {
953-
// remove id from container to avoid to report a user removal
954-
imageNode.parent().attr("id", "");
955-
imageNode.parent().replaceWith(imageNode);
956-
}
957-
// Wrap link around image
958-
var linkTag = '<a href="' + imageNode.attr("src") + '"></a>';
959-
imageNode.wrap(linkTag);
960983
}
961984

962985
var joinedArguments = ZSSEditor.getJoinedFocusedFieldIdAndCaretArguments();
@@ -1000,7 +1023,6 @@ ZSSEditor.markImageUploadFailed = function(imageNodeIdentifier, message) {
10001023
}
10011024

10021025
imageNode.addClass('failed');
1003-
10041026
var imageContainerNode = this.getImageContainerNodeWithIdentifier(imageNodeIdentifier);
10051027
if(imageContainerNode.length != 0){
10061028
imageContainerNode.attr("data-failed", message);
@@ -2735,24 +2757,10 @@ ZSSField.prototype.wrapCaretInParagraphIfNecessary = function()
27352757
|| closerParentNode.nodeName == NodeName.BLOCKQUOTE);
27362758

27372759
if (parentNodeShouldBeParagraph) {
2738-
var selection = window.getSelection();
2739-
2740-
if (selection) {
2741-
var range = selection.getRangeAt(0);
2742-
2743-
if (range.startContainer == range.endContainer) {
2744-
var paragraph = document.createElement("p");
2745-
var textNode = document.createTextNode("&#x200b;");
2746-
2747-
paragraph.appendChild(textNode);
2748-
2749-
range.insertNode(paragraph);
2750-
range.selectNode(textNode);
2751-
2752-
selection.removeAllRanges();
2753-
selection.addRange(range);
2754-
}
2755-
}
2760+
2761+
var savedSelection = rangy.saveSelection();
2762+
$(closerParentNode).wrapInner("<p>");
2763+
rangy.restoreSelection(savedSelection);
27562764
}
27572765
};
27582766

Assets/editor.css

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ hr {
6666
}
6767

6868
img {
69-
width: auto;
7069
height: auto;
7170
margin: 0px 0 0px 0;
7271
min-width: 30px;
@@ -75,6 +74,24 @@ img {
7574
opacity:1;
7675
}
7776

77+
img.alignright {
78+
display: inline;
79+
float: right;
80+
margin-left: 24px
81+
}
82+
83+
img.alignleft {
84+
display: inline;
85+
float: left;
86+
margin-right: 24px
87+
}
88+
89+
img.aligncenter {
90+
clear: both;
91+
display: block;
92+
margin: 0 auto
93+
}
94+
7895
video {
7996
width: auto;
8097
height: auto;

Example/EditorDemo.xcodeproj/project.pbxproj

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@
225225
isa = PBXNativeTarget;
226226
buildConfigurationList = 748D2ABA193E516000D5ACC8 /* Build configuration list for PBXNativeTarget "EditorDemo" */;
227227
buildPhases = (
228-
6CE9E7A78A7D2DBBC1BC238B /* 📦 Check Pods Manifest.lock */,
228+
6CE9E7A78A7D2DBBC1BC238B /* [CP] Check Pods Manifest.lock */,
229229
748D2A81193E516000D5ACC8 /* Sources */,
230230
748D2A82193E516000D5ACC8 /* Frameworks */,
231231
748D2A83193E516000D5ACC8 /* Resources */,
232-
4695D4EE8336F768836ED41D /* 📦 Embed Pods Frameworks */,
233-
170B864A8E43A234A08171F5 /* 📦 Copy Pods Resources */,
232+
4695D4EE8336F768836ED41D /* [CP] Embed Pods Frameworks */,
233+
170B864A8E43A234A08171F5 /* [CP] Copy Pods Resources */,
234234
);
235235
buildRules = (
236236
);
@@ -245,12 +245,12 @@
245245
isa = PBXNativeTarget;
246246
buildConfigurationList = 748D2ABD193E516000D5ACC8 /* Build configuration list for PBXNativeTarget "EditorDemoTests" */;
247247
buildPhases = (
248-
19DDA6B0A0EAF45D6723B64A /* 📦 Check Pods Manifest.lock */,
248+
19DDA6B0A0EAF45D6723B64A /* [CP] Check Pods Manifest.lock */,
249249
748D2AA5193E516000D5ACC8 /* Sources */,
250250
748D2AA6193E516000D5ACC8 /* Frameworks */,
251251
748D2AA7193E516000D5ACC8 /* Resources */,
252-
62F4CCED3A7DBAC3DE4D56EA /* 📦 Embed Pods Frameworks */,
253-
D3F5DB2B0020A9B77E64179A /* 📦 Copy Pods Resources */,
252+
62F4CCED3A7DBAC3DE4D56EA /* [CP] Embed Pods Frameworks */,
253+
D3F5DB2B0020A9B77E64179A /* [CP] Copy Pods Resources */,
254254
);
255255
buildRules = (
256256
);
@@ -324,89 +324,89 @@
324324
/* End PBXResourcesBuildPhase section */
325325

326326
/* Begin PBXShellScriptBuildPhase section */
327-
170B864A8E43A234A08171F5 /* 📦 Copy Pods Resources */ = {
327+
170B864A8E43A234A08171F5 /* [CP] Copy Pods Resources */ = {
328328
isa = PBXShellScriptBuildPhase;
329329
buildActionMask = 2147483647;
330330
files = (
331331
);
332332
inputPaths = (
333333
);
334-
name = "📦 Copy Pods Resources";
334+
name = "[CP] Copy Pods Resources";
335335
outputPaths = (
336336
);
337337
runOnlyForDeploymentPostprocessing = 0;
338338
shellPath = /bin/sh;
339339
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EditorDemo/Pods-EditorDemo-resources.sh\"\n";
340340
showEnvVarsInLog = 0;
341341
};
342-
19DDA6B0A0EAF45D6723B64A /* 📦 Check Pods Manifest.lock */ = {
342+
19DDA6B0A0EAF45D6723B64A /* [CP] Check Pods Manifest.lock */ = {
343343
isa = PBXShellScriptBuildPhase;
344344
buildActionMask = 2147483647;
345345
files = (
346346
);
347347
inputPaths = (
348348
);
349-
name = "📦 Check Pods Manifest.lock";
349+
name = "[CP] Check Pods Manifest.lock";
350350
outputPaths = (
351351
);
352352
runOnlyForDeploymentPostprocessing = 0;
353353
shellPath = /bin/sh;
354354
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
355355
showEnvVarsInLog = 0;
356356
};
357-
4695D4EE8336F768836ED41D /* 📦 Embed Pods Frameworks */ = {
357+
4695D4EE8336F768836ED41D /* [CP] Embed Pods Frameworks */ = {
358358
isa = PBXShellScriptBuildPhase;
359359
buildActionMask = 2147483647;
360360
files = (
361361
);
362362
inputPaths = (
363363
);
364-
name = "📦 Embed Pods Frameworks";
364+
name = "[CP] Embed Pods Frameworks";
365365
outputPaths = (
366366
);
367367
runOnlyForDeploymentPostprocessing = 0;
368368
shellPath = /bin/sh;
369369
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EditorDemo/Pods-EditorDemo-frameworks.sh\"\n";
370370
showEnvVarsInLog = 0;
371371
};
372-
62F4CCED3A7DBAC3DE4D56EA /* 📦 Embed Pods Frameworks */ = {
372+
62F4CCED3A7DBAC3DE4D56EA /* [CP] Embed Pods Frameworks */ = {
373373
isa = PBXShellScriptBuildPhase;
374374
buildActionMask = 2147483647;
375375
files = (
376376
);
377377
inputPaths = (
378378
);
379-
name = "📦 Embed Pods Frameworks";
379+
name = "[CP] Embed Pods Frameworks";
380380
outputPaths = (
381381
);
382382
runOnlyForDeploymentPostprocessing = 0;
383383
shellPath = /bin/sh;
384384
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EditorDemoTests/Pods-EditorDemoTests-frameworks.sh\"\n";
385385
showEnvVarsInLog = 0;
386386
};
387-
6CE9E7A78A7D2DBBC1BC238B /* 📦 Check Pods Manifest.lock */ = {
387+
6CE9E7A78A7D2DBBC1BC238B /* [CP] Check Pods Manifest.lock */ = {
388388
isa = PBXShellScriptBuildPhase;
389389
buildActionMask = 2147483647;
390390
files = (
391391
);
392392
inputPaths = (
393393
);
394-
name = "📦 Check Pods Manifest.lock";
394+
name = "[CP] Check Pods Manifest.lock";
395395
outputPaths = (
396396
);
397397
runOnlyForDeploymentPostprocessing = 0;
398398
shellPath = /bin/sh;
399399
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
400400
showEnvVarsInLog = 0;
401401
};
402-
D3F5DB2B0020A9B77E64179A /* 📦 Copy Pods Resources */ = {
402+
D3F5DB2B0020A9B77E64179A /* [CP] Copy Pods Resources */ = {
403403
isa = PBXShellScriptBuildPhase;
404404
buildActionMask = 2147483647;
405405
files = (
406406
);
407407
inputPaths = (
408408
);
409-
name = "📦 Copy Pods Resources";
409+
name = "[CP] Copy Pods Resources";
410410
outputPaths = (
411411
);
412412
runOnlyForDeploymentPostprocessing = 0;

Example/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ PODS:
88
- CocoaLumberjack/Extensions (2.2.0):
99
- CocoaLumberjack/Default
1010
- NSObject-SafeExpectations (0.0.2)
11-
- WordPress-iOS-Editor (1.7):
11+
- WordPress-iOS-Editor (1.8):
1212
- CocoaLumberjack (~> 2.2.0)
1313
- NSObject-SafeExpectations (~> 0.0.2)
1414
- WordPressCom-Analytics-iOS (~> 0.1.0)
1515
- WordPress-iOS-Shared (0.5.9):
1616
- CocoaLumberjack (~> 2.2.0)
17-
- WordPressCom-Analytics-iOS (0.1.11)
17+
- WordPressCom-Analytics-iOS (0.1.15)
1818

1919
DEPENDENCIES:
2020
- CocoaLumberjack (~> 2.2.0)
@@ -29,10 +29,10 @@ EXTERNAL SOURCES:
2929
SPEC CHECKSUMS:
3030
CocoaLumberjack: 17fe8581f84914d5d7e6360f7c70022b173c3ae0
3131
NSObject-SafeExpectations: 7d7f48df90df4e11da7cfe86b64f45eff7a7f521
32-
WordPress-iOS-Editor: 973cfd00f5ceea89d9337ae7be7c59144931edef
32+
WordPress-iOS-Editor: 50a09646fb62af3efdbb56d13ff656272a079066
3333
WordPress-iOS-Shared: 50a7bd7056b8721e86c3cbe167eab49ef85ec07b
34-
WordPressCom-Analytics-iOS: a844ac791b2627dbb64ba62090654f43dd2abc1c
34+
WordPressCom-Analytics-iOS: e1a7111255e98561c4b5a33ef4baa75a68e0d5d3
3535

3636
PODFILE CHECKSUM: 33e0b5312e2d220c5a6e0e29251cbd5cd92f03e1
3737

38-
COCOAPODS: 1.0.0
38+
COCOAPODS: 1.0.1

Example/Pods/Local Podspecs/WordPress-iOS-Editor.podspec.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Manifest.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)