Socket
Book a DemoInstallSign in
Socket

prosemirror-svelte-nodeview

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-svelte-nodeview

Create a ProseMirror NodeView using Svelte.

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
8
-11.11%
Maintainers
1
Weekly downloads
 
Created
Source

prosemirror-svelte-nodeview

Create a ProseMirror NodeView using Svelte.

Basic usage

A basic heading NodeView (SimpleHeadingView)

<script lang="ts">
  export var attrs: { level: number };
  export let contentDOM:  (node: HTMLElement) => void;

  $: tag = `h${attrs.level}`;

</script>

<svelte:element this={tag} use:contentDOM />

Loading the component using the plugin


EditorState.create({
  doc,
  plugins: [
    sveltePlugin({
      nodes: {
        heading: SimpleHeadingView,
      }
    })
  ]
})

Component props

These props are passed to the components loaded into this plugin.

type ComponentProps = {
  attrs?: Record<string, unknown>;
  controls?: SvelteNodeViewControls,
  contentDOM?: (node: HTMLElement) => void,
  rootDOM?: (node: HTMLElement) => void,
}

export interface SvelteNodeViewControls {
  delete: () => void;
  update: (cb: (editorState: EditorState, node?: Node, getPos?: () => number) => Transaction) => void;
}

Examples

Check out the basic example project for a more complete example component showing the use of a nested editor to edit attributes.

Keywords

svelte

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.