{"version":3,"sources":["jsdelivr-header.js","/npm/@milkdown/plugin-cursor@7.19.0/src/__internal__/with-meta.ts","/npm/@milkdown/plugin-cursor@7.19.0/src/drop-indicator/state.ts","/npm/@milkdown/plugin-cursor@7.19.0/src/drop-indicator/drop-indicator-dom.ts","/npm/@milkdown/plugin-cursor@7.19.0/src/drop-indicator/plugin.ts","/npm/@milkdown/plugin-cursor@7.19.0/src/gap-cursor.ts","/npm/@milkdown/plugin-cursor@7.19.0/src/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,gNCJO,SAAS,SACd,EACA,GASA,OAPA,OAAO,OAAO,EAAQ,CACpB,KAAM,CACJ,QAAS,6BACN,KAIA,CACT,CCJO,MAAM,mBAAqB,KAChC,KACA,sBAGF,SAAS,mBAAoB,CAC3B,YAAa,4BAcR,MAAM,oBAAsB,KACjC,CACE,MAAO,EACP,OAAO,EACP,MAAO,2BAET,uBAGF,SAAS,oBAAqB,CAC5B,YAAa,6BC5Bf,MAAM,IAAM,IAAI,UAAU,+BAGb,uBAAyB,QACnC,GACC,IAAI,OAAO,CACT,QACA,KAAO,IACL,MAAM,EAAS,EAAI,IAAI,oBAAoB,KACrC,EAAM,SAAS,cAAc,OACnC,OAAO,OAAO,EAAI,MAAO,CACvB,SAAU,QACV,cAAe,OACf,QAAS,OACT,gBAAiB,EAAO,MACxB,IAAK,IACL,KAAM,MAER,EAAI,UAAU,IAAI,EAAO,OACzB,EAAI,UAAU,IAAI,2BAElB,EAAK,IAAI,YAAY,YAAY,GACjC,MAAM,EAAa,EAAI,IAAI,mBAAmB,KAExC,EAAY,IAChB,gBAAgB,EAAK,EAAO,EAAM,EAKpC,OAFA,EAAW,GAAG,GAEP,CACL,QAAS,KACP,EAAW,IAAI,GACf,EAAI,QAAA,EACN,MAUV,SAAS,gBACP,EACA,EACA,GAEA,IAAK,EAEH,YADA,OAAO,OAAO,EAAI,MAAO,CAAE,QAAS,SAItC,MAAM,KAAE,GAAS,GACT,MAAO,GAAc,GAG3B,IAAM,EAAG,EAAI,EAAG,GAChB,IAAM,EAAG,EAAI,EAAG,IACd,EAGJ,IAAI,EACA,EACA,EAAc,EACd,EAAe,EALA,IAAO,GAQxB,EAAQ,EAAK,EACb,EAAS,EACT,GAAO,EAAY,IAEnB,EAAQ,EACR,EAAS,EAAK,EACd,GAAQ,EAAY,GAGtB,EAAM,KAAK,MAAM,GACjB,EAAO,KAAK,MAAM,GAElB,OAAO,OAAO,EAAI,MAAO,CACvB,QAAS,QACT,MAAO,GAAG,MACV,OAAQ,GAAG,MACX,UAAW,aAAa,QAAW,QAEvC,CA/CA,SAAS,uBAAwB,CAC/B,YAAa,4BC3CR,MAAM,oBAAsB,QAAQ,GAQ1B,0BAA0B,CACvC,OAR2B,IAC3B,EAAI,IAAI,mBAAmB,IAAK,EAAO,EAQvC,OAN2B,KAC3B,EAAI,IAAI,mBAAmB,IAAK,KAAI,EAMpC,OAAQ,KAAM,MAMlB,SAAS,oBAAqB,CAC5B,YAAa,yBCtBR,MAAM,gBAAkB,QAAO,IAAM,cAE5C,SAAS,gBAAiB,CACxB,YAAa,qBCIR,MAAM,iBAAmB,oBAMnB,OAA2B,CACtC,gBACA,oBACA,mBACA,uBACA,qBACA,c","file":"/npm/@milkdown/plugin-cursor@7.19.0/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@milkdown/plugin-cursor@7.19.0/lib/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 type { Meta, MilkdownPlugin } from '@milkdown/ctx'\n\nexport function withMeta<T extends MilkdownPlugin>(\n  plugin: T,\n  meta: Partial<Meta> & Pick<Meta, 'displayName'>\n): T {\n  Object.assign(plugin, {\n    meta: {\n      package: '@milkdown/plugin-cursor',\n      ...meta,\n    },\n  })\n\n  return plugin\n}\n","import type { ShowHandlerOptions } from 'prosemirror-drop-indicator'\n\nimport { $ctx } from '@milkdown/utils'\n\nimport { withMeta } from '../__internal__/with-meta'\n\n/// @internal\nexport type DropIndicatorState = ShowHandlerOptions | null\n\n/// The drop indicator state to store the current drop indicator information.\nexport const dropIndicatorState = $ctx(\n  null as DropIndicatorState,\n  'dropIndicatorState'\n)\n\nwithMeta(dropIndicatorState, {\n  displayName: 'Ctx<dropIndicatorState>',\n})\n\n/// Configuration for the drop indicator.\nexport type dropIndicatorConfig = {\n  /// The width of the drop indicator in pixels.\n  width: number\n  /// The color of the drop indicator.\n  color: string | false\n  /// The CSS class of the drop indicator.\n  class: string\n}\n\n/// The drop indicator configuration with default values.\nexport const dropIndicatorConfig = $ctx(\n  {\n    width: 2,\n    color: false,\n    class: 'milkdown-drop-indicator',\n  } as dropIndicatorConfig,\n  'dropIndicatorConfig'\n)\n\nwithMeta(dropIndicatorConfig, {\n  displayName: 'Ctx<dropIndicatorConfig>',\n})\n","import type { Ctx } from '@milkdown/ctx'\n\nimport { Plugin, PluginKey } from '@milkdown/prose/state'\nimport { $prose } from '@milkdown/utils'\n\nimport { withMeta } from '../__internal__/with-meta'\nimport {\n  dropIndicatorConfig,\n  dropIndicatorState,\n  type DropIndicatorState,\n} from './state'\n\nconst key = new PluginKey('MILKDOWN_DROP_INDICATOR_DOM')\n\n/// The drop indicator DOM plugin to render the drop indicator as a DOM element.\nexport const dropIndicatorDOMPlugin = $prose(\n  (ctx: Ctx) =>\n    new Plugin({\n      key,\n      view: (view) => {\n        const config = ctx.get(dropIndicatorConfig.key)\n        const dom = document.createElement('div')\n        Object.assign(dom.style, {\n          position: 'fixed',\n          pointerEvents: 'none',\n          display: 'none',\n          backgroundColor: config.color,\n          top: '0',\n          left: '0',\n        })\n        dom.classList.add(config.class)\n        dom.classList.add('milkdown-drop-indicator')\n\n        view.dom.parentNode?.appendChild(dom)\n        const stateSlice = ctx.use(dropIndicatorState.key)\n\n        const onUpdate = (state: DropIndicatorState) => {\n          renderIndicator(dom, state, config)\n        }\n\n        stateSlice.on(onUpdate)\n\n        return {\n          destroy: () => {\n            stateSlice.off(onUpdate)\n            dom.remove()\n          },\n        }\n      },\n    })\n)\n\nwithMeta(dropIndicatorDOMPlugin, {\n  displayName: 'Prose<dropIndicatorDOM>',\n})\n\nfunction renderIndicator(\n  dom: HTMLDivElement,\n  state: DropIndicatorState,\n  config: dropIndicatorConfig\n) {\n  if (!state) {\n    Object.assign(dom.style, { display: 'none' })\n    return\n  }\n\n  const { line } = state\n  const { width: lineWidth } = config\n\n  const {\n    p1: { x: x1, y: y1 },\n    p2: { x: x2, y: y2 },\n  } = line\n  const horizontal = y1 === y2\n\n  let width: number\n  let height: number\n  let top: number = y1\n  let left: number = x1\n\n  if (horizontal) {\n    width = x2 - x1\n    height = lineWidth\n    top -= lineWidth / 2\n  } else {\n    width = lineWidth\n    height = y2 - y1\n    left -= lineWidth / 2\n  }\n\n  top = Math.round(top)\n  left = Math.round(left)\n\n  Object.assign(dom.style, {\n    display: 'block',\n    width: `${width}px`,\n    height: `${height}px`,\n    transform: `translate(${left}px, ${top}px)`,\n  })\n}\n","import { $prose } from '@milkdown/utils'\nimport {\n  createDropIndicatorPlugin,\n  type ShowHandler,\n} from 'prosemirror-drop-indicator'\n\nimport { withMeta } from '../__internal__/with-meta'\nimport { dropIndicatorState } from './state'\n\n/// Drop indicator plugin to update the drop indicator state.\nexport const dropIndicatorPlugin = $prose((ctx) => {\n  const onShow: ShowHandler = (options) => {\n    ctx.set(dropIndicatorState.key, options)\n  }\n  const onHide: VoidFunction = () => {\n    ctx.set(dropIndicatorState.key, null)\n  }\n\n  const plugin = createDropIndicatorPlugin({\n    onShow,\n    onHide,\n    onDrag: () => true,\n  })\n\n  return plugin\n})\n\nwithMeta(dropIndicatorPlugin, {\n  displayName: 'Prose<dropIndicator>',\n})\n","import { gapCursor } from '@milkdown/prose/gapcursor'\nimport { $prose } from '@milkdown/utils'\n\nimport { withMeta } from './__internal__/with-meta'\n\n/// This plugin wraps [gap cursor](https://github.com/ProseMirror/prosemirror-gapcursor).\nexport const gapCursorPlugin = $prose(() => gapCursor())\n\nwithMeta(gapCursorPlugin, {\n  displayName: 'Prose<gapCursor>',\n})\n","import type { MilkdownPlugin } from '@milkdown/ctx'\n\nimport {\n  dropIndicatorConfig,\n  dropIndicatorDOMPlugin,\n  dropIndicatorState,\n} from './drop-indicator'\nimport { dropIndicatorPlugin } from './drop-indicator/plugin'\nimport { gapCursorPlugin } from './gap-cursor'\n\n/// @deprecated\n/// Use `dropIndicatorConfig` instead.\n/// Backward compatibility export for `dropCursorConfig`\nexport const dropCursorConfig = dropIndicatorConfig\n\nexport * from './drop-indicator'\nexport * from './gap-cursor'\n\n/// All plugins exported by this package.\nexport const cursor: MilkdownPlugin[] = [\n  gapCursorPlugin,\n  dropIndicatorConfig,\n  dropIndicatorState,\n  dropIndicatorDOMPlugin,\n  dropIndicatorPlugin,\n].flat()\n"]}