@milkdown/crepe 7.11.1 → 7.12.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.
Files changed (191) hide show
  1. package/lib/cjs/builder/builder.js +107 -0
  2. package/lib/cjs/builder/builder.js.map +1 -0
  3. package/lib/cjs/{index-CtTpZYVe.js → feature/block-edit/index.js} +165 -61
  4. package/lib/cjs/feature/block-edit/index.js.map +1 -0
  5. package/lib/cjs/feature/code-mirror/index.js +161 -0
  6. package/lib/cjs/feature/code-mirror/index.js.map +1 -0
  7. package/lib/cjs/feature/cursor/index.js +57 -0
  8. package/lib/cjs/feature/cursor/index.js.map +1 -0
  9. package/lib/cjs/feature/image-block/index.js +123 -0
  10. package/lib/cjs/feature/image-block/index.js.map +1 -0
  11. package/lib/cjs/{index-2icTTGim.js → feature/latex/index.js} +111 -24
  12. package/lib/cjs/feature/latex/index.js.map +1 -0
  13. package/lib/cjs/feature/link-tooltip/index.js +124 -0
  14. package/lib/cjs/feature/link-tooltip/index.js.map +1 -0
  15. package/lib/cjs/{index-Dw6lXgs6.js → feature/list-item/index.js} +39 -8
  16. package/lib/cjs/feature/list-item/index.js.map +1 -0
  17. package/lib/cjs/{index-B91KhPew.js → feature/placeholder/index.js} +46 -6
  18. package/lib/cjs/feature/placeholder/index.js.map +1 -0
  19. package/lib/cjs/{index-DEs_IHHy.js → feature/table/index.js} +78 -16
  20. package/lib/cjs/feature/table/index.js.map +1 -0
  21. package/lib/cjs/{index-k3lGvKiX.js → feature/toolbar/index.js} +133 -31
  22. package/lib/cjs/feature/toolbar/index.js.map +1 -0
  23. package/lib/cjs/index/index.js +2464 -0
  24. package/lib/cjs/index/index.js.map +1 -0
  25. package/lib/esm/builder/builder.js +105 -0
  26. package/lib/esm/builder/builder.js.map +1 -0
  27. package/lib/esm/{index-BEe1TpeS.js → feature/block-edit/index.js} +161 -57
  28. package/lib/esm/feature/block-edit/index.js.map +1 -0
  29. package/lib/esm/feature/code-mirror/index.js +159 -0
  30. package/lib/esm/feature/code-mirror/index.js.map +1 -0
  31. package/lib/esm/feature/cursor/index.js +55 -0
  32. package/lib/esm/feature/cursor/index.js.map +1 -0
  33. package/lib/esm/feature/image-block/index.js +121 -0
  34. package/lib/esm/feature/image-block/index.js.map +1 -0
  35. package/lib/esm/{index-ZGfGszIQ.js → feature/latex/index.js} +107 -20
  36. package/lib/esm/feature/latex/index.js.map +1 -0
  37. package/lib/esm/feature/link-tooltip/index.js +122 -0
  38. package/lib/esm/feature/link-tooltip/index.js.map +1 -0
  39. package/lib/esm/{index-E8UgFLeN.js → feature/list-item/index.js} +39 -8
  40. package/lib/esm/feature/list-item/index.js.map +1 -0
  41. package/lib/esm/{index-BCvtgOeI.js → feature/placeholder/index.js} +45 -5
  42. package/lib/esm/feature/placeholder/index.js.map +1 -0
  43. package/lib/esm/{index-CwMVnVeI.js → feature/table/index.js} +78 -16
  44. package/lib/esm/feature/table/index.js.map +1 -0
  45. package/lib/esm/{index-CTBg0aec.js → feature/toolbar/index.js} +128 -26
  46. package/lib/esm/feature/toolbar/index.js.map +1 -0
  47. package/lib/esm/index/index.js +2458 -0
  48. package/lib/esm/index/index.js.map +1 -0
  49. package/lib/tsconfig.tsbuildinfo +1 -1
  50. package/lib/types/builder.d.ts +2 -0
  51. package/lib/types/builder.d.ts.map +1 -0
  52. package/lib/types/core/builder.d.ts +23 -0
  53. package/lib/types/core/builder.d.ts.map +1 -0
  54. package/lib/types/core/crepe.d.ts +4 -15
  55. package/lib/types/core/crepe.d.ts.map +1 -1
  56. package/lib/types/core/index.d.ts +2 -1
  57. package/lib/types/core/index.d.ts.map +1 -1
  58. package/lib/types/core/slice.d.ts +6 -4
  59. package/lib/types/core/slice.d.ts.map +1 -1
  60. package/lib/types/default-config/index.d.ts +3 -0
  61. package/lib/types/default-config/index.d.ts.map +1 -0
  62. package/lib/types/feature/block-edit/handle/component.d.ts +2 -3
  63. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  64. package/lib/types/feature/block-edit/index.d.ts +20 -20
  65. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  66. package/lib/types/feature/code-mirror/index.d.ts +7 -7
  67. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  68. package/lib/types/feature/cursor/index.d.ts +1 -1
  69. package/lib/types/feature/cursor/index.d.ts.map +1 -1
  70. package/lib/types/feature/image-block/index.d.ts +9 -9
  71. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  72. package/lib/types/feature/index.d.ts +2 -4
  73. package/lib/types/feature/index.d.ts.map +1 -1
  74. package/lib/types/feature/latex/index.d.ts +3 -3
  75. package/lib/types/feature/latex/index.d.ts.map +1 -1
  76. package/lib/types/feature/link-tooltip/index.d.ts +6 -6
  77. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
  78. package/lib/types/feature/list-item/index.d.ts +5 -5
  79. package/lib/types/feature/list-item/index.d.ts.map +1 -1
  80. package/lib/types/feature/loader.d.ts +4 -0
  81. package/lib/types/feature/loader.d.ts.map +1 -0
  82. package/lib/types/feature/placeholder/index.d.ts +2 -2
  83. package/lib/types/feature/placeholder/index.d.ts.map +1 -1
  84. package/lib/types/feature/shared.d.ts +1 -2
  85. package/lib/types/feature/shared.d.ts.map +1 -1
  86. package/lib/types/feature/table/index.d.ts +11 -11
  87. package/lib/types/feature/table/index.d.ts.map +1 -1
  88. package/lib/types/feature/toolbar/index.d.ts +8 -8
  89. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  90. package/lib/types/icons/index.d.ts +1 -0
  91. package/lib/types/icons/index.d.ts.map +1 -1
  92. package/lib/types/index.d.ts +1 -1
  93. package/lib/types/index.d.ts.map +1 -1
  94. package/lib/types/utils/index.d.ts +0 -1
  95. package/lib/types/utils/index.d.ts.map +1 -1
  96. package/package.json +60 -3
  97. package/src/builder.ts +1 -0
  98. package/src/core/builder.ts +143 -0
  99. package/src/core/crepe.ts +14 -130
  100. package/src/core/index.ts +2 -1
  101. package/src/core/slice.ts +37 -8
  102. package/src/default-config/index.ts +25 -0
  103. package/src/feature/block-edit/handle/component.tsx +6 -8
  104. package/src/feature/block-edit/handle/index.ts +2 -2
  105. package/src/feature/block-edit/index.ts +23 -20
  106. package/src/feature/block-edit/menu/config.ts +19 -19
  107. package/src/feature/code-mirror/index.ts +32 -28
  108. package/src/feature/cursor/index.ts +10 -6
  109. package/src/feature/image-block/index.ts +19 -16
  110. package/src/feature/index.ts +2 -53
  111. package/src/feature/latex/index.ts +8 -10
  112. package/src/feature/latex/inline-tooltip/component.tsx +1 -1
  113. package/src/feature/link-tooltip/index.ts +13 -10
  114. package/src/feature/list-item/index.ts +11 -8
  115. package/src/feature/loader.ts +52 -0
  116. package/src/feature/placeholder/index.ts +5 -2
  117. package/src/feature/shared.ts +1 -3
  118. package/src/feature/table/index.ts +23 -23
  119. package/src/feature/toolbar/component.tsx +9 -9
  120. package/src/feature/toolbar/index.ts +14 -11
  121. package/src/icons/index.ts +1 -0
  122. package/src/index.ts +1 -1
  123. package/src/utils/index.ts +0 -8
  124. package/lib/cjs/confirm-CNveM9QH.js +0 -26
  125. package/lib/cjs/confirm-CNveM9QH.js.map +0 -1
  126. package/lib/cjs/edit-BUtBJHpV.js +0 -24
  127. package/lib/cjs/edit-BUtBJHpV.js.map +0 -1
  128. package/lib/cjs/functions-BAY51plB.js +0 -39
  129. package/lib/cjs/functions-BAY51plB.js.map +0 -1
  130. package/lib/cjs/image-BXLkOVnO.js +0 -24
  131. package/lib/cjs/image-BXLkOVnO.js.map +0 -1
  132. package/lib/cjs/index-2icTTGim.js.map +0 -1
  133. package/lib/cjs/index-B91KhPew.js.map +0 -1
  134. package/lib/cjs/index-BsrJn8Jp.js +0 -41
  135. package/lib/cjs/index-BsrJn8Jp.js.map +0 -1
  136. package/lib/cjs/index-C2CAbC2F.js +0 -26
  137. package/lib/cjs/index-C2CAbC2F.js.map +0 -1
  138. package/lib/cjs/index-CtTpZYVe.js.map +0 -1
  139. package/lib/cjs/index-DEs_IHHy.js.map +0 -1
  140. package/lib/cjs/index-DLIudQKW.js +0 -126
  141. package/lib/cjs/index-DLIudQKW.js.map +0 -1
  142. package/lib/cjs/index-Dw6lXgs6.js.map +0 -1
  143. package/lib/cjs/index-k3lGvKiX.js.map +0 -1
  144. package/lib/cjs/index-urTgNBfI.js +0 -202
  145. package/lib/cjs/index-urTgNBfI.js.map +0 -1
  146. package/lib/cjs/index-xbwf60wt.js +0 -15
  147. package/lib/cjs/index-xbwf60wt.js.map +0 -1
  148. package/lib/cjs/index-xbxqAqH2.js +0 -52
  149. package/lib/cjs/index-xbxqAqH2.js.map +0 -1
  150. package/lib/cjs/index.js +0 -20
  151. package/lib/cjs/index.js.map +0 -1
  152. package/lib/cjs/inline-latex-D0G71cGk.js +0 -54
  153. package/lib/cjs/inline-latex-D0G71cGk.js.map +0 -1
  154. package/lib/cjs/plus-XLomtlXf.js +0 -24
  155. package/lib/cjs/plus-XLomtlXf.js.map +0 -1
  156. package/lib/cjs/remove-Ba-ypwBf.js +0 -17
  157. package/lib/cjs/remove-Ba-ypwBf.js.map +0 -1
  158. package/lib/esm/confirm-DtE-HkVd.js +0 -24
  159. package/lib/esm/confirm-DtE-HkVd.js.map +0 -1
  160. package/lib/esm/edit-D--t_JAb.js +0 -22
  161. package/lib/esm/edit-D--t_JAb.js.map +0 -1
  162. package/lib/esm/functions-DlJPkGmE.js +0 -36
  163. package/lib/esm/functions-DlJPkGmE.js.map +0 -1
  164. package/lib/esm/image-DoB1o1sl.js +0 -22
  165. package/lib/esm/image-DoB1o1sl.js.map +0 -1
  166. package/lib/esm/index-BCvtgOeI.js.map +0 -1
  167. package/lib/esm/index-BEe1TpeS.js.map +0 -1
  168. package/lib/esm/index-BPG8iO8t.js +0 -12
  169. package/lib/esm/index-BPG8iO8t.js.map +0 -1
  170. package/lib/esm/index-BUBXHhHG.js +0 -39
  171. package/lib/esm/index-BUBXHhHG.js.map +0 -1
  172. package/lib/esm/index-Bvz1Yyiz.js +0 -24
  173. package/lib/esm/index-Bvz1Yyiz.js.map +0 -1
  174. package/lib/esm/index-C1aVAv1l.js +0 -124
  175. package/lib/esm/index-C1aVAv1l.js.map +0 -1
  176. package/lib/esm/index-CTBg0aec.js.map +0 -1
  177. package/lib/esm/index-ChR5Qhyf.js +0 -50
  178. package/lib/esm/index-ChR5Qhyf.js.map +0 -1
  179. package/lib/esm/index-CshFzSt2.js +0 -197
  180. package/lib/esm/index-CshFzSt2.js.map +0 -1
  181. package/lib/esm/index-CwMVnVeI.js.map +0 -1
  182. package/lib/esm/index-E8UgFLeN.js.map +0 -1
  183. package/lib/esm/index-ZGfGszIQ.js.map +0 -1
  184. package/lib/esm/index.js +0 -12
  185. package/lib/esm/index.js.map +0 -1
  186. package/lib/esm/inline-latex-C9IGAXXQ.js +0 -51
  187. package/lib/esm/inline-latex-C9IGAXXQ.js.map +0 -1
  188. package/lib/esm/plus-lrX0Q75O.js +0 -22
  189. package/lib/esm/plus-lrX0Q75O.js.map +0 -1
  190. package/lib/esm/remove-D3g0Cd6_.js +0 -15
  191. package/lib/esm/remove-D3g0Cd6_.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/caption.ts","../../../../src/icons/confirm.ts","../../../../src/icons/image.ts","../../../../src/feature/index.ts","../../../../src/feature/image-block/index.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","export const captionIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"32\"\n height=\"32\"\n viewBox=\"0 0 24 24\"\n >\n <path\n fill=\"currentColor\"\n d=\"M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z\"\n />\n </svg>\n`\n","export const confirmIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <g clip-path=\"url(#clip0_1013_1606)\">\n <path\n d=\"M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z\"\n fill=\"#817567\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1606\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const imageIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_977_8075)\">\n <path\n d=\"M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_977_8075\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","import type { BlockEditFeatureConfig } from './block-edit'\nimport type { CodeMirrorFeatureConfig } from './code-mirror'\nimport type { CursorFeatureConfig } from './cursor'\nimport type { ImageBlockFeatureConfig } from './image-block'\nimport type { LatexFeatureConfig } from './latex'\nimport type { LinkTooltipFeatureConfig } from './link-tooltip'\nimport type { ListItemFeatureConfig } from './list-item'\nimport type { PlaceholderFeatureConfig } from './placeholder'\nimport type { TableFeatureConfig } from './table'\nimport type { ToolbarFeatureConfig } from './toolbar'\n\n/// The crepe editor feature flags.\n/// Every feature is enabled by default.\n/// Every feature is a string literal type.\nexport enum CrepeFeature {\n /// Syntax highlighting and editing for code blocks with language support, theme customization, and preview capabilities.\n CodeMirror = 'code-mirror',\n\n /// Support for bullet lists, ordered lists, and todo lists with customizable icons and formatting.\n ListItem = 'list-item',\n\n /// Enhanced link editing and preview with customizable tooltips, edit/remove actions, and copy functionality.\n LinkTooltip = 'link-tooltip',\n\n /// Enhanced cursor experience with drop cursor and gap cursor for better content placement.\n Cursor = 'cursor',\n\n /// Image upload and management with resizing, captions, and support for both inline and block images.\n ImageBlock = 'image-block',\n\n /// Drag-and-drop block management and slash commands for quick content insertion and organization.\n BlockEdit = 'block-edit',\n\n /// Formatting toolbar for selected text with customizable icons and actions.\n Toolbar = 'toolbar',\n\n /// Document or block level placeholders to guide users when content is empty.\n Placeholder = 'placeholder',\n\n /// Full-featured table editing with row/column management, alignment options, and drag-and-drop functionality.\n Table = 'table',\n\n /// Mathematical formula support with both inline and block math rendering using KaTeX.\n Latex = 'latex',\n}\n\nexport interface CrepeFeatureConfig {\n [CrepeFeature.Cursor]?: CursorFeatureConfig\n [CrepeFeature.ListItem]?: ListItemFeatureConfig\n [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig\n [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig\n [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig\n [CrepeFeature.Placeholder]?: PlaceholderFeatureConfig\n [CrepeFeature.Toolbar]?: ToolbarFeatureConfig\n [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig\n [CrepeFeature.Table]?: TableFeatureConfig\n [CrepeFeature.Latex]?: LatexFeatureConfig\n}\n\nexport const defaultFeatures: Record<CrepeFeature, boolean> = {\n [CrepeFeature.Cursor]: true,\n [CrepeFeature.ListItem]: true,\n [CrepeFeature.LinkTooltip]: true,\n [CrepeFeature.ImageBlock]: true,\n [CrepeFeature.BlockEdit]: true,\n [CrepeFeature.Placeholder]: true,\n [CrepeFeature.Toolbar]: true,\n [CrepeFeature.CodeMirror]: true,\n [CrepeFeature.Table]: true,\n [CrepeFeature.Latex]: true,\n}\n","import {\n imageBlockComponent,\n imageBlockConfig,\n} from '@milkdown/kit/component/image-block'\nimport {\n imageInlineComponent,\n inlineImageConfig,\n} from '@milkdown/kit/component/image-inline'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { captionIcon, imageIcon, confirmIcon } from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface ImageBlockConfig {\n onUpload: (file: File) => Promise<string>\n proxyDomURL: (url: string) => Promise<string> | string\n\n inlineImageIcon: string\n inlineConfirmButton: string\n inlineUploadButton: string\n inlineUploadPlaceholderText: string\n inlineOnUpload: (file: File) => Promise<string>\n\n blockImageIcon: string\n blockConfirmButton: string\n blockCaptionIcon: string\n blockUploadButton: string\n blockCaptionPlaceholderText: string\n blockUploadPlaceholderText: string\n blockOnUpload: (file: File) => Promise<string>\n}\n\nexport type ImageBlockFeatureConfig = Partial<ImageBlockConfig>\n\nexport const imageBlock: DefineFeature<ImageBlockFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.ImageBlock))\n .config((ctx) => {\n ctx.update(inlineImageConfig.key, (value) => ({\n uploadButton: config?.inlineUploadButton ?? 'Upload',\n imageIcon: config?.inlineImageIcon ?? imageIcon,\n confirmButton: config?.inlineConfirmButton ?? confirmIcon,\n uploadPlaceholderText:\n config?.inlineUploadPlaceholderText ?? 'or paste link',\n onUpload: config?.inlineOnUpload ?? config?.onUpload ?? value.onUpload,\n proxyDomURL: config?.proxyDomURL,\n }))\n ctx.update(imageBlockConfig.key, (value) => ({\n uploadButton: config?.blockUploadButton ?? 'Upload file',\n imageIcon: config?.blockImageIcon ?? imageIcon,\n captionIcon: config?.blockCaptionIcon ?? captionIcon,\n confirmButton: config?.blockConfirmButton ?? 'Confirm',\n captionPlaceholderText:\n config?.blockCaptionPlaceholderText ?? 'Write Image Caption',\n uploadPlaceholderText:\n config?.blockUploadPlaceholderText ?? 'or paste link',\n onUpload: config?.blockOnUpload ?? config?.onUpload ?? value.onUpload,\n proxyDomURL: config?.proxyDomURL,\n }))\n })\n .use(imageBlockComponent)\n .use(imageInlineComponent)\n}\n"],"names":["createSlice","CrepeFeature","inlineImageConfig","imageBlockConfig","imageBlockComponent","imageInlineComponent"],"mappings":";;;;;;AAQ2BA,eAAA,CAAY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AAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,aAAA,KAAR,YAAyB,MAAQ,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,QAAA,KAAjC,YAA6C,KAAM,CAAA,QAAA;AAAA,QAC7D,aAAa,MAAQ,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA;AAAA,OACvB;AAAA,KAAE,CAAA;AAAA,GACH,CACA,CAAA,GAAA,CAAIC,gCAAmB,CAAA,CACvB,IAAIC,gCAAoB,CAAA;AAC7B;;;;"}
