OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-editor / src / extensions / text-content.js

21 lines · javascript ref:
import { Extension as t } from "@tiptap/core"
export const TextContent = t.create({
  name: "textContent",
  addKeyboardShortcuts() {
    return {
      "Shift-Enter": () => {
        const { editor: t } = this,
          { state: e } = t,
          { $head: r, $anchor: o, from: n, to: a } = e.selection
        if (n === a && r.sameParent(o) && !(r.depth > 1))
          return this.editor.commands.first(({ commands: t }) => [
            () => t.newlineInCode(),
            () => t.createParagraphNear(),
            () => t.liftEmptyBlock(),
            () => t.splitBlock(),
          ])
      },
    }
  },
})