New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

prosemirror-resizable-view

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-resizable-view

A ProseMirror node view that make your node resizable


Version published
Weekly downloads
35K
decreased by-25.61%
Maintainers
1
Weekly downloads
 
Created

prosemirror-resizable-view

A ProseMirror node view that make your node resizable

Version Weekly Downloads Bundled size Typed Codebase MIT License

Installation

# yarn
yarn add prosemirror-resizable-view

# pnpm
pnpm add prosemirror-resizable-view

# npm
npm install prosemirror-resizable-view

Usage

The following code creates an resizable image node view.

import { ResizableNodeView } from 'prosemirror-resizable-view';

const createInnerImage = ({ node }: { node: ProsemirrorNode }) => {
  const inner = document.createElement('img');
  inner.setAttribute('src', node.attrs.src);
  inner.style.width = '100%';
  inner.style.minWidth = '50px';
  inner.style.objectFit = 'contain'; // maintain image's aspect ratio
  return inner;
};

/**
 * ResizableImageView is a NodeView for image. You can resize the image by
 * dragging the handle over the image.
 */
export class ResizableImageView extends ResizableNodeView implements NodeView {
  constructor(node: ProsemirrorNode, view: EditorView, getPos: () => number) {
    super({ node, view, getPos, createElement: createInnerImage });
  }
}

FAQs

Package last updated on 15 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts