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AW,EAE/C,EACF,GAGN,CAAA","names":["Placeholder","Extension","Plugin","PluginKey","doc","selection","active","anchor","decorations","emptyDocInstance","isEditorEmpty","node","pos","hasAnchor","isEmpty","classes","decoration","Decoration","DecorationSet"],"sources":["../esm/npm/@tiptap/extension-placeholder@2.1.13/node_modules/@tiptap/extension-placeholder/src/placeholder.ts"],"sourcesContent":["import { Editor, Extension } 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  emptyEditorClass: string\n  emptyNodeClass: string\n  placeholder:\n    | ((PlaceholderProps: {\n        editor: Editor\n        node: ProsemirrorNode\n        pos: number\n        hasAnchor: boolean\n      }) =\u003e string)\n    | string\n  showOnlyWhenEditable: boolean\n  showOnlyCurrent: boolean\n  includeChildren: boolean\n}\n\nexport const Placeholder = Extension.create\u003cPlaceholderOptions\u003e({\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 }) =\u003e {\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            // only calculate isEmpty once due to its performance impacts (see issue #3360)\n            const emptyDocInstance = doc.type.createAndFill()\n            const isEditorEmpty = emptyDocInstance?.sameMarkup(doc)\n              \u0026\u0026 emptyDocInstance.content.findDiffStart(doc.content) === null\n\n            doc.descendants((node, pos) =\u003e {\n              const hasAnchor = anchor \u003e= pos \u0026\u0026 anchor \u003c= pos + node.nodeSize\n              const isEmpty = !node.isLeaf \u0026\u0026 !node.childCount\n\n              if ((hasAnchor || !this.options.showOnlyCurrent) \u0026\u0026 isEmpty) {\n                const classes = [this.options.emptyNodeClass]\n\n                if (isEditorEmpty) {\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"],"version":3}