@@ -2,10 +2,9 @@
2
2
 
3
3
  var codeBlock = require('@milkdown/kit/component/code-block');
4
4
  var katex = require('katex');
5
- var index = require('./index-urTgNBfI.js');
6
- var confirm = require('./confirm-CNveM9QH.js');
5
+ var ctx = require('@milkdown/kit/ctx');
7
6
  var commonmark = require('@milkdown/kit/preset/commonmark');
8
- var inlineLatex = require('./inline-latex-D0G71cGk.js');
7
+ var utils = require('@milkdown/kit/utils');
9
8
  var tooltip = require('@milkdown/kit/plugin/tooltip');
10
9
  var history = require('@milkdown/kit/prose/history');
11
10
  var keymap = require('@milkdown/kit/prose/keymap');
@@ -16,17 +15,60 @@ var vue = require('vue');
16
15
  var component = require('@milkdown/kit/component');
17
16
  var prose = require('@milkdown/kit/prose');
18
17
  var inputrules = require('@milkdown/kit/prose/inputrules');
19
- var utils = require('@milkdown/kit/utils');
20
18
  var remarkMath = require('remark-math');
21
19
  var unistUtilVisit = require('unist-util-visit');
22
- require('@milkdown/kit/core');
23
- require('@milkdown/kit/plugin/clipboard');
24
- require('@milkdown/kit/plugin/history');
25
- require('@milkdown/kit/plugin/indent');
26
- require('@milkdown/kit/plugin/listener');
27
- require('@milkdown/kit/plugin/trailing');
28
- require('@milkdown/kit/preset/gfm');
29
- require('@milkdown/kit/ctx');
20
+
21
+ ctx.createSlice([], "FeaturesCtx");
22
+ ctx.createSlice({}, "CrepeCtx");
23
+ function useCrepeFeatures(ctx) {
24
+ return ctx.use("FeaturesCtx");
25
+ }
26
+ function crepeFeatureConfig(feature) {
27
+ return (ctx) => {
28
+ useCrepeFeatures(ctx).update((features) => {
29
+ if (features.includes(feature)) {
30
+ return features;
31
+ }
32
+ return [...features, feature];
33
+ });
34
+ };
35
+ }
36
+
37
+ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
38
+ CrepeFeature2["CodeMirror"] = "code-mirror";
39
+ CrepeFeature2["ListItem"] = "list-item";
40
+ CrepeFeature2["LinkTooltip"] = "link-tooltip";
41
+ CrepeFeature2["Cursor"] = "cursor";
42
+ CrepeFeature2["ImageBlock"] = "image-block";
43
+ CrepeFeature2["BlockEdit"] = "block-edit";
44
+ CrepeFeature2["Toolbar"] = "toolbar";
45
+ CrepeFeature2["Placeholder"] = "placeholder";
46
+ CrepeFeature2["Table"] = "table";
47
+ CrepeFeature2["Latex"] = "latex";
48
+ return CrepeFeature2;
49
+ })(CrepeFeature || {});
50
+
51
+ const confirmIcon = `
52
+ <svg
53
+ xmlns="http://www.w3.org/2000/svg"
54
+ width="24"
55
+ height="24"
56
+ viewBox="0 0 24 24"
57
+ fill="none"
58
+ >
59
+ <g clip-path="url(#clip0_1013_1606)">
60
+ <path
61
+ d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z"
62
+ fill="#817567"
63
+ />
64
+ </g>
65
+ <defs>
66
+ <clipPath id="clip0_1013_1606">
67
+ <rect width="24" height="24" />
68
+ </clipPath>
69
+ </defs>
70
+ </svg>
71
+ `;
30
72
 
