帮助与文档 > 产品文档 > 多文本编辑器 > iOS SDK 文档

一、有道云笔记编辑器 SDK 简介

有道编辑器SDK是有道开放平台提供的云服务之一,是有道编辑器接口的一种实现。拥有多年产品化实践经验,服务于有道云笔记千万用户。

通过SDK接入优势:

  1. 支持常用的编辑功能,满足绝大多数的内容编辑场景
  2. 支持iOS、Android和桌面端WebKit内核的浏览器
  3. 自由格式的文档结构定义

二、集成前提

开始集成SDK之前开发者需要登录有道开放平台(http://ai.youdao.com),创建应用获取应用ID(或者通过运营人员获取应用ID),以便使用编辑器sdk服务,编辑器SDK只支持iOS 9及以后的系统。

编辑器sdk由如下几个sdk组成:

文件说明
Release-iphoneos/editorSDK.framework用于真机调试、打包发布的framework
Release-iphonesimulator/editorSDK.framework用于模拟器调试的framework
editorSDKSamplesdk使用demo

文件目录如下图所示:

image

三、SDK集成步骤

1. 头文件及SDK库引入

编辑器SDK使用的是framework引入方式,需要把对应的editorSDK.framework导入到工程目录下(真机调试、打包发布使用Release-iphoneos/editorSDK.framework,模拟器调试使用Release-iphonesimulator/editorSDK.framework),按如下配置target:

  1. 在General --> Embedded Binaries中加入对应的editorSDK.framework
  2. 在General --> Linked Frameworks and Libraries中加入对应的editorSDK.framework
    image
  3. 在Build Phrases --> Link Binary With Libraries中加入对应的editorSDK.framework
  4. 在Build Phrases --> Embed Frameworks中加入对应的editorSDK.framework
    image
  5. 在Build Settings --> Combined --> Search Paths -->Framework Search Path中填写对应editorSDK.framework的所在路径
    image
  6. 在 Info.plist 中添加 NSAppTransportSecurity 字典并且将 NSAllowsArbitraryLoads 设置为 YES
    image

2. 功能集成说明

2.1. 初始化key:

所有的编辑器功能都需要初始化key,只执行初始化一次即可。建议用户在AppDelegate.m中的-application:didFinishLaunchingWithOptions:中初始化key。

#import <editorSDK/YNESDKEditorView.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [YNESDKEditorRegister registerWithAppKey:@"zhudytest123" completionBlock:^(BOOL isSuccess, NSError *aError) {
        // hander error
    }];
    return YES;
}

2.2. 初始化编辑器:
在代码中使用时,可用#import <editorSDK/YNESDKEditorView.h>引如sdk,然后就可以新建YNESDKEditorView实例,并使用YNESDKEditorView.h中的- initWithContent: withType:方法初始化,也支持默认初始化和用xib初始化,设置代理之后则可使用YNESDKEditorDelegate中定义的代理接口。

#import <editorSDK/YNESDKEditorView.h>
...

- (void)viewDidLoad {
    ...

    self.editorView = [[YNESDKEditorView alloc] initWithContent:content withType:YNESDKEditorContentTypeXML];
    self.editorView.delegate = self;
    [self.view addSubview:self.editorView];
}
...

-(void)editorViewClickLinkButton:(YNESDKEditorView *)editorView {
    ...
    [self.editorView insertURL:src];
}

2.3 YNESDKEditorView接口

  • 初始化编辑器
- (instancetype)initWithContent:(NSString *)content withType:(YNESDKEditorContentType)type;
  • 设置编辑器内容
- (void) setContent:(NSString*)content withType:(YNESDKEditorContentType)type;
  • 获取编辑器内容
- (NSString*)getContentWithType:(YNESDKEditorContentType)type;
  • 插入超链接
- (void)insertURL:(NSString*)src;
  • 插入图片
- (void)insertImage:(NSString*)path;
  • 获取编辑器图片资源目录
+ (NSString*)resourcePath;
  • 拷贝资源到编辑器图片资源目录
+ (NSString*)copyToResourcePath:(NSString*)originalPath;
  • 插入附件
- (void)insertAttachmentWithPath:(NSString*)path length:(NSUInteger)length;
  • 更新附件下载进度
- (void)updateProgress:(NSInteger)progress ofAttachment:(NSString*)filePath;
  • 编辑器是否可以撤销
- (BOOL)canUndo;
  • 编辑器是否可以重做
- (BOOL)canRedo;
  • 撤销
- (void)undo;
  • 重做
- (void)redo;

注:接口详情请参考BulbEditor iOS SDK API文档

2.4 YNESDKEditorDelegate代理

  • 编辑器初始化之后触发
-(void)editorView:(YNESDKEditorView *)editorView initIsSuccess:(BOOL)isSuccess withError:(NSError *)error;
  • 点击编辑器中的图片时触发
-(void)editorView:(YNESDKEditorView*)editorView clickImageList:(NSArray*)imageList atIndex:(NSUInteger)index;
  • 点击编辑器中的附件时触发
-(void)editorView:(YNESDKEditorView*)editorView clickAttachment:(NSString*)filePath;
  • 编辑器首次渲染附件时触发
-(NSInteger)editorView:(YNESDKEditorView*)editorView getAttachmentInitProgress:(NSString*)filePath;
  • 点击编辑器中的链接时触发
-(void)editorView:(YNESDKEditorView*)editorView clickLink:(NSString*)url;
  • 点击编辑器工具栏的插入图片按钮时触发
-(void)editorViewClickPhotoButton:(YNESDKEditorView *)editorView;
  • 点击编辑器工具栏的拍照按钮时触发
-(void)editorViewClickCameraButton:(YNESDKEditorView *)editorView;
  • 点击编辑器工具栏的插入视频按钮时触发
-(void)editorViewClickVideoButton:(YNESDKEditorView *)editorView;
  • 点击编辑器工具栏的插入链接按钮时触发
-(void)editorViewClickLinkButton:(YNESDKEditorView *)editorView;
  • 编辑器撤销状态改变时触发
-(void)editorView:(YNESDKEditorView *)editorView undoStatusDidChange:(BOOL)undo;
  • 编辑器重做状态改变时触发
-(void)editorView:(YNESDKEditorView *)editorView redoStatusDidChange:(BOOL)redo;

四、常见问题及注意事项

  1. 无法使用编辑器

    请检查APP_KEY和包名是否匹配。另外,第一次进入APP需要联网校验该APP是否授权,请检查是否联网。
    

五、错误代码列表

错误码含义
101缺少必填的参数
102不支持的语言类型
103请求文本过长
104不支持的API类型
105不支持的签名类型
106不支持的响应类型
107不支持的传输加密类型
108appKey无效
109batchLog格式不正确
110无相关服务的有效实例
111用户无效
112请求服务无效
201解密失败
202签名检验失败
203访问IP地址不在可访问IP列表
303服务的异常
401账户已经欠费停止
402offlinesdk不可用
404服务访问被禁止,请联系服务提供者
-1网络不可用

六、版本更新记录

上线日期版本号更新内容
2018.4.26v1.0.0有道编辑器SDK iOS版上线,支持富文本编辑
2018.11.9v1.1.0增加纯文本和html格式输出
文档是否有帮助解决问题?

如有其它疑问,可在此提交意见和反馈
详细描述(选填)
联系邮箱(选填)
留下您的合作信息,专业顾问将联系您提供免费的咨询
是否为渠道商:
服务类型:
详细分类:
所属地区:
所属行业:
公司名称:
业务简介:
使用场景:
使用量级:
联系人姓名:
联系人电话:
联系人邮箱:
联系人职务:
来源渠道:
verificatiton pics
验证码:
联系方式
合作咨询
联系电话:010-8255-8901
商务合作:
投诉反馈:
地       址:北京市海淀区西北旺东路10号院 中关村软件园二期西区7号 网易(北京)公司
微信公众号
微信小程序
 
 
©2019 网易公司 京ICP证080268号