@vrite/tiptap-solid
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

TipTap-Solid

TipTap integration with Solid.js, used in Vrite

Installation

Make sure to have peer-dependencies (solid-js, @tiptap/core and @tiptap/pm) already installed.

npm i @vrite/tiptap-solid

Getting started

The integration is based on the official @tiptap/react package, that's documented in the TipTap docs, with several changes necessary to adapt it to Solid.js.

Here are some examples of common use-cases:

Creating the editor

import { SolidEditorContent, useEditor } from "@vrite/tiptap-solid";

// ...
const editor = useEditor({
  extensions: [
    // ...
  ],
  // ...
});

// Rendering
<SolidEditorContent editor={editor()} />;

Creating Solid-based Node Views

import { SolidNodeViewRenderer } from "@vrite/tiptap-solid";

const CustomNode = Node.create({
  // ...
  addNodeView() {
    return SolidNodeViewRenderer(CustomNodeView);
  },
  // ...
});

In the CustomNodeView component, you can access the Node's state, including attributes, options, etc.

import { NodeViewWrapper, useSolidNodeView } from "@vrite/tiptap-solid";

const CustomNodeView = () => {
  const { state } = useSolidNodeView();
  const updateAttribute = (key, value) => {
    state().updateAttributes({ [key]: value });
  };
  const options = () => state().extension.options;
  const selected = () => {
    return state().selected;
  };
  const attrs = () => {
    return state().node.attrs;
  };

  return <NodeViewWrapper>{/* Your Node View*/}</NodeViewWrapper>;
};

Creating Bubble Menu

// Rendering
<BubbleMenuWrapper
  editor={editor()}
  tippyOptions={
    {
      // ...
    }
  }
  shouldShow={({ editor, state, view, from, to }) => {
    // ...
  }}
>
  {/* Your menu */}
</BubbleMenuWrapper>

Package Sidebar

Install

npm i @vrite/tiptap-solid

Weekly Downloads

238

Version

1.0.0

License

MIT

Unpacked Size

103 kB

Total Files

31

Last publish

Collaborators

  • areknawo(u)