31
73
  const blockLatexSchema = commonmark.codeBlockSchema.extendSchema((prev) => {
32
74
  return (ctx) => {
@@ -53,6 +95,52 @@ const blockLatexSchema = commonmark.codeBlockSchema.extendSchema((prev) => {
53
95
  };
54
96
  });
55
97
 
98
+ const mathInlineId = "math_inline";
99
+ const mathInlineSchema = utils.$nodeSchema(mathInlineId, () => ({
100
+ group: "inline",
101
+ inline: true,
102
+ draggable: true,
103
+ atom: true,
104
+ attrs: {
105
+ value: {
106
+ default: ""
107
+ }
108
+ },
109
+ parseDOM: [
110
+ {
111
+ tag: `span[data-type="${mathInlineId}"]`,
112
+ getAttrs: (dom) => {
113
+ var _a;
114
+ return {
115
+ value: (_a = dom.dataset.value) != null ? _a : ""
116
+ };
117
+ }
118
+ }
119
+ ],
120
+ toDOM: (node) => {
121
+ const code = node.attrs.value;
122
+ const dom = document.createElement("span");
123
+ dom.dataset.type = mathInlineId;
124
+ dom.dataset.value = code;
125
+ katex.render(code, dom, {
126
+ throwOnError: false
127
+ });
128
+ return dom;
129
+ },
130
+ parseMarkdown: {
131
+ match: (node) => node.type === "inlineMath",
132
+ runner: (state, node, type) => {
133
+ state.addNode(type, { value: node.value });
134
+ }
135
+ },
136
+ toMarkdown: {
137
+ match: (node) => node.type.name === mathInlineId,
138
+ runner: (state, node) => {
139
+ state.addNode("inlineMath", void 0, node.attrs.value);
140
+ }
141
+ }
142
+ }));
143
+
56
144
  const inlineLatexTooltip = tooltip.tooltipFactory("INLINE_LATEX");
57
145
 
58
146
  const LatexTooltip = vue.defineComponent({
@@ -85,8 +173,7 @@ const LatexTooltip = vue.defineComponent({
85
173
  props.updateValue.value();
86
174
  };
87
175
  return () => {
88
- var _a, _b;
89
- return /* @__PURE__ */ vue.h("div", { class: "container" }, props.innerView && /* @__PURE__ */ vue.h("div", { ref: innerViewRef }), /* @__PURE__ */ vue.h("button", { onPointerdown: onUpdate }, /* @__PURE__ */ vue.h(component.Icon, { icon: (_b = (_a = props.config).inlineEditConfirm) == null ? void 0 : _b.call(_a) })));
176
+ return /* @__PURE__ */ vue.h("div", { class: "container" }, props.innerView && /* @__PURE__ */ vue.h("div", { ref: innerViewRef }), /* @__PURE__ */ vue.h("button", { onPointerdown: onUpdate }, /* @__PURE__ */ vue.h(component.Icon, { icon: props.config.inlineEditConfirm })));
90
177
  };
91
178
  }
92
179
  });
@@ -121,7 +208,7 @@ class LatexInlineTooltip {
121
208
  if (selection.empty) return false;
122
209
  if (!(selection instanceof state.NodeSelection)) return false;
123
210
  const node = selection.node;
124
- if (node.type.name !== inlineLatex.mathInlineId) return false;
211
+ if (node.type.name !== mathInlineId) return false;
125
212
  const textFrom = selection.from;
126
213
  const paragraph = schema.nodes.paragraph.create(
127
214
  null,
@@ -216,7 +303,7 @@ _onHide = new WeakMap();
216
303
  _shouldShow = new WeakMap();
217
304
 
218
305
  const mathInlineInputRule = utils.$inputRule(
219
- (ctx) => prose.nodeRule(/(?:\$)([^$]+)(?:\$)$/, inlineLatex.mathInlineSchema.type(ctx), {
306
+ (ctx) => prose.nodeRule(/(?:\$)([^$]+)(?:\$)$/, mathInlineSchema.type(ctx), {
220
307
  getAttr: (match) => {
221
308
  var _a;
222
309
  return {
@@ -255,10 +342,10 @@ const remarkMathBlockPlugin = utils.$remark(
255
342
  () => () => visitMathBlock
256
343
  );
257
344
 
258
- const defineFeature = (editor, config) => {
259
- editor.config((ctx) => {
260
- const flags = ctx.get(index.FeaturesCtx);
261
- const isCodeMirrorEnabled = flags.includes(index.CrepeFeature.CodeMirror);
345
+ const latex = (editor, config) => {
346
+ editor.config(crepeFeatureConfig(CrepeFeature.Latex)).config((ctx) => {
347
+ const flags = useCrepeFeatures(ctx).get();
348
+ const isCodeMirrorEnabled = flags.includes(CrepeFeature.CodeMirror);
262
349
  if (!isCodeMirrorEnabled) {
263
350
  throw new Error("You need to enable CodeMirror to use LaTeX feature");
264
351
  }
@@ -276,12 +363,12 @@ const defineFeature = (editor, config) => {
276
363
  view: (view) => {
277
364
  var _a;
278
365
  return new LatexInlineTooltip(ctx, view, {
279
- inlineEditConfirm: (_a = config == null ? void 0 : config.inlineEditConfirm) != null ? _a : () => confirm.confirmIcon,
366
+ inlineEditConfirm: (_a = config == null ? void 0 : config.inlineEditConfirm) != null ? _a : confirmIcon,
280
367
  ...config
281
368
  });
282
369
  }
283
370
  });
284
- }).use(remarkMathPlugin).use(remarkMathBlockPlugin).use(inlineLatex.mathInlineSchema).use(inlineLatexTooltip).use(mathInlineInputRule).use(mathBlockInputRule).use(blockLatexSchema);
371
+ }).use(remarkMathPlugin).use(remarkMathBlockPlugin).use(mathInlineSchema).use(inlineLatexTooltip).use(mathInlineInputRule).use(mathBlockInputRule).use(blockLatexSchema);
285
372
  };
286
373
  function renderLatex(content, options) {
287
374
  const html = katex.renderToString(content, {
@@ -292,5 +379,5 @@ function renderLatex(content, options) {
292
379
  return html;
293
380
  }
294
381
 
295
- exports.defineFeature = defineFeature;
296
- //# sourceMappingURL=index-2icTTGim.js.map
382
+ exports.latex = latex;
383
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/feature/index.ts","../../../../src/icons/confirm.ts","../../../../src/feature/latex/block-latex.ts","../../../../src/feature/latex/inline-latex.ts","../../../../src/feature/latex/inline-tooltip/tooltip.ts","../../../../src/feature/latex/inline-tooltip/component.tsx","../../../../src/feature/latex/inline-tooltip/view.ts","../../../../src/feature/latex/input-rule.ts","../../../../src/feature/latex/remark.ts","../../../../src/feature/latex/index.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","import type { BlockEditFeatureConfig } from './block-edit'\nimport type { CodeMirrorFeatureConfig } from './code-mirror'\nimport type { CursorFeatureConfig } from './cursor'\nimport type { ImageBlockFeatureConfig } from './image-block'\nimport type { LatexFeatureConfig } from './latex'\nimport type { LinkTooltipFeatureConfig } from './link-tooltip'\nimport type { ListItemFeatureConfig } from './list-item'\nimport type { PlaceholderFeatureConfig } from './placeholder'\nimport type { TableFeatureConfig } from './table'\nimport type { ToolbarFeatureConfig } from './toolbar'\n\n/// The crepe editor feature flags.\n/// Every feature is enabled by default.\n/// Every feature is a string literal type.\nexport enum CrepeFeature {\n /// Syntax highlighting and editing for code blocks with language support, theme customization, and preview capabilities.\n CodeMirror = 'code-mirror',\n\n /// Support for bullet lists, ordered lists, and todo lists with customizable icons and formatting.\n ListItem = 'list-item',\n\n /// Enhanced link editing and preview with customizable tooltips, edit/remove actions, and copy functionality.\n LinkTooltip = 'link-tooltip',\n\n /// Enhanced cursor experience with drop cursor and gap cursor for better content placement.\n Cursor = 'cursor',\n\n /// Image upload and management with resizing, captions, and support for both inline and block images.\n ImageBlock = 'image-block',\n\n /// Drag-and-drop block management and slash commands for quick content insertion and organization.\n BlockEdit = 'block-edit',\n\n /// Formatting toolbar for selected text with customizable icons and actions.\n Toolbar = 'toolbar',\n\n /// Document or block level placeholders to guide users when content is empty.\n Placeholder = 'placeholder',\n\n /// Full-featured table editing with row/column management, alignment options, and drag-and-drop functionality.\n Table = 'table',\n\n /// Mathematical formula support with both inline and block math rendering using KaTeX.\n Latex = 'latex',\n}\n\nexport interface CrepeFeatureConfig {\n [CrepeFeature.Cursor]?: CursorFeatureConfig\n [CrepeFeature.ListItem]?: ListItemFeatureConfig\n [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig\n [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig\n [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig\n [CrepeFeature.Placeholder]?: PlaceholderFeatureConfig\n [CrepeFeature.Toolbar]?: ToolbarFeatureConfig\n [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig\n [CrepeFeature.Table]?: TableFeatureConfig\n [CrepeFeature.Latex]?: LatexFeatureConfig\n}\n\nexport const defaultFeatures: Record<CrepeFeature, boolean> = {\n [CrepeFeature.Cursor]: true,\n [CrepeFeature.ListItem]: true,\n [CrepeFeature.LinkTooltip]: true,\n [CrepeFeature.ImageBlock]: true,\n [CrepeFeature.BlockEdit]: true,\n [CrepeFeature.Placeholder]: true,\n [CrepeFeature.Toolbar]: true,\n [CrepeFeature.CodeMirror]: true,\n [CrepeFeature.Table]: true,\n [CrepeFeature.Latex]: true,\n}\n","export const confirmIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <g clip-path=\"url(#clip0_1013_1606)\">\n <path\n d=\"M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z\"\n fill=\"#817567\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1606\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'\n\nexport const blockLatexSchema = codeBlockSchema.extendSchema((prev) => {\n return (ctx) => {\n const baseSchema = prev(ctx)\n return {\n ...baseSchema,\n toMarkdown: {\n match: baseSchema.toMarkdown.match,\n runner: (state, node) => {\n const language = node.attrs.language ?? ''\n if (language.toLowerCase() === 'latex') {\n state.addNode(\n 'math',\n undefined,\n node.content.firstChild?.text || ''\n )\n } else {\n return baseSchema.toMarkdown.runner(state, node)\n }\n },\n },\n }\n }\n})\n","import { $nodeSchema } from '@milkdown/kit/utils'\nimport katex from 'katex'\n\nexport const mathInlineId = 'math_inline'\n\n/// Schema for inline math node.\n/// Add support for:\n///\n/// ```markdown\n/// $a^2 + b^2 = c^2$\n/// ```\nexport const mathInlineSchema = $nodeSchema(mathInlineId, () => ({\n group: 'inline',\n inline: true,\n draggable: true,\n atom: true,\n attrs: {\n value: {\n default: '',\n },\n },\n parseDOM: [\n {\n tag: `span[data-type=\"${mathInlineId}\"]`,\n getAttrs: (dom) => {\n return {\n value: (dom as HTMLElement).dataset.value ?? '',\n }\n },\n },\n ],\n toDOM: (node) => {\n const code: string = node.attrs.value\n const dom = document.createElement('span')\n dom.dataset.type = mathInlineId\n dom.dataset.value = code\n katex.render(code, dom, {\n throwOnError: false,\n })\n\n return dom\n },\n parseMarkdown: {\n match: (node) => node.type === 'inlineMath',\n runner: (state, node, type) => {\n state.addNode(type, { value: node.value as string })\n },\n },\n toMarkdown: {\n match: (node) => node.type.name === mathInlineId,\n runner: (state, node) => {\n state.addNode('inlineMath', undefined, node.attrs.value)\n },\n },\n}))\n","import { tooltipFactory } from '@milkdown/kit/plugin/tooltip'\n\nexport const inlineLatexTooltip = tooltipFactory('INLINE_LATEX')\n","import type { EditorView } from '@milkdown/kit/prose/view'\n\nimport { Icon } from '@milkdown/kit/component'\nimport { defineComponent, type ShallowRef, type VNodeRef, h } from 'vue'\n\nimport type { LatexConfig } from '..'\n\ntype LatexTooltipProps = {\n config: Partial<LatexConfig>\n innerView: ShallowRef<EditorView | null>\n updateValue: ShallowRef<() => void>\n}\n\nh\n\nexport const LatexTooltip = defineComponent<LatexTooltipProps>({\n props: {\n config: {\n type: Object,\n required: true,\n },\n innerView: {\n type: Object,\n required: true,\n },\n updateValue: {\n type: Object,\n required: true,\n },\n },\n setup(props) {\n const innerViewRef: VNodeRef = (el) => {\n if (!el || !(el instanceof HTMLElement)) return\n while (el.firstChild) {\n el.removeChild(el.firstChild)\n }\n if (props.innerView.value) {\n el.appendChild(props.innerView.value.dom)\n }\n }\n const onUpdate = (e: Event) => {\n e.preventDefault()\n props.updateValue.value()\n }\n\n return () => {\n return (\n <div class=\"container\">\n {props.innerView && <div ref={innerViewRef} />}\n <button onPointerdown={onUpdate}>\n <Icon icon={props.config.inlineEditConfirm} />\n </button>\n </div>\n )\n }\n },\n})\n","import type { Ctx } from '@milkdown/kit/ctx'\nimport type { PluginView } from '@milkdown/kit/prose/state'\n\nimport { TooltipProvider } from '@milkdown/kit/plugin/tooltip'\nimport { redo, undo } from '@milkdown/kit/prose/history'\nimport { keymap } from '@milkdown/kit/prose/keymap'\nimport { Schema } from '@milkdown/kit/prose/model'\nimport { EditorState, NodeSelection } from '@milkdown/kit/prose/state'\nimport { EditorView } from '@milkdown/kit/prose/view'\nimport { createApp, shallowRef, type App, type ShallowRef } from 'vue'\n\nimport type { LatexConfig } from '..'\n\nimport { mathInlineId } from '../inline-latex'\nimport { LatexTooltip } from './component'\n\nexport class LatexInlineTooltip implements PluginView {\n #content: HTMLElement\n #provider: TooltipProvider\n #dom: HTMLElement\n #innerView: ShallowRef<EditorView | null> = shallowRef(null)\n #updateValue: ShallowRef<() => void> = shallowRef(() => {})\n #app: App\n\n constructor(\n readonly ctx: Ctx,\n view: EditorView,\n config: Partial<LatexConfig>\n ) {\n const content = document.createElement('div')\n content.className = 'milkdown-latex-inline-edit'\n this.#content = content\n this.#app = createApp(LatexTooltip, {\n config,\n innerView: this.#innerView,\n updateValue: this.#updateValue,\n })\n this.#app.mount(content)\n this.#provider = new TooltipProvider({\n debounce: 0,\n content: this.#content,\n shouldShow: this.#shouldShow,\n offset: 10,\n floatingUIOptions: {\n placement: 'bottom',\n },\n })\n this.#provider.update(view)\n this.#dom = document.createElement('div')\n }\n\n #onHide = () => {\n if (this.#innerView.value) {\n this.#innerView.value.destroy()\n this.#innerView.value = null\n }\n }\n\n #shouldShow = (view: EditorView) => {\n const shouldShow = () => {\n const { selection, schema } = view.state\n if (selection.empty) return false\n if (!(selection instanceof NodeSelection)) return false\n const node = selection.node\n if (node.type.name !== mathInlineId) return false\n\n const textFrom = selection.from\n\n const paragraph = schema.nodes.paragraph!.create(\n null,\n schema.text(node.attrs.value)\n )\n\n const innerView = new EditorView(this.#dom, {\n state: EditorState.create({\n doc: paragraph,\n schema: new Schema({\n nodes: {\n doc: {\n content: 'block+',\n },\n paragraph: {\n content: 'inline*',\n group: 'block',\n parseDOM: [{ tag: 'p' }],\n toDOM() {\n return ['p', 0]\n },\n },\n text: {\n group: 'inline',\n },\n },\n }),\n plugins: [\n keymap({\n 'Mod-z': undo,\n 'Mod-Z': redo,\n 'Mod-y': redo,\n Enter: () => {\n this.#updateValue.value()\n return true\n },\n }),\n ],\n }),\n })\n\n this.#innerView.value = innerView\n this.#updateValue.value = () => {\n const { tr } = view.state\n tr.setNodeAttribute(textFrom, 'value', innerView.state.doc.textContent)\n view.dispatch(tr)\n requestAnimationFrame(() => {\n view.focus()\n })\n }\n return true\n }\n\n const show = shouldShow()\n if (!show) this.#onHide()\n return show\n }\n\n update = (view: EditorView, prevState?: EditorState) => {\n this.#provider.update(view, prevState)\n }\n\n destroy = () => {\n this.#app.unmount()\n this.#provider.destroy()\n this.#content.remove()\n }\n}\n","import { codeBlockSchema } from '@milkdown/kit/preset/commonmark'\nimport { nodeRule } from '@milkdown/kit/prose'\nimport { textblockTypeInputRule } from '@milkdown/kit/prose/inputrules'\nimport { $inputRule } from '@milkdown/kit/utils'\n\nimport { mathInlineSchema } from './inline-latex'\n\n/// Input rule for inline math.\n/// When you type $E=MC^2$, it will create an inline math node.\nexport const mathInlineInputRule = $inputRule((ctx) =>\n nodeRule(/(?:\\$)([^$]+)(?:\\$)$/, mathInlineSchema.type(ctx), {\n getAttr: (match) => {\n return {\n value: match[1] ?? '',\n }\n },\n })\n)\n\n/// A input rule for creating block math.\n/// For example, `$$ ` will create a code block with language javascript.\nexport const mathBlockInputRule = $inputRule((ctx) =>\n textblockTypeInputRule(/^\\$\\$[\\s\\n]$/, codeBlockSchema.type(ctx), () => ({\n language: 'LaTeX',\n }))\n)\n","import type { Node } from '@milkdown/kit/transformer'\n\nimport { $remark } from '@milkdown/kit/utils'\nimport remarkMath from 'remark-math'\nimport { visit } from 'unist-util-visit'\n\nexport const remarkMathPlugin = $remark<'remarkMath', undefined>(\n 'remarkMath',\n () => remarkMath\n)\n\nfunction visitMathBlock(ast: Node) {\n return visit(\n ast,\n 'math',\n (\n node: Node & { value: string },\n index: number,\n parent: Node & { children: Node[] }\n ) => {\n const { value } = node as Node & { value: string }\n const newNode = {\n type: 'code',\n lang: 'LaTeX',\n value,\n }\n parent.children.splice(index, 1, newNode)\n }\n )\n}\n\n/// Turn math block into code block with language LaTeX.\nexport const remarkMathBlockPlugin = $remark(\n 'remarkMathBlock',\n () => () => visitMathBlock\n)\n","import type { KatexOptions } from 'katex'\n\nimport { codeBlockConfig } from '@milkdown/kit/component/code-block'\nimport katex from 'katex'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig, useCrepeFeatures } from '../../core/slice'\nimport { CrepeFeature } from '../../feature'\nimport { confirmIcon } from '../../icons'\nimport { blockLatexSchema } from './block-latex'\nimport { mathInlineSchema } from './inline-latex'\nimport { inlineLatexTooltip } from './inline-tooltip/tooltip'\nimport { LatexInlineTooltip } from './inline-tooltip/view'\nimport { mathBlockInputRule, mathInlineInputRule } from './input-rule'\nimport { remarkMathBlockPlugin, remarkMathPlugin } from './remark'\n\nexport interface LatexConfig {\n katexOptions: KatexOptions\n inlineEditConfirm: string\n}\n\nexport type LatexFeatureConfig = Partial<LatexConfig>\n\nexport const latex: DefineFeature<LatexFeatureConfig> = (editor, config) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.Latex))\n .config((ctx) => {\n const flags = useCrepeFeatures(ctx).get()\n const isCodeMirrorEnabled = flags.includes(CrepeFeature.CodeMirror)\n if (!isCodeMirrorEnabled) {\n throw new Error('You need to enable CodeMirror to use LaTeX feature')\n }\n\n ctx.update(codeBlockConfig.key, (prev) => ({\n ...prev,\n renderPreview: (language, content) => {\n if (language.toLowerCase() === 'latex' && content.length > 0) {\n return renderLatex(content, config?.katexOptions)\n }\n const renderPreview = prev.renderPreview\n return renderPreview(language, content)\n },\n }))\n\n ctx.set(inlineLatexTooltip.key, {\n view: (view) => {\n return new LatexInlineTooltip(ctx, view, {\n inlineEditConfirm: config?.inlineEditConfirm ?? confirmIcon,\n ...config,\n })\n },\n })\n })\n .use(remarkMathPlugin)\n .use(remarkMathBlockPlugin)\n .use(mathInlineSchema)\n .use(inlineLatexTooltip)\n .use(mathInlineInputRule)\n .use(mathBlockInputRule)\n .use(blockLatexSchema)\n}\n\nfunction renderLatex(content: string, options?: KatexOptions) {\n const html = katex.renderToString(content, {\n ...options,\n throwOnError: false,\n displayMode: true,\n })\n return html\n}\n"],"names":["createSlice","CrepeFeature","codeBlockSchema","$nodeSchema","tooltipFactory","defineComponent","h","Icon","view","shallowRef","NodeSelection","EditorView","EditorState","Schema","keymap","undo","redo","createApp","TooltipProvider","$inputRule","nodeRule","textblockTypeInputRule","$remark","visit","codeBlockConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa;AAKlDA,eAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAU,EAAA;AAEzC,EAAO,OAAA,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAuB,EAAA;AACxD,EAAA,OAAO,CAAC,GAAa,KAAA;AACnB,IAAA,gBAAA,CAAiB,GAAG,CAAA,CAAE,MAAO,CAAA,CAAC,QAAa,KAAA;AACzC,MAAI,IAAA,QAAA,CAAS,QAAS,CAAA,OAAO,CAAG,EAAA;AAC9B,QAAO,OAAA,QAAA;AAAA;AAET,MAAO,OAAA,CAAC,GAAG,QAAA,EAAU,OAAO,CAAA;AAAA,KAC7B,CAAA;AAAA,GACH;AACF;;ACzCY,IAAA,YAAA,qBAAAC,aAAL,KAAA;AAEL,EAAAA,cAAA,YAAa,CAAA,GAAA,aAAA;AAGb,EAAAA,cAAA,UAAW,CAAA,GAAA,WAAA;AAGX,EAAAA,cAAA,aAAc,CAAA,GAAA,cAAA;AAGd,EAAAA,cAAA,QAAS,CAAA,GAAA,QAAA;AAGT,EAAAA,cAAA,YAAa,CAAA,GAAA,aAAA;AAGb,EAAAA,cAAA,WAAY,CAAA,GAAA,YAAA;AAGZ,EAAAA,cAAA,SAAU,CAAA,GAAA,SAAA;AAGV,EAAAA,cAAA,aAAc,CAAA,GAAA,aAAA;AAGd,EAAAA,cAAA,OAAQ,CAAA,GAAA,OAAA;AAGR,EAAAA,cAAA,OAAQ,CAAA,GAAA,OAAA;AA7BE,EAAAA,OAAAA,aAAAA;AAAA,CAAA,EAAA,YAAA,IAAA,EAAA,CAAA;;ACdL,MAAM,WAAc,GAAA;AAAA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SAAiB,OAAwB,EAAA;AAC5D,EAAM,MAAA,IAAA,GAAO,KAAM,CAAA,cAAA,CAAe,OAAS,EAAA;AAAA,IACzC,GAAG,OAAA;AAAA,IACH,YAAc,EAAA,KAAA;AAAA,IACd,WAAa,EAAA;AAAA,GACd,CAAA;AACD,EAAO,OAAA,IAAA;AACT;;;;"}
@@ -0,0 +1,124 @@
1
+ 'use strict';
2
+
3
+ var linkTooltip$1 = require('@milkdown/kit/component/link-tooltip');
4
+ var ctx = require('@milkdown/kit/ctx');
5
+
6
+ ctx.createSlice([], "FeaturesCtx");
7
+ ctx.createSlice({}, "CrepeCtx");
8
+ function useCrepeFeatures(ctx) {
9
+ return ctx.use("FeaturesCtx");
10
+ }
11
+ function crepeFeatureConfig(feature) {
12
+ return (ctx) => {
13
+ useCrepeFeatures(ctx).update((features) => {
14
+ if (features.includes(feature)) {
15
+ return features;
16
+ }
17
+ return [...features, feature];
18
+ });
19
+ };
20
+ }
21
+
22
+ const confirmIcon = `
23
+ <svg
24
+ xmlns="http://www.w3.org/2000/svg"
25
+ width="24"
26
+ height="24"
27
+ viewBox="0 0 24 24"
28
+ fill="none"
29
+ >
30
+ <g clip-path="url(#clip0_1013_1606)">
31
+ <path
32
+ d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z"
33
+ fill="#817567"
34
+ />
35
+ </g>
36
+ <defs>
37
+ <clipPath id="clip0_1013_1606">
38
+ <rect width="24" height="24" />
39
+ </clipPath>
40
+ </defs>
41
+ </svg>
42
+ `;
43
+
44
+ const copyIcon = `
45
+ <svg
46
+ xmlns="http://www.w3.org/2000/svg"
47
+ height="24px"
48
+ viewBox="0 -960 960 960"
49
+ width="24px"
50
+ fill="none"
51
+ >
52
+ <path
53
+ d="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"
54
+ />
55
+ </svg>
56
+ `;
57
+
58
+ const editIcon = `
59
+ <svg
60
+ xmlns="http://www.w3.org/2000/svg"
61
+ width="24"
62
+ height="24"
63
+ viewBox="0 0 24 24"
64
+ >
65
+ <g clip-path="url(#clip0_1013_1585)">
66
+ <path
67
+ d="M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z"
68
+ />
69
+ </g>
70
+ <defs>
71
+ <clipPath id="clip0_1013_1585">
72
+ <rect width="24" height="24" />
73
+ </clipPath>
74
+ </defs>
75
+ </svg>
76
+ `;
77
+
78
+ const removeIcon = `
79
+ <svg
80
+ xmlns="http://www.w3.org/2000/svg"
81
+ width="24"
82
+ height="24"
83
+ viewBox="0 0 24 24"
84
+ >
85
+ <path
86
+ d="M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z"
87
+ />
88
+ </svg>
89
+ `;
90
+
91
+ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
92
+ CrepeFeature2["CodeMirror"] = "code-mirror";
93
+ CrepeFeature2["ListItem"] = "list-item";
94
+ CrepeFeature2["LinkTooltip"] = "link-tooltip";
95
+ CrepeFeature2["Cursor"] = "cursor";
96
+ CrepeFeature2["ImageBlock"] = "image-block";
97
+ CrepeFeature2["BlockEdit"] = "block-edit";
98
+ CrepeFeature2["Toolbar"] = "toolbar";
99
+ CrepeFeature2["Placeholder"] = "placeholder";
100
+ CrepeFeature2["Table"] = "table";
101
+ CrepeFeature2["Latex"] = "latex";
102
+ return CrepeFeature2;
103
+ })(CrepeFeature || {});
104
+
105
+ const linkTooltip = (editor, config) => {
106
+ editor.config(crepeFeatureConfig(CrepeFeature.LinkTooltip)).config(linkTooltip$1.configureLinkTooltip).config((ctx) => {
107
+ ctx.update(linkTooltip$1.linkTooltipConfig.key, (prev) => {
108
+ var _a, _b, _c, _d, _e, _f;
109
+ return {
110
+ ...prev,
111
+ linkIcon: (_a = config == null ? void 0 : config.linkIcon) != null ? _a : copyIcon,
112
+ editButton: (_b = config == null ? void 0 : config.editButton) != null ? _b : editIcon,
113
+ removeButton: (_c = config == null ? void 0 : config.removeButton) != null ? _c : removeIcon,
114
+ confirmButton: (_d = config == null ? void 0 : config.confirmButton) != null ? _d : confirmIcon,
115
+ inputPlaceholder: (_e = config == null ? void 0 : config.inputPlaceholder) != null ? _e : "Paste link...",
116
+ onCopyLink: (_f = config == null ? void 0 : config.onCopyLink) != null ? _f : () => {
117
+ }
118
+ };
119
+ });
120
+ }).use(linkTooltip$1.linkTooltipPlugin);
121
+ };
122
+
123
+ exports.linkTooltip = linkTooltip;
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/confirm.ts","../../../../src/icons/copy.ts","../../../../src/icons/edit.ts","../../../../src/icons/remove.ts","../../../../src/feature/index.ts","../../../../src/feature/link-tooltip/index.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","export const confirmIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <g clip-path=\"url(#clip0_1013_1606)\">\n <path\n d=\"M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z\"\n fill=\"#817567\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1606\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const copyIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"24px\"\n viewBox=\"0 -960 960 960\"\n width=\"24px\"\n fill=\"none\"\n >\n <path\n d=\"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z\"\n />\n </svg>\n`\n","export const editIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1013_1585)\">\n <path\n d=\"M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1585\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const removeIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z\"\n />\n </svg>\n`\n","import type { BlockEditFeatureConfig } from './block-edit'\nimport type { CodeMirrorFeatureConfig } from './code-mirror'\nimport type { CursorFeatureConfig } from './cursor'\nimport type { ImageBlockFeatureConfig } from './image-block'\nimport type { LatexFeatureConfig } from './latex'\nimport type { LinkTooltipFeatureConfig } from './link-tooltip'\nimport type { ListItemFeatureConfig } from './list-item'\nimport type { PlaceholderFeatureConfig } from './placeholder'\nimport type { TableFeatureConfig } from './table'\nimport type { ToolbarFeatureConfig } from './toolbar'\n\n/// The crepe editor feature flags.\n/// Every feature is enabled by default.\n/// Every feature is a string literal type.\nexport enum CrepeFeature {\n /// Syntax highlighting and editing for code blocks with language support, theme customization, and preview capabilities.\n CodeMirror = 'code-mirror',\n\n /// Support for bullet lists, ordered lists, and todo lists with customizable icons and formatting.\n ListItem = 'list-item',\n\n /// Enhanced link editing and preview with customizable tooltips, edit/remove actions, and copy functionality.\n LinkTooltip = 'link-tooltip',\n\n /// Enhanced cursor experience with drop cursor and gap cursor for better content placement.\n Cursor = 'cursor',\n\n /// Image upload and management with resizing, captions, and support for both inline and block images.\n ImageBlock = 'image-block',\n\n /// Drag-and-drop block management and slash commands for quick content insertion and organization.\n BlockEdit = 'block-edit',\n\n /// Formatting toolbar for selected text with customizable icons and actions.\n Toolbar = 'toolbar',\n\n /// Document or block level placeholders to guide users when content is empty.\n Placeholder = 'placeholder',\n\n /// Full-featured table editing with row/column management, alignment options, and drag-and-drop functionality.\n Table = 'table',\n\n /// Mathematical formula support with both inline and block math rendering using KaTeX.\n Latex = 'latex',\n}\n\nexport interface CrepeFeatureConfig {\n [CrepeFeature.Cursor]?: CursorFeatureConfig\n [CrepeFeature.ListItem]?: ListItemFeatureConfig\n [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig\n [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig\n [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig\n [CrepeFeature.Placeholder]?: PlaceholderFeatureConfig\n [CrepeFeature.Toolbar]?: ToolbarFeatureConfig\n [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig\n [CrepeFeature.Table]?: TableFeatureConfig\n [CrepeFeature.Latex]?: LatexFeatureConfig\n}\n\nexport const defaultFeatures: Record<CrepeFeature, boolean> = {\n [CrepeFeature.Cursor]: true,\n [CrepeFeature.ListItem]: true,\n [CrepeFeature.LinkTooltip]: true,\n [CrepeFeature.ImageBlock]: true,\n [CrepeFeature.BlockEdit]: true,\n [CrepeFeature.Placeholder]: true,\n [CrepeFeature.Toolbar]: true,\n [CrepeFeature.CodeMirror]: true,\n [CrepeFeature.Table]: true,\n [CrepeFeature.Latex]: true,\n}\n","import {\n configureLinkTooltip,\n linkTooltipConfig,\n linkTooltipPlugin,\n} from '@milkdown/kit/component/link-tooltip'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport { copyIcon, editIcon, removeIcon, confirmIcon } from '../../icons'\nimport { CrepeFeature } from '../index'\n\ninterface LinkTooltipConfig {\n linkIcon: string\n editButton: string\n removeButton: string\n confirmButton: string\n inputPlaceholder: string\n onCopyLink: (link: string) => void\n}\n\nexport type LinkTooltipFeatureConfig = Partial<LinkTooltipConfig>\n\nexport const linkTooltip: DefineFeature<LinkTooltipFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.LinkTooltip))\n .config(configureLinkTooltip)\n .config((ctx) => {\n ctx.update(linkTooltipConfig.key, (prev) => ({\n ...prev,\n linkIcon: config?.linkIcon ?? copyIcon,\n editButton: config?.editButton ?? editIcon,\n removeButton: config?.removeButton ?? removeIcon,\n confirmButton: config?.confirmButton ?? confirmIcon,\n inputPlaceholder: config?.inputPlaceholder ?? 'Paste link...',\n onCopyLink: config?.onCopyLink ?? (() => {}),\n }))\n })\n .use(linkTooltipPlugin)\n}\n"],"names":["createSlice","CrepeFeature","configureLinkTooltip","linkTooltipConfig","linkTooltipPlugin"],"mappings":";;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa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ACxC,gBAAA,EAAA,CAAkB,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,gBAAA,KAAR,IAA4B,GAAA,EAAA,GAAA,eAAA;AAAA,QAC9C,UAAY,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,UAAR,KAAA,IAAA,GAAA,EAAA,GAAuB,MAAM;AAAA;AAAC,OAC5C;AAAA,KAAE,CAAA;AAAA,GACH,CACA,CAAA,GAAA,CAAIC,+BAAiB,CAAA;AAC1B;;;;"}
@@ -1,6 +1,23 @@
1
1
  'use strict';
2
2
 
3
3
  var listItemBlock = require('@milkdown/kit/component/list-item-block');
4
+ var ctx = require('@milkdown/kit/ctx');
5
+
6
+ ctx.createSlice([], "FeaturesCtx");
7
+ ctx.createSlice({}, "CrepeCtx");
8
+ function useCrepeFeatures(ctx) {
9
+ return ctx.use("FeaturesCtx");
10
+ }
11
+ function crepeFeatureConfig(feature) {
12
+ return (ctx) => {
13
+ useCrepeFeatures(ctx).update((features) => {
14
+ if (features.includes(feature)) {
15
+ return features;
16
+ }
17
+ return [...features, feature];
18
+ });
19
+ };
20
+ }
4
21
 
5
22
  const bulletIcon = `
6
23
  <svg
@@ -60,22 +77,36 @@ const checkBoxUncheckedIcon = `
60
77
  </svg>
61
78
  `;
62
79
 
80
+ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
81
+ CrepeFeature2["CodeMirror"] = "code-mirror";
82
+ CrepeFeature2["ListItem"] = "list-item";
83
+ CrepeFeature2["LinkTooltip"] = "link-tooltip";
84
+ CrepeFeature2["Cursor"] = "cursor";
85
+ CrepeFeature2["ImageBlock"] = "image-block";
86
+ CrepeFeature2["BlockEdit"] = "block-edit";
87
+ CrepeFeature2["Toolbar"] = "toolbar";
88
+ CrepeFeature2["Placeholder"] = "placeholder";
89
+ CrepeFeature2["Table"] = "table";
90
+ CrepeFeature2["Latex"] = "latex";
91
+ return CrepeFeature2;
92
+ })(CrepeFeature || {});
93
+
63
94
  function configureListItem(ctx, config) {
64
95
  ctx.set(listItemBlock.listItemBlockConfig.key, {
65
96
  renderLabel: ({ label, listType, checked }) => {
66
- var _a, _b, _c, _d, _e, _f;
97
+ var _a, _b, _c;
67
98
  if (checked == null) {
68
- if (listType === "bullet") return (_b = (_a = config == null ? void 0 : config.bulletIcon) == null ? void 0 : _a.call(config)) != null ? _b : bulletIcon;
99
+ if (listType === "bullet") return (_a = config == null ? void 0 : config.bulletIcon) != null ? _a : bulletIcon;
69
100
  return label;
70
101
  }
71
- if (checked) return (_d = (_c = config == null ? void 0 : config.checkBoxCheckedIcon) == null ? void 0 : _c.call(config)) != null ? _d : checkBoxCheckedIcon;
72
- return (_f = (_e = config == null ? void 0 : config.checkBoxUncheckedIcon) == null ? void 0 : _e.call(config)) != null ? _f : checkBoxUncheckedIcon;
102
+ if (checked) return (_b = config == null ? void 0 : config.checkBoxCheckedIcon) != null ? _b : checkBoxCheckedIcon;
103
+ return (_c = config == null ? void 0 : config.checkBoxUncheckedIcon) != null ? _c : checkBoxUncheckedIcon;
73
104
  }
74
105
  });
75
106
  }
76
- const defineFeature = (editor, config) => {
77
- editor.config((ctx) => configureListItem(ctx, config)).use(listItemBlock.listItemBlockComponent);
107
+ const listItem = (editor, config) => {
108
+ editor.config(crepeFeatureConfig(CrepeFeature.ListItem)).config((ctx) => configureListItem(ctx, config)).use(listItemBlock.listItemBlockComponent);
78
109
  };
79
110
 
80
- exports.defineFeature = defineFeature;
81
- //# sourceMappingURL=index-Dw6lXgs6.js.map
111
+ exports.listItem = listItem;
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/slice.ts","../../../../src/icons/bullet.ts","../../../../src/icons/check-box-checked.ts","../../../../src/icons/check-box-unchecked.ts","../../../../src/feature/index.ts","../../../../src/feature/list-item/index.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","export const bulletIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_952_6527)\">\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </g>\n <defs>\n <clipPath id=\"clip0_952_6527\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const checkBoxCheckedIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1803_1151)\">\n <path\n d=\"M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM10.71 16.29C10.32 16.68 9.69 16.68 9.3 16.29L5.71 12.7C5.32 12.31 5.32 11.68 5.71 11.29C6.1 10.9 6.73 10.9 7.12 11.29L10 14.17L16.88 7.29C17.27 6.9 17.9 6.9 18.29 7.29C18.68 7.68 18.68 8.31 18.29 8.7L10.71 16.29Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1803_1151\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const checkBoxUncheckedIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1803_535)\">\n <path\n d=\"M18 19H6C5.45 19 5 18.55 5 18V6C5 5.45 5.45 5 6 5H18C18.55 5 19 5.45 19 6V18C19 18.55 18.55 19 18 19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1803_535\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","import type { BlockEditFeatureConfig } from './block-edit'\nimport type { CodeMirrorFeatureConfig } from './code-mirror'\nimport type { CursorFeatureConfig } from './cursor'\nimport type { ImageBlockFeatureConfig } from './image-block'\nimport type { LatexFeatureConfig } from './latex'\nimport type { LinkTooltipFeatureConfig } from './link-tooltip'\nimport type { ListItemFeatureConfig } from './list-item'\nimport type { PlaceholderFeatureConfig } from './placeholder'\nimport type { TableFeatureConfig } from './table'\nimport type { ToolbarFeatureConfig } from './toolbar'\n\n/// The crepe editor feature flags.\n/// Every feature is enabled by default.\n/// Every feature is a string literal type.\nexport enum CrepeFeature {\n /// Syntax highlighting and editing for code blocks with language support, theme customization, and preview capabilities.\n CodeMirror = 'code-mirror',\n\n /// Support for bullet lists, ordered lists, and todo lists with customizable icons and formatting.\n ListItem = 'list-item',\n\n /// Enhanced link editing and preview with customizable tooltips, edit/remove actions, and copy functionality.\n LinkTooltip = 'link-tooltip',\n\n /// Enhanced cursor experience with drop cursor and gap cursor for better content placement.\n Cursor = 'cursor',\n\n /// Image upload and management with resizing, captions, and support for both inline and block images.\n ImageBlock = 'image-block',\n\n /// Drag-and-drop block management and slash commands for quick content insertion and organization.\n BlockEdit = 'block-edit',\n\n /// Formatting toolbar for selected text with customizable icons and actions.\n Toolbar = 'toolbar',\n\n /// Document or block level placeholders to guide users when content is empty.\n Placeholder = 'placeholder',\n\n /// Full-featured table editing with row/column management, alignment options, and drag-and-drop functionality.\n Table = 'table',\n\n /// Mathematical formula support with both inline and block math rendering using KaTeX.\n Latex = 'latex',\n}\n\nexport interface CrepeFeatureConfig {\n [CrepeFeature.Cursor]?: CursorFeatureConfig\n [CrepeFeature.ListItem]?: ListItemFeatureConfig\n [CrepeFeature.LinkTooltip]?: LinkTooltipFeatureConfig\n [CrepeFeature.ImageBlock]?: ImageBlockFeatureConfig\n [CrepeFeature.BlockEdit]?: BlockEditFeatureConfig\n [CrepeFeature.Placeholder]?: PlaceholderFeatureConfig\n [CrepeFeature.Toolbar]?: ToolbarFeatureConfig\n [CrepeFeature.CodeMirror]?: CodeMirrorFeatureConfig\n [CrepeFeature.Table]?: TableFeatureConfig\n [CrepeFeature.Latex]?: LatexFeatureConfig\n}\n\nexport const defaultFeatures: Record<CrepeFeature, boolean> = {\n [CrepeFeature.Cursor]: true,\n [CrepeFeature.ListItem]: true,\n [CrepeFeature.LinkTooltip]: true,\n [CrepeFeature.ImageBlock]: true,\n [CrepeFeature.BlockEdit]: true,\n [CrepeFeature.Placeholder]: true,\n [CrepeFeature.Toolbar]: true,\n [CrepeFeature.CodeMirror]: true,\n [CrepeFeature.Table]: true,\n [CrepeFeature.Latex]: true,\n}\n","import type { Ctx } from '@milkdown/kit/ctx'\n\nimport {\n listItemBlockComponent,\n listItemBlockConfig,\n} from '@milkdown/kit/component/list-item-block'\n\nimport type { DefineFeature } from '../shared'\n\nimport { crepeFeatureConfig } from '../../core/slice'\nimport {\n bulletIcon,\n checkBoxCheckedIcon,\n checkBoxUncheckedIcon,\n} from '../../icons'\nimport { CrepeFeature } from '../index'\n\nexport interface ListItemConfig {\n bulletIcon: string\n checkBoxCheckedIcon: string\n checkBoxUncheckedIcon: string\n}\n\nexport type ListItemFeatureConfig = Partial<ListItemConfig>\n\nfunction configureListItem(ctx: Ctx, config?: ListItemFeatureConfig) {\n ctx.set(listItemBlockConfig.key, {\n renderLabel: ({ label, listType, checked }) => {\n if (checked == null) {\n if (listType === 'bullet') return config?.bulletIcon ?? bulletIcon\n\n return label\n }\n\n if (checked) return config?.checkBoxCheckedIcon ?? checkBoxCheckedIcon\n\n return config?.checkBoxUncheckedIcon ?? checkBoxUncheckedIcon\n },\n })\n}\n\nexport const listItem: DefineFeature<ListItemFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config(crepeFeatureConfig(CrepeFeature.ListItem))\n .config((ctx) => configureListItem(ctx, config))\n .use(listItemBlockComponent)\n}\n"],"names":["createSlice","CrepeFeature","listItemBlockConfig","listItemBlockComponent"],"mappings":";;;;;AAQ2BA,eAAA,CAAY,EAAC,EAAqB,aAAa;AAKlDA,eAAA,CAAY,EAAC,EAAmB,UAAU;AA2B3D,SAAS,iBAAiB,GAAU,EAAA;AAEzC,EAAO,OAAA,GAAA,CAAI,IAAmC,aAAa,CAAA;AAC7D;AAGO,SAAS,mBAAmB,OAAuB,EAAA;AACxD,EAAA,OAAO,CAAC,GAAa,KA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