{"version":3,"file":"schema.cjs","sources":["../../../components/editor/schema.ts"],"sourcesContent":["import { Schema } from 'prosemirror-model';\nimport type { MentionAttrs } from './mention';\n\n/**\n * A deliberately tiny schema: one paragraph of text, hard breaks, and atomic\n * mentions. Nothing else, so pasted HTML sanitizes to plain text for free —\n * there is no mark or block the parser could keep.\n */\nexport const editorSchema = new Schema({\n  nodes: {\n    doc: { content: 'paragraph' },\n\n    paragraph: {\n      content: 'inline*',\n      parseDOM: [{ tag: 'p' }],\n      toDOM: () => ['p', 0]\n    },\n\n    text: { group: 'inline' },\n\n    hardBreak: {\n      inline: true,\n      group: 'inline',\n      selectable: false,\n      parseDOM: [{ tag: 'br' }],\n      toDOM: () => ['br']\n    },\n\n    mention: {\n      inline: true,\n      group: 'inline',\n      // Atomic: the cursor never enters it, so it deletes and moves as one unit.\n      atom: true,\n      selectable: true,\n      // ProseMirror makes inline atoms draggable by default, which would let a\n      // chip be dropped into the middle of a word.\n      draggable: false,\n      attrs: {\n        id: {},\n        label: {},\n        type: { default: 'mention' },\n        trigger: { default: '@' }\n      },\n      parseDOM: [\n        {\n          tag: 'span[data-mention-id]',\n          getAttrs: dom => {\n            const el = dom as HTMLElement;\n            return {\n              id: el.getAttribute('data-mention-id') ?? '',\n              label: el.getAttribute('data-mention-label') ?? el.textContent,\n              type: el.getAttribute('data-mention-type') ?? 'mention',\n              trigger: el.getAttribute('data-mention-trigger') ?? '@'\n            };\n          }\n        }\n      ],\n      // Only used for the clipboard's `text/html` flavour — on screen the node\n      // view owns the element. Pasting this back restores the chip with its id.\n      toDOM: node => {\n        const { id, label, type, trigger } = node.attrs as MentionAttrs;\n        return [\n          'span',\n          {\n            'data-mention-id': id,\n            'data-mention-label': label,\n            'data-mention-type': type,\n            'data-mention-trigger': trigger\n          },\n          `${trigger}${label}`\n        ];\n      }\n    }\n  }\n});\n\nexport const mentionType = editorSchema.nodes.mention;\nexport const hardBreakType = editorSchema.nodes.hardBreak;\nexport const paragraphType = editorSchema.nodes.pa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