智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LightingSystemApp-serial/.svn/pristine/05/0551df5f96e9a6e0e7b45dceb07...

46 lines
952 B

3 years ago
import {
callback
} from 'uni-shared'
function operateEditor (componentId, pageId, type, data) {
UniServiceJSBridge.publishHandler(pageId + '-editor-' + componentId, {
componentId,
type,
data
}, pageId)
}
UniServiceJSBridge.subscribe('onEditorMethodCallback', ({
callbackId,
data
}) => {
callback.invoke(callbackId, data)
})
const methods = ['insertDivider', 'insertImage', 'insertText', 'setContents', 'getContents', 'clear', 'removeFormat', 'undo', 'redo']
export class EditorContext {
constructor (id, pageId) {
this.id = id
this.pageId = pageId
}
format (name, value) {
operateEditor(this.id, this.pageId, 'format', {
options: {
name,
value
}
})
}
}
methods.forEach(function (method) {
EditorContext.prototype[method] = callback.warp(function (options, callbackId) {
operateEditor(this.id, this.pageId, method, {
options,
callbackId
})
})
})