tinacms 0.0.0-a28012f-20250515060252 → 0.0.0-a30bc52-20251201062201

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 (181) hide show
  1. package/dist/__vite-browser-external-d06ac358.js +4 -0
  2. package/dist/admin/api.d.ts +4 -1
  3. package/dist/admin/components/Page.d.ts +3 -9
  4. package/dist/admin/components/Sidebar.d.ts +0 -3
  5. package/dist/admin/components/ui/tooltip.d.ts +7 -0
  6. package/dist/admin/pages/CollectionCreatePage.d.ts +1 -1
  7. package/dist/admin/pages/CollectionListPage.d.ts +2 -2
  8. package/dist/admin/pages/DashboardPage.d.ts +0 -3
  9. package/dist/admin/pages/ScreenPage.d.ts +0 -3
  10. package/dist/auth/AuthModal.d.ts +1 -4
  11. package/dist/auth/TinaCloudProvider.d.ts +0 -1
  12. package/dist/client.js +131 -186
  13. package/dist/index.js +121770 -33753
  14. package/dist/internalClient/index.d.ts +26 -1
  15. package/dist/{node-cache-5e8db9f0.mjs → node-cache-c9558e1e.js} +5 -6
  16. package/dist/react.d.ts +13 -6
  17. package/dist/react.js +209 -205
  18. package/dist/rich-text/index.d.ts +6 -0
  19. package/dist/rich-text/index.js +234 -225
  20. package/dist/rich-text/prism.js +16 -19
  21. package/dist/rich-text/static.d.ts +154 -0
  22. package/dist/rich-text/{index.mjs → static.js} +99 -100
  23. package/dist/tina-cms.d.ts +1 -1
  24. package/dist/toolkit/components/ProgressBar.d.ts +11 -0
  25. package/dist/toolkit/components/media/media-item.d.ts +11 -1
  26. package/dist/toolkit/components/ui/breadcrumb.d.ts +11 -0
  27. package/dist/toolkit/components/ui/button.d.ts +11 -0
  28. package/dist/toolkit/components/ui/calendar.d.ts +8 -0
  29. package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
  30. package/dist/toolkit/components/ui/dropdown-menu.d.ts +25 -0
  31. package/dist/toolkit/components/ui/input.d.ts +3 -0
  32. package/dist/toolkit/components/ui/popover.d.ts +7 -0
  33. package/dist/toolkit/components/ui/select.d.ts +13 -0
  34. package/dist/toolkit/fields/components/password-field.d.ts +1 -1
  35. package/dist/toolkit/fields/components/reference/components/button.d.ts +2 -2
  36. package/dist/toolkit/fields/components/reference/components/command.d.ts +21 -33
  37. package/dist/toolkit/fields/components/reference/components/popover.d.ts +1 -1
  38. package/dist/toolkit/fields/components/reference/model/reference-link-props.d.ts +2 -0
  39. package/dist/toolkit/fields/components/select.d.ts +2 -2
  40. package/dist/toolkit/fields/components/text-field.d.ts +1 -1
  41. package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
  42. package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
  43. package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
  44. package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
  45. package/dist/toolkit/fields/plugins/group-field-plugin.d.ts +1 -1
  46. package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +3 -1
  47. package/dist/toolkit/fields/plugins/list-field-meta.d.ts +1 -1
  48. package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +3 -0
  49. package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +2 -2
  50. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +20 -18
  51. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +14 -10
  52. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +5 -5
  53. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +17 -0
  54. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/error-message.d.ts +6 -0
  55. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-combobox.d.ts +6 -0
  56. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-toolbar-button.d.ts +6 -6
  57. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-leaf.d.ts +2 -11
  58. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +14 -10
  59. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-syntax-leaf.d.ts +2 -11
  60. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +112 -0
  61. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dialog.d.ts +12 -0
  62. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dropdown-menu.d.ts +10 -10
  63. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/floating-toolbar.d.ts +2 -2
  64. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-element.d.ts +3 -0
  65. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-toolbar-button.d.ts +18 -0
  66. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -1
  67. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/image-toolbar-button.d.ts +6 -6
  68. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/indent-list-toolbar-button.d.ts +6 -19
  69. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/inline-combobox.d.ts +1 -1
  70. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/input.d.ts +3 -3
  71. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-element.d.ts +4 -11
  72. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-floating-toolbar.d.ts +4 -5
  73. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-toolbar-button.d.ts +4 -4
  74. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +28 -11
  75. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +3 -10
  76. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +6 -8
  77. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +15 -0
  78. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/popover.d.ts +7 -2
  79. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/quote-toolbar-button.d.ts +6 -6
  80. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/raw-markdown-toolbar-button.d.ts +6 -6
  81. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +24 -21
  82. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/separator.d.ts +2 -2
  83. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +15 -11
  84. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/block-selection.d.ts +6 -0
  85. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +33 -0
  86. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/{table-dropdown-menu.d.ts → table/table-dropdown-menu.d.ts} +1 -0
  87. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +20 -0
  88. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +15 -0
  89. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/toolbar.d.ts +7 -7
  90. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +10 -0
  91. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-state.d.ts +22 -0
  92. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/hooks/use-create-editor.d.ts +6 -0
  93. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-block.d.ts +1 -1
  94. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-lists.d.ts +1 -1
  95. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-marks.d.ts +1 -1
  96. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-utils.d.ts +3 -5
  97. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +11 -6
  98. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/formatting.d.ts +18 -2
  99. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/index.d.ts +0 -1
  100. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-html-block/index.d.ts +6 -0
  101. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-img-plugin/index.d.ts +2 -2
  102. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-invalid-markdown-plugin/index.d.ts +5 -5
  103. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/component.d.ts +7 -4
  104. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/index.d.ts +3 -5
  105. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/editor-plugins.d.ts +520 -0
  106. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +262 -207
  107. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/floating-toolbar-plugin.d.ts +1 -0
  108. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +1 -1
  109. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/is-url.d.ts +1 -2
  110. package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
  111. package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
  112. package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
  113. package/dist/toolkit/form-builder/create-branch-modal.d.ts +13 -0
  114. package/dist/toolkit/form-builder/editorial-workflow-constants.d.ts +17 -0
  115. package/dist/toolkit/form-builder/fields-builder.d.ts +1 -1
  116. package/dist/toolkit/form-builder/form-builder.d.ts +8 -9
  117. package/dist/toolkit/form-builder/index.d.ts +1 -0
  118. package/dist/toolkit/forms/field.d.ts +3 -0
  119. package/dist/toolkit/forms/form.d.ts +22 -3
  120. package/dist/toolkit/git-client/git-client.d.ts +25 -2
  121. package/dist/toolkit/git-client/git-file.d.ts +18 -0
  122. package/dist/toolkit/git-client/git-media-store.d.ts +13 -0
  123. package/dist/toolkit/git-client/use-git-file.d.ts +4 -0
  124. package/dist/toolkit/icons/Tina.d.ts +0 -5
  125. package/dist/toolkit/icons/TinaExtended.d.ts +4 -0
  126. package/dist/toolkit/icons/index.d.ts +1 -0
  127. package/dist/toolkit/index.d.ts +1 -1
  128. package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +4 -1
  129. package/dist/toolkit/plugin-branch-switcher/index.d.ts +0 -1
  130. package/dist/toolkit/react-modals/modal/modal-actions.d.ts +2 -1
  131. package/dist/toolkit/react-modals/modal/modal-header.d.ts +1 -1
  132. package/dist/toolkit/react-sidebar/components/VersionInfo.d.ts +2 -0
  133. package/dist/toolkit/react-sidebar/components/badge.d.ts +6 -0
  134. package/dist/toolkit/react-sidebar/components/callout.d.ts +5 -0
  135. package/dist/toolkit/react-sidebar/components/form-list.d.ts +1 -1
  136. package/dist/toolkit/react-sidebar/components/local-warning.d.ts +3 -1
  137. package/dist/toolkit/react-sidebar/components/nav.d.ts +6 -3
  138. package/dist/toolkit/react-sidebar/components/resize-handle.d.ts +0 -5
  139. package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +3 -7
  140. package/dist/toolkit/react-sidebar/components/sidebar.d.ts +0 -7
  141. package/dist/toolkit/react-sidebar/components/sync-status.d.ts +5 -8
  142. package/dist/toolkit/react-sidebar/index.d.ts +1 -1
  143. package/dist/toolkit/styles/button.d.ts +2 -2
  144. package/dist/toolkit/styles/dropdown-button.d.ts +75 -0
  145. package/dist/toolkit/styles/index.d.ts +1 -0
  146. package/dist/toolkit/tina-state.d.ts +11 -0
  147. package/dist/utils/cn.d.ts +2 -0
  148. package/dist/utils/index.d.ts +1 -0
  149. package/package.json +52 -67
  150. package/dist/admin/pages/IndexingPage.d.ts +0 -2
  151. package/dist/client.js.map +0 -1
  152. package/dist/client.mjs +0 -133
  153. package/dist/client.mjs.map +0 -1
  154. package/dist/index.js.map +0 -1
  155. package/dist/index.mjs +0 -35106
  156. package/dist/index.mjs.map +0 -1
  157. package/dist/node-cache-5e8db9f0.mjs.map +0 -1
  158. package/dist/react.js.map +0 -1
  159. package/dist/react.mjs +0 -247
  160. package/dist/react.mjs.map +0 -1
  161. package/dist/rich-text/index.js.map +0 -1
  162. package/dist/rich-text/index.mjs.map +0 -1
  163. package/dist/rich-text/prism.js.map +0 -1
  164. package/dist/rich-text/prism.mjs +0 -17
  165. package/dist/rich-text/prism.mjs.map +0 -1
  166. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-element.d.ts +0 -11
  167. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +0 -27
  168. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +0 -14
  169. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +0 -13
  170. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/with-correct-void-behavior.d.ts +0 -8
  171. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-code-block/index.d.ts +0 -3
  172. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-link-plugin/index.d.ts +0 -15
  173. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +0 -2
  174. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/create-soft-break-plugin.d.ts +0 -7
  175. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/index.d.ts +0 -6
  176. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/on-key-down-soft-break.d.ts +0 -5
  177. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/types.d.ts +0 -11
  178. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +0 -11
  179. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/insert-empty-block.d.ts +0 -2
  180. package/dist/toolkit/plugin-branch-switcher/branch-banner.d.ts +0 -2
  181. package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-cache-5e8db9f0.mjs","sources":["../src/cache/node-cache.ts"],"sourcesContent":["import type { Cache } from './index';\n\n// Create the cache directory if it doesn't exist.\n// Returns the path of the cache directory.\nexport const makeCacheDir = async (\n dir: string,\n fs: any,\n path: any,\n os: any\n) => {\n const pathParts = dir.split(path.sep).filter(Boolean);\n const cacheHash = pathParts[pathParts.length - 1];\n const rootUser = pathParts[0];\n let cacheDir = dir;\n\n // Check if the root directory exists. If not, create the cache in the tmp directory.\n if (!fs.existsSync(path.join(path.sep, rootUser))) {\n cacheDir = path.join(os.tmpdir(), cacheHash);\n }\n\n try {\n fs.mkdirSync(cacheDir, { recursive: true });\n } catch (error) {\n throw new Error(`Failed to create cache directory: ${error.message}`);\n }\n\n return cacheDir;\n};\n\nexport const NodeCache = async (dir: string): Promise<Cache> => {\n // TODO: These will need to be changed from using require to import when we eventually move to ESM\n const fs = require('node:fs');\n const path = require('node:path');\n const os = require('node:os');\n\n const { createHash } = require('node:crypto');\n const cacheDir = await makeCacheDir(dir, fs, path, os);\n\n return {\n makeKey: (key: any) => {\n const input =\n key && key instanceof Object ? JSON.stringify(key) : key || '';\n return createHash('sha256').update(input).digest('hex');\n },\n get: async (key: string) => {\n let readValue: object | undefined;\n\n const cacheFilename = `${cacheDir}/${key}`;\n try {\n const data = await fs.promises.readFile(cacheFilename, 'utf-8');\n readValue = JSON.parse(data);\n } catch (e) {\n if (e.code !== 'ENOENT') {\n console.error(\n `Failed to read cache file to ${cacheFilename}: ${e.message}`\n );\n }\n }\n\n return readValue;\n },\n set: async (key: string, value: any) => {\n const cacheFilename = `${cacheDir}/${key}`;\n try {\n await fs.promises.writeFile(cacheFilename, JSON.stringify(value), {\n encoding: 'utf-8',\n flag: 'wx', // Don't overwrite existing caches\n });\n } catch (e) {\n if (e.code !== 'EEXIST') {\n console.error(\n `Failed to write cache file to ${cacheFilename}: ${e.message}`\n );\n }\n }\n },\n };\n};\n"],"names":[],"mappings":"AAIO,MAAM,eAAe,OAC1B,KACA,IACA,MACA,OACG;AACH,QAAM,YAAY,IAAI,MAAM,KAAK,GAAG,EAAE,OAAO,OAAO;AACpD,QAAM,YAAY,UAAU,UAAU,SAAS,CAAC;AAC1C,QAAA,WAAW,UAAU,CAAC;AAC5B,MAAI,WAAW;AAGX,MAAA,CAAC,GAAG,WAAW,KAAK,KAAK,KAAK,KAAK,QAAQ,CAAC,GAAG;AACjD,eAAW,KAAK,KAAK,GAAG,OAAA,GAAU,SAAS;AAAA,EAC7C;AAEI,MAAA;AACF,OAAG,UAAU,UAAU,EAAE,WAAW,KAAM,CAAA;AAAA,WACnC,OAAO;AACd,UAAM,IAAI,MAAM,qCAAqC,MAAM,OAAO,EAAE;AAAA,EACtE;AAEO,SAAA;AACT;AAEa,MAAA,YAAY,OAAO,QAAgC;AAExD,QAAA,KAAK,QAAQ,SAAS;AACtB,QAAA,OAAO,QAAQ,WAAW;AAC1B,QAAA,KAAK,QAAQ,SAAS;AAE5B,QAAM,EAAE,WAAA,IAAe,QAAQ,aAAa;AAC5C,QAAM,WAAW,MAAM,aAAa,KAAK,IAAI,MAAM,EAAE;AAE9C,SAAA;AAAA,IACL,SAAS,CAAC,QAAa;AACf,YAAA,QACJ,OAAO,eAAe,SAAS,KAAK,UAAU,GAAG,IAAI,OAAO;AAC9D,aAAO,WAAW,QAAQ,EAAE,OAAO,KAAK,EAAE,OAAO,KAAK;AAAA,IACxD;AAAA,IACA,KAAK,OAAO,QAAgB;AACtB,UAAA;AAEJ,YAAM,gBAAgB,GAAG,QAAQ,IAAI,GAAG;AACpC,UAAA;AACF,cAAM,OAAO,MAAM,GAAG,SAAS,SAAS,eAAe,OAAO;AAClD,oBAAA,KAAK,MAAM,IAAI;AAAA,eACpB,GAAG;AACN,YAAA,EAAE,SAAS,UAAU;AACf,kBAAA;AAAA,YACN,gCAAgC,aAAa,KAAK,EAAE,OAAO;AAAA,UAAA;AAAA,QAE/D;AAAA,MACF;AAEO,aAAA;AAAA,IACT;AAAA,IACA,KAAK,OAAO,KAAa,UAAe;AACtC,YAAM,gBAAgB,GAAG,QAAQ,IAAI,GAAG;AACpC,UAAA;AACF,cAAM,GAAG,SAAS,UAAU,eAAe,KAAK,UAAU,KAAK,GAAG;AAAA,UAChE,UAAU;AAAA,UACV,MAAM;AAAA;AAAA,QAAA,CACP;AAAA,eACM,GAAG;AACN,YAAA,EAAE,SAAS,UAAU;AACf,kBAAA;AAAA,YACN,iCAAiC,aAAa,KAAK,EAAE,OAAO;AAAA,UAAA;AAAA,QAEhE;AAAA,MACF;AAAA,IACF;AAAA,EAAA;AAEJ;"}
