Types
ts
export type PluginNewCall = (
imageMarkInstance: ImageMark,
pluginOptions?: PluginOptions
) => PluginStatic Methods
usePlugin
ts
// Use a plugin
usePlugin(plugin: typeof Plugin, pluginOptions?: PluginOptions): ImageMarkunusePlugin
ts
// Unuse a plugin
unusePlugin(plugin: typeof Plugin): ImageMarkhasPlugin
ts
// Check if a plugin is in use
hasPlugin(plugin: typeof Plugin): booleanuseDefaultPlugin
Use default plugins, which include the built-in shape and selection plugins
ts
useDefaultPlugin(): voidunuseDefaultPlugin
ts
// Unuse default plugins
unuseDefaultPlugin(): voidInstance Methods
resize
ts
// Triggered when the container size changes
resize(): voidrerender
ts
// Triggered when re-rendering
rerender(): voiddestroy
ts
// Destroy the instance
destroy(): voidaddDefaultAction
ts
// Add default actions to the instance, currently including canvas zooming and moving
addDefaultAction(): ImageMarkremoveDefaultAction
ts
// Remove default actions from the instance
removeDefaultAction(): ImageMarkaddStageLmbDownMoveing
ts
// Add canvas moving
addStageLmbDownMoveing(): ImageMarkremoveStageLmbDownMoveing
ts
// Remove canvas moving
removeStageLmbDownMoveing(): ImageMarkaddStageMouseScale
ts
// Add canvas zooming
addStageMouseScale(): ImageMarkremoveStageMouseScale
ts
// Remove canvas zooming
removeStageMouseScale(): ImageMarkmoveTo
ts
export type Position =
| 'left-top'
| 'right-top'
| 'left-bottom'
| 'right-bottom'
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'center'
// Move to a specified position
moveTo(position: Position): ImageMarkmove
ts
export type ArrayPoint = [number, number]
// Move to specified coordinates
move(point: ArrayPoint): ImageMarkstartSuccessiveMove
ts
// Start successive moving
startSuccessiveMove(point: ArrayPoint): ImageMarkmoveSuccessive
ts
// Successive moving
moveSuccessive(point: ArrayPoint): ImageMarkendSuccessiveMove
ts
// Stop successive moving
endSuccessiveMove(): ImageMarkscale
ts
// Scale the canvas
scale(
direction: 1 | -1, // 1 for zoom-in, -1 for zoom-out
point: ArrayPoint | 'left-top' | 'center', // zoom-in point
reletiveTo: 'container' | 'image' = 'container', // relative to whom
newScale?: number // new scaling ratio, if provided, scale directly to this ratio
): ImageMarkscaleTo
ts
// Scale to a specific ratio
scaleTo(
options: ImageMarkOptions['initScaleConfig'],
point: ArrayPoint | 'left-top' | 'center', // zoom-in point
reletiveTo: 'container' | 'image' = 'container' // relative to whom
): ImageMarksetMinScale
ts
export type InitialScaleSize = 'fit' | 'original' | 'width' | 'height' | 'cover'
// Set minimum scaling ratio
setMinScale(minScale: number|InitialScaleSize): ImageMarksetMaxScale
ts
// Set maximum scaling ratio
setMaxScale(maxScale: number|InitialScaleSize): ImageMarkgetCurrentScale
ts
// Get the current scale ratio
getCurrentScale(): numberon
Bind instance events, currently refer to the events documentation for events that can be listened to by the instance
ts
on(...rest: any): void // Reference the on method of eventemitter3off
ts
// Unbind instance events
off(...rest: any): void // Reference the off method of eventemitter3setImageFullOfContainer
ts
// Set whether the image can be full of the container
setImageFullOfContainer(enable: boolean): ImageMarksetEnableDrawShapeOutOfImg
ts
// Set whether the shape can be out of the image when drawing
setEnableDrawShapeOutOfImg(enable: boolean): ImageMarksetEnableMoveShapeOutOfImg
ts
// Set whether the shape can be out of the image when moving
setEnableMoveShapeOutOfImg(enable: boolean): ImageMarksetEnableEditShapeOutOfImg
ts
// Set whether the shape can be out of the image when editing
setEnableEditShapeOutOfImg(enable: boolean): ImageMarksetEnableShapeOutOfImg
ts
// Set whether the shape can be out of the image, including all actions, such as moving, drawing, and editing
setEnableShapeOutOfImg(enable: boolean): ImageMarkinitPlugin
ts
// Initialize a plugin
initPlugin(plugin: typeof Plugin|PluginNewCall, pluginOptions?: PluginOptions): ImageMarkaddPlugin
ts
// Add a plugin to the instance, currently has the same effect as `initPlugin`
addPlugin(plugin: typeof Plugin|PluginNewCall, pluginOptions?: PluginOptions): ImageMarkremovePlugin
ts
// Remove a plugin from the instance
removePlugin(plugin: typeof Plugin): ImageMarkgetShapePlugin
ts
// Get the `shape plugin` instance on the instance
getShapePlugin(): ShapePlugin | nullgetSelectionPlugin
ts
// Get the `selection plugin` instance on the instance
getSelectionPlugin(): SelectionPlugin | nullgetHistoryPlugin
ts
// Get the `history plugin` instance on the instance
getHistoryPlugin(): HistoryPlugin | nullgetShortcutPlugin
ts
// Get the `shortcut plugin` instance on the instance
getShortcutPlugin(): ShortcutPlugin | nullsetReadonly
ts
// Set the readonly state of the instance
setReadonly(readonly: boolean): ImageMark