0.1.7 • Published 5 months ago

@prose-motions/core v0.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@prose-motions/core is a lightweight extension that brings Vim's Normal / Insert modes and an ever-growing collection of native keybindings to any Tiptap (v2) or ProseMirror editor.

Installation

bun add @prose-motions/core  # or npm/yarn/pnpm

Usage (Tiptap React example)

import { EditorContent, useEditor } from '@tiptap/react'
import StarterKit from '@tiptap/starter-kit'
import { VimMode } from '@prose-motions/core'

function MyEditor () {
  const editor = useEditor({
    extensions: [StarterKit, VimMode],
    content: '<p>hello world</p>'
  })

  return <EditorContent editor={editor} />
}

Usage (ProseMirror React example)

import { useState } from 'react'
import {
	ProseMirror,
	ProseMirrorDoc,
	reactKeys,
} from '@handlewithcare/react-prosemirror'
import { EditorState } from 'prosemirror-state'
import { schema } from 'prosemirror-schema-basic'
import { VimMode } from '@prose-motions/core'

export default function MyProseMirror () {
    return (
        <ProseMirror
            defaultState={EditorState.create({
                schema,
                plugins: [
                // The reactKeys plugin is required for the ProseMirror component to work!
                reactKeys(),
                ...VimMode.addProseMirrorPlugins()
                ],
            })}
        >
            <ProseMirrorDoc />
        </ProseMirror>
  );
}

This snippet uses the modern "React × ProseMirror" bridge maintained by Handle with Care (handlewithcarecollective/react-prosemirror). It automatically handles state-tearing issues by updating the EditorView inside a layout effect

0.1.7

5 months ago

0.1.6

5 months ago

0.1.5

5 months ago

0.1.4

5 months ago

0.1.3

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago

0.1.0

5 months ago