{
  "name": "lit-example-table",
  "title": "lit-example-table",
  "type": "registry:block",
  "description": "Table node with row and column operations.",
  "registryDependencies": [
    "https://unpkg.com/prosekit-registry/dist/r/lit-sample-sample-doc-table.json",
    "https://unpkg.com/prosekit-registry/dist/r/lit-ui-editor-context.json",
    "https://unpkg.com/prosekit-registry/dist/r/lit-ui-table-handle.json"
  ],
  "dependencies": [
    "@lit/context",
    "prosekit@^0.23.2"
  ],
  "files": [
    {
      "path": "registry/src/lit/examples/table/editor.ts",
      "type": "registry:component",
      "target": "components/editor/examples/table/editor.ts",
      "content": "import 'prosekit/basic/style.css'\nimport 'prosekit/basic/typography.css'\n\nimport { ContextProvider } from '@lit/context'\nimport { html, LitElement, type PropertyDeclaration, type PropertyValues } from 'lit'\nimport { createRef, ref, type Ref } from 'lit/directives/ref.js'\nimport type { Editor, NodeJSON } from 'prosekit/core'\nimport { createEditor } from 'prosekit/core'\n\nimport { sampleContent } from '../../sample/sample-doc-table.ts'\nimport { editorContext } from '../../ui/editor-context.ts'\nimport { registerLitEditorTableHandle } from '../../ui/table-handle/index.ts'\n\nimport { defineExtension } from './extension.ts'\n\nexport class LitEditor extends LitElement {\n  static override properties = {\n    initialContent: { attribute: false } satisfies PropertyDeclaration<NodeJSON | undefined>,\n  }\n\n  initialContent?: NodeJSON\n\n  private editor?: Editor\n  private ref: Ref<HTMLDivElement>\n\n  constructor() {\n    super()\n    this.ref = createRef<HTMLDivElement>()\n  }\n\n  override createRenderRoot() {\n    return this\n  }\n\n  override disconnectedCallback() {\n    this.editor?.unmount()\n    super.disconnectedCallback()\n  }\n\n  override willUpdate() {\n    if (this.editor) {\n      return\n    }\n\n    const extension = defineExtension()\n    this.editor = createEditor({\n      extension,\n      defaultContent: this.initialContent ?? sampleContent,\n    })\n    new ContextProvider(this, {\n      context: editorContext,\n      initialValue: this.editor,\n    })\n  }\n\n  override updated(changedProperties: PropertyValues) {\n    super.updated(changedProperties)\n    this.editor?.mount(this.ref.value)\n  }\n\n  override render() {\n    return html`<div class=\"box-border h-full w-full min-h-36 overflow-y-hidden overflow-x-hidden rounded-md border border-solid border-gray-200 dark:border-gray-700 shadow-sm flex flex-col bg-[canvas] text-black dark:text-white\">\n      <div class=\"relative w-full flex-1 box-border overflow-y-auto\">\n        <div ${ref(this.ref)} class=\"ProseMirror box-border min-h-full px-[max(4rem,calc(50%-20rem))] py-8 outline-hidden outline-0 [&_span[data-mention=user]]:text-blue-500 [&_span[data-mention=tag]]:text-violet-500\"></div>\n        <lit-editor-table-handle></lit-editor-table-handle>\n      </div>\n    </div>`\n  }\n}\n\nexport function registerLitEditor() {\n  registerLitEditorTableHandle()\n\n  if (customElements.get('lit-editor-example-table')) return\n  customElements.define('lit-editor-example-table', LitEditor)\n}\n\ndeclare global {\n  interface HTMLElementTagNameMap {\n    'lit-editor-example-table': LitEditor\n  }\n}\n"
    },
    {
      "path": "registry/src/lit/examples/table/extension.ts",
      "type": "registry:component",
      "target": "components/editor/examples/table/extension.ts",
      "content": "import { defineBaseKeymap, defineHistory, union } from 'prosekit/core'\nimport { defineDoc } from 'prosekit/extensions/doc'\nimport { defineGapCursor } from 'prosekit/extensions/gap-cursor'\nimport { defineParagraph } from 'prosekit/extensions/paragraph'\nimport { defineTable } from 'prosekit/extensions/table'\nimport { defineText } from 'prosekit/extensions/text'\n\nexport function defineExtension() {\n  return union(\n    defineBaseKeymap(),\n    defineDoc(),\n    defineText(),\n    defineParagraph(),\n    defineTable(),\n    defineHistory(),\n    defineGapCursor(),\n  )\n}\n\nexport type EditorExtension = ReturnType<typeof defineExtension>\n"
    },
    {
      "path": "registry/src/lit/examples/table/index.ts",
      "type": "registry:component",
      "target": "components/editor/examples/table/index.ts",
      "content": "export { LitEditor as ExampleEditor, registerLitEditor } from './editor.ts'\n"
    }
  ],
  "meta": {
    "hasIcons": false,
    "hidden": false,
    "story": "table",
    "framework": "lit",
    "accumulatedFiles": [
      "registry/src/lit/examples/table/editor.ts",
      "registry/src/lit/examples/table/extension.ts",
      "registry/src/lit/examples/table/index.ts",
      "registry/src/lit/sample/sample-doc-table.ts",
      "registry/src/lit/ui/editor-context.ts",
      "registry/src/lit/ui/table-handle/index.ts",
      "registry/src/lit/ui/table-handle/table-handle.ts"
    ],
    "internalDependencies": [
      "lit-sample-sample-doc-table",
      "lit-ui-editor-context",
      "lit-ui-table-handle"
    ]
  },
  "$schema": "https://ui.shadcn.com/schema/registry-item.json"
}
