{"version":3,"sources":["jsdelivr-header.js","/npm/@tiptap/extension-placeholder@2.11.9/src/placeholder.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,sOCkEa,MAAA,EAAc,EAAU,OAA2B,CAC9D,KAAM,cAEN,WAAU,KACD,CACL,iBAAkB,kBAClB,eAAgB,WAChB,YAAa,oBACb,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,IAIrB,qBAAA,GACE,MAAO,CACL,IAAI,EAAO,CACT,IAAK,IAAI,EAAU,eACnB,MAAO,CACL,YAAa,EAAG,MAAK,gBACnB,MAAM,EAAS,KAAK,OAAO,aAAe,KAAK,QAAQ,sBACjD,OAAE,GAAW,EACb,EAA4B,GAElC,IAAK,EACH,OAAO,KAGT,MAAM,EAAa,KAAK,OAAO,QAgC/B,OA9BA,EAAI,aAAY,CAAC,EAAM,KACrB,MAAM,EAAY,GAAU,GAAO,GAAU,EAAM,EAAK,SAClD,GAAW,EAAK,QAAU,EAAY,GAE5C,IAAK,IAAc,KAAK,QAAQ,kBAAoB,EAAS,CAC3D,MAAM,EAAU,CAAC,KAAK,QAAQ,gBAE1B,GACF,EAAQ,KAAK,KAAK,QAAQ,kBAG5B,MAAM,EAAa,EAAW,KAAK,EAAK,EAAM,EAAK,SAAU,CAC3D,MAAO,EAAQ,KAAK,KACpB,mBACsC,mBAA7B,KAAK,QAAQ,YAChB,KAAK,QAAQ,YAAY,CACzB,OAAQ,KAAK,OACb,OACA,MACA,cAEA,KAAK,QAAQ,cAGrB,EAAY,KAAK,E,CAGnB,OAAO,KAAK,QAAQ,eAAe,IAG9B,EAAc,OAAO,EAAK,EAAY,KAKtD,W","file":"/npm/@tiptap/extension-placeholder@2.11.9/dist/index.js/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/@tiptap/extension-placeholder@2.11.9/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { Editor, Extension, isNodeEmpty } from '@tiptap/core'\nimport { Node as ProsemirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport interface PlaceholderOptions {\n  /**\n   * **The class name for the empty editor**\n   * @default 'is-editor-empty'\n   */\n  emptyEditorClass: string\n\n  /**\n   * **The class name for empty nodes**\n   * @default 'is-empty'\n   */\n  emptyNodeClass: string\n\n  /**\n   * **The placeholder content**\n   *\n   * You can use a function to return a dynamic placeholder or a string.\n   * @default 'Write something …'\n   */\n  placeholder:\n    | ((PlaceholderProps: {\n        editor: Editor\n        node: ProsemirrorNode\n        pos: number\n        hasAnchor: boolean\n      }) => string)\n    | string\n\n  /**\n   * See https://github.com/ueberdosis/tiptap/pull/5278 for more information.\n   * @deprecated This option is no longer respected and this type will be removed in the next major version.\n   */\n  considerAnyAsEmpty?: boolean\n\n  /**\n   * **Checks if the placeholder should be only shown when the editor is editable.**\n   *\n   * If true, the placeholder will only be shown when the editor is editable.\n   * If false, the placeholder will always be shown.\n   * @default true\n   */\n  showOnlyWhenEditable: boolean\n\n  /**\n   * **Checks if the placeholder should be only shown when the current node is empty.**\n   *\n   * If true, the placeholder will only be shown when the current node is empty.\n   * If false, the placeholder will be shown when any node is empty.\n   * @default true\n   */\n  showOnlyCurrent: boolean\n\n  /**\n   * **Controls if the placeholder should be shown for all descendents.**\n   *\n   * If true, the placeholder will be shown for all descendents.\n   * If false, the placeholder will only be shown for the current node.\n   * @default false\n   */\n  includeChildren: boolean\n}\n\n/**\n * This extension allows you to add a placeholder to your editor.\n * A placeholder is a text that appears when the editor or a node is empty.\n * @see https://www.tiptap.dev/api/extensions/placeholder\n */\nexport const Placeholder = Extension.create<PlaceholderOptions>({\n  name: 'placeholder',\n\n  addOptions() {\n    return {\n      emptyEditorClass: 'is-editor-empty',\n      emptyNodeClass: 'is-empty',\n      placeholder: 'Write something …',\n      showOnlyWhenEditable: true,\n      showOnlyCurrent: true,\n      includeChildren: false,\n    }\n  },\n\n  addProseMirrorPlugins() {\n    return [\n      new Plugin({\n        key: new PluginKey('placeholder'),\n        props: {\n          decorations: ({ doc, selection }) => {\n            const active = this.editor.isEditable || !this.options.showOnlyWhenEditable\n            const { anchor } = selection\n            const decorations: Decoration[] = []\n\n            if (!active) {\n              return null\n            }\n\n            const isEmptyDoc = this.editor.isEmpty\n\n            doc.descendants((node, pos) => {\n              const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize\n              const isEmpty = !node.isLeaf && isNodeEmpty(node)\n\n              if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {\n                const classes = [this.options.emptyNodeClass]\n\n                if (isEmptyDoc) {\n                  classes.push(this.options.emptyEditorClass)\n                }\n\n                const decoration = Decoration.node(pos, pos + node.nodeSize, {\n                  class: classes.join(' '),\n                  'data-placeholder':\n                    typeof this.options.placeholder === 'function'\n                      ? this.options.placeholder({\n                        editor: this.editor,\n                        node,\n                        pos,\n                        hasAnchor,\n                      })\n                      : this.options.placeholder,\n                })\n\n                decorations.push(decoration)\n              }\n\n              return this.options.includeChildren\n            })\n\n            return DecorationSet.create(doc, decorations)\n          },\n        },\n      }),\n    ]\n  },\n})\n"]}