@gotipe/core
v0.1.6
Published
Headless core of the GoTipe editor: document model, transactions, commands, events and extensions.
Maintainers
Readme
@gotipe/core
The headless core of GoTipe: the editor, its document model, transactions, commands, events and the built-in extensions. It draws nothing itself; the framework adapters and the ready UI are built on it.
Docs · Website · Repository
Install
npm install @gotipe/core@gotipe/wasm is an optional peer dependency: install it when you want the Rust engine, for
example for collaboration. Without it, use engine: "js". See
engines.
Usage
import { createEditor } from "@gotipe/core";
import { DefaultPreset } from "@gotipe/core/presets";
const editor = await createEditor({
extensions: [DefaultPreset],
engine: "js",
content: {
version: 1,
blocks: [
{
id: "intro",
type: "paragraph",
attrs: {},
content: [{ text: "Hello, GoTipe.", marks: [] }],
children: [],
},
],
},
});
editor.on("update", ({ editor }) => localStorage.setItem("doc", JSON.stringify(editor.getJSON())));
console.log(editor.getMarkdown(), editor.getHTML());To show and edit the document in a page, use an adapter such as
@gotipe/react or
@gotipe/vue, or mount the editor on your own
renderer with editor.mount(element).
On a server, convert a document without a DOM:
import { renderToHtml } from "@gotipe/core/server";
const html = await renderToHtml(documentJson);Entry points
@gotipe/core:createEditor(engine"auto","js"or"wasm"),createEditorWithLoader,defineExtension,GoTipeErrorand the document types.@gotipe/core/js: the same API with the JS engine only; nothing references WebAssembly.@gotipe/core/presets:MinimalPreset,DefaultPresetandFullPreset.@gotipe/core/extensions: the individual extensions (Paragraph,Heading,Table,Placeholder,CharacterCountand more).@gotipe/core/server:renderToHtml,renderToMarkdown,renderToTextandcreateHeadlessEditorfor Node.@gotipe/core/menus:createBubbleMenuandcreateFloatingMenuwithout a framework.@gotipe/core/emoji,@gotipe/core/emoji/ruand@gotipe/core/math: optional emoji data and the TeX to MathML converter.
License
MIT. See LICENSE.
