Skip to content

Commit

Permalink
add get all image function
Browse files Browse the repository at this point in the history
  • Loading branch information
pzhtpf committed May 28, 2016
1 parent 075d09e commit 634e33d
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PODS:
- NSObject-SafeExpectations (0.0.2)
- Specta (1.0.5)
- UIAlertView+Blocks (0.9)
- WordPress-Editor-iOS-Extension (0.1.2):
- WordPress-Editor-iOS-Extension (0.1.3):
- NSObject-SafeExpectations
- UIAlertView+Blocks
- WordPress-iOS-Shared
Expand Down Expand Up @@ -67,7 +67,7 @@ SPEC CHECKSUMS:
NSObject-SafeExpectations: 7d7f48df90df4e11da7cfe86b64f45eff7a7f521
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
UIAlertView+Blocks: a46c99c5144f6c5dbc7d62fd2a0678daceec89a3
WordPress-Editor-iOS-Extension: b0be70c3215bb285596f56d25278f69cd664b246
WordPress-Editor-iOS-Extension: 03bb68160766a8c12df9080ae0119de9da1f6b83
WordPress-iOS-Shared: 50a7bd7056b8721e86c3cbe167eab49ef85ec07b
WordPressCom-Analytics-iOS: 5daf418f358bf6ae72f14824e7e90c74d95631a6
WYPopoverController: a9db25ac2841a686acdc0f3a99bdb21545db32f4
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions Example/WordPress-Editor-iOS-Extension/WPViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,31 @@ - (IBAction)publishedAction:(id)sender {

if(_viewModel.title.length == 0){

// _alartViewController = [[AlartViewController alloc] initTitle:NSLocalizedString(@"pleaseInputTitle",@"请输入标题") positiveButton:nil negativeButton:NSLocalizedString(@"sure", @"确认") showCloseButton:NO];
// _alartViewController.expendAbleAlartViewDelegate = self;
// _alartViewController.view.tag = 3;
// [_alartViewController showView:^(BOOL finished){}];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"pleaseInputTitle",@"请输入标题") message:NSLocalizedString(@"pleaseInputTitle",@"请输入标题") delegate:nil cancelButtonTitle:NSLocalizedString(@"sure", @"确认") otherButtonTitles:nil, nil];

[alertView show];

return;
}



if(_viewModel.content.length>0){
if(_viewModel.content.length==0){


UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"pleaseInputMessage",@"请输入内容") message:NSLocalizedString(@"pleaseInputMessage",@"请输入内容") delegate:nil cancelButtonTitle:NSLocalizedString(@"sure", @"确认") otherButtonTitles:nil, nil];

[alertView show];

return;

}
else{



return;
_viewModel.cover_image_url = [self.editorView getCoverImage];
NSArray *allImage = [self.editorView getAllImage];

NSLog(@"Image Count:%ld",allImage.count);

}

Expand Down
18 changes: 17 additions & 1 deletion WordPress-Editor-iOS-Extension/Assets/ZSSRichTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2785,7 +2785,23 @@ ZSSEditor.getCoverImage = function(){
coverImageUrl = coverImage.attr("src");

return coverImageUrl;
}
};

ZSSEditor.getAllImage = function(){

var imageUrl = "";

$("img").each(function(){

imageUrl = imageUrl + $(this).attr("src")+";";

});

return imageUrl;
};




// MARK: - Wrapped Object

Expand Down
1 change: 1 addition & 0 deletions WordPress-Editor-iOS-Extension/Assets/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
<div contenteditable="false" id="zss_field_content" class="field">

</div>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#import "WPEditorToolbarButton.h"
//#import <WordPress-iOS-Shared/WPStyleGuide.h>
@import WordPressShared;

