Skip to main content

prosemirror-resizable-view

package prosemirror-resizable-view

class ResizableNodeView

ResizableNodeView serves as a base NodeView for resizable element, and cannot be directly instantiated. With this base NodeView, you can resize the DOM element by dragging the handle over the image.

Signature:

export declare abstract class ResizableNodeView implements NodeView 

Implements: NodeView

ResizableNodeView.(constructor)

Constructs a new instance of the ResizableNodeView class

Signature:

constructor({ node, view, getPos, aspectRatio, options, initialSize, }: {
node: ProsemirrorNode;
view: EditorView;
getPos: () => number;
aspectRatio?: ResizableRatioType;
options?: OptionShape;
initialSize?: {
width: number;
height: number;
};
});

Parameters:

ParameterTypeDescription
{ node, view, getPos, aspectRatio, options, initialSize, }{ node: ProsemirrorNode; view: EditorView; getPos: () => number; aspectRatio?: ResizableRatioType; options?: OptionShape; initialSize?: { width: number; height: number; }; }

property aspectRatio

Signature:

readonly aspectRatio: ResizableRatioType;

property dom

Signature:

dom: HTMLElement;

method createElement

createElement - a method to produce the element DOM element for this prosemirror node. The subclasses have to implement this abstract method.

Signature:

abstract createElement(props: {
node: ProsemirrorNode;
view: EditorView;
getPos: () => number;
options?: OptionShape;
}): HTMLElement;

Parameters:

ParameterTypeDescription
props{ node: ProsemirrorNode; view: EditorView; getPos: () => number; options?: OptionShape; }

Returns:

HTMLElement

method createWrapper

Signature:

createWrapper(node: ProsemirrorNode, initialSize?: {
width: number;
height: number;
}): HTMLElement;

Parameters:

ParameterTypeDescription
nodeProsemirrorNode
initialSize{ width: number; height: number; }(Optional)

Returns:

HTMLElement

method destroy

Signature:

destroy(): void;

Returns:

void

method startResizing

Signature:

startResizing(e: MouseEvent, view: EditorView, getPos: () => number, handle: ResizableHandle): void;

Parameters:

ParameterTypeDescription
eMouseEvent
viewEditorView
getPos() => number
handleResizableHandle

Returns:

void

method update

update will be called by Prosemirror, when the view is updating itself.

Signature:

update(node: ProsemirrorNode): boolean;

Parameters:

ParameterTypeDescription
nodeProsemirrorNode

Returns:

boolean

enum ResizableRatioType

Signature:

export declare enum ResizableRatioType 

Enumeration Members:

MemberValueDescription
Fixed0
Flexible1