package/dist/react.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.js","sources":["../src/react.tsx"],"sourcesContent":["import React from 'react';\n\nexport function useTina<T extends object>(props: {\n query: string;\n variables: object;\n data: T;\n experimental___selectFormByFormId?: () => string | false | undefined;\n}): { data: T; isClient: boolean } {\n const stringifiedQuery = JSON.stringify({\n query: props.query,\n variables: props.variables,\n });\n const id = React.useMemo(\n () => hashFromQuery(stringifiedQuery),\n [stringifiedQuery]\n );\n const [data, setData] = React.useState(props.data);\n const [isClient, setIsClient] = React.useState(false);\n const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);\n const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);\n\n React.useEffect(() => {\n setIsClient(true);\n setData(props.data);\n parent.postMessage({\n type: 'url-changed',\n });\n }, [id]);\n\n React.useEffect(() => {\n if (quickEditEnabled) {\n const style = document.createElement('style');\n style.type = 'text/css';\n style.textContent = `\n [data-tina-field] {\n outline: 2px dashed rgba(34,150,254,0.5);\n transition: box-shadow ease-out 150ms;\n }\n [data-tina-field]:hover {\n box-shadow: inset 100vi 100vh rgba(34,150,254,0.3);\n outline: 2px solid rgba(34,150,254,1);\n cursor: pointer;\n }\n [data-tina-field-overlay] {\n outline: 2px dashed rgba(34,150,254,0.5);\n position: relative;\n }\n [data-tina-field-overlay]:hover {\n cursor: pointer;\n outline: 2px solid rgba(34,150,254,1);\n }\n [data-tina-field-overlay]::after {\n content: '';\n position: absolute;\n inset: 0;\n z-index: 20;\n transition: opacity ease-out 150ms;\n background-color: rgba(34,150,254,0.3);\n opacity: 0;\n }\n [data-tina-field-overlay]:hover::after {\n opacity: 1;\n }\n `;\n document.head.appendChild(style);\n document.body.classList.add('__tina-quick-editing-enabled');\n\n function mouseDownHandler(e) {\n const attributeNames = e.target.getAttributeNames();\n // If multiple attributes start with data-tina-field, only the first is used\n const tinaAttribute = attributeNames.find((name) =>\n name.startsWith('data-tina-field')\n );\n let fieldName;\n if (tinaAttribute) {\n e.preventDefault();\n e.stopPropagation();\n fieldName = e.target.getAttribute(tinaAttribute);\n } else {\n const ancestor = e.target.closest(\n '[data-tina-field], [data-tina-field-overlay]'\n );\n if (ancestor) {\n const attributeNames = ancestor.getAttributeNames();\n const tinaAttribute = attributeNames.find((name) =>\n name.startsWith('data-tina-field')\n );\n if (tinaAttribute) {\n e.preventDefault();\n e.stopPropagation();\n fieldName = ancestor.getAttribute(tinaAttribute);\n }\n }\n }\n if (fieldName) {\n if (isInTinaIframe) {\n parent.postMessage(\n { type: 'field:selected', fieldName: fieldName },\n window.location.origin\n );\n } else {\n // if (preview?.redirect) {\n // const tinaAdminBasePath = preview.redirect.startsWith('/')\n // ? preview.redirect\n // : `/${preview.redirect}`\n // const tinaAdminPath = `${tinaAdminBasePath}/index.html#/~${window.location.pathname}?active-field=${fieldName}`\n // window.location.assign(tinaAdminPath)\n // }\n }\n }\n }\n document.addEventListener('click', mouseDownHandler, true);\n\n return () => {\n document.removeEventListener('click', mouseDownHandler, true);\n document.body.classList.remove('__tina-quick-editing-enabled');\n style.remove();\n };\n }\n }, [quickEditEnabled, isInTinaIframe]);\n\n React.useEffect(() => {\n if (props?.experimental___selectFormByFormId) {\n parent.postMessage({\n type: 'user-select-form',\n formId: props.experimental___selectFormByFormId(),\n });\n }\n }, [id]);\n\n React.useEffect(() => {\n const { experimental___selectFormByFormId, ...rest } = props;\n parent.postMessage({ type: 'open', ...rest, id }, window.location.origin);\n window.addEventListener('message', (event) => {\n if (event.data.type === 'quickEditEnabled') {\n setQuickEditEnabled(event.data.value);\n }\n if (event.data.id === id && event.data.type === 'updateData') {\n setData(event.data.data);\n setIsInTinaIframe(true);\n // Ensure we still have a tina-field on the page\n const anyTinaField = document.querySelector('[data-tina-field]');\n if (anyTinaField) {\n parent.postMessage(\n { type: 'quick-edit', value: true },\n window.location.origin\n );\n } else {\n parent.postMessage(\n { type: 'quick-edit', value: false },\n window.location.origin\n );\n }\n }\n });\n\n return () => {\n parent.postMessage({ type: 'close', id }, window.location.origin);\n };\n }, [id, setQuickEditEnabled]);\n\n // Probably don't want to always do this on every data update,\n // Just needs to be done once when in non-edit mode\n // addMetadata(id, data, [])\n\n return { data, isClient };\n}\n\nexport function useEditState(): { edit: boolean } {\n const [edit, setEdit] = React.useState(false);\n React.useEffect(() => {\n if (typeof window !== 'undefined') {\n parent.postMessage({ type: 'isEditMode' }, window.location.origin);\n window.addEventListener('message', (event) => {\n if (event.data?.type === 'tina:editMode') {\n setEdit(true);\n }\n });\n }\n }, []);\n return { edit } as any;\n}\n\n/**\n * Grab the field name for the given attribute\n * to signal to Tina which DOM element the field\n * is working with.\n */\nexport const tinaField = <\n T extends\n | (object & {\n _content_source?: {\n queryId: string;\n path: (number | string)[];\n };\n })\n | undefined\n | null,\n>(\n object: T,\n property?: keyof Omit<NonNullable<T>, '__typename' | '_sys'>,\n index?: number\n) => {\n if (!object) {\n return '';\n }\n if (object._content_source) {\n if (!property) {\n return [\n object._content_source?.queryId,\n object._content_source.path.join('.'),\n ].join('---');\n }\n if (typeof index === 'number') {\n return [\n object._content_source?.queryId,\n [...object._content_source.path, property, index].join('.'),\n ].join('---');\n }\n return [\n object._content_source?.queryId,\n [...object._content_source.path, property].join('.'),\n ].join('---');\n }\n return '';\n};\n\nexport const addMetadata = <T extends object>(\n id: string,\n object: T & { type?: string; _content_source?: unknown },\n path: (string | number)[]\n): T => {\n Object.entries(object).forEach(([key, value]) => {\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n if (isScalarOrUndefined(item)) {\n return;\n }\n if (Array.isArray(item)) {\n return; // we don't expect arrays of arrays\n }\n const itemObject = item as object;\n addMetadata(id, itemObject, [...path, key, index]);\n });\n } else {\n if (isScalarOrUndefined(value)) {\n return;\n }\n const itemObject = value as object;\n addMetadata(id, itemObject, [...path, key]);\n }\n });\n // This is a rich-text field object\n if (object?.type === 'root') {\n return;\n }\n\n object._content_source = {\n queryId: id,\n path,\n };\n return object;\n};\nfunction isScalarOrUndefined(value: unknown) {\n const type = typeof value;\n if (type === 'string') return true;\n if (type === 'number') return true;\n if (type === 'boolean') return true;\n if (type === 'undefined') return true;\n\n if (value == null) return true;\n if (value instanceof String) return true;\n if (value instanceof Number) return true;\n if (value instanceof Boolean) return true;\n\n return false;\n}\n\n/**\n * This is a pretty rudimentary approach to hashing the query and variables to\n * ensure we treat multiple queries on the page uniquely. It's possible\n * that we would have collisions, and I'm not sure of the likeliness but seems\n * like it'd be rare.\n */\nexport const hashFromQuery = (input: string) => {\n let hash = 0;\n for (let i = 0; i < input.length; i++) {\n const char = input.charCodeAt(i);\n hash = ((hash << 5) - hash + char) & 0xffffffff; // Apply bitwise AND to ensure non-negative value\n }\n const nonNegativeHash = Math.abs(hash);\n const alphanumericHash = nonNegativeHash.toString(36);\n return alphanumericHash;\n};\n"],"names":["attributeNames","tinaAttribute"],"mappings":";;;;AAEO,WAAS,QAA0B,OAKP;AAC3B,UAAA,mBAAmB,KAAK,UAAU;AAAA,MACtC,OAAO,MAAM;AAAA,MACb,WAAW,MAAM;AAAA,IAAA,CAClB;AACD,UAAM,KAAK,MAAM;AAAA,MACf,MAAM,cAAc,gBAAgB;AAAA,MACpC,CAAC,gBAAgB;AAAA,IAAA;AAEnB,UAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,MAAM,IAAI;AACjD,UAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAS,KAAK;AACpD,UAAM,CAAC,kBAAkB,mBAAmB,IAAI,MAAM,SAAS,KAAK;AACpE,UAAM,CAAC,gBAAgB,iBAAiB,IAAI,MAAM,SAAS,KAAK;AAEhE,UAAM,UAAU,MAAM;AACpB,kBAAY,IAAI;AAChB,cAAQ,MAAM,IAAI;AAClB,aAAO,YAAY;AAAA,QACjB,MAAM;AAAA,MAAA,CACP;AAAA,IAAA,GACA,CAAC,EAAE,CAAC;AAEP,UAAM,UAAU,MAAM;AACpB,UAAI,kBAAkB;AAqCX,YAAA,mBAAT,SAA0B,GAAG;AACrB,gBAAA,iBAAiB,EAAE,OAAO,kBAAkB;AAElD,gBAAM,gBAAgB,eAAe;AAAA,YAAK,CAAC,SACzC,KAAK,WAAW,iBAAiB;AAAA,UAAA;AAE/B,cAAA;AACJ,cAAI,eAAe;AACjB,cAAE,eAAe;AACjB,cAAE,gBAAgB;AACN,wBAAA,EAAE,O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CAAQ,UAAS,QAAQ;AAC3B;AAAA,IACF;AAEA,WAAO,kBAAkB;AAAA,MACvB,SAAS;AAAA,MACT;AAAA,IAAA;AAEK,WAAA;AAAA,EACT;AACA,WAAS,oBAAoB,OAAgB;AAC3C,UAAM,OAAO,OAAO;AACpB,QAAI,SAAS;AAAiB,aAAA;AAC9B,QAAI,SAAS;AAAiB,aAAA;AAC9B,QAAI,SAAS;AAAkB,aAAA;AAC/B,QAAI,SAAS;AAAoB,aAAA;AAEjC,QAAI,SAAS;AAAa,aAAA;AAC1B,QAAI,iBAAiB;AAAe,aAAA;AACpC,QAAI,iBAAiB;AAAe,aAAA;AACpC,QAAI,iBAAiB;AAAgB,aAAA;AAE9B,WAAA;AAAA,EACT;AAQa,QAAA,gBAAgB,CAAC,UAAkB;AAC9C,QAAI,OAAO;AACX,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAC/B,YAAA,OAAO,MAAM,WAAW,CAAC;AACtB,cAAA,QAAQ,KAAK,OAAO,OAAQ;AAAA,IACvC;AACM,UAAA,kBAAkB,KAAK,IAAI,IAAI;AAC/B,UAAA,mBAAmB,gBAAgB,SAAS,EAAE;AAC7C,WAAA;AAAA,EACT;;;;;;;;"}
package/dist/react.mjs DELETED
@@ -1,247 +0,0 @@
1
- import React from "react";
2
- function useTina(props) {
3
- const stringifiedQuery = JSON.stringify({
4
- query: props.query,
5
- variables: props.variables
6
- });
7
- const id = React.useMemo(
8
- () => hashFromQuery(stringifiedQuery),
9
- [stringifiedQuery]
10
- );
11
- const [data, setData] = React.useState(props.data);
12
- const [isClient, setIsClient] = React.useState(false);
13
- const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
14
- const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
15
- React.useEffect(() => {
16
- setIsClient(true);
17
- setData(props.data);
18
- parent.postMessage({
19
- type: "url-changed"
20
- });
21
- }, [id]);
22
- React.useEffect(() => {
23
- if (quickEditEnabled) {
24
- let mouseDownHandler = function(e) {
25
- const attributeNames = e.target.getAttributeNames();
26
- const tinaAttribute = attributeNames.find(
27
- (name) => name.startsWith("data-tina-field")
28
- );
29
- let fieldName;
30
- if (tinaAttribute) {
31
- e.preventDefault();
32
- e.stopPropagation();
33
- fieldName = e.target.getAttribute(tinaAttribute);
34
- } else {
35
- const ancestor = e.target.closest(
36
- "[data-tina-field], [data-tina-field-overlay]"
37
- );
38
- if (ancestor) {
39
- const attributeNames2 = ancestor.getAttributeNames();
40
- const tinaAttribute2 = attributeNames2.find(
41
- (name) => name.startsWith("data-tina-field")
42
- );
43
- if (tinaAttribute2) {
44
- e.preventDefault();
45
- e.stopPropagation();
46
- fieldName = ancestor.getAttribute(tinaAttribute2);
47
- }
48
- }
49
- }
50
- if (fieldName) {
51
- if (isInTinaIframe) {
52
- parent.postMessage(
53
- { type: "field:selected", fieldName },
54
- window.location.origin
55
- );
56
- }
57
- }
58
- };
59
- const style = document.createElement("style");
60
- style.type = "text/css";
61
- style.textContent = `
62
- [data-tina-field] {
63
- outline: 2px dashed rgba(34,150,254,0.5);
64
- transition: box-shadow ease-out 150ms;
65
- }
66
- [data-tina-field]:hover {
67
- box-shadow: inset 100vi 100vh rgba(34,150,254,0.3);
68
- outline: 2px solid rgba(34,150,254,1);
69
- cursor: pointer;
70
- }
71
- [data-tina-field-overlay] {
72
- outline: 2px dashed rgba(34,150,254,0.5);
73
- position: relative;
74
- }
75
- [data-tina-field-overlay]:hover {
76
- cursor: pointer;
77
- outline: 2px solid rgba(34,150,254,1);
78
- }
79
- [data-tina-field-overlay]::after {
80
- content: '';
81
- position: absolute;
82
- inset: 0;
83
- z-index: 20;
84
- transition: opacity ease-out 150ms;
85
- background-color: rgba(34,150,254,0.3);
86
- opacity: 0;
87
- }
88
- [data-tina-field-overlay]:hover::after {
89
- opacity: 1;
90
- }
91
- `;
92
- document.head.appendChild(style);
93
- document.body.classList.add("__tina-quick-editing-enabled");
94
- document.addEventListener("click", mouseDownHandler, true);
95
- return () => {
96
- document.removeEventListener("click", mouseDownHandler, true);
97
- document.body.classList.remove("__tina-quick-editing-enabled");
98
- style.remove();
99
- };
100
- }
101
- }, [quickEditEnabled, isInTinaIframe]);
102
- React.useEffect(() => {
103
- if (props == null ? void 0 : props.experimental___selectFormByFormId) {
104
- parent.postMessage({
105
- type: "user-select-form",
106
- formId: props.experimental___selectFormByFormId()
107
- });
108
- }
109
- }, [id]);
110
- React.useEffect(() => {
111
- const { experimental___selectFormByFormId, ...rest } = props;
112
- parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
113
- window.addEventListener("message", (event) => {
114
- if (event.data.type === "quickEditEnabled") {
115
- setQuickEditEnabled(event.data.value);
116
- }
117
- if (event.data.id === id && event.data.type === "updateData") {
118
- setData(event.data.data);
119
- setIsInTinaIframe(true);
120
- const anyTinaField = document.querySelector("[data-tina-field]");
121
- if (anyTinaField) {
122
- parent.postMessage(
123
- { type: "quick-edit", value: true },
124
- window.location.origin
125
- );
126
- } else {
127
- parent.postMessage(
128
- { type: "quick-edit", value: false },
129
- window.location.origin
130
- );
131
- }
132
- }
133
- });
134
- return () => {
135
- parent.postMessage({ type: "close", id }, window.location.origin);
136
- };
137
- }, [id, setQuickEditEnabled]);
138
- return { data, isClient };
139
- }
140
- function useEditState() {
141
- const [edit, setEdit] = React.useState(false);
142
- React.useEffect(() => {
143
- if (typeof window !== "undefined") {
144
- parent.postMessage({ type: "isEditMode" }, window.location.origin);
145
- window.addEventListener("message", (event) => {
146
- var _a;
147
- if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
148
- setEdit(true);
149
- }
150
- });
151
- }
152
- }, []);
153
- return { edit };
154
- }
155
- const tinaField = (object, property, index) => {
156
- var _a, _b, _c;
157
- if (!object) {
158
- return "";
159
- }
160
- if (object._content_source) {
161
- if (!property) {
162
- return [
163
- (_a = object._content_source) == null ? void 0 : _a.queryId,
164
- object._content_source.path.join(".")
165
- ].join("---");
166
- }
167
- if (typeof index === "number") {
168
- return [
169
- (_b = object._content_source) == null ? void 0 : _b.queryId,
170
- [...object._content_source.path, property, index].join(".")
171
- ].join("---");
172
- }
173
- return [
174
- (_c = object._content_source) == null ? void 0 : _c.queryId,
175
- [...object._content_source.path, property].join(".")
176
- ].join("---");
177
- }
178
- return "";
179
- };
180
- const addMetadata = (id, object, path) => {
181
- Object.entries(object).forEach(([key, value]) => {
182
- if (Array.isArray(value)) {
183
- value.forEach((item, index) => {
184
- if (isScalarOrUndefined(item)) {
185
- return;
186
- }
187
- if (Array.isArray(item)) {
188
- return;
189
- }
190
- const itemObject = item;
191
- addMetadata(id, itemObject, [...path, key, index]);
192
- });
193
- } else {
194
- if (isScalarOrUndefined(value)) {
195
- return;
196
- }
197
- const itemObject = value;
198
- addMetadata(id, itemObject, [...path, key]);
199
- }
200
- });
201
- if ((object == null ? void 0 : object.type) === "root") {
202
- return;
203
- }
204
- object._content_source = {
205
- queryId: id,
206
- path
207
- };
208
- return object;
209
- };
210
- function isScalarOrUndefined(value) {
211
- const type = typeof value;
212
- if (type === "string")
213
- return true;
214
- if (type === "number")
215
- return true;
216
- if (type === "boolean")
217
- return true;
218
- if (type === "undefined")
219
- return true;
220
- if (value == null)
221
- return true;
222
- if (value instanceof String)
223
- return true;
224
- if (value instanceof Number)
225
- return true;
226
- if (value instanceof Boolean)
227
- return true;
228
- return false;
229
- }
230
- const hashFromQuery = (input) => {
231
- let hash = 0;
232
- for (let i = 0; i < input.length; i++) {
233
- const char = input.charCodeAt(i);
234
- hash = (hash << 5) - hash + char & 4294967295;
235
- }
236
- const nonNegativeHash = Math.abs(hash);
237
- const alphanumericHash = nonNegativeHash.toString(36);
238
- return alphanumericHash;
239
- };
240
- export {
241
- addMetadata,
242
- hashFromQuery,
243
- tinaField,
244
- useEditState,
245
- useTina
246
- };
247
- //# sourceMappingURL=react.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.mjs","sources":["../src/react.tsx"],"sourcesContent":["import React from 'react';\n\nexport function useTina<T extends object>(props: {\n query: string;\n variables: object;\n data: T;\n experimental___selectFormByFormId?: () => string | false | undefined;\n}): { data: T; isClient: boolean } {\n const stringifiedQuery = JSON.stringify({\n query: props.query,\n variables: props.variables,\n });\n const id = React.useMemo(\n () => hashFromQuery(stringifiedQuery),\n [stringifiedQuery]\n );\n const [data, setData] = React.useState(props.data);\n const [isClient, setIsClient] = React.useState(false);\n const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);\n const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);\n\n React.useEffect(() => {\n setIsClient(true);\n setData(props.data);\n parent.postMessage({\n type: 'url-changed',\n });\n }, [id]);\n\n React.useEffect(() => {\n if (quickEditEnabled) {\n const style = document.createElement('style');\n style.type = 'text/css';\n style.textContent = `\n [data-tina-field] {\n outline: 2px dashed rgba(34,150,254,0.5);\n transition: box-shadow ease-out 150ms;\n }\n [data-tina-field]:hover {\n box-shadow: inset 100vi 100vh rgba(34,150,254,0.3);\n outline: 2px solid rgba(34,150,254,1);\n cursor: pointer;\n }\n [data-tina-field-overlay] {\n outline: 2px dashed rgba(34,150,254,0.5);\n position: relative;\n }\n [data-tina-field-overlay]:hover {\n cursor: pointer;\n outline: 2px solid rgba(34,150,254,1);\n }\n [data-tina-field-overlay]::after {\n content: '';\n position: absolute;\n inset: 0;\n z-index: 20;\n transition: opacity ease-out 150ms;\n background-color: rgba(34,150,254,0.3);\n opacity: 0;\n }\n [data-tina-field-overlay]:hover::after {\n opacity: 1;\n }\n `;\n document.head.appendChild(style);\n document.body.classList.add('__tina-quick-editing-enabled');\n\n function mouseDownHandler(e) {\n const attributeNames = e.target.getAttributeNames();\n // If multiple attributes start with data-tina-field, only the first is used\n const tinaAttribute = attributeNames.find((name) =>\n name.startsWith('data-tina-field')\n );\n let fieldName;\n if (tinaAttribute) {\n e.preventDefault();\n e.stopPropagation();\n fieldName = e.target.getAttribute(tinaAttribute);\n } else {\n const ancestor = e.target.closest(\n '[data-tina-field], [data-tina-field-overlay]'\n );\n if (ancestor) {\n const attributeNames = ancestor.getAttributeNames();\n const tinaAttribute = attributeNames.find((name) =>\n name.startsWith('data-tina-field')\n );\n if (tinaAttribute) {\n e.preventDefault();\n e.stopPropagation();\n fieldName = ancestor.getAttribute(tinaAttribute);\n }\n }\n }\n if (fieldName) {\n if (isInTinaIframe) {\n parent.postMessage(\n { type: 'field:selected', fieldName: fieldName },\n window.location.origin\n );\n } else {\n // if (preview?.redirect) {\n // const tinaAdminBasePath = preview.redirect.startsWith('/')\n // ? preview.redirect\n // : `/${preview.redirect}`\n // const tinaAdminPath = `${tinaAdminBasePath}/index.html#/~${window.location.pathname}?active-field=${fieldName}`\n // window.location.assign(tinaAdminPath)\n // }\n }\n }\n }\n document.addEventListener('click', mouseDownHandler, true);\n\n return () => {\n document.removeEventListener('click', mouseDownHandler, true);\n document.body.classList.remove('__tina-quick-editing-enabled');\n style.remove();\n };\n }\n }, [quickEditEnabled, isInTinaIframe]);\n\n React.useEffect(() => {\n if (props?.experimental___selectFormByFormId) {\n parent.postMessage({\n type: 'user-select-form',\n formId: props.experimental___selectFormByFormId(),\n });\n }\n }, [id]);\n\n React.useEffect(() => {\n const { experimental___selectFormByFormId, ...rest } = props;\n parent.postMessage({ type: 'open', ...rest, id }, window.location.origin);\n window.addEventListener('message', (event) => {\n if (event.data.type === 'quickEditEnabled') {\n setQuickEditEnabled(event.data.value);\n }\n if (event.data.id === id && event.data.type === 'updateData') {\n setData(event.data.data);\n setIsInTinaIframe(true);\n // Ensure we still have a tina-field on the page\n const anyTinaField = document.querySelector('[data-tina-field]');\n if (anyTinaField) {\n parent.postMessage(\n { type: 'quick-edit', value: true },\n window.location.origin\n );\n } else {\n parent.postMessage(\n { type: 'quick-edit', value: false },\n window.location.origin\n );\n }\n }\n });\n\n return () => {\n parent.postMessage({ type: 'close', id }, window.location.origin);\n };\n }, [id, setQuickEditEnabled]);\n\n // Probably don't want to always do this on every data update,\n // Just needs to be done once when in non-edit mode\n // addMetadata(id, data, [])\n\n return { data, isClient };\n}\n\nexport function useEditState(): { edit: boolean } {\n const [edit, setEdit] = React.useState(false);\n React.useEffect(() => {\n if (typeof window !== 'undefined') {\n parent.postMessage({ type: 'isEditMode' }, window.location.origin);\n window.addEventListener('message', (event) => {\n if (event.data?.type === 'tina:editMode') {\n setEdit(true);\n }\n });\n }\n }, []);\n return { edit } as any;\n}\n\n/**\n * Grab the field name for the given attribute\n * to signal to Tina which DOM element the field\n * is working with.\n */\nexport const tinaField = <\n T extends\n | (object & {\n _content_source?: {\n queryId: string;\n path: (number | string)[];\n };\n })\n | undefined\n | null,\n>(\n object: T,\n property?: keyof Omit<NonNullable<T>, '__typename' | '_sys'>,\n index?: number\n) => {\n if (!object) {\n return '';\n }\n if (object._content_source) {\n if (!property) {\n return [\n object._content_source?.queryId,\n object._content_source.path.join('.'),\n ].join('---');\n }\n if (typeof index === 'number') {\n return [\n object._content_source?.queryId,\n [...object._content_source.path, property, index].join('.'),\n ].join('---');\n }\n return [\n object._content_source?.queryId,\n [...object._content_source.path, property].join('.'),\n ].join('---');\n }\n return '';\n};\n\nexport const addMetadata = <T extends object>(\n id: string,\n object: T & { type?: string; _content_source?: unknown },\n path: (string | number)[]\n): T => {\n Object.entries(object).forEach(([key, value]) => {\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n if (isScalarOrUndefined(item)) {\n return;\n }\n if (Array.isArray(item)) {\n return; // we don't expect arrays of arrays\n }\n const itemObject = item as object;\n addMetadata(id, itemObject, [...path, key, index]);\n });\n } else {\n if (isScalarOrUndefined(value)) {\n return;\n }\n const itemObject = value as object;\n addMetadata(id, itemObject, [...path, key]);\n }\n });\n // This is a rich-text field object\n if (object?.type === 'root') {\n return;\n }\n\n object._content_source = {\n queryId: id,\n path,\n };\n return object;\n};\nfunction isScalarOrUndefined(value: unknown) {\n const type = typeof value;\n if (type === 'string') return true;\n if (type === 'number') return true;\n if (type === 'boolean') return true;\n if (type === 'undefined') return true;\n\n if (value == null) return true;\n if (value instanceof String) return true;\n if (value instanceof Number) return true;\n if (value instanceof Boolean) return true;\n\n return false;\n}\n\n/**\n * This is a pretty rudimentary approach to hashing the query and variables to\n * ensure we treat multiple queries on the page uniquely. It's possible\n * that we would have collisions, and I'm not sure of the likeliness but seems\n * like it'd be rare.\n */\nexport const hashFromQuery = (input: string) => {\n let hash = 0;\n for (let i = 0; i < input.length; i++) {\n const char = input.charCodeAt(i);\n hash = ((hash << 5) - hash + char) & 0xffffffff; // Apply bitwise AND to ensure non-negative value\n }\n const nonNegativeHash = Math.abs(hash);\n const alphanumericHash = nonNegativeHash.toString(36);\n return alphanumericHash;\n};\n"],"names":["attributeNames","tinaAttribute"],"mappings":";AAEO,SAAS,QAA0B,OAKP;AAC3B,QAAA,mBAAmB,KAAK,UAAU;AAAA,IACtC,OAAO,MAAM;AAAA,IACb,WAAW,MAAM;AAAA,EAAA,CAClB;AACD,QAAM,KAAK,MAAM;AAAA,IACf,MAAM,cAAc,gBAAgB;AAAA,IACpC,CAAC,gBAAgB;AAAA,EAAA;AAEnB,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,MAAM,IAAI;AACjD,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAS,KAAK;AACpD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,MAAM,SAAS,KAAK;AACpE,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,MAAM,SAAS,KAAK;AAEhE,QAAM,UAAU,MAAM;AACpB,gBAAY,IAAI;AAChB,YAAQ,MAAM,IAAI;AAClB,WAAO,YAAY;AAAA,MACjB,MAAM;AAAA,IAAA,CACP;AAAA,EAAA,GACA,CAAC,EAAE,CAAC;AAEP,QAAM,UAAU,MAAM;AACpB,QAAI,kBAAkB;AAqCX,UAAA,mBAAT,SAA0B,GAAG;AACrB,cAAA,iBAAiB,EAAE,OAAO,kBAAkB;AAElD,cAAM,gBAAgB,eAAe;AAAA,UAAK,CAAC,SACzC,KAAK,WAAW,iBAAiB;AAAA,QAAA;AAE/B,YAAA;AACJ,YAAI,eAA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5C;AAAA,EAAA,CACD;AAEG,OAAA,iCAAQ,UAAS,QAAQ;AAC3B;AAAA,EACF;AAEA,SAAO,kBAAkB;AAAA,IACvB,SAAS;AAAA,IACT;AAAA,EAAA;AAEK,SAAA;AACT;AACA,SAAS,oBAAoB,OAAgB;AAC3C,QAAM,OAAO,OAAO;AACpB,MAAI,SAAS;AAAiB,WAAA;AAC9B,MAAI,SAAS;AAAiB,WAAA;AAC9B,MAAI,SAAS;AAAkB,WAAA;AAC/B,MAAI,SAAS;AAAoB,WAAA;AAEjC,MAAI,SAAS;AAAa,WAAA;AAC1B,MAAI,iBAAiB;AAAe,WAAA;AACpC,MAAI,iBAAiB;AAAe,WAAA;AACpC,MAAI,iBAAiB;AAAgB,WAAA;AAE9B,SAAA;AACT;AAQa,MAAA,gBAAgB,CAAC,UAAkB;AAC9C,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAC/B,UAAA,OAAO,MAAM,WAAW,CAAC;AACtB,YAAA,QAAQ,KAAK,OAAO,OAAQ;AAAA,EACvC;AACM,QAAA,kBAAkB,KAAK,IAAI,IAAI;AAC/B,QAAA,mBAAmB,gBAAgB,SAAS,EAAE;AAC7C,SAAA;AACT;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/rich-text/index.tsx"],"sourcesContent":["/**\n\n*/\n\nimport React from 'react';\n\ntype BaseComponents = {\n h1?: { children: JSX.Element };\n h2?: { children: JSX.Element };\n h3?: { children: JSX.Element };\n h4?: { children: JSX.Element };\n h5?: { children: JSX.Element };\n h6?: { children: JSX.Element };\n p?: { children: JSX.Element };\n a?: { url: string; children: JSX.Element };\n italic?: { children: JSX.Element };\n bold?: { children: JSX.Element };\n strikethrough?: { children: JSX.Element };\n underline?: { children: JSX.Element };\n code?: { children: JSX.Element };\n text?: { children: string };\n ul?: { children: JSX.Element };\n ol?: { children: JSX.Element };\n li?: { children: JSX.Element };\n lic?: { children: JSX.Element };\n block_quote?: { children: JSX.Element };\n code_block?: { lang?: string; value: string };\n mermaid?: { value: string };\n img?: { url: string; caption?: string; alt?: string };\n hr?: {};\n break?: {};\n maybe_mdx?: { children: JSX.Element };\n html?: { value: string };\n html_inline?: { value: string };\n // th?: { children: JSX.Element }\n // td?: { children: JSX.Element }\n // tr?: { children: JSX.Element }\n table?: {\n align?: ('left' | 'right' | 'center')[];\n tableRows: { tableCells: { value: TinaMarkdownContent }[] }[];\n };\n // Provide a fallback when a JSX component wasn't provided\n component_missing?: { name: string };\n};\n\ntype BaseComponentSignature = {\n [BK in keyof BaseComponents]: (props: BaseComponents[BK]) => JSX.Element;\n};\n\n/**\n * Define the allowed components and their props\n * ```ts\n * const components:\n * Components<{\n * BlockQuote: {\n * children: TinaMarkdownContent;\n * authorName: string;\n * };\n * }> = {\n * BlockQuote: (props: {\n * children: TinaMarkdownContent;\n * authorName: string;\n * }) => {\n * return (\n * <div>\n * <blockquote>\n * <TinaMarkdown content={props.children} />\n * {props.authorName}\n * </blockquote>\n * </div>\n * );\n * }\n * }\n * }\n * ```\n */\nexport type Components<ComponentAndProps extends object> = {\n [K in keyof ComponentAndProps]: (props: ComponentAndProps[K]) => JSX.Element;\n} & BaseComponentSignature;\n\nexport type TinaMarkdownContent = {\n type: string;\n children: TinaMarkdownContent[];\n};\n\nexport const TinaMarkdown = <\n CustomComponents extends { [key: string]: object } = any,\n>({\n content,\n components = {},\n}: {\n content: TinaMarkdownContent | TinaMarkdownContent[];\n components?:\n | Components<{}>\n | Components<{\n [BK in keyof CustomComponents]: (\n props: CustomComponents[BK]\n ) => JSX.Element;\n }>;\n}) => {\n if (!content) {\n return null;\n }\n const nodes = Array.isArray(content) ? content : content.children;\n if (!nodes) {\n return null;\n }\n return (\n <>\n {nodes.map((child, index) => {\n return <MemoNode components={components} key={index} child={child} />;\n })}\n </>\n );\n};\n\nconst Leaf = (props: {\n type: 'text';\n text: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strikethrough?: boolean;\n code?: boolean;\n components: Pick<\n BaseComponentSignature,\n 'bold' | 'italic' | 'underline' | 'strikethrough' | 'code' | 'text'\n >;\n}) => {\n if (props.bold) {\n const { bold, ...rest } = props;\n if (props.components.bold) {\n const Component = props.components.bold;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <strong>\n <Leaf {...rest} />\n </strong>\n );\n }\n if (props.italic) {\n const { italic, ...rest } = props;\n if (props.components.italic) {\n const Component = props.components.italic;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <em>\n <Leaf {...rest} />\n </em>\n );\n }\n if (props.underline) {\n const { underline, ...rest } = props;\n if (props.components.underline) {\n const Component = props.components.underline;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <u>\n <Leaf {...rest} />\n </u>\n );\n }\n if (props.strikethrough) {\n const { strikethrough, ...rest } = props;\n if (props.components.strikethrough) {\n const Component = props.components.strikethrough;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <s>\n <Leaf {...rest} />\n </s>\n );\n }\n if (props.code) {\n const { code, ...rest } = props;\n if (props.components.code) {\n const Component = props.components.code;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <code>\n <Leaf {...rest} />\n </code>\n );\n }\n if (props.components.text) {\n const Component = props.components.text;\n return <Component>{props.text}</Component>;\n }\n return <>{props.text}</>;\n};\n\n// FIXME: this needs more testing. But in theory all props\n// are serializable anyway so the JSON.stringify comparison makes sense.\n// I haven't thought all the way through this though, and maybe it'll break\n// down with custom components in some way.\n// In general this component handles most things without too many issues but for\n// large bodies of text it becomes pretty painful to see as-you-type updates, especially\n// in Safari.\nconst MemoNode = (props) => {\n const MNode = React.useMemo(\n () => <Node {...props} />,\n [JSON.stringify(props)]\n );\n return MNode;\n};\nconst Node = ({ components, child }) => {\n const { children, ...props } = child;\n switch (child.type) {\n case 'h1':\n case 'h2':\n case 'h3':\n case 'h4':\n case 'h5':\n case 'h6':\n case 'p':\n case 'blockquote':\n case 'ol':\n case 'ul':\n case 'li':\n if (components[child.type]) {\n const Component = components[child.type];\n return (\n <Component {...props}>\n <TinaMarkdown components={components} content={children} />\n </Component>\n );\n }\n return React.createElement(child.type, {\n children: <TinaMarkdown components={components} content={children} />,\n });\n case 'lic': // List Item Content\n if (components.lic) {\n const Component = components.lic;\n return (\n <Component {...props}>\n <TinaMarkdown components={components} content={children} />\n </Component>\n );\n }\n return (\n <div>\n <TinaMarkdown components={components} content={child.children} />\n </div>\n );\n case 'img':\n if (components[child.type]) {\n const Component = components[child.type];\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <Component {...props} />;\n }\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <img src={child.url} alt={child.alt} />;\n case 'a':\n if (components[child.type]) {\n const Component = components[child.type];\n return (\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n <Component {...props}>\n <TinaMarkdown components={components} content={children} />\n </Component>\n );\n }\n return (\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n <a href={child.url}>\n <TinaMarkdown components={components} content={children} />\n </a>\n );\n case 'mermaid':\n case 'code_block': {\n const value = child.value;\n if (components[child.type]) {\n const Component = components[child.type];\n return (\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n <Component {...props} />\n );\n }\n return (\n <pre>\n <code>{value}</code>\n </pre>\n );\n }\n case 'hr':\n if (components[child.type]) {\n const Component = components[child.type];\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <Component {...props} />;\n }\n return <hr />;\n case 'break':\n if (components[child.type]) {\n const Component = components[child.type];\n return <Component {...props} />;\n }\n return <br />;\n case 'text':\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <Leaf components={components} {...child} />;\n case 'mdxJsxTextElement':\n case 'mdxJsxFlowElement':\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n const Component = components[child.name];\n if (Component) {\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n const props = child.props ? child.props : {};\n return <Component {...props} />;\n } else {\n if (child.name === 'table') {\n const firstRowHeader = child.props?.firstRowHeader;\n const rows =\n (firstRowHeader\n ? child.props?.tableRows.filter((_, i) => i !== 0)\n : child.props?.tableRows) || [];\n const header = child.props?.tableRows?.at(0);\n const TableComponent =\n components['table'] || ((props) => <table {...props} />);\n const TrComponent =\n components['tr'] || ((props) => <tr {...props} />);\n const ThComponent =\n components['th'] ||\n ((props) => (\n <th style={{ textAlign: props?.align || 'auto' }} {...props} />\n ));\n const TdComponent =\n components['td'] ||\n ((props) => (\n <td style={{ textAlign: props?.align || 'auto' }} {...props} />\n ));\n const align = child.props?.align || [];\n return (\n <TableComponent>\n {firstRowHeader && (\n <thead>\n <TrComponent>\n {header.tableCells.map((c, i) => {\n return (\n <TinaMarkdown\n key={i}\n components={{\n p: (props) => (\n <ThComponent align={align[i]} {...props} />\n ),\n }}\n content={c.value}\n />\n );\n })}\n </TrComponent>\n </thead>\n )}\n <tbody>\n {rows.map((row, i) => {\n return (\n <TrComponent key={i}>\n {row?.tableCells?.map((c, i) => {\n return (\n <TinaMarkdown\n key={i}\n components={{\n p: (props) => (\n <TdComponent align={align[i]} {...props} />\n ),\n }}\n content={c.value}\n />\n );\n })}\n </TrComponent>\n );\n })}\n </tbody>\n </TableComponent>\n );\n }\n const ComponentMissing = components['component_missing'];\n if (ComponentMissing) {\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <ComponentMissing name={child.name} />;\n } else {\n return <span>{`No component provided for ${child.name}`}</span>;\n }\n }\n case 'table':\n const rows = child.children || [];\n const TableComponent =\n components['table'] ||\n ((props) => (\n <table style={{ border: '1px solid #EDECF3' }} {...props} />\n ));\n const TrComponent = components['tr'] || ((props) => <tr {...props} />);\n const TdComponent =\n components['td'] ||\n ((props) => (\n <td\n style={{\n textAlign: props?.align || 'auto',\n border: '1px solid #EDECF3',\n padding: '0.25rem',\n }}\n {...props}\n />\n ));\n const align = child.props?.align || [];\n return (\n <TableComponent>\n <tbody>\n {rows.map((row, i) => {\n return (\n <TrComponent key={i}>\n {row.children?.map((cell, i) => {\n return (\n <TinaMarkdown\n key={i}\n components={{\n p: (props) => (\n <TdComponent align={align[i]} {...props} />\n ),\n }}\n content={cell.children}\n />\n );\n })}\n </TrComponent>\n );\n })}\n </tbody>\n </TableComponent>\n );\n case 'maybe_mdx':\n /**\n * We don't want to render this as it's only displayed while editing an mdx node and should\n * be transformed before form submission\n */\n return null;\n case 'html':\n case 'html_inline':\n if (components[child.type]) {\n const Component = components[child.type];\n return <Component {...props} />;\n }\n return child.value;\n case 'invalid_markdown':\n return <pre>{child.value}</pre>;\n default:\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n if (typeof child.text === 'string') {\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <Leaf components={components} {...child} />;\n }\n\n // console.log(`No tina renderer for ${child.type}`, child)\n }\n};\n"],"names":["Component","props","rows","TableComponent","TrComponent","TdComponent","align","_a","i"],"mappings":";;;;AAqFa,QAAA,eAAe,CAE1B;AAAA,IACA;AAAA,IACA,aAAa,CAAC;AAAA,EAChB,MASM;AACJ,QAAI,CAAC,SAAS;AACL,aAAA;AAAA,IACT;AACA,UAAM,QAAQ,MAAM,QAAQ,OAAO,IAAI,UAAU,QAAQ;AACzD,QAAI,CAAC,OAAO;AACH,aAAA;AAAA,IACT;AACA,WAEK,sBAAA,cAAA,MAAA,UAAA,MAAA,MAAM,IAAI,CAAC,OAAO,UAAU;AAC3B,aAAQ,sBAAA,cAAA,UAAA,EAAS,YAAwB,KAAK,OAAO,MAAc,CAAA;AAAA,IACpE,CAAA,CACH;AAAA,EAEJ;AAEA,QAAM,OAAO,CAAC,UAYR;AACJ,QAAI,MAAM,MAAM;AACd,YAAM,EAAE,MAAM,GAAG,KAAA,IAAS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,YAAA,OAAO,MAAM,SAAS,UAAU;AAElC,iBAAQ,sBAAA,cAAA,MAAA,EAAK,YAAyB,GAAG,MAAO,CAAA;AAAA,QAClD;AAAA,IAGJ;AAAA,EACF;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/rich-text/index.tsx"],"sourcesContent":["/**\n\n*/\n\nimport React from 'react';\n\ntype BaseComponents = {\n h1?: { children: JSX.Element };\n h2?: { children: JSX.Element };\n h3?: { children: JSX.Element };\n h4?: { children: JSX.Element };\n h5?: { children: JSX.Element };\n h6?: { children: JSX.Element };\n p?: { children: JSX.Element };\n a?: { url: string; children: JSX.Element };\n italic?: { children: JSX.Element };\n bold?: { children: JSX.Element };\n strikethrough?: { children: JSX.Element };\n underline?: { children: JSX.Element };\n code?: { children: JSX.Element };\n text?: { children: string };\n ul?: { children: JSX.Element };\n ol?: { children: JSX.Element };\n li?: { children: JSX.Element };\n lic?: { children: JSX.Element };\n block_quote?: { children: JSX.Element };\n code_block?: { lang?: string; value: string };\n mermaid?: { value: string };\n img?: { url: string; caption?: string; alt?: string };\n hr?: {};\n break?: {};\n maybe_mdx?: { children: JSX.Element };\n html?: { value: string };\n html_inline?: { value: string };\n // th?: { children: JSX.Element }\n // td?: { children: JSX.Element }\n // tr?: { children: JSX.Element }\n table?: {\n align?: ('left' | 'right' | 'center')[];\n tableRows: { tableCells: { value: TinaMarkdownContent }[] }[];\n };\n // Provide a fallback when a JSX component wasn't provided\n component_missing?: { name: string };\n};\n\ntype BaseComponentSignature = {\n [BK in keyof BaseComponents]: (props: BaseComponents[BK]) => JSX.Element;\n};\n\n/**\n * Define the allowed components and their props\n * ```ts\n * const components:\n * Components<{\n * BlockQuote: {\n * children: TinaMarkdownContent;\n * authorName: string;\n * };\n * }> = {\n * BlockQuote: (props: {\n * children: TinaMarkdownContent;\n * authorName: string;\n * }) => {\n * return (\n * <div>\n * <blockquote>\n * <TinaMarkdown content={props.children} />\n * {props.authorName}\n * </blockquote>\n * </div>\n * );\n * }\n * }\n * }\n * ```\n */\nexport type Components<ComponentAndProps extends object> = {\n [K in keyof ComponentAndProps]: (props: ComponentAndProps[K]) => JSX.Element;\n} & BaseComponentSignature;\n\nexport type TinaMarkdownContent = {\n type: string;\n children: TinaMarkdownContent[];\n};\n\nexport const TinaMarkdown = <\n CustomComponents extends { [key: string]: object } = any,\n>({\n content,\n components = {},\n}: {\n content: TinaMarkdownContent | TinaMarkdownContent[];\n components?:\n | Components<{}>\n | Components<{\n [BK in keyof CustomComponents]: (\n props: CustomComponents[BK]\n ) => JSX.Element;\n }>;\n}) => {\n if (!content) {\n return null;\n }\n const nodes = Array.isArray(content) ? content : content.children;\n if (!nodes) {\n return null;\n }\n return (\n <>\n {nodes.map((child, index) => {\n return <MemoNode components={components} key={index} child={child} />;\n })}\n </>\n );\n};\n\nconst Leaf = (props: {\n type: 'text';\n text: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strikethrough?: boolean;\n code?: boolean;\n components: Pick<\n BaseComponentSignature,\n 'bold' | 'italic' | 'underline' | 'strikethrough' | 'code' | 'text'\n >;\n}) => {\n if (props.bold) {\n const { bold, ...rest } = props;\n if (props.components.bold) {\n const Component = props.components.bold;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <strong>\n <Leaf {...rest} />\n </strong>\n );\n }\n if (props.italic) {\n const { italic, ...rest } = props;\n if (props.components.italic) {\n const Component = props.components.italic;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <em>\n <Leaf {...rest} />\n </em>\n );\n }\n if (props.underline) {\n const { underline, ...rest } = props;\n if (props.components.underline) {\n const Component = props.components.underline;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <u>\n <Leaf {...rest} />\n </u>\n );\n }\n if (props.strikethrough) {\n const { strikethrough, ...rest } = props;\n if (props.components.strikethrough) {\n const Component = props.components.strikethrough;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <s>\n <Leaf {...rest} />\n </s>\n );\n }\n if (props.code) {\n const { code, ...rest } = props;\n if (props.components.code) {\n const Component = props.components.code;\n return (\n <Component>\n <Leaf {...rest} />\n </Component>\n );\n }\n return (\n <code>\n <Leaf {...rest} />\n </code>\n );\n }\n if (props.components.text) {\n const Component = props.components.text;\n return <Component>{props.text}</Component>;\n }\n return <>{props.text}</>;\n};\n\n// FIXME: this needs more testing. But in theory all props\n// are serializable anyway so the JSON.stringify comparison makes sense.\n// I haven't thought all the way through this though, and maybe it'll break\n// down with custom components in some way.\n// In general this component handles most things without too many issues but for\n// large bodies of text it becomes pretty painful to see as-you-type updates, especially\n// in Safari.\nconst MemoNode = (props) => {\n const MNode = React.useMemo(\n () => <Node {...props} />,\n [JSON.stringify(props)]\n );\n return MNode;\n};\nconst Node = ({ components, child }) => {\n const { children, ...props } = child;\n switch (child.type) {\n case 'h1':\n case 'h2':\n case 'h3':\n case 'h4':\n case 'h5':\n case 'h6':\n case 'p':\n case 'blockquote':\n case 'ol':\n case 'ul':\n case 'li':\n if (components[child.type]) {\n const Component = components[child.type];\n return (\n <Component {...props}>\n <TinaMarkdown components={components} content={children} />\n </Component>\n );\n }\n return React.createElement(child.type, {\n children: <TinaMarkdown components={components} content={children} />,\n });\n case 'lic': // List Item Content\n if (components.lic) {\n const Component = components.lic;\n return (\n <Component {...props}>\n <TinaMarkdown components={components} content={children} />\n </Component>\n );\n }\n return (\n <div>\n <TinaMarkdown components={components} content={child.children} />\n </div>\n );\n case 'img':\n if (components[child.type]) {\n const Component = components[child.type];\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <Component {...props} />;\n }\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <img src={child.url} alt={child.alt} />;\n case 'a':\n if (components[child.type]) {\n const Component = components[child.type];\n return (\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n <Component {...props}>\n <TinaMarkdown components={components} content={children} />\n </Component>\n );\n }\n return (\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n <a href={child.url}>\n <TinaMarkdown components={components} content={children} />\n </a>\n );\n case 'mermaid':\n case 'code_block': {\n const value = child.value;\n if (components[child.type]) {\n const Component = components[child.type];\n return (\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n <Component {...props} />\n );\n }\n return (\n <pre>\n <code>{value}</code>\n </pre>\n );\n }\n case 'hr':\n if (components[child.type]) {\n const Component = components[child.type];\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <Component {...props} />;\n }\n return <hr />;\n case 'break':\n if (components[child.type]) {\n const Component = components[child.type];\n return <Component {...props} />;\n }\n return <br />;\n case 'text':\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <Leaf components={components} {...child} />;\n case 'mdxJsxTextElement':\n case 'mdxJsxFlowElement':\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n const Component = components[child.name];\n if (Component) {\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n const props = child.props ? child.props : {};\n return <Component {...props} />;\n } else {\n if (child.name === 'table') {\n const firstRowHeader = child.props?.firstRowHeader;\n const rows =\n (firstRowHeader\n ? child.props?.tableRows.filter((_, i) => i !== 0)\n : child.props?.tableRows) || [];\n const header = child.props?.tableRows?.at(0);\n const TableComponent =\n components['table'] || ((props) => <table {...props} />);\n const TrComponent =\n components['tr'] || ((props) => <tr {...props} />);\n const ThComponent =\n components['th'] ||\n ((props) => (\n <th style={{ textAlign: props?.align || 'auto' }} {...props} />\n ));\n const TdComponent =\n components['td'] ||\n ((props) => (\n <td style={{ textAlign: props?.align || 'auto' }} {...props} />\n ));\n const align = child.props?.align || [];\n return (\n <TableComponent>\n {firstRowHeader && (\n <thead>\n <TrComponent>\n {header.tableCells.map((c, i) => {\n return (\n <TinaMarkdown\n key={i}\n components={{\n p: (props) => (\n <ThComponent align={align[i]} {...props} />\n ),\n }}\n content={c.value}\n />\n );\n })}\n </TrComponent>\n </thead>\n )}\n <tbody>\n {rows.map((row, i) => {\n return (\n <TrComponent key={i}>\n {row?.tableCells?.map((c, i) => {\n return (\n <TinaMarkdown\n key={i}\n components={{\n p: (props) => (\n <TdComponent align={align[i]} {...props} />\n ),\n }}\n content={c.value}\n />\n );\n })}\n </TrComponent>\n );\n })}\n </tbody>\n </TableComponent>\n );\n }\n const ComponentMissing = components['component_missing'];\n if (ComponentMissing) {\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <ComponentMissing name={child.name} />;\n } else {\n return <span>{`No component provided for ${child.name}`}</span>;\n }\n }\n case 'table':\n const rows = child.children || [];\n const TableComponent =\n components['table'] ||\n ((props) => (\n <table style={{ border: '1px solid #EDECF3' }} {...props} />\n ));\n const TrComponent = components['tr'] || ((props) => <tr {...props} />);\n const TdComponent =\n components['td'] ||\n ((props) => (\n <td\n style={{\n textAlign: props?.align || 'auto',\n border: '1px solid #EDECF3',\n padding: '0.25rem',\n }}\n {...props}\n />\n ));\n const align = child.props?.align || [];\n return (\n <TableComponent>\n <tbody>\n {rows.map((row, i) => {\n return (\n <TrComponent key={i}>\n {row.children?.map((cell, i) => {\n return (\n <TinaMarkdown\n key={i}\n components={{\n p: (props) => (\n <TdComponent align={align[i]} {...props} />\n ),\n }}\n content={cell.children}\n />\n );\n })}\n </TrComponent>\n );\n })}\n </tbody>\n </TableComponent>\n );\n case 'maybe_mdx':\n /**\n * We don't want to render this as it's only displayed while editing an mdx node and should\n * be transformed before form submission\n */\n return null;\n case 'html':\n case 'html_inline':\n if (components[child.type]) {\n const Component = components[child.type];\n return <Component {...props} />;\n }\n return child.value;\n case 'invalid_markdown':\n return <pre>{child.value}</pre>;\n default:\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n if (typeof child.text === 'string') {\n // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types\n return <Leaf components={components} {...child} />;\n }\n\n // console.log(`No tina renderer for ${child.type}`, child)\n }\n};\n"],"names":["Component","props","rows","TableComponent","TrComponent","TdComponent","align","_a","i"],"mappings":";AAqFO,MAAM,eAAe,CAE1B;AAAA,EACA;AAAA,EACA,aAAa,CAAC;AAChB,MASM;AACJ,MAAI,CAAC,SAAS;AACL,WAAA;AAAA,EACT;AACA,QAAM,QAAQ,MAAM,QAAQ,OAAO,IAAI,UAAU,QAAQ;AACzD,MAAI,CAAC,OAAO;AACH,WAAA;AAAA,EACT;AACA,SAEK,sBAAA,cAAA,MAAA,UAAA,MAAA,MAAM,IAAI,CAAC,OAAO,UAAU;AAC3B,WAAQ,sBAAA,cAAA,UAAA,EAAS,YAAwB,KAAK,OAAO,MAAc,CAAA;AAAA,EACpE,CAAA,CACH;AAEJ;AAEA,MAAM,OAAO,CAAC,UAYR;AACJ,MAAI,MAAM,MAAM;AACd,UAAM,EAAE,MAAM,GAAG,KAAA,IAAS;AACtB,QAAA,MAAM,WAAW,MAAM;AACnB,YAAA,YAAY,MAAM,WAAW;AACnC,iDACG,WACC,MAAA,sBAAA,cAAC,MAAM,EAAA,GAAG,MAAM,CAClB;AAAA,IAEJ;AACA,+CACG,UACC,MAAA,sBAAA,cAAC,MAAM,EAAA,GAAG,MAAM,CAClB;AAAA,EAEJ;AACA,MAAI,MAAM,QAAQ;AAChB,UAAM,EAAE,QAAQ,GAAG,KAAA,IAAS;AACxB,QAAA,MAAM,WAAW,QAAQ;AACrB,YAAA,YAAY,MAAM,WAAW;AACnC,iDACG,WACC,MAAA,sBAAA,cAAC,MAAM,EAAA,GAAG,MAAM,CAClB;AAAA,IAEJ;AACA,+CACG,MACC,MAAA,sBAAA,cAAC,MAAM,EAAA,GAAG,MAAM,CAClB;AAAA,EAEJ;AACA,MAAI,MAAM,WAAW;AACnB,UAAM,EAAE,WAAW,GAAG,KAAA,IAAS;AAC3B,QAAA,MAAM,WAAW,WAAW;AACxB,YAAA,YAAY,MAAM,WAAW;AACnC,iDACG,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cACC,KAAKA;AAAAA,cACL,YAAY;AAAA,gBACV,GAAG,CAACP,WACD,sBAAA,cAAA,aAAA,EAAY,OAAO,MAAMO,EAAC,GAAI,GAAGP,OAAO,CAAA;AAAA,cAE7C;AAAA,cACA,SAAS,KAAK;AAAA,YAAA;AAAA,UAAA;AAAA,QAGnB,EACH;AAAA,MAEH,CAAA,CACH,CACF;AAAA,IAEJ,KAAK;AAKI,aAAA;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACC,UAAA,WAAW,MAAM,IAAI,GAAG;AACpBD,cAAAA,aAAY,WAAW,MAAM,IAAI;AACvC,eAAQA,sBAAAA,cAAAA,YAAA,EAAW,GAAG,MAAO,CAAA;AAAA,MAC/B;AACA,aAAO,MAAM;AAAA,IACf,KAAK;AACI,aAAA,sBAAA,cAAC,OAAK,MAAA,MAAM,KAAM;AAAA,IAC3B;AAEM,UAAA,OAAO,MAAM,SAAS,UAAU;AAElC,eAAQ,sBAAA,cAAA,MAAA,EAAK,YAAyB,GAAG,MAAO,CAAA;AAAA,MAClD;AAAA,EAGJ;AACF;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prism.js","sources":["../../src/rich-text/prism.tsx"],"sourcesContent":["/**\n\n*/\n\nimport React from 'react';\nimport { Highlight, themes } from 'prism-react-renderer';\n\nexport const Prism = (props: {\n value: string;\n lang?: string;\n theme?: keyof typeof themes;\n}) => {\n return (\n <Highlight\n theme={themes[props.theme || 'github']}\n code={props.value || ''}\n language={props.lang || ''}\n >\n {({ className, style, tokens, getLineProps, getTokenProps }) => (\n <pre className={className} style={style}>\n {tokens.map((line, i) => (\n <div {...getLineProps({ line, key: i })}>\n {line.map((token, key) => (\n <span {...getTokenProps({ token, key })} />\n ))}\n </div>\n ))}\n </pre>\n )}\n </Highlight>\n );\n};\n"],"names":["Highlight","themes"],"mappings":";;;;AAOa,QAAA,QAAQ,CAAC,UAIhB;AAEF,WAAA,sBAAA;AAAA,MAACA,mBAAA;AAAA,MAAA;AAAA,QACC,OAAOC,mBAAA,OAAO,MAAM,SAAS,QAAQ;AAAA,QACrC,MAAM,MAAM,SAAS;AAAA,QACrB,UAAU,MAAM,QAAQ;AAAA,MAAA;AAAA,MAEvB,CAAC,EAAE,WAAW,OAAO,QAAQ,cAAc,oBACzC,sBAAA,cAAA,OAAA,EAAI,WAAsB,MACxB,GAAA,OAAO,IAAI,CAAC,MAAM,MAChB,sBAAA,cAAA,OAAA,EAAK,GAAG,aAAa,EAAE,MAAM,KAAK,GAAG,EACnC,GAAA,KAAK,IAAI,CAAC,OAAO,QACf,sBAAA,cAAA,QAAA,EAAM,GAAG,cAAc,EAAE,OAAO,KAAK,GAAG,CAC1C,CACH,CACD,CACH;AAAA,IAAA;AAAA,EAIR;;;;"}
@@ -1,17 +0,0 @@
1
- import React from "react";
2
- import { Highlight, themes } from "prism-react-renderer";
3
- const Prism = (props) => {
4
- return /* @__PURE__ */ React.createElement(
5
- Highlight,
6
- {
7
- theme: themes[props.theme || "github"],
8
- code: props.value || "",
9
- language: props.lang || ""
10
- },
11
- ({ className, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ React.createElement("pre", { className, style }, tokens.map((line, i) => /* @__PURE__ */ React.createElement("div", { ...getLineProps({ line, key: i }) }, line.map((token, key) => /* @__PURE__ */ React.createElement("span", { ...getTokenProps({ token, key }) })))))
12
- );
13
- };
14
- export {
15
- Prism
16
- };
17
- //# sourceMappingURL=prism.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prism.mjs","sources":["../../src/rich-text/prism.tsx"],"sourcesContent":["/**\n\n*/\n\nimport React from 'react';\nimport { Highlight, themes } from 'prism-react-renderer';\n\nexport const Prism = (props: {\n value: string;\n lang?: string;\n theme?: keyof typeof themes;\n}) => {\n return (\n <Highlight\n theme={themes[props.theme || 'github']}\n code={props.value || ''}\n language={props.lang || ''}\n >\n {({ className, style, tokens, getLineProps, getTokenProps }) => (\n <pre className={className} style={style}>\n {tokens.map((line, i) => (\n <div {...getLineProps({ line, key: i })}>\n {line.map((token, key) => (\n <span {...getTokenProps({ token, key })} />\n ))}\n </div>\n ))}\n </pre>\n )}\n </Highlight>\n );\n};\n"],"names":[],"mappings":";;AAOa,MAAA,QAAQ,CAAC,UAIhB;AAEF,SAAA,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO,OAAO,MAAM,SAAS,QAAQ;AAAA,MACrC,MAAM,MAAM,SAAS;AAAA,MACrB,UAAU,MAAM,QAAQ;AAAA,IAAA;AAAA,IAEvB,CAAC,EAAE,WAAW,OAAO,QAAQ,cAAc,oBACzC,sBAAA,cAAA,OAAA,EAAI,WAAsB,MACxB,GAAA,OAAO,IAAI,CAAC,MAAM,MAChB,sBAAA,cAAA,OAAA,EAAK,GAAG,aAAa,EAAE,MAAM,KAAK,GAAG,EACnC,GAAA,KAAK,IAAI,CAAC,OAAO,QACf,sBAAA,cAAA,QAAA,EAAM,GAAG,cAAc,EAAE,OAAO,KAAK,GAAG,CAC1C,CACH,CACD,CACH;AAAA,EAAA;AAIR;"}
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- export declare const CodeBlockElement: React.ForwardRefExoticComponent<Omit<Omit<{
3
- elementToAttributes?: (element: import("@udecode/plate-common").TElement) => any;
4
- } & Omit<{
5
- as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
6
- asChild?: boolean | undefined;
7
- } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & {
8
- ref?: React.Ref<any>;
9
- } & import("@udecode/plate-common").PlateRenderNodeProps<import("@udecode/plate-common").Value, import("@udecode/plate-common").PlateEditor<import("@udecode/plate-common").Value>> & {
10
- element: import("@udecode/plate-common").TElement;
11
- } & Omit<import("slate-react").RenderElementProps, "element"> & React.RefAttributes<HTMLDivElement>, "ref">, never> & React.RefAttributes<any>>;
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
- export declare const TableCellElement: React.ForwardRefExoticComponent<{
3
- hideBorder?: boolean;
4
- isHeader?: boolean;
5
- } & Omit<Omit<{
6
- elementToAttributes?: (element: import("@udecode/plate-common").TElement) => any;
7
- } & Omit<{
8
- as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
9
- asChild?: boolean | undefined;
10
- } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & {
11
- ref?: React.Ref<any>;
12
- } & import("@udecode/plate-common").PlateRenderNodeProps<import("@udecode/plate-common").Value, import("@udecode/plate-common").PlateEditor<import("@udecode/plate-common").Value>> & {
13
- element: import("@udecode/plate-common").TElement;
14
- } & Omit<import("slate-react").RenderElementProps, "element"> & React.RefAttributes<HTMLDivElement>, "ref">, "hideBorder" | "isHeader"> & React.RefAttributes<any>>;
15
- export declare const TableCellHeaderElement: React.ForwardRefExoticComponent<Omit<{
16
- hideBorder?: boolean;
17
- isHeader?: boolean;
18
- } & Omit<Omit<{
19
- elementToAttributes?: (element: import("@udecode/plate-common").TElement) => any;
20
- } & Omit<{
21
- as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
22
- asChild?: boolean | undefined;
23
- } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & {
24
- ref?: React.Ref<any>;
25
- } & import("@udecode/plate-common").PlateRenderNodeProps<import("@udecode/plate-common").Value, import("@udecode/plate-common").PlateEditor<import("@udecode/plate-common").Value>> & {
26
- element: import("@udecode/plate-common").TElement;
27
- } & Omit<import("slate-react").RenderElementProps, "element"> & React.RefAttributes<HTMLDivElement>, "ref">, "hideBorder" | "isHeader"> & React.RefAttributes<any>, "ref"> & React.RefAttributes<any>>;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import type * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
3
- export declare const TableBordersDropdownMenuContent: React.ForwardRefExoticComponent<Omit<Omit<DropdownMenuPrimitive.DropdownMenuContentProps & React.RefAttributes<HTMLDivElement>, "ref">, never> & React.RefAttributes<HTMLDivElement>>;
4
- export declare const TableFloatingToolbar: React.ForwardRefExoticComponent<Omit<Omit<Omit<Omit<import("@radix-ui/react-popover").PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref">, never> & React.RefAttributes<HTMLDivElement>, "ref">, never> & React.RefAttributes<HTMLDivElement>>;
5
- export declare const TableElement: React.ForwardRefExoticComponent<Omit<Omit<Omit<{
6
- elementToAttributes?: (element: import("@udecode/plate-common").TElement) => any;
7
- } & Omit<{
8
- as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
9
- asChild?: boolean | undefined;
10
- } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & {
11
- ref?: React.Ref<any>;
12
- } & import("@udecode/plate-common").PlateRenderNodeProps<import("@udecode/plate-common").Value, import("@udecode/plate-common").PlateEditor<import("@udecode/plate-common").Value>> & {
13
- element: import("@udecode/plate-common").TElement;
14
- } & Omit<import("slate-react").RenderElementProps, "element"> & React.RefAttributes<HTMLDivElement>, "ref">, never> & React.RefAttributes<any>, "ref"> & React.RefAttributes<unknown>>;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- export declare const TableRowElement: React.ForwardRefExoticComponent<{
3
- hideBorder?: boolean;
4
- } & Omit<Omit<{
5
- elementToAttributes?: (element: import("@udecode/plate-common").TElement) => any;
6
- } & Omit<{
7
- as?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
8
- asChild?: boolean | undefined;
9
- } & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & {
10
- ref?: React.Ref<any>;
11
- } & import("@udecode/plate-common").PlateRenderNodeProps<import("@udecode/plate-common").Value, import("@udecode/plate-common").PlateEditor<import("@udecode/plate-common").Value>> & {
12
- element: import("@udecode/plate-common").TElement;
13
- } & Omit<import("slate-react").RenderElementProps, "element"> & React.RefAttributes<HTMLDivElement>, "ref">, "hideBorder"> & React.RefAttributes<any>>;
@@ -1,8 +0,0 @@
1
- /**
2
- *
3
- * This fixes a bug where you can't delete between two void nodes
4
- * without deleting the first node.
5
- *
6
- * https://github.com/ianstormtaylor/slate/issues/3991#issuecomment-832160304
7
- */
8
- export declare const withCorrectVoidBehavior: (editor: any) => any;
@@ -1,3 +0,0 @@
1
- export declare const createCodeBlockPlugin: <OP = import("@udecode/plate-common").AnyObject, OV extends import("@udecode/plate-common").Value = import("@udecode/plate-common").Value, OE extends import("@udecode/plate-common").PlateEditor<OV> = import("@udecode/plate-common").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>>, overrideByKey?: import("@udecode/plate-common").OverrideByKey<OV, OE>) => import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>;
2
- export declare const createHTMLBlockPlugin: <OP = import("@udecode/plate-common").AnyObject, OV extends import("@udecode/plate-common").Value = import("@udecode/plate-common").Value, OE extends import("@udecode/plate-common").PlateEditor<OV> = import("@udecode/plate-common").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>>, overrideByKey?: import("@udecode/plate-common").OverrideByKey<OV, OE>) => import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>;
3
- export declare const createHTMLInlinePlugin: <OP = import("@udecode/plate-common").AnyObject, OV extends import("@udecode/plate-common").Value = import("@udecode/plate-common").Value, OE extends import("@udecode/plate-common").PlateEditor<OV> = import("@udecode/plate-common").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>>, overrideByKey?: import("@udecode/plate-common").OverrideByKey<OV, OE>) => import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>;
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { type BaseRange } from 'slate';
3
- import { createLinkPlugin } from '@udecode/plate-link';
4
- import { type PlateEditor } from '@udecode/plate-common';
5
- export { createLinkPlugin };
6
- type LinkElement = {
7
- url?: string;
8
- title?: string;
9
- text: string | undefined;
10
- };
11
- export declare const wrapOrRewrapLink: (editor: any) => void;
12
- export declare const LinkForm: (props: any) => React.JSX.Element;
13
- export declare const unwrapLink: (editor: PlateEditor, selection?: BaseRange) => void;
14
- export declare const getLinks: (editor: any) => Generator<import("@udecode/plate-common").TNodeEntry<LinkElement>, void, undefined>;
15
- export declare const isLinkActive: (editor: any) => boolean;
@@ -1,2 +0,0 @@
1
- export declare const ELEMENT_MERMAID = "mermaid";
2
- export declare const createMermaidPlugin: <OP = import("@udecode/plate-common").AnyObject, OV extends import("@udecode/plate-common").Value = import("@udecode/plate-common").Value, OE extends import("@udecode/plate-common").PlateEditor<OV> = import("@udecode/plate-common").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>>, overrideByKey?: import("@udecode/plate-common").OverrideByKey<OV, OE>) => import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>;
@@ -1,7 +0,0 @@
1
- import type { SoftBreakPlugin } from './types';
2
- export declare const KEY_SOFT_BREAK = "break";
3
- /**
4
- * This code is mostly copied from the plate soft-break plugin
5
- * [here](https://github.com/udecode/plate/blob/3c0de39a66308a9b718cf9f35623502702ae2af4/packages/editor/break/src/soft-break/index.ts)
6
- */
7
- export declare const createSoftBreakPlugin: <OP = SoftBreakPlugin, OV extends import("@udecode/plate-common").Value = import("@udecode/plate-common").Value, OE extends import("@udecode/plate-common").PlateEditor<OV> = import("@udecode/plate-common").PlateEditor<OV>>(override?: Partial<import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>>, overrideByKey?: import("@udecode/plate-common").OverrideByKey<OV, OE>) => import("@udecode/plate-common").PlatePlugin<import("@udecode/plate-common").NoInfer<OP>, OV, OE>;
@@ -1,6 +0,0 @@
1
- /**
2
- * @file Automatically generated by barrelsby.
3
- */
4
- export * from './create-soft-break-plugin';
5
- export * from './on-key-down-soft-break';
6
- export * from './types';
@@ -1,5 +0,0 @@
1
- export declare const onKeyDownSoftBreak: (editor: any, { options: { rules } }: {
2
- options: {
3
- rules?: any[];
4
- };
5
- }) => (event: any) => void;
@@ -1,11 +0,0 @@
1
- import type { QueryNodeOptions } from '@udecode/plate-common';
2
- export interface SoftBreakRule {
3
- hotkey: string;
4
- /**
5
- * Filter the block types where the rule applies.
6
- */
7
- query?: QueryNodeOptions;
8
- }
9
- export interface SoftBreakPlugin {
10
- rules?: SoftBreakRule[];
11
- }