static NSString* const CircleLayerKey = @"circleLayer";
Expand Down
1 change: 1 addition & 0 deletions WordPress-Editor-iOS-Extension/Classes/WPEditorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,5 @@ stylesForCurrentSelection:(NSArray*)styles;
- (void)heading6;
- (void)removeFormat;
- (NSString *)getCoverImage;
- (NSArray *)getAllImage;
@end
21 changes: 20 additions & 1 deletion WordPress-Editor-iOS-Extension/Classes/WPEditorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,26 @@ - (NSString *)getCoverImage
return [self.webView stringByEvaluatingJavaScriptFromString:trigger];

}

- (NSArray *)getAllImage
{
NSString *trigger = @"ZSSEditor.getAllImage();";

[self callDelegateEditorTextDidChange];

NSString *imageUrl = [self.webView stringByEvaluatingJavaScriptFromString:trigger];

NSArray *arrayUrl = [imageUrl componentsSeparatedByString:@";"];

NSMutableArray *mutableArrayUrl = [NSMutableArray new];

for (NSString *url in arrayUrl) {

if(url.length>0)
[mutableArrayUrl addObject:url];
}

return mutableArrayUrl;
}


#pragma mark - UITextViewDelegate
Expand Down
12 changes: 6 additions & 6 deletions WordPress-Editor-iOS-Extension/Classes/WPEditorViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ - (ZSSBarButtonItem*)alignLeftBarButton
{
ZSSBarButtonItem *barButtonItem = [self barButtonItemWithTag:kWPEditorViewControllerElementTagJustifyLeftBarButton
htmlProperty:@"justifyLeft"
imageName:@"ZSSleftjustify"
imageName:@"ZSSleftjustify@2x"
target:self
selector:@selector(alignLeft)
accessibilityLabel:nil];
Expand All @@ -566,7 +566,7 @@ - (UIBarButtonItem*)alignCenterBarButton
{
ZSSBarButtonItem *barButtonItem = [self barButtonItemWithTag:kWPEditorViewControllerElementTagJustifyCenterBarButton
htmlProperty:@"justifyCenter"
imageName:@"ZSScenterjustify"
imageName:@"ZSScenterjustify@2x"
target:self
selector:@selector(alignCenter)
accessibilityLabel:nil];
Expand All @@ -578,7 +578,7 @@ - (UIBarButtonItem*)alignFullBarButton
{
ZSSBarButtonItem *barButtonItem = [self barButtonItemWithTag:kWPEditorViewControllerElementTagJustifyFullBarButton
htmlProperty:@"justifyFull"
imageName:@"ZSSforcejustify"
imageName:@"ZSSforcejustify@2x"
target:self
selector:@selector(alignFull)
accessibilityLabel:nil];
Expand All @@ -590,7 +590,7 @@ - (UIBarButtonItem*)alignRightBarButton
{
ZSSBarButtonItem *barButtonItem = [self barButtonItemWithTag:kWPEditorViewControllerElementTagJustifyRightBarButton
htmlProperty:@"justifyRight"
imageName:@"ZSSrightjustify"
imageName:@"ZSSrightjustify@2x"
target:self
selector:@selector(alignRight)
accessibilityLabel:nil];
Expand Down Expand Up @@ -632,7 +632,7 @@ - (UIBarButtonItem*)boldBarButton

ZSSBarButtonItem *barButtonItem = [self barButtonItemWithTag:kWPEditorViewControllerElementTagBoldBarButton
htmlProperty:@"bold"
imageName:@"icon_format_bold"
imageName:@"icon_format_bold@2x"
target:self
selector:@selector(setBold)
accessibilityLabel:accessibilityLabel];
Expand All @@ -644,7 +644,7 @@ - (UIBarButtonItem*)header1BarButton
{
ZSSBarButtonItem *barButtonItem = [self barButtonItemWithTag:kWPEditorViewControllerElementTagH1BarButton
htmlProperty:@"h1"
imageName:@"ZSSh1"
imageName:@"ZSSh1@2x"
target:self
selector:@selector(heading1)
accessibilityLabel:nil];
Expand Down

0 comments on commit 634e33d

Please sign in to comment.