Skip to content

Instantly share code, notes, and snippets.

@angelikatyborska
Created March 24, 2023 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelikatyborska/48bf910c6a3a79a9441e5c03a721211c to your computer and use it in GitHub Desktop.
Save angelikatyborska/48bf910c6a3a79a9441e5c03a721211c to your computer and use it in GitHub Desktop.
TipTap recipes
// Copy the HTML of the current selection
import { getHTMLFromFragment } from "@tiptap/core";
import { Fragment, Node } from "prosemirror-model";
getHTMLFromFragment(
editor.view.state.selection.content().content,
editor.schema
)
// Copy the text of the current selection
const { view, state } = editor
const { from, to } = view.state.selection
state.doc.textBetween(from, to, '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment