May 18, 2021 WeChat Mini Program Development Document
EditorContext
Base library 2.7.0 starts to support, and low versions need to be compatible.
EditorContext instance, available at wx.createSelectorQuery.
EditorContext binds to a editor component via id, operating the corresponding editor component.
Base library 2.8.3 is supported from now on, and low versions need to be compatible.
The editor loses focus while rescuing the keyboard.
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Base library 2.7.0 starts to support, and low versions need to be compatible.
Empty the editor content
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Base library 2.7.0 starts to support, and low versions need to be compatible.
Modify the style
Property
Value
name | value | verson |
---|---|---|
bold | 2.7.0 | |
italic | 2.7.0 | |
underline | 2.7.0 | |
strike | 2.7.0 | |
Ins | 2.7.0 | |
script | sub / super | 2.7.0 |
header | H1 / H2 / h3 / H4 / h5 / H6 | 2.7.0 |
align | left / center / right / justify | 2.7.0 |
direction | Rtl | 2.7.0 |
indent | -1 / +1 | 2.7.0 |
list | ordered / bullet / check | 2.7.0 |
color | hex color | 2.7.0 |
backgroundColor | hex color | 2.7.0 |
margin/marginTop/marginBottom/marginLeft/marginRight | css style | 2.7.0 |
padding/paddingTop/paddingBottom/paddingLeft/paddingRight | css style | 2.7.0 |
font/fontSize/fontStyle/fontVariant/fontWeight/fontFamily | css style | 2.7.0 |
lineHeight | css style | 2.7.0 |
letterSpacing | css style | 2.7.0 |
textDecoration | css style | 2.7.0 |
textIndent | css style | 2.8.0 |
wordWrap | css style | 2.10.2 |
wordBreak | css style | 2.10.2 |
whiteSpace | css style | 2.10.2 |
Setting a selection that has been applied to a style cancels the style. css style represents the allowed value specified in css.
Base library 2.7.0 starts to support, and low versions need to be compatible.
Get the editor content
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Property | Type | Description |
---|---|---|
Html | string | Tagged HTML content |
text | string | Plain text content |
delta | Object | The delta object that represents the content |
Base library 2.10.2 starts to support, and low versions need to be compatible.
Gets plain text content in the selected area of the editor. When the editor loses focus or does not select a interval, the returned content is empty.
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Property | Type | Description |
---|---|---|
text | string | Plain text content |
Base library 2.7.0 starts to support, and low versions need to be compatible.
Insert a split line
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Base library 2.7.0 starts to support, and low versions need to be compatible.
Insert a picture.
When the address is a temporary file, the get editor html format content in the label adds the property data-local, the delta format content in the picture attributes property adds the data-local field, the value is the incoming temporary file address.
Developers can choose to upload images to the server during the submission phase and replace them with a network address. The src value of slt;img> should be replaced for html content when replaced, and the insert value of image: abc should be replaced for delta content.
Property | Type | The default | Required | Description |
---|---|---|---|---|
Src | string | Is | Image address, only http(s), base64, cloud image (2.8.0), temporary file (2.8.3). | |
Alt | string | Whether | Alternative text when the image cannot be displayed | |
width | string | Whether | Picture width (pixels/percentage) | |
height | string | Whether | Picture height (pixels/percentage) | |
extClass | string | Whether | The class name added to the picture img label | |
data | Object | Whether | data is serialized as name-value; The format of name1-value2 hangs on the property data-custom | |
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
this.editorCtx.insertImage({
src: 'xx',
width: '100px',
height: '50px',
extClass: className
})
Base library 2.7.0 starts to support, and low versions need to be compatible.
Override the current selection and set a paragraph of text
Property | Type | The default | Required | Description |
---|---|---|---|---|
text | string | Whether | The content of the text | |
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Base library 2.7.0 starts to support, and low versions need to be compatible.
Recovery
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Base library 2.7.0 starts to support, and low versions need to be compatible.
Clears the style of the current selection
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Base library 2.8.3 is supported from now on, and low versions need to be compatible.
Causes the editor cursor to scroll into the window's visual area.
Base library 2.7.0 starts to support, and low versions need to be compatible.
Initialize the editor content, html and delta only take effect when they exist at the same time
Property | Type | The default | Required | Description |
---|---|---|---|---|
Html | string | Whether | Tagged HTML content | |
delta | Object | Whether | The delta object that represents the content | |
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
Base library 2.7.0 starts to support, and low versions need to be compatible.
Revoke
Property | Type | The default | Required | Description |
---|---|---|---|---|
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |