Rich Text
EditorContext
Functional description: EditorContext instance, which can be obtained bywx.createSelectorQuery EditorContext is bound to an editor component by id and operates the corresponding editor component.
.blur
TIP
The API usage is as follows: EditorContext.blur(Object object)
- Functional description: The editor loses focus and the keyboard is closed at the same time.
- Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)
.clear
TIP
The API usage is as follows: EditorContext.clear(Object object)
- Functional description: Clear the editor content.
- Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)
.format
TIP
The API usage is as follows: EditorContext.format(string name, string value)
Functional description: Modify the style.
Parameters and descriptions:
- string name,Properties;
- string value, Value
List of styles that can be set:
name value bold - italic - underline - strike - ins - script sub / super header H1 / H2 / h3 / H4 / h5 / H6 align left / center / right / justify direction rtl indent -1 / +1 list ordered / bullet / check color hex color backgroundColor hex color margin/marginTop/marginBottom/marginLeft/marginRight css style padding/paddingTop/paddingBottom/paddingLeft/paddingRight css style font/fontSize/fontStyle/fontVariant/fontWeight/fontFamily css style lineHeight css style letterSpacing css style textDecoration css style textIndent css style wordWrap css style wordBreak css style whiteSpace css style Setting a selection that has already applied a style will cancel the style. css style represents the allowed values
.getContents
TIP
The API usage is as follows: EditorContext.getContents(Object object)
Functional description: Get the editor content.
Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) - object.success Callback function
Parameter Object.res
Properties Type Description html string HTML content with tags text string Plain text content delta Object Delta object representing the content
.getSelectionText
TIP
The API usage is as follows: EditorContext.getSelectionText(Object object)
Functional description: Get the plain text content in the selected area of
Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) - object.success Callback function
Parameter Object.res
Properties Type Description text string Plain text content
.insertDivider
TIP
The API usage is as follows: EditorContext.insertDivider(Object object)
- Functional description: Insert a dividing line.
- Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)
.insertlmage
TIP
The API usage is as follows: EditorContext.insertlmage(Object object)
Functional description: Insert an image.
- When the address is a temporary file, the tag in the obtained editor html format content adds the attribute data-local, and the image attributes in the deta format content adds the data-local field, which is the temporary file address passed in.
- Developers can choose to upload images to the server during the submission phase and replace them after obtaining the network address. When replacing, the src value of should be replaced for html content, and the insert { image: abc } value should be replaced for delta content.
Parameters and descriptions: Object object
Properties Type Default value Required Description src string - Yes Image address, only supports http(s), base64, temporary files nowrap boolean false No Whether to automatically wrap after inserting the image, default wrap alt string - No Alternative text when the image cannot be displayed width string - No Image width (pixels/percentage) height string - No Image height (pixels/percentage) extClass string - No Class name added to the image img tag data Object - No Data is serialized into the format of name=value;name1=value2 and hung on the attribute data-custom success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (will be executed for both successful and failed calls) Sample code:
this.editorCtx.insertImage({
src: 'xx',
width: '100px',
height: '50px',
extClass: className
}).insertText
TIP
The API usage is as follows: EditorContext.insertText(Object object)
- Functional description: Overwrite the current selection and set a text.
- Parameters and descriptions: Object object
Properties Type Default value Required Description text string - No Text content success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)
.redo
TIP
The API usage is as follows: EditorContext.redo(Object object)
- Functional description: Restore
- Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)
.removeFormat
TIP
The API usage is as follows: EditorContext.removeFormat(Object object)
- Functional description: Clear the style of the current selection.
- Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)
.scrolllntoView
TIP
The API usage is as follows: EditorContext.scrollIntoView()
- Functional description: Make the editor cursor scroll to the visible area of
.setContents
TIP
The API usage is as follows: EditorContext.setContents(Object object)
- Functional description: Initialize the editor content, only delta takes effect when html and delta exist at the same time.
- Parameters and descriptions: Object object
Properties Type Default value Required Description html string - No HTML content with tags delta Object - No Delta object representing the content success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)
.undo
TIP
The API usage is as follows: EditorContext.undo(Object object)
- Functional description: Undo.
- Parameters and descriptions: Object object
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure)