编辑器
幻灯片编辑器类,提供了获取内容、渲染内容、操作幻灯片的方法。
构造函数
用法
var editor = new window.shimo.sdk.slide.Editor(options) var editor = new window.shimo.sdk.slide.Editor({ file, localeConfig: { locale: 'en-US', fetchLocaleSync: () => Editor.LocaleResources['en-US'], }, templateSettings: { title: '这是一个标题', } })
参数
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
options.file | string | 必选 | 设置幻灯片初始化渲染数据 |
options.localeConfig | Object | 可选 | 国际化相关配置,如果未传,默认使用中文(zh-CN) |
options.localeConfig.fetchLocaleSync | Function | 必选 | 获取翻译资源的方式 |
options.localeConfig.locale | String | 必选 | 设置当前要使用的语言,eg: 'en-US' |
options.templateSettings | Object | 可选 | 模板配置 |
options.templateSettings.title | String | 可选 | 模板标题 |
options.templateSettings.subtitle | String | 可选 | 模板副标题 |
options.templateSettings.normal | String | 可选 | 模板普通文字内容 |
方法列表
render
渲染幻灯片单页内容。
- 返回
undefined
- 用法
render(container, options)
- 参数
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
container | HTMLElement | 无 | 幻灯片渲染容器 |
options | Object | 无 | 渲染配置项 |
options.editable | boolean | true | 是否可编辑 |
options.scope | 'slides' ,'layouts' | 'slides' | 渲染范围 |
options.slide | string / number | 0 | 渲染的幻灯片 id 或序号 |
options.scalable | boolean | true | 是否支持双指缩放 |
options.reactive | boolean | true | 是否支持实时更新 |
options.placeholder | boolean | false | 占位符内容是否显示 |
options.canvas | Object | 无 | 画布渲染配置项 |
options.canvas.withPadding | boolean | false | 是否显示超出画布内容区域的内容 |
options.canvas.fitContainer | boolean | true | 初始缩放比例是否适应容器 |
options.canvas.minRatio | number | 0.25 | 画布缩放比例下限,默认 25% |
options.canvas.maxRatio | number | 4 | 画布缩放比例上限,默认 400% |
destroy
销毁幻灯片编辑器实例。
- 返回
undefined
- 用法
destroy()
- 参数
undefined
getContent
获取幻灯片内容。
- 返回
Promise (string)
- 用法
editor.getContent().then(function (content) {
console.log(content)
})
getLocale
获取当前语言。
- 返回
string
- 用法
const currentLocale = editor.getLocale(); // eg: en-US、zh-CN