@tiptap/extension-details 3.21.0 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -229,7 +229,10 @@ var Details = import_core2.Node.create({
229
229
  if (mutation.type === "selection") {
230
230
  return false;
231
231
  }
232
- return !dom.contains(mutation.target) || dom === mutation.target;
232
+ const target = mutation.target;
233
+ const isInsideWrapper = dom.contains(target);
234
+ const isInsideToggleButton = toggle.contains(target);
235
+ return isInsideToggleButton || !isInsideWrapper || dom === target;
233
236
  },
234
237
  update: (updatedNode) => {
235
238
  if (updatedNode.type !== this.type) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/details.ts","../src/helpers/isNodeVisible.ts","../src/helpers/findClosestVisibleNode.ts","../src/helpers/setGapCursor.ts","../src/content/details-content.ts","../src/summary/details-summary.ts"],"sourcesContent":["import { Details } from './details.js'\n\nexport * from './content/index.js'\nexport * from './details.js'\nexport * from './summary/index.js'\n\nexport default Details\n","import {\n createBlockMarkdownSpec,\n defaultBlockAt,\n findChildren,\n findParentNode,\n isActive,\n mergeAttributes,\n Node,\n} from '@tiptap/core'\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey, Selection, TextSelection } from '@tiptap/pm/state'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nimport { findClosestVisibleNode } from './helpers/findClosestVisibleNode.js'\nimport { isNodeVisible } from './helpers/isNodeVisible.js'\nimport { setGapCursor } from './helpers/setGapCursor.js'\n\nexport interface DetailsRenderToggleButtonOptions {\n /**\n * The toggle button element rendered by the node view.\n */\n element: HTMLButtonElement\n /**\n * The current open state of the details node.\n */\n isOpen: boolean\n /**\n * The current node used to derive toggle button state.\n */\n node: ProseMirrorNode\n}\n\nexport interface DetailsOptions {\n /**\n * Specify if the open status should be saved in the document. Defaults to `false`.\n */\n persist: boolean\n /**\n * Specifies a CSS class that is set when toggling the content. Defaults to `is-open`.\n */\n openClassName: string\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n /**\n * Customizes the rendered toggle button.\n */\n renderToggleButton: (options: DetailsRenderToggleButtonOptions) => void\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n details: {\n /**\n * Set a details node\n */\n setDetails: () => ReturnType\n /**\n * Unset a details node\n */\n unsetDetails: () => ReturnType\n }\n }\n}\n\nexport const Details = Node.create<DetailsOptions>({\n name: 'details',\n\n content: 'detailsSummary detailsContent',\n\n group: 'block',\n\n defining: true,\n\n isolating: true,\n\n // @ts-ignore reason: `allowGapCursor` is not a valid property by default, but the `GapCursor` extension adds it to the Nodeconfig type\n allowGapCursor: false,\n\n addOptions() {\n return {\n persist: false,\n openClassName: 'is-open',\n HTMLAttributes: {},\n renderToggleButton: ({ element, isOpen }) => {\n element.setAttribute('aria-label', isOpen ? 'Collapse details content' : 'Expand details content')\n },\n }\n },\n\n addAttributes() {\n if (!this.options.persist) {\n return []\n }\n\n return {\n open: {\n default: false,\n parseHTML: element => element.hasAttribute('open'),\n renderHTML: ({ open }) => {\n if (!open) {\n return {}\n }\n\n return { open: '' }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'details',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['details', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'details',\n content: 'block',\n }),\n\n addNodeView() {\n return ({ editor, getPos, node, HTMLAttributes }) => {\n const dom = document.createElement('div')\n const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n })\n\n Object.entries(attributes).forEach(([key, value]) => dom.setAttribute(key, value))\n\n const toggle = document.createElement('button')\n\n toggle.type = 'button'\n\n const renderToggleButton = (options: Omit<DetailsRenderToggleButtonOptions, 'element'>) => {\n this.options.renderToggleButton({\n element: toggle,\n ...options,\n })\n }\n\n dom.append(toggle)\n\n const content = document.createElement('div')\n\n dom.append(content)\n\n const toggleDetailsContent = (options?: { setToValue?: boolean; node?: ProseMirrorNode }) => {\n const { setToValue, node: currentNode = node } = options || {}\n\n if (setToValue !== undefined) {\n if (setToValue) {\n if (dom.classList.contains(this.options.openClassName)) {\n return\n }\n dom.classList.add(this.options.openClassName)\n } else {\n if (!dom.classList.contains(this.options.openClassName)) {\n return\n }\n dom.classList.remove(this.options.openClassName)\n }\n } else {\n dom.classList.toggle(this.options.openClassName)\n }\n\n const isOpen = dom.classList.contains(this.options.openClassName)\n\n renderToggleButton({\n isOpen,\n node: currentNode,\n })\n\n const event = new Event('toggleDetailsContent')\n const detailsContent = content.querySelector(':scope > div[data-type=\"detailsContent\"]')\n\n detailsContent?.dispatchEvent(event)\n }\n\n renderToggleButton({\n isOpen: Boolean(node.attrs.open),\n node,\n })\n\n if (node.attrs.open) {\n setTimeout(() => toggleDetailsContent())\n }\n\n toggle.addEventListener('click', () => {\n toggleDetailsContent()\n\n if (!this.options.persist) {\n editor.commands.focus(undefined, { scrollIntoView: false })\n\n return\n }\n\n if (editor.isEditable && typeof getPos === 'function') {\n const { from, to } = editor.state.selection\n\n editor\n .chain()\n .command(({ tr }) => {\n const pos = getPos()\n\n if (!pos) {\n return false\n }\n\n const currentNode = tr.doc.nodeAt(pos)\n\n if (currentNode?.type !== this.type) {\n return false\n }\n\n tr.setNodeMarkup(pos, undefined, {\n open: !currentNode.attrs.open,\n })\n\n return true\n })\n .setTextSelection({\n from,\n to,\n })\n .focus(undefined, { scrollIntoView: false })\n .run()\n }\n })\n\n return {\n dom,\n contentDOM: content,\n ignoreMutation(mutation: ViewMutationRecord) {\n if (mutation.type === 'selection') {\n return false\n }\n\n return !dom.contains(mutation.target) || dom === mutation.target\n },\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n // Only update the open state if set\n if (updatedNode.attrs.open !== undefined) {\n toggleDetailsContent({\n setToValue: updatedNode.attrs.open,\n node: updatedNode,\n })\n } else {\n renderToggleButton({\n isOpen: dom.classList.contains(this.options.openClassName),\n node: updatedNode,\n })\n }\n\n return true\n },\n }\n }\n },\n\n addCommands() {\n return {\n setDetails:\n () =>\n ({ state, chain }) => {\n const { schema, selection } = state\n const { $from, $to } = selection\n const range = $from.blockRange($to)\n\n if (!range) {\n return false\n }\n\n const slice = state.doc.slice(range.start, range.end)\n const match = schema.nodes.detailsContent.contentMatch.matchFragment(slice.content)\n\n if (!match) {\n return false\n }\n\n const content = slice.toJSON()?.content || []\n\n return chain()\n .insertContentAt(\n { from: range.start, to: range.end },\n {\n type: this.name,\n content: [\n {\n type: 'detailsSummary',\n },\n {\n type: 'detailsContent',\n content,\n },\n ],\n },\n )\n .setTextSelection(range.start + 2)\n .run()\n },\n\n unsetDetails:\n () =>\n ({ state, chain }) => {\n const { selection, schema } = state\n const details = findParentNode(node => node.type === this.type)(selection)\n\n if (!details) {\n return false\n }\n\n const detailsSummaries = findChildren(details.node, node => node.type === schema.nodes.detailsSummary)\n const detailsContents = findChildren(details.node, node => node.type === schema.nodes.detailsContent)\n\n if (!detailsSummaries.length || !detailsContents.length) {\n return false\n }\n\n const detailsSummary = detailsSummaries[0]\n const detailsContent = detailsContents[0]\n const from = details.pos\n const $from = state.doc.resolve(from)\n const to = from + details.node.nodeSize\n const range = { from, to }\n const content = (detailsContent.node.content.toJSON() as []) || []\n const defaultTypeForSummary = $from.parent.type.contentMatch.defaultType\n\n // TODO: this may break for some custom schemas\n const summaryContent = defaultTypeForSummary?.create(null, detailsSummary.node.content).toJSON()\n const mergedContent = [summaryContent, ...content]\n\n return chain()\n .insertContentAt(range, mergedContent)\n .setTextSelection(from + 1)\n .run()\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: () => {\n const { schema, selection } = this.editor.state\n const { empty, $anchor } = selection\n\n if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary) {\n return false\n }\n\n // for some reason safari removes the whole text content within a `<summary>`tag on backspace\n // so we have to remove the text manually\n // see: https://discuss.prosemirror.net/t/safari-backspace-bug-with-details-tag/4223\n if ($anchor.parentOffset !== 0) {\n return this.editor.commands.command(({ tr }) => {\n const from = $anchor.pos - 1\n const to = $anchor.pos\n\n tr.delete(from, to)\n\n return true\n })\n }\n\n return this.editor.commands.unsetDetails()\n },\n\n // Creates a new node below it if it is closed.\n // Otherwise inside `DetailsContent`.\n Enter: ({ editor }) => {\n const { state, view } = editor\n const { schema, selection } = state\n const { $head } = selection\n\n if ($head.parent.type !== schema.nodes.detailsSummary) {\n return false\n }\n\n const isVisible = isNodeVisible($head.after() + 1, editor)\n const above = isVisible ? state.doc.nodeAt($head.after()) : $head.node(-2)\n\n if (!above) {\n return false\n }\n\n const after = isVisible ? 0 : $head.indexAfter(-1)\n const type = defaultBlockAt(above.contentMatchAt(after))\n\n if (!type || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n const node = type.createAndFill()\n\n if (!node) {\n return false\n }\n\n const pos = isVisible ? $head.after() + 1 : $head.after(-1)\n const tr = state.tr.replaceWith(pos, pos, node)\n const $pos = tr.doc.resolve(pos)\n const newSelection = Selection.near($pos, 1)\n\n tr.setSelection(newSelection)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n },\n\n // The default gapcursor implementation can’t handle hidden content, so we need to fix this.\n ArrowRight: ({ editor }) => {\n return setGapCursor(editor, 'right')\n },\n\n // The default gapcursor implementation can’t handle hidden content, so we need to fix this.\n ArrowDown: ({ editor }) => {\n return setGapCursor(editor, 'down')\n },\n }\n },\n\n addProseMirrorPlugins() {\n return [\n // This plugin prevents text selections within the hidden content in `DetailsContent`.\n // The cursor is moved to the next visible position.\n new Plugin({\n key: new PluginKey('detailsSelection'),\n appendTransaction: (transactions, oldState, newState) => {\n const { editor, type } = this\n const isComposing = editor.view.composing\n\n if (isComposing) {\n return\n }\n\n const selectionSet = transactions.some(transaction => transaction.selectionSet)\n\n if (!selectionSet || !oldState.selection.empty || !newState.selection.empty) {\n return\n }\n\n const detailsIsActive = isActive(newState, type.name)\n\n if (!detailsIsActive) {\n return\n }\n\n const { $from } = newState.selection\n const isVisible = isNodeVisible($from.pos, editor)\n\n if (isVisible) {\n return\n }\n\n const details = findClosestVisibleNode($from, node => node.type === type, editor)\n\n if (!details) {\n return\n }\n\n const detailsSummaries = findChildren(\n details.node,\n node => node.type === newState.schema.nodes.detailsSummary,\n )\n\n if (!detailsSummaries.length) {\n return\n }\n\n const detailsSummary = detailsSummaries[0]\n const selectionDirection = oldState.selection.from < newState.selection.from ? 'forward' : 'backward'\n const correctedPosition =\n selectionDirection === 'forward'\n ? details.start + detailsSummary.pos\n : details.pos + detailsSummary.pos + detailsSummary.node.nodeSize\n const selection = TextSelection.create(newState.doc, correctedPosition)\n const transaction = newState.tr.setSelection(selection)\n\n return transaction\n },\n }),\n ]\n },\n})\n","import type { Editor } from '@tiptap/core'\n\nexport const isNodeVisible = (position: number, editor: Editor): boolean => {\n const node = editor.view.domAtPos(position).node as HTMLElement\n const isOpen = node.offsetParent !== null\n\n return isOpen\n}\n","import type { Editor, Predicate } from '@tiptap/core'\nimport type { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'\n\nimport { isNodeVisible } from './isNodeVisible.js'\n\nexport const findClosestVisibleNode = (\n $pos: ResolvedPos,\n predicate: Predicate,\n editor: Editor,\n):\n | {\n pos: number\n start: number\n depth: number\n node: ProseMirrorNode\n }\n | undefined => {\n for (let i = $pos.depth; i > 0; i -= 1) {\n const node = $pos.node(i)\n const match = predicate(node)\n const isVisible = isNodeVisible($pos.start(i), editor)\n\n if (match && isVisible) {\n return {\n pos: i > 0 ? $pos.before(i) : 0,\n start: $pos.start(i),\n depth: i,\n node,\n }\n }\n }\n}\n","import type { Editor } from '@tiptap/core'\nimport { findChildren, findParentNode } from '@tiptap/core'\nimport { GapCursor } from '@tiptap/pm/gapcursor'\nimport type { ResolvedPos } from '@tiptap/pm/model'\nimport type { Selection } from '@tiptap/pm/state'\n\nimport { isNodeVisible } from './isNodeVisible.js'\n\nexport const setGapCursor = (editor: Editor, direction: 'down' | 'right') => {\n const { state, view, extensionManager } = editor\n const { schema, selection } = state\n const { empty, $anchor } = selection\n const hasGapCursorExtension = !!extensionManager.extensions.find(extension => extension.name === 'gapCursor')\n\n if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary || !hasGapCursorExtension) {\n return false\n }\n\n if (direction === 'right' && $anchor.parentOffset !== $anchor.parent.nodeSize - 2) {\n return false\n }\n\n const details = findParentNode(node => node.type === schema.nodes.details)(selection)\n\n if (!details) {\n return false\n }\n\n const detailsContent = findChildren(details.node, node => node.type === schema.nodes.detailsContent)\n\n if (!detailsContent.length) {\n return false\n }\n\n const isOpen = isNodeVisible(details.start + detailsContent[0].pos + 1, editor)\n\n if (isOpen) {\n return false\n }\n\n const $position = state.doc.resolve(details.pos + details.node.nodeSize)\n const $validPosition = GapCursor.findFrom($position, 1, false) as unknown as null | ResolvedPos\n\n if (!$validPosition) {\n return false\n }\n\n const { tr } = state\n const gapCursorSelection = new GapCursor($validPosition) as Selection\n\n tr.setSelection(gapCursorSelection)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n}\n","import { createBlockMarkdownSpec, defaultBlockAt, findParentNode, mergeAttributes, Node } from '@tiptap/core'\nimport { Selection } from '@tiptap/pm/state'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nexport interface DetailsContentOptions {\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n}\n\nexport const DetailsContent = Node.create<DetailsContentOptions>({\n name: 'detailsContent',\n\n content: 'block+',\n\n defining: true,\n\n selectable: false,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `div[data-type=\"${this.name}\"]`,\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { 'data-type': this.name }), 0]\n },\n\n addNodeView() {\n return ({ HTMLAttributes }) => {\n const dom = document.createElement('div')\n const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n hidden: 'hidden',\n })\n\n Object.entries(attributes).forEach(([key, value]) => dom.setAttribute(key, value))\n\n dom.addEventListener('toggleDetailsContent', () => {\n dom.toggleAttribute('hidden')\n })\n\n return {\n dom,\n contentDOM: dom,\n ignoreMutation(mutation: ViewMutationRecord) {\n if (mutation.type === 'selection') {\n return false\n }\n\n return !dom.contains(mutation.target) || dom === mutation.target\n },\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n return true\n },\n }\n }\n },\n\n addKeyboardShortcuts() {\n return {\n // Escape node on double enter\n Enter: ({ editor }) => {\n const { state, view } = editor\n const { selection } = state\n const { $from, empty } = selection\n const detailsContent = findParentNode(node => node.type === this.type)(selection)\n\n if (!empty || !detailsContent || !detailsContent.node.childCount) {\n return false\n }\n\n const fromIndex = $from.index(detailsContent.depth)\n const { childCount } = detailsContent.node\n const isAtEnd = childCount === fromIndex + 1\n\n if (!isAtEnd) {\n return false\n }\n\n const defaultChildType = detailsContent.node.type.contentMatch.defaultType\n const defaultChildNode = defaultChildType?.createAndFill()\n\n if (!defaultChildNode) {\n return false\n }\n\n const $childPos = state.doc.resolve(detailsContent.pos + 1)\n const lastChildIndex = childCount - 1\n const lastChildNode = detailsContent.node.child(lastChildIndex)\n const lastChildPos = $childPos.posAtIndex(lastChildIndex, detailsContent.depth)\n const lastChildNodeIsEmpty = lastChildNode.eq(defaultChildNode)\n\n if (!lastChildNodeIsEmpty) {\n return false\n }\n\n // get parent of details node\n const above = $from.node(-3)\n\n if (!above) {\n return false\n }\n\n // get default node type after details node\n const after = $from.indexAfter(-3)\n const type = defaultBlockAt(above.contentMatchAt(after))\n\n if (!type || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n const node = type.createAndFill()\n\n if (!node) {\n return false\n }\n\n const { tr } = state\n const pos = $from.after(-2)\n\n tr.replaceWith(pos, pos, node)\n\n const $pos = tr.doc.resolve(pos)\n const newSelection = Selection.near($pos, 1)\n\n tr.setSelection(newSelection)\n\n const deleteFrom = lastChildPos\n const deleteTo = lastChildPos + lastChildNode.nodeSize\n\n tr.delete(deleteFrom, deleteTo)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n },\n }\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'detailsContent',\n }),\n})\n","import { createBlockMarkdownSpec, mergeAttributes, Node } from '@tiptap/core'\n\nexport interface DetailsSummaryOptions {\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n}\n\nexport const DetailsSummary = Node.create<DetailsSummaryOptions>({\n name: 'detailsSummary',\n\n content: 'text*',\n\n defining: true,\n\n selectable: false,\n\n isolating: true,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'summary',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['summary', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'detailsSummary',\n content: 'inline',\n }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAQO;AAEP,mBAA4D;;;ACRrD,IAAM,gBAAgB,CAAC,UAAkB,WAA4B;AAC1E,QAAM,OAAO,OAAO,KAAK,SAAS,QAAQ,EAAE;AAC5C,QAAM,SAAS,KAAK,iBAAiB;AAErC,SAAO;AACT;;;ACFO,IAAM,yBAAyB,CACpC,MACA,WACA,WAQe;AACf,WAAS,IAAI,KAAK,OAAO,IAAI,GAAG,KAAK,GAAG;AACtC,UAAM,OAAO,KAAK,KAAK,CAAC;AACxB,UAAM,QAAQ,UAAU,IAAI;AAC5B,UAAM,YAAY,cAAc,KAAK,MAAM,CAAC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C,YAAI,CAAC,MAAM;AACT,iBAAO;AAAA,QACT;AAEA,cAAM,EAAE,GAAG,IAAI;AACf,cAAM,MAAM,MAAM,MAAM,EAAE;AAE1B,WAAG,YAAY,KAAK,KAAK,IAAI;AAE7B,cAAM,OAAO,GAAG,IAAI,QAAQ,GAAG;AAC/B,cAAM,eAAe,wBAAU,KAAK,MAAM,CAAC;AAE3C,WAAG,aAAa,YAAY;AAE5B,cAAM,aAAa;AACnB,cAAM,WAAW,eAAe,cAAc;AAE9C,WAAG,OAAO,YAAY,QAAQ;AAC9B,WAAG,eAAe;AAClB,aAAK,SAAS,EAAE;AAEhB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAG,sCAAwB;AAAA,IACzB,UAAU;AAAA,EACZ,CAAC;AACH,CAAC;;;AC/JD,IAAAC,eAA+D;AAWxD,IAAM,iBAAiB,kBAAK,OAA8B;AAAA,EAC/D,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,UAAU;AAAA,EAEV,YAAY;AAAA,EAEZ,WAAW;AAAA,EAEX,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,eAAW,8BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EACpF;AAAA,EAEA,OAAG,sCAAwB;AAAA,IACzB,UAAU;AAAA,IACV,SAAS;AAAA,EACX,CAAC;AACH,CAAC;;;ANtCD,IAAO,gBAAQ;","names":["import_core","transaction","import_core","import_state","node","import_core"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/details.ts","../src/helpers/isNodeVisible.ts","../src/helpers/findClosestVisibleNode.ts","../src/helpers/setGapCursor.ts","../src/content/details-content.ts","../src/summary/details-summary.ts"],"sourcesContent":["import { Details } from './details.js'\n\nexport * from './content/index.js'\nexport * from './details.js'\nexport * from './summary/index.js'\n\nexport default Details\n","import {\n createBlockMarkdownSpec,\n defaultBlockAt,\n findChildren,\n findParentNode,\n isActive,\n mergeAttributes,\n Node,\n} from '@tiptap/core'\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey, Selection, TextSelection } from '@tiptap/pm/state'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nimport { findClosestVisibleNode } from './helpers/findClosestVisibleNode.js'\nimport { isNodeVisible } from './helpers/isNodeVisible.js'\nimport { setGapCursor } from './helpers/setGapCursor.js'\n\nexport interface DetailsRenderToggleButtonOptions {\n /**\n * The toggle button element rendered by the node view.\n */\n element: HTMLButtonElement\n /**\n * The current open state of the details node.\n */\n isOpen: boolean\n /**\n * The current node used to derive toggle button state.\n */\n node: ProseMirrorNode\n}\n\nexport interface DetailsOptions {\n /**\n * Specify if the open status should be saved in the document. Defaults to `false`.\n */\n persist: boolean\n /**\n * Specifies a CSS class that is set when toggling the content. Defaults to `is-open`.\n */\n openClassName: string\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n /**\n * Customizes the rendered toggle button.\n */\n renderToggleButton: (options: DetailsRenderToggleButtonOptions) => void\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n details: {\n /**\n * Set a details node\n */\n setDetails: () => ReturnType\n /**\n * Unset a details node\n */\n unsetDetails: () => ReturnType\n }\n }\n}\n\nexport const Details = Node.create<DetailsOptions>({\n name: 'details',\n\n content: 'detailsSummary detailsContent',\n\n group: 'block',\n\n defining: true,\n\n isolating: true,\n\n // @ts-ignore reason: `allowGapCursor` is not a valid property by default, but the `GapCursor` extension adds it to the Nodeconfig type\n allowGapCursor: false,\n\n addOptions() {\n return {\n persist: false,\n openClassName: 'is-open',\n HTMLAttributes: {},\n renderToggleButton: ({ element, isOpen }) => {\n element.setAttribute('aria-label', isOpen ? 'Collapse details content' : 'Expand details content')\n },\n }\n },\n\n addAttributes() {\n if (!this.options.persist) {\n return []\n }\n\n return {\n open: {\n default: false,\n parseHTML: element => element.hasAttribute('open'),\n renderHTML: ({ open }) => {\n if (!open) {\n return {}\n }\n\n return { open: '' }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'details',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['details', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'details',\n content: 'block',\n }),\n\n addNodeView() {\n return ({ editor, getPos, node, HTMLAttributes }) => {\n const dom = document.createElement('div')\n const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n })\n\n Object.entries(attributes).forEach(([key, value]) => dom.setAttribute(key, value))\n\n const toggle = document.createElement('button')\n\n toggle.type = 'button'\n\n const renderToggleButton = (options: Omit<DetailsRenderToggleButtonOptions, 'element'>) => {\n this.options.renderToggleButton({\n element: toggle,\n ...options,\n })\n }\n\n dom.append(toggle)\n\n const content = document.createElement('div')\n\n dom.append(content)\n\n const toggleDetailsContent = (options?: { setToValue?: boolean; node?: ProseMirrorNode }) => {\n const { setToValue, node: currentNode = node } = options || {}\n\n if (setToValue !== undefined) {\n if (setToValue) {\n if (dom.classList.contains(this.options.openClassName)) {\n return\n }\n dom.classList.add(this.options.openClassName)\n } else {\n if (!dom.classList.contains(this.options.openClassName)) {\n return\n }\n dom.classList.remove(this.options.openClassName)\n }\n } else {\n dom.classList.toggle(this.options.openClassName)\n }\n\n const isOpen = dom.classList.contains(this.options.openClassName)\n\n renderToggleButton({\n isOpen,\n node: currentNode,\n })\n\n const event = new Event('toggleDetailsContent')\n const detailsContent = content.querySelector(':scope > div[data-type=\"detailsContent\"]')\n\n detailsContent?.dispatchEvent(event)\n }\n\n renderToggleButton({\n isOpen: Boolean(node.attrs.open),\n node,\n })\n\n if (node.attrs.open) {\n setTimeout(() => toggleDetailsContent())\n }\n\n toggle.addEventListener('click', () => {\n toggleDetailsContent()\n\n if (!this.options.persist) {\n editor.commands.focus(undefined, { scrollIntoView: false })\n\n return\n }\n\n if (editor.isEditable && typeof getPos === 'function') {\n const { from, to } = editor.state.selection\n\n editor\n .chain()\n .command(({ tr }) => {\n const pos = getPos()\n\n if (!pos) {\n return false\n }\n\n const currentNode = tr.doc.nodeAt(pos)\n\n if (currentNode?.type !== this.type) {\n return false\n }\n\n tr.setNodeMarkup(pos, undefined, {\n open: !currentNode.attrs.open,\n })\n\n return true\n })\n .setTextSelection({\n from,\n to,\n })\n .focus(undefined, { scrollIntoView: false })\n .run()\n }\n })\n\n return {\n dom,\n contentDOM: content,\n ignoreMutation(mutation: ViewMutationRecord) {\n if (mutation.type === 'selection') {\n return false\n }\n\n const target = mutation.target\n const isInsideWrapper = dom.contains(target)\n const isInsideToggleButton = toggle.contains(target)\n\n return isInsideToggleButton || !isInsideWrapper || dom === target\n },\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n // Only update the open state if set\n if (updatedNode.attrs.open !== undefined) {\n toggleDetailsContent({\n setToValue: updatedNode.attrs.open,\n node: updatedNode,\n })\n } else {\n renderToggleButton({\n isOpen: dom.classList.contains(this.options.openClassName),\n node: updatedNode,\n })\n }\n\n return true\n },\n }\n }\n },\n\n addCommands() {\n return {\n setDetails:\n () =>\n ({ state, chain }) => {\n const { schema, selection } = state\n const { $from, $to } = selection\n const range = $from.blockRange($to)\n\n if (!range) {\n return false\n }\n\n const slice = state.doc.slice(range.start, range.end)\n const match = schema.nodes.detailsContent.contentMatch.matchFragment(slice.content)\n\n if (!match) {\n return false\n }\n\n const content = slice.toJSON()?.content || []\n\n return chain()\n .insertContentAt(\n { from: range.start, to: range.end },\n {\n type: this.name,\n content: [\n {\n type: 'detailsSummary',\n },\n {\n type: 'detailsContent',\n content,\n },\n ],\n },\n )\n .setTextSelection(range.start + 2)\n .run()\n },\n\n unsetDetails:\n () =>\n ({ state, chain }) => {\n const { selection, schema } = state\n const details = findParentNode(node => node.type === this.type)(selection)\n\n if (!details) {\n return false\n }\n\n const detailsSummaries = findChildren(details.node, node => node.type === schema.nodes.detailsSummary)\n const detailsContents = findChildren(details.node, node => node.type === schema.nodes.detailsContent)\n\n if (!detailsSummaries.length || !detailsContents.length) {\n return false\n }\n\n const detailsSummary = detailsSummaries[0]\n const detailsContent = detailsContents[0]\n const from = details.pos\n const $from = state.doc.resolve(from)\n const to = from + details.node.nodeSize\n const range = { from, to }\n const content = (detailsContent.node.content.toJSON() as []) || []\n const defaultTypeForSummary = $from.parent.type.contentMatch.defaultType\n\n // TODO: this may break for some custom schemas\n const summaryContent = defaultTypeForSummary?.create(null, detailsSummary.node.content).toJSON()\n const mergedContent = [summaryContent, ...content]\n\n return chain()\n .insertContentAt(range, mergedContent)\n .setTextSelection(from + 1)\n .run()\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: () => {\n const { schema, selection } = this.editor.state\n const { empty, $anchor } = selection\n\n if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary) {\n return false\n }\n\n // for some reason safari removes the whole text content within a `<summary>`tag on backspace\n // so we have to remove the text manually\n // see: https://discuss.prosemirror.net/t/safari-backspace-bug-with-details-tag/4223\n if ($anchor.parentOffset !== 0) {\n return this.editor.commands.command(({ tr }) => {\n const from = $anchor.pos - 1\n const to = $anchor.pos\n\n tr.delete(from, to)\n\n return true\n })\n }\n\n return this.editor.commands.unsetDetails()\n },\n\n // Creates a new node below it if it is closed.\n // Otherwise inside `DetailsContent`.\n Enter: ({ editor }) => {\n const { state, view } = editor\n const { schema, selection } = state\n const { $head } = selection\n\n if ($head.parent.type !== schema.nodes.detailsSummary) {\n return false\n }\n\n const isVisible = isNodeVisible($head.after() + 1, editor)\n const above = isVisible ? state.doc.nodeAt($head.after()) : $head.node(-2)\n\n if (!above) {\n return false\n }\n\n const after = isVisible ? 0 : $head.indexAfter(-1)\n const type = defaultBlockAt(above.contentMatchAt(after))\n\n if (!type || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n const node = type.createAndFill()\n\n if (!node) {\n return false\n }\n\n const pos = isVisible ? $head.after() + 1 : $head.after(-1)\n const tr = state.tr.replaceWith(pos, pos, node)\n const $pos = tr.doc.resolve(pos)\n const newSelection = Selection.near($pos, 1)\n\n tr.setSelection(newSelection)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n },\n\n // The default gapcursor implementation can’t handle hidden content, so we need to fix this.\n ArrowRight: ({ editor }) => {\n return setGapCursor(editor, 'right')\n },\n\n // The default gapcursor implementation can’t handle hidden content, so we need to fix this.\n ArrowDown: ({ editor }) => {\n return setGapCursor(editor, 'down')\n },\n }\n },\n\n addProseMirrorPlugins() {\n return [\n // This plugin prevents text selections within the hidden content in `DetailsContent`.\n // The cursor is moved to the next visible position.\n new Plugin({\n key: new PluginKey('detailsSelection'),\n appendTransaction: (transactions, oldState, newState) => {\n const { editor, type } = this\n const isComposing = editor.view.composing\n\n if (isComposing) {\n return\n }\n\n const selectionSet = transactions.some(transaction => transaction.selectionSet)\n\n if (!selectionSet || !oldState.selection.empty || !newState.selection.empty) {\n return\n }\n\n const detailsIsActive = isActive(newState, type.name)\n\n if (!detailsIsActive) {\n return\n }\n\n const { $from } = newState.selection\n const isVisible = isNodeVisible($from.pos, editor)\n\n if (isVisible) {\n return\n }\n\n const details = findClosestVisibleNode($from, node => node.type === type, editor)\n\n if (!details) {\n return\n }\n\n const detailsSummaries = findChildren(\n details.node,\n node => node.type === newState.schema.nodes.detailsSummary,\n )\n\n if (!detailsSummaries.length) {\n return\n }\n\n const detailsSummary = detailsSummaries[0]\n const selectionDirection = oldState.selection.from < newState.selection.from ? 'forward' : 'backward'\n const correctedPosition =\n selectionDirection === 'forward'\n ? details.start + detailsSummary.pos\n : details.pos + detailsSummary.pos + detailsSummary.node.nodeSize\n const selection = TextSelection.create(newState.doc, correctedPosition)\n const transaction = newState.tr.setSelection(selection)\n\n return transaction\n },\n }),\n ]\n },\n})\n","import type { Editor } from '@tiptap/core'\n\nexport const isNodeVisible = (position: number, editor: Editor): boolean => {\n const node = editor.view.domAtPos(position).node as HTMLElement\n const isOpen = node.offsetParent !== null\n\n return isOpen\n}\n","import type { Editor, Predicate } from '@tiptap/core'\nimport type { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'\n\nimport { isNodeVisible } from './isNodeVisible.js'\n\nexport const findClosestVisibleNode = (\n $pos: ResolvedPos,\n predicate: Predicate,\n editor: Editor,\n):\n | {\n pos: number\n start: number\n depth: number\n node: ProseMirrorNode\n }\n | undefined => {\n for (let i = $pos.depth; i > 0; i -= 1) {\n const node = $pos.node(i)\n const match = predicate(node)\n const isVisible = isNodeVisible($pos.start(i), editor)\n\n if (match && isVisible) {\n return {\n pos: i > 0 ? $pos.before(i) : 0,\n start: $pos.start(i),\n depth: i,\n node,\n }\n }\n }\n}\n","import type { Editor } from '@tiptap/core'\nimport { findChildren, findParentNode } from '@tiptap/core'\nimport { GapCursor } from '@tiptap/pm/gapcursor'\nimport type { ResolvedPos } from '@tiptap/pm/model'\nimport type { Selection } from '@tiptap/pm/state'\n\nimport { isNodeVisible } from './isNodeVisible.js'\n\nexport const setGapCursor = (editor: Editor, direction: 'down' | 'right') => {\n const { state, view, extensionManager } = editor\n const { schema, selection } = state\n const { empty, $anchor } = selection\n const hasGapCursorExtension = !!extensionManager.extensions.find(extension => extension.name === 'gapCursor')\n\n if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary || !hasGapCursorExtension) {\n return false\n }\n\n if (direction === 'right' && $anchor.parentOffset !== $anchor.parent.nodeSize - 2) {\n return false\n }\n\n const details = findParentNode(node => node.type === schema.nodes.details)(selection)\n\n if (!details) {\n return false\n }\n\n const detailsContent = findChildren(details.node, node => node.type === schema.nodes.detailsContent)\n\n if (!detailsContent.length) {\n return false\n }\n\n const isOpen = isNodeVisible(details.start + detailsContent[0].pos + 1, editor)\n\n if (isOpen) {\n return false\n }\n\n const $position = state.doc.resolve(details.pos + details.node.nodeSize)\n const $validPosition = GapCursor.findFrom($position, 1, false) as unknown as null | ResolvedPos\n\n if (!$validPosition) {\n return false\n }\n\n const { tr } = state\n const gapCursorSelection = new GapCursor($validPosition) as Selection\n\n tr.setSelection(gapCursorSelection)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n}\n","import { createBlockMarkdownSpec, defaultBlockAt, findParentNode, mergeAttributes, Node } from '@tiptap/core'\nimport { Selection } from '@tiptap/pm/state'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nexport interface DetailsContentOptions {\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n}\n\nexport const DetailsContent = Node.create<DetailsContentOptions>({\n name: 'detailsContent',\n\n content: 'block+',\n\n defining: true,\n\n selectable: false,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `div[data-type=\"${this.name}\"]`,\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { 'data-type': this.name }), 0]\n },\n\n addNodeView() {\n return ({ HTMLAttributes }) => {\n const dom = document.createElement('div')\n const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n hidden: 'hidden',\n })\n\n Object.entries(attributes).forEach(([key, value]) => dom.setAttribute(key, value))\n\n dom.addEventListener('toggleDetailsContent', () => {\n dom.toggleAttribute('hidden')\n })\n\n return {\n dom,\n contentDOM: dom,\n ignoreMutation(mutation: ViewMutationRecord) {\n if (mutation.type === 'selection') {\n return false\n }\n\n return !dom.contains(mutation.target) || dom === mutation.target\n },\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n return true\n },\n }\n }\n },\n\n addKeyboardShortcuts() {\n return {\n // Escape node on double enter\n Enter: ({ editor }) => {\n const { state, view } = editor\n const { selection } = state\n const { $from, empty } = selection\n const detailsContent = findParentNode(node => node.type === this.type)(selection)\n\n if (!empty || !detailsContent || !detailsContent.node.childCount) {\n return false\n }\n\n const fromIndex = $from.index(detailsContent.depth)\n const { childCount } = detailsContent.node\n const isAtEnd = childCount === fromIndex + 1\n\n if (!isAtEnd) {\n return false\n }\n\n const defaultChildType = detailsContent.node.type.contentMatch.defaultType\n const defaultChildNode = defaultChildType?.createAndFill()\n\n if (!defaultChildNode) {\n return false\n }\n\n const $childPos = state.doc.resolve(detailsContent.pos + 1)\n const lastChildIndex = childCount - 1\n const lastChildNode = detailsContent.node.child(lastChildIndex)\n const lastChildPos = $childPos.posAtIndex(lastChildIndex, detailsContent.depth)\n const lastChildNodeIsEmpty = lastChildNode.eq(defaultChildNode)\n\n if (!lastChildNodeIsEmpty) {\n return false\n }\n\n // get parent of details node\n const above = $from.node(-3)\n\n if (!above) {\n return false\n }\n\n // get default node type after details node\n const after = $from.indexAfter(-3)\n const type = defaultBlockAt(above.contentMatchAt(after))\n\n if (!type || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n const node = type.createAndFill()\n\n if (!node) {\n return false\n }\n\n const { tr } = state\n const pos = $from.after(-2)\n\n tr.replaceWith(pos, pos, node)\n\n const $pos = tr.doc.resolve(pos)\n const newSelection = Selection.near($pos, 1)\n\n tr.setSelection(newSelection)\n\n const deleteFrom = lastChildPos\n const deleteTo = lastChildPos + lastChildNode.nodeSize\n\n tr.delete(deleteFrom, deleteTo)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n },\n }\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'detailsContent',\n }),\n})\n","import { createBlockMarkdownSpec, mergeAttributes, Node } from '@tiptap/core'\n\nexport interface DetailsSummaryOptions {\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n}\n\nexport const DetailsSummary = Node.create<DetailsSummaryOptions>({\n name: 'detailsSummary',\n\n content: 'text*',\n\n defining: true,\n\n selectable: false,\n\n isolating: true,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'summary',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['summary', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'detailsSummary',\n content: 'inline',\n }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAQO;AAEP,mBAA4D;;;ACRrD,IAAM,gBAAgB,CAAC,UAAkB,WAA4B;AAC1E,QAAM,OAAO,OAAO,KAAK,SAAS,QAAQ,EAAE;AAC5C,QAAM,SAAS,KAAK,iBAAiB;AAErC,SAAO;AACT;;;ACFO,IAAM,yBAAyB,CACpC,MACA,WACA,WAQe;AACf,WAAS,IAAI,KAAK,OAAO,IAAI,GAAG,KAAK,GAAG;AACtC,UAAM,OAAO,KAAK,KAAK,CAAC;AACxB,UAAM,QAAQ,UAAU,IAAI;AAC5B,UAAM,YAAY,cAAc,KAAK,MAAM,CAAC,GAAG,MAAM;AAErD,QAAI,SAAS,WAAW;AACtB,aAAO;AAAA,QACL,KAAK,IAAI,IAAI,KAAK,OAAO,CAAC,IAAI;AAAA,QAC9B,OAAO,KAAK,MAAM,CAAC;AAAA,QACnB,OAAO;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;AC9BA,kBAA6C;AAC7C,uBAA0B;AAMnB,IAAM,eAAe,CAAC,QAAgB,cAAgC;AAC3E,QAAM,EAAE,OAAO,MAAM,iBAAiB,IAAI;AAC1C,QAAM,EAAE,QAAQ,UAAU,IAAI;AAC9B,QAAM,EAAE,OAAO,QAAQ,IAAI;AAC3B,QAAM,wBAAwB,CAAC,CAAC,iBAAiB,WAAW,KAAK,eAAa,UAAU,SAAS,WAAW;AAE5G,MAAI,CAAC,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AAA,IACF;AAAA,EACF;AAAA,EAEA,OAAG,sCAAwB;AAAA,IACzB,UAAU;AAAA,EACZ,CAAC;AACH,CAAC;;;AC/JD,IAAAC,eAA+D;AAWxD,IAAM,iBAAiB,kBAAK,OAA8B;AAAA,EAC/D,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,UAAU;AAAA,EAEV,YAAY;AAAA,EAEZ,WAAW;AAAA,EAEX,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,eAAW,8BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EACpF;AAAA,EAEA,OAAG,sCAAwB;AAAA,IACzB,UAAU;AAAA,IACV,SAAS;AAAA,EACX,CAAC;AACH,CAAC;;;ANtCD,IAAO,gBAAQ;","names":["import_core","transaction","import_core","import_state","node","import_core"]}
package/dist/index.js CHANGED
@@ -208,7 +208,10 @@ var Details = Node.create({
208
208
  if (mutation.type === "selection") {
209
209
  return false;
210
210
  }
211
- return !dom.contains(mutation.target) || dom === mutation.target;
211
+ const target = mutation.target;
212
+ const isInsideWrapper = dom.contains(target);
213
+ const isInsideToggleButton = toggle.contains(target);
214
+ return isInsideToggleButton || !isInsideWrapper || dom === target;
212
215
  },
213
216
  update: (updatedNode) => {
214
217
  if (updatedNode.type !== this.type) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/details.ts","../src/helpers/isNodeVisible.ts","../src/helpers/findClosestVisibleNode.ts","../src/helpers/setGapCursor.ts","../src/content/details-content.ts","../src/summary/details-summary.ts","../src/index.ts"],"sourcesContent":["import {\n createBlockMarkdownSpec,\n defaultBlockAt,\n findChildren,\n findParentNode,\n isActive,\n mergeAttributes,\n Node,\n} from '@tiptap/core'\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey, Selection, TextSelection } from '@tiptap/pm/state'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nimport { findClosestVisibleNode } from './helpers/findClosestVisibleNode.js'\nimport { isNodeVisible } from './helpers/isNodeVisible.js'\nimport { setGapCursor } from './helpers/setGapCursor.js'\n\nexport interface DetailsRenderToggleButtonOptions {\n /**\n * The toggle button element rendered by the node view.\n */\n element: HTMLButtonElement\n /**\n * The current open state of the details node.\n */\n isOpen: boolean\n /**\n * The current node used to derive toggle button state.\n */\n node: ProseMirrorNode\n}\n\nexport interface DetailsOptions {\n /**\n * Specify if the open status should be saved in the document. Defaults to `false`.\n */\n persist: boolean\n /**\n * Specifies a CSS class that is set when toggling the content. Defaults to `is-open`.\n */\n openClassName: string\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n /**\n * Customizes the rendered toggle button.\n */\n renderToggleButton: (options: DetailsRenderToggleButtonOptions) => void\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n details: {\n /**\n * Set a details node\n */\n setDetails: () => ReturnType\n /**\n * Unset a details node\n */\n unsetDetails: () => ReturnType\n }\n }\n}\n\nexport const Details = Node.create<DetailsOptions>({\n name: 'details',\n\n content: 'detailsSummary detailsContent',\n\n group: 'block',\n\n defining: true,\n\n isolating: true,\n\n // @ts-ignore reason: `allowGapCursor` is not a valid property by default, but the `GapCursor` extension adds it to the Nodeconfig type\n allowGapCursor: false,\n\n addOptions() {\n return {\n persist: false,\n openClassName: 'is-open',\n HTMLAttributes: {},\n renderToggleButton: ({ element, isOpen }) => {\n element.setAttribute('aria-label', isOpen ? 'Collapse details content' : 'Expand details content')\n },\n }\n },\n\n addAttributes() {\n if (!this.options.persist) {\n return []\n }\n\n return {\n open: {\n default: false,\n parseHTML: element => element.hasAttribute('open'),\n renderHTML: ({ open }) => {\n if (!open) {\n return {}\n }\n\n return { open: '' }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'details',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['details', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'details',\n content: 'block',\n }),\n\n addNodeView() {\n return ({ editor, getPos, node, HTMLAttributes }) => {\n const dom = document.createElement('div')\n const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n })\n\n Object.entries(attributes).forEach(([key, value]) => dom.setAttribute(key, value))\n\n const toggle = document.createElement('button')\n\n toggle.type = 'button'\n\n const renderToggleButton = (options: Omit<DetailsRenderToggleButtonOptions, 'element'>) => {\n this.options.renderToggleButton({\n element: toggle,\n ...options,\n })\n }\n\n dom.append(toggle)\n\n const content = document.createElement('div')\n\n dom.append(content)\n\n const toggleDetailsContent = (options?: { setToValue?: boolean; node?: ProseMirrorNode }) => {\n const { setToValue, node: currentNode = node } = options || {}\n\n if (setToValue !== undefined) {\n if (setToValue) {\n if (dom.classList.contains(this.options.openClassName)) {\n return\n }\n dom.classList.add(this.options.openClassName)\n } else {\n if (!dom.classList.contains(this.options.openClassName)) {\n return\n }\n dom.classList.remove(this.options.openClassName)\n }\n } else {\n dom.classList.toggle(this.options.openClassName)\n }\n\n const isOpen = dom.classList.contains(this.options.openClassName)\n\n renderToggleButton({\n isOpen,\n node: currentNode,\n })\n\n const event = new Event('toggleDetailsContent')\n const detailsContent = content.querySelector(':scope > div[data-type=\"detailsContent\"]')\n\n detailsContent?.dispatchEvent(event)\n }\n\n renderToggleButton({\n isOpen: Boolean(node.attrs.open),\n node,\n })\n\n if (node.attrs.open) {\n setTimeout(() => toggleDetailsContent())\n }\n\n toggle.addEventListener('click', () => {\n toggleDetailsContent()\n\n if (!this.options.persist) {\n editor.commands.focus(undefined, { scrollIntoView: false })\n\n return\n }\n\n if (editor.isEditable && typeof getPos === 'function') {\n const { from, to } = editor.state.selection\n\n editor\n .chain()\n .command(({ tr }) => {\n const pos = getPos()\n\n if (!pos) {\n return false\n }\n\n const currentNode = tr.doc.nodeAt(pos)\n\n if (currentNode?.type !== this.type) {\n return false\n }\n\n tr.setNodeMarkup(pos, undefined, {\n open: !currentNode.attrs.open,\n })\n\n return true\n })\n .setTextSelection({\n from,\n to,\n })\n .focus(undefined, { scrollIntoView: false })\n .run()\n }\n })\n\n return {\n dom,\n contentDOM: content,\n ignoreMutation(mutation: ViewMutationRecord) {\n if (mutation.type === 'selection') {\n return false\n }\n\n return !dom.contains(mutation.target) || dom === mutation.target\n },\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n // Only update the open state if set\n if (updatedNode.attrs.open !== undefined) {\n toggleDetailsContent({\n setToValue: updatedNode.attrs.open,\n node: updatedNode,\n })\n } else {\n renderToggleButton({\n isOpen: dom.classList.contains(this.options.openClassName),\n node: updatedNode,\n })\n }\n\n return true\n },\n }\n }\n },\n\n addCommands() {\n return {\n setDetails:\n () =>\n ({ state, chain }) => {\n const { schema, selection } = state\n const { $from, $to } = selection\n const range = $from.blockRange($to)\n\n if (!range) {\n return false\n }\n\n const slice = state.doc.slice(range.start, range.end)\n const match = schema.nodes.detailsContent.contentMatch.matchFragment(slice.content)\n\n if (!match) {\n return false\n }\n\n const content = slice.toJSON()?.content || []\n\n return chain()\n .insertContentAt(\n { from: range.start, to: range.end },\n {\n type: this.name,\n content: [\n {\n type: 'detailsSummary',\n },\n {\n type: 'detailsContent',\n content,\n },\n ],\n },\n )\n .setTextSelection(range.start + 2)\n .run()\n },\n\n unsetDetails:\n () =>\n ({ state, chain }) => {\n const { selection, schema } = state\n const details = findParentNode(node => node.type === this.type)(selection)\n\n if (!details) {\n return false\n }\n\n const detailsSummaries = findChildren(details.node, node => node.type === schema.nodes.detailsSummary)\n const detailsContents = findChildren(details.node, node => node.type === schema.nodes.detailsContent)\n\n if (!detailsSummaries.length || !detailsContents.length) {\n return false\n }\n\n const detailsSummary = detailsSummaries[0]\n const detailsContent = detailsContents[0]\n const from = details.pos\n const $from = state.doc.resolve(from)\n const to = from + details.node.nodeSize\n const range = { from, to }\n const content = (detailsContent.node.content.toJSON() as []) || []\n const defaultTypeForSummary = $from.parent.type.contentMatch.defaultType\n\n // TODO: this may break for some custom schemas\n const summaryContent = defaultTypeForSummary?.create(null, detailsSummary.node.content).toJSON()\n const mergedContent = [summaryContent, ...content]\n\n return chain()\n .insertContentAt(range, mergedContent)\n .setTextSelection(from + 1)\n .run()\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: () => {\n const { schema, selection } = this.editor.state\n const { empty, $anchor } = selection\n\n if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary) {\n return false\n }\n\n // for some reason safari removes the whole text content within a `<summary>`tag on backspace\n // so we have to remove the text manually\n // see: https://discuss.prosemirror.net/t/safari-backspace-bug-with-details-tag/4223\n if ($anchor.parentOffset !== 0) {\n return this.editor.commands.command(({ tr }) => {\n const from = $anchor.pos - 1\n const to = $anchor.pos\n\n tr.delete(from, to)\n\n return true\n })\n }\n\n return this.editor.commands.unsetDetails()\n },\n\n // Creates a new node below it if it is closed.\n // Otherwise inside `DetailsContent`.\n Enter: ({ editor }) => {\n const { state, view } = editor\n const { schema, selection } = state\n const { $head } = selection\n\n if ($head.parent.type !== schema.nodes.detailsSummary) {\n return false\n }\n\n const isVisible = isNodeVisible($head.after() + 1, editor)\n const above = isVisible ? state.doc.nodeAt($head.after()) : $head.node(-2)\n\n if (!above) {\n return false\n }\n\n const after = isVisible ? 0 : $head.indexAfter(-1)\n const type = defaultBlockAt(above.contentMatchAt(after))\n\n if (!type || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n const node = type.createAndFill()\n\n if (!node) {\n return false\n }\n\n const pos = isVisible ? $head.after() + 1 : $head.after(-1)\n const tr = state.tr.replaceWith(pos, pos, node)\n const $pos = tr.doc.resolve(pos)\n const newSelection = Selection.near($pos, 1)\n\n tr.setSelection(newSelection)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n },\n\n // The default gapcursor implementation can’t handle hidden content, so we need to fix this.\n ArrowRight: ({ editor }) => {\n return setGapCursor(editor, 'right')\n },\n\n // The default gapcursor implementation can’t handle hidden content, so we need to fix this.\n ArrowDown: ({ editor }) => {\n return setGapCursor(editor, 'down')\n },\n }\n },\n\n addProseMirrorPlugins() {\n return [\n // This plugin prevents text selections within the hidden content in `DetailsContent`.\n // The cursor is moved to the next visible position.\n new Plugin({\n key: new PluginKey('detailsSelection'),\n appendTransaction: (transactions, oldState, newState) => {\n const { editor, type } = this\n const isComposing = editor.view.composing\n\n if (isComposing) {\n return\n }\n\n const selectionSet = transactions.some(transaction => transaction.selectionSet)\n\n if (!selectionSet || !oldState.selection.empty || !newState.selection.empty) {\n return\n }\n\n const detailsIsActive = isActive(newState, type.name)\n\n if (!detailsIsActive) {\n return\n }\n\n const { $from } = newState.selection\n const isVisible = isNodeVisible($from.pos, editor)\n\n if (isVisible) {\n return\n }\n\n const details = findClosestVisibleNode($from, node => node.type === type, editor)\n\n if (!details) {\n return\n }\n\n const detailsSummaries = findChildren(\n details.node,\n node => node.type === newState.schema.nodes.detailsSummary,\n )\n\n if (!detailsSummaries.length) {\n return\n }\n\n const detailsSummary = detailsSummaries[0]\n const selectionDirection = oldState.selection.from < newState.selection.from ? 'forward' : 'backward'\n const correctedPosition =\n selectionDirection === 'forward'\n ? details.start + detailsSummary.pos\n : details.pos + detailsSummary.pos + detailsSummary.node.nodeSize\n const selection = TextSelection.create(newState.doc, correctedPosition)\n const transaction = newState.tr.setSelection(selection)\n\n return transaction\n },\n }),\n ]\n },\n})\n","import type { Editor } from '@tiptap/core'\n\nexport const isNodeVisible = (position: number, editor: Editor): boolean => {\n const node = editor.view.domAtPos(position).node as HTMLElement\n const isOpen = node.offsetParent !== null\n\n return isOpen\n}\n","import type { Editor, Predicate } from '@tiptap/core'\nimport type { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'\n\nimport { isNodeVisible } from './isNodeVisible.js'\n\nexport const findClosestVisibleNode = (\n $pos: ResolvedPos,\n predicate: Predicate,\n editor: Editor,\n):\n | {\n pos: number\n start: number\n depth: number\n node: ProseMirrorNode\n }\n | undefined => {\n for (let i = $pos.depth; i > 0; i -= 1) {\n const node = $pos.node(i)\n const match = predicate(node)\n const isVisible = isNodeVisible($pos.start(i), editor)\n\n if (match && isVisible) {\n return {\n pos: i > 0 ? $pos.before(i) : 0,\n start: $pos.start(i),\n depth: i,\n node,\n }\n }\n }\n}\n","import type { Editor } from '@tiptap/core'\nimport { findChildren, findParentNode } from '@tiptap/core'\nimport { GapCursor } from '@tiptap/pm/gapcursor'\nimport type { ResolvedPos } from '@tiptap/pm/model'\nimport type { Selection } from '@tiptap/pm/state'\n\nimport { isNodeVisible } from './isNodeVisible.js'\n\nexport const setGapCursor = (editor: Editor, direction: 'down' | 'right') => {\n const { state, view, extensionManager } = editor\n const { schema, selection } = state\n const { empty, $anchor } = selection\n const hasGapCursorExtension = !!extensionManager.extensions.find(extension => extension.name === 'gapCursor')\n\n if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary || !hasGapCursorExtension) {\n return false\n }\n\n if (direction === 'right' && $anchor.parentOffset !== $anchor.parent.nodeSize - 2) {\n return false\n }\n\n const details = findParentNode(node => node.type === schema.nodes.details)(selection)\n\n if (!details) {\n return false\n }\n\n const detailsContent = findChildren(details.node, node => node.type === schema.nodes.detailsContent)\n\n if (!detailsContent.length) {\n return false\n }\n\n const isOpen = isNodeVisible(details.start + detailsContent[0].pos + 1, editor)\n\n if (isOpen) {\n return false\n }\n\n const $position = state.doc.resolve(details.pos + details.node.nodeSize)\n const $validPosition = GapCursor.findFrom($position, 1, false) as unknown as null | ResolvedPos\n\n if (!$validPosition) {\n return false\n }\n\n const { tr } = state\n const gapCursorSelection = new GapCursor($validPosition) as Selection\n\n tr.setSelection(gapCursorSelection)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n}\n","import { createBlockMarkdownSpec, defaultBlockAt, findParentNode, mergeAttributes, Node } from '@tiptap/core'\nimport { Selection } from '@tiptap/pm/state'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nexport interface DetailsContentOptions {\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n}\n\nexport const DetailsContent = Node.create<DetailsContentOptions>({\n name: 'detailsContent',\n\n content: 'block+',\n\n defining: true,\n\n selectable: false,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `div[data-type=\"${this.name}\"]`,\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { 'data-type': this.name }), 0]\n },\n\n addNodeView() {\n return ({ HTMLAttributes }) => {\n const dom = document.createElement('div')\n const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n hidden: 'hidden',\n })\n\n Object.entries(attributes).forEach(([key, value]) => dom.setAttribute(key, value))\n\n dom.addEventListener('toggleDetailsContent', () => {\n dom.toggleAttribute('hidden')\n })\n\n return {\n dom,\n contentDOM: dom,\n ignoreMutation(mutation: ViewMutationRecord) {\n if (mutation.type === 'selection') {\n return false\n }\n\n return !dom.contains(mutation.target) || dom === mutation.target\n },\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n return true\n },\n }\n }\n },\n\n addKeyboardShortcuts() {\n return {\n // Escape node on double enter\n Enter: ({ editor }) => {\n const { state, view } = editor\n const { selection } = state\n const { $from, empty } = selection\n const detailsContent = findParentNode(node => node.type === this.type)(selection)\n\n if (!empty || !detailsContent || !detailsContent.node.childCount) {\n return false\n }\n\n const fromIndex = $from.index(detailsContent.depth)\n const { childCount } = detailsContent.node\n const isAtEnd = childCount === fromIndex + 1\n\n if (!isAtEnd) {\n return false\n }\n\n const defaultChildType = detailsContent.node.type.contentMatch.defaultType\n const defaultChildNode = defaultChildType?.createAndFill()\n\n if (!defaultChildNode) {\n return false\n }\n\n const $childPos = state.doc.resolve(detailsContent.pos + 1)\n const lastChildIndex = childCount - 1\n const lastChildNode = detailsContent.node.child(lastChildIndex)\n const lastChildPos = $childPos.posAtIndex(lastChildIndex, detailsContent.depth)\n const lastChildNodeIsEmpty = lastChildNode.eq(defaultChildNode)\n\n if (!lastChildNodeIsEmpty) {\n return false\n }\n\n // get parent of details node\n const above = $from.node(-3)\n\n if (!above) {\n return false\n }\n\n // get default node type after details node\n const after = $from.indexAfter(-3)\n const type = defaultBlockAt(above.contentMatchAt(after))\n\n if (!type || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n const node = type.createAndFill()\n\n if (!node) {\n return false\n }\n\n const { tr } = state\n const pos = $from.after(-2)\n\n tr.replaceWith(pos, pos, node)\n\n const $pos = tr.doc.resolve(pos)\n const newSelection = Selection.near($pos, 1)\n\n tr.setSelection(newSelection)\n\n const deleteFrom = lastChildPos\n const deleteTo = lastChildPos + lastChildNode.nodeSize\n\n tr.delete(deleteFrom, deleteTo)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n },\n }\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'detailsContent',\n }),\n})\n","import { createBlockMarkdownSpec, mergeAttributes, Node } from '@tiptap/core'\n\nexport interface DetailsSummaryOptions {\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n}\n\nexport const DetailsSummary = Node.create<DetailsSummaryOptions>({\n name: 'detailsSummary',\n\n content: 'text*',\n\n defining: true,\n\n selectable: false,\n\n isolating: true,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'summary',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['summary', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'detailsSummary',\n content: 'inline',\n }),\n})\n","import { Details } from './details.js'\n\nexport * from './content/index.js'\nexport * from './details.js'\nexport * from './summary/index.js'\n\nexport default Details\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA,gBAAAA;AAAA,EACA,kBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,QAAQ,WAAW,WAAW,qBAAqB;;;ACRrD,IAAM,gBAAgB,CAAC,UAAkB,WAA4B;AAC1E,QAAM,OAAO,OAAO,KAAK,SAAS,QAAQ,EAAE;AAC5C,QAAM,SAAS,KAAK,iBAAiB;AAErC,SAAO;AACT;;;ACFO,IAAM,yBAAyB,CACpC,MACA,WACA,WAQe;AACf,WAAS,IAAI,KAAK,OAAO,IAAI,GAAG,KAAK,GAAG;AACtC,UAAM,OAAO,KAAK,KAAK,CAAC;AACxB,UAAM,QAAQ,UAAU,IAAI;AAC5B,UAAM,YAAY,cAAc,KAAK,MAAM,CAAC,GAAG,MAAM;AAErD,QAAI,SAAS,WAAW;AACtB,aAAO;AAAA,QACL,KAAK,IAAI,IAAI,KAAK,OAAO,CAAC,IAAI;AAAA,QAC9B,OAAO,KAAK,MAAM,CAAC;AAAA,QACnB,OAAO;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;AC9BA,SAAS,cAAc,sBAAsB;AAC7C,SAAS,iBAAiB;AAMnB,IAAM,eAAe,CAAC,QAAgB,cAAgC;AAC3E,QAAM,EAAE,OAAO,MAAM,iBAAiB,IAAI;AAC1C,QAAM,EAAE,QAAQ,UAAU,IAAI;AAC9B,QAAM,EAAE,OAAO,QAAQ,IAAI;AAC3B,QAAM,wBAAwB,CAAC,CAAC,iBAAiB,WAAW,KAAK,eAAa,UAAU,SAAS,WAAW;AAE5G,MAAI,CAAC,SAAS,QAAQ,OAAO,SAAS,OAAO,MAAM,kBAAkB,CAAC,uBAAuB;AAC3F,WAAO;AAAA,EACT;AAEA,MAA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AAAO,0BAAyB,mBAAAC,kBAAiB,QAAAC,aAAY;AAWxD,IAAM,iBAAiBA,MAAK,OAA8B;AAAA,EAC/D,MAAM;AAAA,EAEN,SAAS;AAAA,EAET,UAAU;AAAA,EAEV,YAAY;AAAA,EAEZ,WAAW;AAAA,EAEX,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,WAAWD,iBAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EACpF;AAAA,EAEA,GAAGD,yBAAwB;AAAA,IACzB,UAAU;AAAA,IACV,SAAS;AAAA,EACX,CAAC;AACH,CAAC;;;ACtCD,IAAO,gBAAQ;","names":["findChildren","findParentNode","findParentNode","findChildren","transaction","createBlockMarkdownSpec","defaultBlockAt","findParentNode","mergeAttributes","Node","Selection","node","createBlockMarkdownSpec","mergeAttributes","Node"]}
1
+ {"version":3,"sources":["../src/details.ts","../src/helpers/isNodeVisible.ts","../src/helpers/findClosestVisibleNode.ts","../src/helpers/setGapCursor.ts","../src/content/details-content.ts","../src/summary/details-summary.ts","../src/index.ts"],"sourcesContent":["import {\n createBlockMarkdownSpec,\n defaultBlockAt,\n findChildren,\n findParentNode,\n isActive,\n mergeAttributes,\n Node,\n} from '@tiptap/core'\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Plugin, PluginKey, Selection, TextSelection } from '@tiptap/pm/state'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nimport { findClosestVisibleNode } from './helpers/findClosestVisibleNode.js'\nimport { isNodeVisible } from './helpers/isNodeVisible.js'\nimport { setGapCursor } from './helpers/setGapCursor.js'\n\nexport interface DetailsRenderToggleButtonOptions {\n /**\n * The toggle button element rendered by the node view.\n */\n element: HTMLButtonElement\n /**\n * The current open state of the details node.\n */\n isOpen: boolean\n /**\n * The current node used to derive toggle button state.\n */\n node: ProseMirrorNode\n}\n\nexport interface DetailsOptions {\n /**\n * Specify if the open status should be saved in the document. Defaults to `false`.\n */\n persist: boolean\n /**\n * Specifies a CSS class that is set when toggling the content. Defaults to `is-open`.\n */\n openClassName: string\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n /**\n * Customizes the rendered toggle button.\n */\n renderToggleButton: (options: DetailsRenderToggleButtonOptions) => void\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n details: {\n /**\n * Set a details node\n */\n setDetails: () => ReturnType\n /**\n * Unset a details node\n */\n unsetDetails: () => ReturnType\n }\n }\n}\n\nexport const Details = Node.create<DetailsOptions>({\n name: 'details',\n\n content: 'detailsSummary detailsContent',\n\n group: 'block',\n\n defining: true,\n\n isolating: true,\n\n // @ts-ignore reason: `allowGapCursor` is not a valid property by default, but the `GapCursor` extension adds it to the Nodeconfig type\n allowGapCursor: false,\n\n addOptions() {\n return {\n persist: false,\n openClassName: 'is-open',\n HTMLAttributes: {},\n renderToggleButton: ({ element, isOpen }) => {\n element.setAttribute('aria-label', isOpen ? 'Collapse details content' : 'Expand details content')\n },\n }\n },\n\n addAttributes() {\n if (!this.options.persist) {\n return []\n }\n\n return {\n open: {\n default: false,\n parseHTML: element => element.hasAttribute('open'),\n renderHTML: ({ open }) => {\n if (!open) {\n return {}\n }\n\n return { open: '' }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'details',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['details', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'details',\n content: 'block',\n }),\n\n addNodeView() {\n return ({ editor, getPos, node, HTMLAttributes }) => {\n const dom = document.createElement('div')\n const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n })\n\n Object.entries(attributes).forEach(([key, value]) => dom.setAttribute(key, value))\n\n const toggle = document.createElement('button')\n\n toggle.type = 'button'\n\n const renderToggleButton = (options: Omit<DetailsRenderToggleButtonOptions, 'element'>) => {\n this.options.renderToggleButton({\n element: toggle,\n ...options,\n })\n }\n\n dom.append(toggle)\n\n const content = document.createElement('div')\n\n dom.append(content)\n\n const toggleDetailsContent = (options?: { setToValue?: boolean; node?: ProseMirrorNode }) => {\n const { setToValue, node: currentNode = node } = options || {}\n\n if (setToValue !== undefined) {\n if (setToValue) {\n if (dom.classList.contains(this.options.openClassName)) {\n return\n }\n dom.classList.add(this.options.openClassName)\n } else {\n if (!dom.classList.contains(this.options.openClassName)) {\n return\n }\n dom.classList.remove(this.options.openClassName)\n }\n } else {\n dom.classList.toggle(this.options.openClassName)\n }\n\n const isOpen = dom.classList.contains(this.options.openClassName)\n\n renderToggleButton({\n isOpen,\n node: currentNode,\n })\n\n const event = new Event('toggleDetailsContent')\n const detailsContent = content.querySelector(':scope > div[data-type=\"detailsContent\"]')\n\n detailsContent?.dispatchEvent(event)\n }\n\n renderToggleButton({\n isOpen: Boolean(node.attrs.open),\n node,\n })\n\n if (node.attrs.open) {\n setTimeout(() => toggleDetailsContent())\n }\n\n toggle.addEventListener('click', () => {\n toggleDetailsContent()\n\n if (!this.options.persist) {\n editor.commands.focus(undefined, { scrollIntoView: false })\n\n return\n }\n\n if (editor.isEditable && typeof getPos === 'function') {\n const { from, to } = editor.state.selection\n\n editor\n .chain()\n .command(({ tr }) => {\n const pos = getPos()\n\n if (!pos) {\n return false\n }\n\n const currentNode = tr.doc.nodeAt(pos)\n\n if (currentNode?.type !== this.type) {\n return false\n }\n\n tr.setNodeMarkup(pos, undefined, {\n open: !currentNode.attrs.open,\n })\n\n return true\n })\n .setTextSelection({\n from,\n to,\n })\n .focus(undefined, { scrollIntoView: false })\n .run()\n }\n })\n\n return {\n dom,\n contentDOM: content,\n ignoreMutation(mutation: ViewMutationRecord) {\n if (mutation.type === 'selection') {\n return false\n }\n\n const target = mutation.target\n const isInsideWrapper = dom.contains(target)\n const isInsideToggleButton = toggle.contains(target)\n\n return isInsideToggleButton || !isInsideWrapper || dom === target\n },\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n // Only update the open state if set\n if (updatedNode.attrs.open !== undefined) {\n toggleDetailsContent({\n setToValue: updatedNode.attrs.open,\n node: updatedNode,\n })\n } else {\n renderToggleButton({\n isOpen: dom.classList.contains(this.options.openClassName),\n node: updatedNode,\n })\n }\n\n return true\n },\n }\n }\n },\n\n addCommands() {\n return {\n setDetails:\n () =>\n ({ state, chain }) => {\n const { schema, selection } = state\n const { $from, $to } = selection\n const range = $from.blockRange($to)\n\n if (!range) {\n return false\n }\n\n const slice = state.doc.slice(range.start, range.end)\n const match = schema.nodes.detailsContent.contentMatch.matchFragment(slice.content)\n\n if (!match) {\n return false\n }\n\n const content = slice.toJSON()?.content || []\n\n return chain()\n .insertContentAt(\n { from: range.start, to: range.end },\n {\n type: this.name,\n content: [\n {\n type: 'detailsSummary',\n },\n {\n type: 'detailsContent',\n content,\n },\n ],\n },\n )\n .setTextSelection(range.start + 2)\n .run()\n },\n\n unsetDetails:\n () =>\n ({ state, chain }) => {\n const { selection, schema } = state\n const details = findParentNode(node => node.type === this.type)(selection)\n\n if (!details) {\n return false\n }\n\n const detailsSummaries = findChildren(details.node, node => node.type === schema.nodes.detailsSummary)\n const detailsContents = findChildren(details.node, node => node.type === schema.nodes.detailsContent)\n\n if (!detailsSummaries.length || !detailsContents.length) {\n return false\n }\n\n const detailsSummary = detailsSummaries[0]\n const detailsContent = detailsContents[0]\n const from = details.pos\n const $from = state.doc.resolve(from)\n const to = from + details.node.nodeSize\n const range = { from, to }\n const content = (detailsContent.node.content.toJSON() as []) || []\n const defaultTypeForSummary = $from.parent.type.contentMatch.defaultType\n\n // TODO: this may break for some custom schemas\n const summaryContent = defaultTypeForSummary?.create(null, detailsSummary.node.content).toJSON()\n const mergedContent = [summaryContent, ...content]\n\n return chain()\n .insertContentAt(range, mergedContent)\n .setTextSelection(from + 1)\n .run()\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: () => {\n const { schema, selection } = this.editor.state\n const { empty, $anchor } = selection\n\n if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary) {\n return false\n }\n\n // for some reason safari removes the whole text content within a `<summary>`tag on backspace\n // so we have to remove the text manually\n // see: https://discuss.prosemirror.net/t/safari-backspace-bug-with-details-tag/4223\n if ($anchor.parentOffset !== 0) {\n return this.editor.commands.command(({ tr }) => {\n const from = $anchor.pos - 1\n const to = $anchor.pos\n\n tr.delete(from, to)\n\n return true\n })\n }\n\n return this.editor.commands.unsetDetails()\n },\n\n // Creates a new node below it if it is closed.\n // Otherwise inside `DetailsContent`.\n Enter: ({ editor }) => {\n const { state, view } = editor\n const { schema, selection } = state\n const { $head } = selection\n\n if ($head.parent.type !== schema.nodes.detailsSummary) {\n return false\n }\n\n const isVisible = isNodeVisible($head.after() + 1, editor)\n const above = isVisible ? state.doc.nodeAt($head.after()) : $head.node(-2)\n\n if (!above) {\n return false\n }\n\n const after = isVisible ? 0 : $head.indexAfter(-1)\n const type = defaultBlockAt(above.contentMatchAt(after))\n\n if (!type || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n const node = type.createAndFill()\n\n if (!node) {\n return false\n }\n\n const pos = isVisible ? $head.after() + 1 : $head.after(-1)\n const tr = state.tr.replaceWith(pos, pos, node)\n const $pos = tr.doc.resolve(pos)\n const newSelection = Selection.near($pos, 1)\n\n tr.setSelection(newSelection)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n },\n\n // The default gapcursor implementation can’t handle hidden content, so we need to fix this.\n ArrowRight: ({ editor }) => {\n return setGapCursor(editor, 'right')\n },\n\n // The default gapcursor implementation can’t handle hidden content, so we need to fix this.\n ArrowDown: ({ editor }) => {\n return setGapCursor(editor, 'down')\n },\n }\n },\n\n addProseMirrorPlugins() {\n return [\n // This plugin prevents text selections within the hidden content in `DetailsContent`.\n // The cursor is moved to the next visible position.\n new Plugin({\n key: new PluginKey('detailsSelection'),\n appendTransaction: (transactions, oldState, newState) => {\n const { editor, type } = this\n const isComposing = editor.view.composing\n\n if (isComposing) {\n return\n }\n\n const selectionSet = transactions.some(transaction => transaction.selectionSet)\n\n if (!selectionSet || !oldState.selection.empty || !newState.selection.empty) {\n return\n }\n\n const detailsIsActive = isActive(newState, type.name)\n\n if (!detailsIsActive) {\n return\n }\n\n const { $from } = newState.selection\n const isVisible = isNodeVisible($from.pos, editor)\n\n if (isVisible) {\n return\n }\n\n const details = findClosestVisibleNode($from, node => node.type === type, editor)\n\n if (!details) {\n return\n }\n\n const detailsSummaries = findChildren(\n details.node,\n node => node.type === newState.schema.nodes.detailsSummary,\n )\n\n if (!detailsSummaries.length) {\n return\n }\n\n const detailsSummary = detailsSummaries[0]\n const selectionDirection = oldState.selection.from < newState.selection.from ? 'forward' : 'backward'\n const correctedPosition =\n selectionDirection === 'forward'\n ? details.start + detailsSummary.pos\n : details.pos + detailsSummary.pos + detailsSummary.node.nodeSize\n const selection = TextSelection.create(newState.doc, correctedPosition)\n const transaction = newState.tr.setSelection(selection)\n\n return transaction\n },\n }),\n ]\n },\n})\n","import type { Editor } from '@tiptap/core'\n\nexport const isNodeVisible = (position: number, editor: Editor): boolean => {\n const node = editor.view.domAtPos(position).node as HTMLElement\n const isOpen = node.offsetParent !== null\n\n return isOpen\n}\n","import type { Editor, Predicate } from '@tiptap/core'\nimport type { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'\n\nimport { isNodeVisible } from './isNodeVisible.js'\n\nexport const findClosestVisibleNode = (\n $pos: ResolvedPos,\n predicate: Predicate,\n editor: Editor,\n):\n | {\n pos: number\n start: number\n depth: number\n node: ProseMirrorNode\n }\n | undefined => {\n for (let i = $pos.depth; i > 0; i -= 1) {\n const node = $pos.node(i)\n const match = predicate(node)\n const isVisible = isNodeVisible($pos.start(i), editor)\n\n if (match && isVisible) {\n return {\n pos: i > 0 ? $pos.before(i) : 0,\n start: $pos.start(i),\n depth: i,\n node,\n }\n }\n }\n}\n","import type { Editor } from '@tiptap/core'\nimport { findChildren, findParentNode } from '@tiptap/core'\nimport { GapCursor } from '@tiptap/pm/gapcursor'\nimport type { ResolvedPos } from '@tiptap/pm/model'\nimport type { Selection } from '@tiptap/pm/state'\n\nimport { isNodeVisible } from './isNodeVisible.js'\n\nexport const setGapCursor = (editor: Editor, direction: 'down' | 'right') => {\n const { state, view, extensionManager } = editor\n const { schema, selection } = state\n const { empty, $anchor } = selection\n const hasGapCursorExtension = !!extensionManager.extensions.find(extension => extension.name === 'gapCursor')\n\n if (!empty || $anchor.parent.type !== schema.nodes.detailsSummary || !hasGapCursorExtension) {\n return false\n }\n\n if (direction === 'right' && $anchor.parentOffset !== $anchor.parent.nodeSize - 2) {\n return false\n }\n\n const details = findParentNode(node => node.type === schema.nodes.details)(selection)\n\n if (!details) {\n return false\n }\n\n const detailsContent = findChildren(details.node, node => node.type === schema.nodes.detailsContent)\n\n if (!detailsContent.length) {\n return false\n }\n\n const isOpen = isNodeVisible(details.start + detailsContent[0].pos + 1, editor)\n\n if (isOpen) {\n return false\n }\n\n const $position = state.doc.resolve(details.pos + details.node.nodeSize)\n const $validPosition = GapCursor.findFrom($position, 1, false) as unknown as null | ResolvedPos\n\n if (!$validPosition) {\n return false\n }\n\n const { tr } = state\n const gapCursorSelection = new GapCursor($validPosition) as Selection\n\n tr.setSelection(gapCursorSelection)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n}\n","import { createBlockMarkdownSpec, defaultBlockAt, findParentNode, mergeAttributes, Node } from '@tiptap/core'\nimport { Selection } from '@tiptap/pm/state'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nexport interface DetailsContentOptions {\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n}\n\nexport const DetailsContent = Node.create<DetailsContentOptions>({\n name: 'detailsContent',\n\n content: 'block+',\n\n defining: true,\n\n selectable: false,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `div[data-type=\"${this.name}\"]`,\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { 'data-type': this.name }), 0]\n },\n\n addNodeView() {\n return ({ HTMLAttributes }) => {\n const dom = document.createElement('div')\n const attributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n 'data-type': this.name,\n hidden: 'hidden',\n })\n\n Object.entries(attributes).forEach(([key, value]) => dom.setAttribute(key, value))\n\n dom.addEventListener('toggleDetailsContent', () => {\n dom.toggleAttribute('hidden')\n })\n\n return {\n dom,\n contentDOM: dom,\n ignoreMutation(mutation: ViewMutationRecord) {\n if (mutation.type === 'selection') {\n return false\n }\n\n return !dom.contains(mutation.target) || dom === mutation.target\n },\n update: updatedNode => {\n if (updatedNode.type !== this.type) {\n return false\n }\n\n return true\n },\n }\n }\n },\n\n addKeyboardShortcuts() {\n return {\n // Escape node on double enter\n Enter: ({ editor }) => {\n const { state, view } = editor\n const { selection } = state\n const { $from, empty } = selection\n const detailsContent = findParentNode(node => node.type === this.type)(selection)\n\n if (!empty || !detailsContent || !detailsContent.node.childCount) {\n return false\n }\n\n const fromIndex = $from.index(detailsContent.depth)\n const { childCount } = detailsContent.node\n const isAtEnd = childCount === fromIndex + 1\n\n if (!isAtEnd) {\n return false\n }\n\n const defaultChildType = detailsContent.node.type.contentMatch.defaultType\n const defaultChildNode = defaultChildType?.createAndFill()\n\n if (!defaultChildNode) {\n return false\n }\n\n const $childPos = state.doc.resolve(detailsContent.pos + 1)\n const lastChildIndex = childCount - 1\n const lastChildNode = detailsContent.node.child(lastChildIndex)\n const lastChildPos = $childPos.posAtIndex(lastChildIndex, detailsContent.depth)\n const lastChildNodeIsEmpty = lastChildNode.eq(defaultChildNode)\n\n if (!lastChildNodeIsEmpty) {\n return false\n }\n\n // get parent of details node\n const above = $from.node(-3)\n\n if (!above) {\n return false\n }\n\n // get default node type after details node\n const after = $from.indexAfter(-3)\n const type = defaultBlockAt(above.contentMatchAt(after))\n\n if (!type || !above.canReplaceWith(after, after, type)) {\n return false\n }\n\n const node = type.createAndFill()\n\n if (!node) {\n return false\n }\n\n const { tr } = state\n const pos = $from.after(-2)\n\n tr.replaceWith(pos, pos, node)\n\n const $pos = tr.doc.resolve(pos)\n const newSelection = Selection.near($pos, 1)\n\n tr.setSelection(newSelection)\n\n const deleteFrom = lastChildPos\n const deleteTo = lastChildPos + lastChildNode.nodeSize\n\n tr.delete(deleteFrom, deleteTo)\n tr.scrollIntoView()\n view.dispatch(tr)\n\n return true\n },\n }\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'detailsContent',\n }),\n})\n","import { createBlockMarkdownSpec, mergeAttributes, Node } from '@tiptap/core'\n\nexport interface DetailsSummaryOptions {\n /**\n * Custom HTML attributes that should be added to the rendered HTML tag.\n */\n HTMLAttributes: {\n [key: string]: any\n }\n}\n\nexport const DetailsSummary = Node.create<DetailsSummaryOptions>({\n name: 'detailsSummary',\n\n content: 'text*',\n\n defining: true,\n\n selectable: false,\n\n isolating: true,\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'summary',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['summary', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n ...createBlockMarkdownSpec({\n nodeName: 'detailsSummary',\n content: 'inline',\n }),\n})\n","import { Details } from './details.js'\n\nexport * from './content/index.js'\nexport * from './details.js'\nexport * from './summary/index.js'\n\nexport default Details\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA,gBAAAA;AAAA,EACA,kBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS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Y;AAAA,EAEZ,WAAW;AAAA,EAEX,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,WAAWD,iBAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EACpF;AAAA,EAEA,GAAGD,yBAAwB;AAAA,IACzB,UAAU;AAAA,IACV,SAAS;AAAA,EACX,CAAC;AACH,CAAC;;;ACtCD,IAAO,gBAAQ;","names":["findChildren","findParentNode","findParentNode","findChildren","transaction","createBlockMarkdownSpec","defaultBlockAt","findParentNode","mergeAttributes","Node","Selection","node","createBlockMarkdownSpec","mergeAttributes","Node"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-details",
3
3
  "description": "details extension for tiptap",
4
- "version": "3.21.0",
4
+ "version": "3.22.0",
5
5
  "homepage": "https://tiptap.dev/api/nodes/details",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -31,14 +31,14 @@
31
31
  "dist"
32
32
  ],
33
33
  "devDependencies": {
34
- "@tiptap/core": "^3.21.0",
35
- "@tiptap/extension-text-style": "^3.21.0",
36
- "@tiptap/pm": "^3.21.0"
34
+ "@tiptap/core": "^3.22.0",
35
+ "@tiptap/extension-text-style": "^3.22.0",
36
+ "@tiptap/pm": "^3.22.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "@tiptap/core": "^3.21.0",
40
- "@tiptap/extension-text-style": "^3.21.0",
41
- "@tiptap/pm": "^3.21.0"
39
+ "@tiptap/core": "^3.22.0",
40
+ "@tiptap/extension-text-style": "^3.22.0",
41
+ "@tiptap/pm": "^3.22.0"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",
package/src/details.ts CHANGED
@@ -245,7 +245,11 @@ export const Details = Node.create<DetailsOptions>({
245
245
  return false
246
246
  }
247
247
 
248
- return !dom.contains(mutation.target) || dom === mutation.target
248
+ const target = mutation.target
249
+ const isInsideWrapper = dom.contains(target)
250
+ const isInsideToggleButton = toggle.contains(target)
251
+
252
+ return isInsideToggleButton || !isInsideWrapper || dom === target
249
253
  },
250
254
  update: updatedNode => {
251
255
  if (updatedNode.type !== this.type) {