@kardalum/plugin-sdk 0.0.0-stage → 0.15.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 (312) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/LICENSE +202 -0
  3. package/README.md +70 -2
  4. package/dist/admin-section-registry.d.ts +34 -0
  5. package/dist/admin-section-registry.js +49 -0
  6. package/dist/built-in-serializers.d.ts +3 -0
  7. package/dist/built-in-serializers.js +18 -0
  8. package/dist/built-in-settings-schemas.d.ts +14 -0
  9. package/dist/built-in-settings-schemas.js +225 -0
  10. package/dist/built-in-value-schemas.d.ts +4 -0
  11. package/dist/built-in-value-schemas.js +47 -0
  12. package/dist/built-ins.d.ts +1 -0
  13. package/dist/built-ins.js +257 -0
  14. package/dist/capabilities.d.ts +99 -0
  15. package/dist/capabilities.js +363 -0
  16. package/dist/data-type-plugin.d.ts +28 -0
  17. package/dist/data-type-plugin.js +1 -0
  18. package/dist/datatype-validation.d.ts +26 -0
  19. package/dist/datatype-validation.js +110 -0
  20. package/dist/datatypes-entry.d.ts +4 -0
  21. package/dist/datatypes-entry.js +18 -0
  22. package/dist/define-plugin.d.ts +25 -0
  23. package/dist/define-plugin.js +51 -0
  24. package/dist/entitlement-entry.d.ts +5 -0
  25. package/dist/entitlement-entry.js +24 -0
  26. package/dist/entitlement-gate.d.ts +36 -0
  27. package/dist/entitlement-gate.js +201 -0
  28. package/dist/entitlement-types.d.ts +39 -0
  29. package/dist/entitlement-types.js +1 -0
  30. package/dist/entitlement.d.ts +57 -0
  31. package/dist/entitlement.js +170 -0
  32. package/dist/host-entry.d.ts +1 -0
  33. package/dist/host-entry.js +11 -0
  34. package/dist/icon-name.d.ts +1 -0
  35. package/dist/icon-name.js +1 -0
  36. package/dist/icons.d.ts +2 -0
  37. package/dist/icons.js +10 -0
  38. package/dist/index.d.ts +28 -0
  39. package/dist/index.js +93 -0
  40. package/dist/license-verdict-keys.d.ts +18 -0
  41. package/dist/license-verdict-keys.js +22 -0
  42. package/dist/local-host.d.ts +3 -0
  43. package/dist/local-host.js +38 -0
  44. package/dist/manifest-entry.d.ts +8 -0
  45. package/dist/manifest-entry.js +13 -0
  46. package/dist/manifest-schema.d.ts +408 -0
  47. package/dist/manifest-schema.js +774 -0
  48. package/dist/manifest.d.ts +546 -0
  49. package/dist/manifest.js +86 -0
  50. package/dist/media/media-picker.d.ts +39 -0
  51. package/dist/media/media-picker.js +438 -0
  52. package/dist/media/upload-error.d.ts +12 -0
  53. package/dist/media/upload-error.js +30 -0
  54. package/dist/plugin-context.d.ts +75 -0
  55. package/dist/plugin-context.js +70 -0
  56. package/dist/plugin-screen-context.d.ts +40 -0
  57. package/dist/plugin-screen-context.js +16 -0
  58. package/dist/register-built-ins.d.ts +1 -0
  59. package/dist/register-built-ins.js +41 -0
  60. package/dist/registry.d.ts +4 -0
  61. package/dist/registry.js +17 -0
  62. package/dist/rendition-eligibility.d.ts +24 -0
  63. package/dist/rendition-eligibility.js +40 -0
  64. package/dist/richtext/block-panel.d.ts +27 -0
  65. package/dist/richtext/block-panel.js +232 -0
  66. package/dist/richtext/extensions.d.ts +19 -0
  67. package/dist/richtext/extensions.js +56 -0
  68. package/dist/richtext/insert-menu.d.ts +24 -0
  69. package/dist/richtext/insert-menu.js +142 -0
  70. package/dist/richtext/kardalum-block.d.ts +33 -0
  71. package/dist/richtext/kardalum-block.js +282 -0
  72. package/dist/richtext/style-listbox.d.ts +10 -0
  73. package/dist/richtext/style-listbox.js +69 -0
  74. package/dist/richtext/text-style-class.d.ts +18 -0
  75. package/dist/richtext/text-style-class.js +36 -0
  76. package/dist/simple-storage-value-provider.d.ts +9 -0
  77. package/dist/simple-storage-value-provider.js +96 -0
  78. package/dist/structured-storage-types.d.ts +61 -0
  79. package/dist/structured-storage-types.js +11 -0
  80. package/dist/tailwind.d.ts +1 -0
  81. package/dist/tailwind.js +5 -0
  82. package/dist/tokens/system-dark.css +75 -0
  83. package/dist/tokens/tokens.css +239 -0
  84. package/dist/tokens/tokens.json +212 -0
  85. package/dist/tokens.d.ts +1 -0
  86. package/dist/tokens.js +11 -0
  87. package/dist/ui-entry.d.ts +5 -0
  88. package/dist/ui-entry.js +42 -0
  89. package/dist/views/content-list-preview.d.ts +1 -0
  90. package/dist/views/content-list-preview.js +14 -0
  91. package/dist/views/content-list-settings-view.d.ts +1 -0
  92. package/dist/views/content-list-settings-view.js +97 -0
  93. package/dist/views/content-list-view.d.ts +19 -0
  94. package/dist/views/content-list-view.js +248 -0
  95. package/dist/views/crop-view.d.ts +55 -0
  96. package/dist/views/crop-view.js +161 -0
  97. package/dist/views/date-range-view.d.ts +6 -0
  98. package/dist/views/date-range-view.js +55 -0
  99. package/dist/views/file-upload-view.d.ts +43 -0
  100. package/dist/views/file-upload-view.js +104 -0
  101. package/dist/views/html-code-editor.d.ts +10 -0
  102. package/dist/views/html-code-editor.js +101 -0
  103. package/dist/views/html-view.d.ts +3 -0
  104. package/dist/views/html-view.js +53 -0
  105. package/dist/views/image-view.d.ts +3 -0
  106. package/dist/views/image-view.js +387 -0
  107. package/dist/views/rich-text-view.d.ts +2 -0
  108. package/dist/views/rich-text-view.js +429 -0
  109. package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
  110. package/node_modules/@kardalum/api-schemas/README.md +56 -0
  111. package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
  112. package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
  113. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +5 -0
  114. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
  115. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
  116. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -0
  117. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
  118. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
  119. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
  120. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
  121. package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
  122. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
  123. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +537 -0
  124. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
  126. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
  127. package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
  128. package/node_modules/@kardalum/api-schemas/dist/content-path.js +256 -0
  129. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
  130. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
  131. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +151 -0
  132. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
  133. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
  134. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
  135. package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
  136. package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
  137. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +302 -0
  138. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -0
  139. package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
  140. package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
  141. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +36 -0
  142. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
  143. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
  144. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
  145. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +296 -0
  146. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
  147. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
  148. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
  149. package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
  150. package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
  151. package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
  153. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +102 -0
  154. package/node_modules/@kardalum/api-schemas/dist/index.js +58 -0
  155. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
  156. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
  157. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +381 -0
  158. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
  159. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
  160. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -0
  161. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
  162. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
  163. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
  164. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
  165. package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
  166. package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
  167. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
  168. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
  169. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
  170. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
  171. package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
  172. package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
  173. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
  174. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
  175. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
  176. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
  177. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +169 -0
  178. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -0
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +89 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +369 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
  193. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +306 -0
  194. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -0
  195. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
  196. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
  197. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
  198. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
  199. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
  200. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
  201. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +90 -0
  202. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -0
  203. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
  204. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
  205. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +108 -0
  206. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -0
  207. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
  208. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
  209. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +43 -0
  210. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -0
  211. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
  212. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
  213. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
  214. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
  215. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
  216. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
  217. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
  218. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
  219. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +89 -0
  220. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -0
  221. package/node_modules/@kardalum/api-schemas/package.json +35 -0
  222. package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
  223. package/node_modules/@kardalum/design-tokens/README.md +29 -0
  224. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
  225. package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
  226. package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
  227. package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
  228. package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
  229. package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
  230. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
  231. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
  232. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
  233. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
  234. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
  235. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
  236. package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
  237. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
  238. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
  239. package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
  240. package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
  241. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
  242. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
  243. package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
  244. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
  245. package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
  246. package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
  247. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
  248. package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
  249. package/node_modules/@kardalum/design-tokens/package.json +42 -0
  250. package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
  251. package/node_modules/@kardalum/plugin-package/README.md +71 -0
  252. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
  253. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
  254. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
  255. package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
  256. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
  257. package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
  258. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
  259. package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
  260. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -0
  261. package/node_modules/@kardalum/plugin-package/dist/index.js +7 -0
  262. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
  263. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
  264. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
  265. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
  266. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +1 -0
  267. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
  268. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
  269. package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
  270. package/node_modules/@kardalum/plugin-package/package.json +49 -0
  271. package/node_modules/@kardalum/ui/LICENSE +202 -0
  272. package/node_modules/@kardalum/ui/README.md +35 -0
  273. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
  274. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
  275. package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
  276. package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
  277. package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
  278. package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
  279. package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
  280. package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
  281. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
  282. package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
  283. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
  284. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
  285. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
  286. package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
  287. package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
  288. package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
  289. package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
  290. package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
  291. package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
  292. package/node_modules/@kardalum/ui/dist/components/property-field.js +86 -0
  293. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
  294. package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
  295. package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
  296. package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
  297. package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
  298. package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
  299. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
  300. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
  301. package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
  302. package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
  303. package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
  304. package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
  305. package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
  306. package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
  307. package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
  308. package/node_modules/@kardalum/ui/dist/index.js +18 -0
  309. package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
  310. package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
  311. package/node_modules/@kardalum/ui/package.json +63 -0
  312. package/package.json +146 -4
@@ -0,0 +1,40 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * Where a plugin screen is being rendered (S280, spec D7). Every slot kind
4
+ * hands its view this one context instead of props, so a view keeps taking
5
+ * no props (as the SDK's other views do) and a screen written for a
6
+ * top-level section reads it the same way a rail entry does.
7
+ *
8
+ * - `kind: "section"`: a plugin's own top-level section, its landing page.
9
+ * `sectionId` is the section's id, `entryId` is null.
10
+ * - `kind: "sectionRail"`: an entry in the rail of the plugin's own section.
11
+ * Both ids are set.
12
+ * - `kind: "rail"`: an entry the plugin adds to a built-in section's rail
13
+ * (content, media, settings, users). `sectionId` is null, because the
14
+ * section is not the plugin's; `entryId` is the entry's id.
15
+ */
16
+ export interface PluginScreenContext {
17
+ pluginId: string;
18
+ slot: {
19
+ kind: "section" | "sectionRail" | "rail";
20
+ sectionId: string | null;
21
+ entryId: string | null;
22
+ };
23
+ /** The admin's active language, for the plugin's own strings. */
24
+ locale: string;
25
+ /**
26
+ * Navigates within the plugin's own section (kind section/sectionRail):
27
+ * pass the id of a rail entry that section declares, or null for the
28
+ * section's landing page. Anything else (a path such as `..`, another
29
+ * plugin's URL, an id the section's rail does not declare) does nothing,
30
+ * with a console warning in development. Always a no-op for a built-in
31
+ * rail entry, whose section is not the plugin's.
32
+ */
33
+ navigate: (entryId: string | null) => void;
34
+ }
35
+ /** Supplied by the host around a plugin screen's view. */
36
+ export declare function PluginScreenProvider({ value, children }: {
37
+ value: PluginScreenContext;
38
+ children: ReactNode;
39
+ }): import("react").JSX.Element;
40
+ export declare function usePluginScreen(): PluginScreenContext;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ const PluginScreenReactContext = createContext(null);
4
+ /** Supplied by the host around a plugin screen's view. */
5
+ export function PluginScreenProvider({ value, children }) {
6
+ return _jsx(PluginScreenReactContext.Provider, { value: value, children: children });
7
+ }
8
+ // A screen calling this outside a host-rendered PluginScreenProvider is a
9
+ // host wiring bug, so it throws, the same as usePluginApi.
10
+ export function usePluginScreen() {
11
+ const ctx = useContext(PluginScreenReactContext);
12
+ if (!ctx) {
13
+ throw new Error("usePluginScreen must be called from a view rendered inside a PluginScreenProvider");
14
+ }
15
+ return ctx;
16
+ }
@@ -0,0 +1 @@
1
+ import "./built-ins.js";
@@ -0,0 +1,41 @@
1
+ // The `@kardalum/plugin-sdk/register-built-ins` subpath: runs the
2
+ // package's built-in datatype registration side effect (the six
3
+ // `registerDataType()` calls in `built-ins.tsx` — text/number/boolean/
4
+ // date/image/richtext/html) and nothing else.
5
+ //
6
+ // S197 final-review fix F5: this used to be the package INDEX's own
7
+ // trailing side effect (`import "./built-ins.js"`), which meant importing
8
+ // ANYTHING from the bare `@kardalum/plugin-sdk` specifier: a UI
9
+ // primitive, a provider, a type — incidentally triggered it too. That was
10
+ // harmless on its own, but it meant the package's main entry could never
11
+ // be lightweight: `built-ins.tsx` statically imports both
12
+ // rich-text-view.tsx (TipTap) and, since S197 Task 8's HTML datatype,
13
+ // html-view.tsx (whose CodeMirror/lezer code editor is `React.lazy()`-
14
+ // split in the ADMIN bundle, but still a real, non-optional dependency of
15
+ // the main entry either way).
16
+ //
17
+ // Every first-party plugin's Module Federation config shares
18
+ // `@kardalum/plugin-sdk` as a runtime singleton (see any
19
+ // `plugins/*/vite.config.ts`) — that `shared` entry resolves to the bare
20
+ // package specifier, i.e. the MAIN entry, regardless of which subpath a
21
+ // plugin's own view code actually imports from. Module Federation still
22
+ // bundles a fallback copy of that shared module into every remote's own
23
+ // artifact (for the case where a host doesn't already provide a
24
+ // compatible version), so as long as the main entry pulled in TipTap +
25
+ // CodeMirror, EVERY plugin's packaged artifact carried a multi-hundred-KB
26
+ // dead-weight fallback chunk that never actually loads at runtime (the
27
+ // admin host's own copy always satisfies the singleton first) — this is
28
+ // what pushed google-maps' packaged bundle size over the marketplace's
29
+ // 250KB budget the moment CodeMirror/lezer landed in plugin-sdk's
30
+ // dependency tree, not anything google-maps' own view code did.
31
+ //
32
+ // Splitting registration out here (main entry now side-effect-free) fixes
33
+ // that at the root for every plugin at once, not just the one that
34
+ // happened to trip a test. Exactly ONE real consumer needs this:
35
+ // apps/admin-ui's own bootstrap (main.tsx) and its vitest setup
36
+ // (vitest.setup.ts) — both import this once, for its side effect, the
37
+ // same "run once at startup" pattern initTheme()/the i18n import already
38
+ // use in main.tsx. A REMOTE plugin never needs this: its own views read
39
+ // datatypes through its OWN manifest object, never through this
40
+ // registry (that's an admin-app-only lookup, `resolve-data-type.ts`).
41
+ import "./built-ins.js";
@@ -0,0 +1,4 @@
1
+ import type { DataTypePlugin } from "./data-type-plugin.js";
2
+ export declare function registerDataType(plugin: DataTypePlugin): void;
3
+ export declare function getDataType(id: string): DataTypePlugin | undefined;
4
+ export declare function listDataTypes(): DataTypePlugin[];
@@ -0,0 +1,17 @@
1
+ // Static registry: built-ins register into this exact same map at module
2
+ // load (Core vs Plugin — built-ins are statically registered, dynamically
3
+ // loaded marketplace plugins are a second registration path into this same
4
+ // registry, not a different kind of plugin).
5
+ const dataTypes = new Map();
6
+ export function registerDataType(plugin) {
7
+ if (dataTypes.has(plugin.id)) {
8
+ throw new Error(`A datatype with id "${plugin.id}" is already registered`);
9
+ }
10
+ dataTypes.set(plugin.id, plugin);
11
+ }
12
+ export function getDataType(id) {
13
+ return dataTypes.get(id);
14
+ }
15
+ export function listDataTypes() {
16
+ return [...dataTypes.values()];
17
+ }
@@ -0,0 +1,24 @@
1
+ /** The source media types that never get a rendition (spec, decision 4).
2
+ *
3
+ * Both would be damaged by a canvas rather than cut by one: an SVG is
4
+ * vector artwork a raster cut throws away, and telling a static GIF from
5
+ * an animated one means parsing the file for extra frames, where a wrong
6
+ * guess silently flattens an animation with nothing to undo it. So no GIF
7
+ * is cut, not only an animated one.
8
+ *
9
+ * DECLARED ONCE, here. The tile that offers the Cut button, the browser
10
+ * cut behind it, and the server route that files the result all read this
11
+ * same set, so a format can never be refused by one and accepted by
12
+ * another.
13
+ */
14
+ export declare const RENDITION_INELIGIBLE_TYPES: ReadonlySet<string>;
15
+ /** Whether this source is one the set above refuses. An unknown source
16
+ * (null, before any file exists) is not ineligible: it is unknown, and the
17
+ * tile says nothing about a format it has not been told.
18
+ *
19
+ * The type is reduced to its base form first, because a stored media type
20
+ * is whatever the uploading client sent: `IMAGE/GIF` and
21
+ * `image/gif; charset=binary` are both `image/gif`. Every caller checks
22
+ * through this rather than against the set directly, so a spelling one of
23
+ * them accepts is a spelling all of them accept. */
24
+ export declare function isRenditionIneligible(mimeType: string | null): boolean;
@@ -0,0 +1,40 @@
1
+ // Which source formats never get a rendition, and the one question worth
2
+ // asking of a stored media type.
3
+ //
4
+ // Zero React import, and it must stay that way: this file is re-exported
5
+ // from the @kardalum/plugin-sdk/datatypes subpath so apps/server can
6
+ // refuse an ineligible source at the cut route without pulling the
7
+ // browser half of the SDK into the server process (same boundary as
8
+ // built-in-settings-schemas.ts, Session 60). It lives here rather than in
9
+ // views/crop-view.tsx for that reason alone; crop-view re-exports it so
10
+ // the tile and the browser cut still read the one set.
11
+ /** The source media types that never get a rendition (spec, decision 4).
12
+ *
13
+ * Both would be damaged by a canvas rather than cut by one: an SVG is
14
+ * vector artwork a raster cut throws away, and telling a static GIF from
15
+ * an animated one means parsing the file for extra frames, where a wrong
16
+ * guess silently flattens an animation with nothing to undo it. So no GIF
17
+ * is cut, not only an animated one.
18
+ *
19
+ * DECLARED ONCE, here. The tile that offers the Cut button, the browser
20
+ * cut behind it, and the server route that files the result all read this
21
+ * same set, so a format can never be refused by one and accepted by
22
+ * another.
23
+ */
24
+ export const RENDITION_INELIGIBLE_TYPES = new Set(["image/svg+xml", "image/gif"]);
25
+ /** Whether this source is one the set above refuses. An unknown source
26
+ * (null, before any file exists) is not ineligible: it is unknown, and the
27
+ * tile says nothing about a format it has not been told.
28
+ *
29
+ * The type is reduced to its base form first, because a stored media type
30
+ * is whatever the uploading client sent: `IMAGE/GIF` and
31
+ * `image/gif; charset=binary` are both `image/gif`. Every caller checks
32
+ * through this rather than against the set directly, so a spelling one of
33
+ * them accepts is a spelling all of them accept. */
34
+ export function isRenditionIneligible(mimeType) {
35
+ if (mimeType === null)
36
+ return false;
37
+ const semicolon = mimeType.indexOf(";");
38
+ const base = (semicolon === -1 ? mimeType : mimeType.slice(0, semicolon)).trim().toLowerCase();
39
+ return RENDITION_INELIGIBLE_TYPES.has(base);
40
+ }
@@ -0,0 +1,27 @@
1
+ import type { Editor } from "@tiptap/react";
2
+ import { type BlockListing } from "./insert-menu.js";
3
+ export interface BlockParamFieldsProps {
4
+ listing: BlockListing | null;
5
+ listingsError: string | null;
6
+ params: Record<string, unknown>;
7
+ onChange: (key: string, next: unknown) => void;
8
+ /** Per-param-key error text (S197 Task 12's inline 400 display); omitted elsewhere. */
9
+ fieldErrors?: Record<string, string>;
10
+ }
11
+ export declare function BlockParamFields({ listing, listingsError, params, onChange, fieldErrors }: BlockParamFieldsProps): import("react").JSX.Element;
12
+ export interface BlockPanelProps {
13
+ editor: Editor;
14
+ /** The kardalumBlock node's current document position. */
15
+ pos: number;
16
+ partial: string;
17
+ params: Record<string, unknown>;
18
+ }
19
+ export declare function BlockPanel({ editor, pos, partial, params }: BlockPanelProps): import("react").JSX.Element;
20
+ export interface BlockPreviewPopoverProps {
21
+ partial: string;
22
+ params: Record<string, unknown>;
23
+ /** Viewport rect of the "preview ⤢" button that opened this popover. */
24
+ anchorRect: DOMRect;
25
+ onClose: () => void;
26
+ }
27
+ export declare function BlockPreviewPopover({ partial, params, anchorRect, onClose }: BlockPreviewPopoverProps): import("react").JSX.Element;
@@ -0,0 +1,232 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { Selection } from "@tiptap/pm/state";
4
+ import { Button, Dialog, DialogCloseButton, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, PropertyField, Switch, } from "@kardalum/ui";
5
+ import { usePluginApi } from "../plugin-context.js";
6
+ import { MediaPicker } from "../media/media-picker.js";
7
+ import { useBlockListings } from "./insert-menu.js";
8
+ function useMediaParamPreview(mediaId) {
9
+ const fetchApi = usePluginApi();
10
+ const [preview, setPreview] = useState(null);
11
+ const [loading, setLoading] = useState(false);
12
+ useEffect(() => {
13
+ if (!mediaId) {
14
+ setPreview(null);
15
+ return;
16
+ }
17
+ let cancelled = false;
18
+ setLoading(true);
19
+ fetchApi(`/api/media/${mediaId}`)
20
+ .then(async (response) => {
21
+ if (!response.ok)
22
+ throw new Error(`Failed to load media (${response.status})`);
23
+ const body = (await response.json());
24
+ if (!cancelled)
25
+ setPreview({ filename: body.filename, downloadUrl: body.downloadUrl });
26
+ })
27
+ .catch(() => {
28
+ if (!cancelled)
29
+ setPreview(null);
30
+ })
31
+ .finally(() => {
32
+ if (!cancelled)
33
+ setLoading(false);
34
+ });
35
+ return () => {
36
+ cancelled = true;
37
+ };
38
+ }, [mediaId, fetchApi]);
39
+ return { preview, loading };
40
+ }
41
+ // One field per declared param, keyed by its type (S197 Task 3 brief:
42
+ // text/textarea/number/boolean(switch)/image(MediaPicker)/choice(select)).
43
+ function BlockParamField({ spec, value, onChange, error }) {
44
+ const fieldId = `block-param-${spec.key}`;
45
+ const [pickerOpen, setPickerOpen] = useState(false);
46
+ const mediaId = spec.type === "image" ? (value ?? null) : null;
47
+ const { preview } = useMediaParamPreview(mediaId);
48
+ switch (spec.type) {
49
+ case "text":
50
+ return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx(Input, { id: fieldId, type: "text", value: value ?? "", onChange: (event) => onChange(event.target.value) }) }));
51
+ case "textarea":
52
+ return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx("textarea", { id: fieldId, rows: 3, value: value ?? "", onChange: (event) => onChange(event.target.value), className: "w-full rounded-md border border-border-strong bg-background-elevated px-3 py-2 text-sm text-text-primary focus-visible:border-primary-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary-50" }) }));
53
+ case "number":
54
+ return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx(Input, { id: fieldId, type: "number", value: value ?? 0, onChange: (event) => {
55
+ // A `type="number"` input still hands back an empty or
56
+ // otherwise unparseable string in plenty of real situations
57
+ // (cleared entirely, "-", "1e", a paste) — Number() turns
58
+ // those into NaN, which must never reach the node's attrs.
59
+ // 0 is the same documented empty-state default this field
60
+ // (and defaultBlockParams) already uses.
61
+ const raw = event.target.value;
62
+ const next = raw === "" ? 0 : Number(raw);
63
+ onChange(Number.isNaN(next) ? 0 : next);
64
+ } }) }));
65
+ case "boolean":
66
+ return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("label", { htmlFor: fieldId, className: "text-sm font-medium text-text-primary", children: spec.label }), _jsx(Switch, { id: fieldId, checked: Boolean(value), onCheckedChange: (checked) => onChange(checked) })] }), error && (_jsx("p", { role: "alert", className: "text-xs text-danger-600", children: error }))] }));
67
+ case "choice":
68
+ return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx("select", { id: fieldId, value: value ?? "", onChange: (event) => onChange(event.target.value), className: "h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 text-sm text-text-primary focus-visible:border-primary-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary-50", children: (spec.options ?? []).map((option) => (_jsx("option", { value: option, children: option }, option))) }) }));
69
+ case "image":
70
+ return (_jsxs(PropertyField, { label: spec.label, error: error, children: [_jsxs("div", { className: "flex items-center gap-3 rounded-md border border-border-default bg-background-subtle p-2", children: [preview ? (_jsx("img", { src: preview.downloadUrl, alt: "", className: "h-10 w-10 shrink-0 rounded-md object-cover" })) : (_jsx("div", { "aria-hidden": "true", className: "h-10 w-10 shrink-0 rounded-md bg-background-hover" })), _jsx("span", { className: "flex-1 truncate text-sm text-text-secondary", children: preview?.filename ?? "No image selected" }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setPickerOpen(true), children: "Change" })] }), pickerOpen && (_jsx(MediaPicker
71
+ // A block param stores the media id and nothing else, so
72
+ // there is nowhere for alt text to go: asking for it here
73
+ // would be collecting something this field then discards.
74
+ , {
75
+ // A block param stores the media id and nothing else, so
76
+ // there is nowhere for alt text to go: asking for it here
77
+ // would be collecting something this field then discards.
78
+ collectAlt: false, onPick: (item) => {
79
+ onChange(item.id);
80
+ setPickerOpen(false);
81
+ }, onClose: () => setPickerOpen(false) }))] }));
82
+ default:
83
+ return null;
84
+ }
85
+ }
86
+ // The typed param field list, extracted out of BlockPanel (S197 Task 12 —
87
+ // same reasoning as StyleListbox's own extraction) so the on-page side
88
+ // panel (apps/admin-ui's block-overlay.tsx) can render the exact same
89
+ // fields inside its OWN chrome (a slide-in side panel, not this Dialog) —
90
+ // the form-view/on-page distinction is only ever about the surrounding
91
+ // panel shell, never about how a param is edited.
92
+ export function BlockParamFields({ listing, listingsError, params, onChange, fieldErrors }) {
93
+ return (_jsxs(_Fragment, { children: [!listing && listingsError && _jsx("p", { className: "text-sm text-danger-600", children: listingsError }), !listing && !listingsError && (_jsx("p", { className: "text-sm text-text-secondary", children: "This block's fields couldn't be loaded. Its template declaration may be missing or the render service is unavailable." })), listing?.params.map((spec) => (_jsx(BlockParamField, { spec: spec, value: params[spec.key], onChange: (next) => onChange(spec.key, next), error: fieldErrors?.[spec.key] }, spec.key)))] }));
94
+ }
95
+ // The mockup's right-hand settings panel (screen 1) for the form view: a
96
+ // modal over the editor (Dialog, per packages/ui — MediaPicker moved to
97
+ // the newer Sheet side-drawer for its own modal in S197 QA-wave C Item 5,
98
+ // but this panel's own content is a centered param form, not a browsing
99
+ // UI, so Dialog is still the right shape here), focus-trapped by Radix.
100
+ // Rendered by rich-text-view.tsx exactly
101
+ // while the current selection is a NodeSelection on this block — see that
102
+ // file for why: the same click that selects the atom node (default
103
+ // ProseMirror behavior for an atom+selectable node, nothing bespoke) is
104
+ // what the mockup calls "click the block to open its settings panel", so
105
+ // panel visibility is just a read of editor state, not separate
106
+ // open/close state duplicated here.
107
+ export function BlockPanel({ editor, pos, partial, params }) {
108
+ const { listings, error: listingsError } = useBlockListings();
109
+ const listing = listings.find((entry) => entry.alias === partial) ?? null;
110
+ // "at the node's position" (S197 Task 3 brief): setNodeSelection(pos)
111
+ // first so updateAttributes — which otherwise acts on whatever the
112
+ // CURRENT selection happens to be — is guaranteed to target this exact
113
+ // node, never whatever the user last clicked elsewhere. No .focus(): a
114
+ // focus() here would yank keyboard focus out of the panel's own input
115
+ // on every keystroke.
116
+ function updateParam(key, next) {
117
+ editor
118
+ .chain()
119
+ .setNodeSelection(pos)
120
+ .updateAttributes("kardalumBlock", { params: { ...params, [key]: next } })
121
+ .run();
122
+ }
123
+ function moveSelectionPastBlock() {
124
+ const size = editor.state.doc.nodeAt(pos)?.nodeSize ?? 1;
125
+ const next = Math.min(pos + size, editor.state.doc.content.size);
126
+ // Selection.near, not setTextSelection(next) directly: when the block
127
+ // is the document's only content, `next` doesn't resolve into any
128
+ // inline content at all, and TipTap's setTextSelection constructs a
129
+ // TextSelection there unconditionally (ProseMirror warns and the
130
+ // resulting selection is unreliable). Selection.near finds the
131
+ // nearest position that's actually valid instead.
132
+ // .focus() here IS wanted — Done/Remove/Escape are all "I'm finished
133
+ // editing this block," and returning keyboard focus to the document is
134
+ // the expected outcome, unlike updateParam's keystroke-time writes.
135
+ editor
136
+ .chain()
137
+ .focus()
138
+ .command(({ tr, dispatch }) => {
139
+ if (dispatch)
140
+ tr.setSelection(Selection.near(tr.doc.resolve(next)));
141
+ return true;
142
+ })
143
+ .run();
144
+ }
145
+ function handleRemove() {
146
+ editor.chain().setNodeSelection(pos).deleteSelection().run();
147
+ editor.commands.focus();
148
+ }
149
+ return (_jsx(Dialog, { open: true, onOpenChange: (next) => {
150
+ if (!next)
151
+ moveSelectionPastBlock();
152
+ }, children: _jsxs(DialogContent, { onCloseAutoFocus: (event) => {
153
+ // Radix's default is to refocus whatever triggered the dialog —
154
+ // there is no trigger button here (the panel opens off a
155
+ // NodeSelection, not a click on some menu item), so without this
156
+ // focus lands on <body> (admin-ui.md's dialog-focus rule).
157
+ event.preventDefault();
158
+ // This callback runs on a rAF after the close, by which point the
159
+ // whole editor can already be gone (e.g. the page navigated away
160
+ // while the panel was open) — commands throws on a destroyed
161
+ // editor, so this is a real guard, not defensive-for-its-own-sake.
162
+ if (!editor.isDestroyed)
163
+ editor.commands.focus();
164
+ }, className: "flex max-h-[80vh] max-w-sm flex-col gap-0 p-0", children: [_jsxs(DialogHeader, { className: "border-b border-border-default px-4 py-3", children: [_jsxs("div", { className: "flex flex-col gap-0.5", children: [_jsx(DialogTitle, { children: listing?.name ?? partial }), _jsxs("span", { className: "font-mono text-xs text-text-tertiary", children: ["partial: ", partial, ".liquid"] })] }), _jsx(DialogCloseButton, { "aria-label": "Close" })] }), _jsxs("div", { className: "flex flex-1 flex-col gap-4 overflow-y-auto p-4", children: [_jsx(BlockParamFields, { listing: listing, listingsError: listingsError, params: params, onChange: updateParam }), _jsxs("p", { className: "rounded-md border border-border-default bg-background-subtle p-2 text-xs text-text-secondary", children: [_jsx("b", { className: "font-semibold text-text-primary", children: "Live preview." }), " This block is rendered by your own template on the server. What you see on the page is exactly what visitors will get."] })] }), _jsxs(DialogFooter, { className: "mt-0 justify-start border-t border-border-default p-4", children: [_jsx(Button, { type: "button", variant: "ghost", className: "text-danger-600 hover:text-danger-700", onClick: handleRemove, children: "Remove block" }), _jsx(Button, { type: "button", className: "ms-auto", onClick: moveSelectionPastBlock, children: "Done" })] })] }) }));
165
+ }
166
+ // The chip's "preview ⤢" affordance (S197 mockup screen 3): fetches
167
+ // POST /api/render/block for the block's CURRENT params and shows the
168
+ // returned HTML in a sandboxed iframe — sandbox="" (no tokens granted) so
169
+ // arbitrary template markup can never run script in the admin UI.
170
+ // Position is computed from a live viewport rect (getBoundingClientRect),
171
+ // which is inherently a physical measurement — plain `top`/`left` here,
172
+ // not logical properties, matches how that rect is expressed.
173
+ export function BlockPreviewPopover({ partial, params, anchorRect, onClose }) {
174
+ const fetchApi = usePluginApi();
175
+ const [html, setHtml] = useState(null);
176
+ const [loading, setLoading] = useState(true);
177
+ const [error, setError] = useState(null);
178
+ const popoverRef = useRef(null);
179
+ useEffect(() => {
180
+ let cancelled = false;
181
+ setLoading(true);
182
+ setError(null);
183
+ fetchApi("/api/render/block", {
184
+ method: "POST",
185
+ headers: { "Content-Type": "application/json" },
186
+ body: JSON.stringify({ partial, params }),
187
+ })
188
+ .then(async (response) => {
189
+ if (!response.ok)
190
+ throw new Error(`Failed to render preview (${response.status})`);
191
+ const body = (await response.json());
192
+ if (!cancelled)
193
+ setHtml(body.html);
194
+ })
195
+ .catch((err) => {
196
+ if (!cancelled)
197
+ setError(err instanceof Error ? err.message : String(err));
198
+ })
199
+ .finally(() => {
200
+ if (!cancelled)
201
+ setLoading(false);
202
+ });
203
+ return () => {
204
+ cancelled = true;
205
+ };
206
+ // params is a fresh object per render (rich-text-view.tsx reads it off
207
+ // node attrs each time) — comparing it by reference would refetch on
208
+ // every unrelated re-render, so key on its serialized form instead.
209
+ // eslint-disable-next-line react-hooks/exhaustive-deps
210
+ }, [partial, JSON.stringify(params), fetchApi]);
211
+ useEffect(() => {
212
+ function handlePointerDown(event) {
213
+ if (popoverRef.current && !popoverRef.current.contains(event.target))
214
+ onClose();
215
+ }
216
+ function handleKeyDown(event) {
217
+ if (event.key === "Escape")
218
+ onClose();
219
+ }
220
+ document.addEventListener("mousedown", handlePointerDown);
221
+ document.addEventListener("keydown", handleKeyDown);
222
+ return () => {
223
+ document.removeEventListener("mousedown", handlePointerDown);
224
+ document.removeEventListener("keydown", handleKeyDown);
225
+ };
226
+ }, [onClose]);
227
+ function handleKeyDownCapture(event) {
228
+ if (event.key === "Escape")
229
+ onClose();
230
+ }
231
+ return (_jsxs("div", { ref: popoverRef, role: "dialog", "aria-label": `Preview: ${partial}`, onKeyDown: handleKeyDownCapture, style: { position: "fixed", top: anchorRect.bottom + 4, left: anchorRect.left }, className: "z-20 w-80 rounded-md border border-border-default bg-background-elevated p-2 shadow-xl", children: [loading && _jsx("p", { className: "text-xs text-text-secondary", children: "Loading preview\u2026" }), error && _jsx("p", { className: "text-xs text-danger-600", children: error }), !loading && !error && (_jsx("iframe", { title: `Preview: ${partial}`, srcDoc: html ?? "", sandbox: "", className: "h-40 w-full rounded-sm border border-border-subtle bg-white" }))] }));
232
+ }
@@ -0,0 +1,19 @@
1
+ import type { Extensions } from "@tiptap/core";
2
+ export type { TextStyleClassAttributes } from "./text-style-class.js";
3
+ export type { KardalumBlockAttributes, KardalumBlockLocation, SelectedKardalumBlock } from "./kardalum-block.js";
4
+ export { TextStyleClass } from "./text-style-class.js";
5
+ export { KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, } from "./kardalum-block.js";
6
+ export interface RichtextTextStyle {
7
+ key: string;
8
+ label: string;
9
+ }
10
+ export interface BuildRichtextExtensionsOptions {
11
+ textStyles?: RichtextTextStyle[];
12
+ blockRenderMode?: "chip" | "onPage";
13
+ }
14
+ declare module "@tiptap/extension-image" {
15
+ interface SetImageOptions {
16
+ mediaId?: string | null;
17
+ }
18
+ }
19
+ export declare function buildRichtextExtensions(options?: BuildRichtextExtensionsOptions): Extensions;
@@ -0,0 +1,56 @@
1
+ import StarterKit from "@tiptap/starter-kit";
2
+ import Image from "@tiptap/extension-image";
3
+ import Link from "@tiptap/extension-link";
4
+ // tiptap 3.31 ships table's row/header/cell as named exports of this ONE
5
+ // package (not the separate @tiptap/extension-table-row/-cell/-header
6
+ // packages older tiptap majors used) — no extra dependencies needed.
7
+ import { Table, TableRow, TableHeader, TableCell } from "@tiptap/extension-table";
8
+ import { TextStyleClass } from "./text-style-class.js";
9
+ import { KardalumBlock, KardalumBlockOnPage } from "./kardalum-block.js";
10
+ export { TextStyleClass } from "./text-style-class.js";
11
+ export { KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, } from "./kardalum-block.js";
12
+ // The media-library image node (S197 spec §3 "Content shape"): `mediaId`
13
+ // is the reference the server resolves at render/edit time, never a raw
14
+ // pasted URL — `src`/`alt` (the base extension's own attrs) are what the
15
+ // editor shows once resolved, kept in sync by whichever mount inserts the
16
+ // image (this package's toolbar today; the on-page iframe editor later).
17
+ const KardalumImage = Image.extend({
18
+ name: "image",
19
+ addAttributes() {
20
+ return {
21
+ ...this.parent?.(),
22
+ mediaId: { default: null },
23
+ };
24
+ },
25
+ });
26
+ // THE shared TipTap extension set (S197 spec §3: "one TipTap editor
27
+ // definition, mounted two ways"). This package's form-view editor
28
+ // (rich-text-view.tsx) consumes it today; the on-page iframe editor (a
29
+ // later task, spec §6.3 — a vanilla @tiptap/core instance, no React)
30
+ // consumes it unchanged. A mount-specific need (a bubble menu, an insert
31
+ // popover) belongs in that mount's own UI layer, never forked in here.
32
+ export function buildRichtextExtensions(options = {}) {
33
+ const { blockRenderMode = "chip" } = options;
34
+ return [
35
+ // StarterKit bundles its own Link internally (tiptap 3.31) — disabled
36
+ // here so this package's own Link instance (prompt-free popover input,
37
+ // spec-listed as its own extension) is the only one registered; two
38
+ // instances of the same mark name throws.
39
+ StarterKit.configure({ link: false }),
40
+ Link.configure({ openOnClick: false, autolink: true }),
41
+ KardalumImage,
42
+ TextStyleClass,
43
+ blockRenderMode === "onPage" ? KardalumBlockOnPage : KardalumBlock,
44
+ // Registered as its own four-node set (S197 Task 11: the on-page
45
+ // insert menu's "Table" row needs a real `insertTable` command on
46
+ // BOTH mounts — form-view and the vanilla iframe editor — since this
47
+ // is the one shared extension list both consume). `resizable: false`
48
+ // — column dragging needs floating-ui-style pointer tracking this
49
+ // project doesn't wire up anywhere yet; a fixed 3x3 grid (the insert
50
+ // menu's only entry point) needs none of that.
51
+ Table.configure({ resizable: false }),
52
+ TableRow,
53
+ TableHeader,
54
+ TableCell,
55
+ ];
56
+ }
@@ -0,0 +1,24 @@
1
+ export type BlockParamType = "text" | "textarea" | "number" | "boolean" | "image" | "choice";
2
+ export interface BlockParamSpec {
3
+ key: string;
4
+ type: BlockParamType;
5
+ label: string;
6
+ options?: string[];
7
+ }
8
+ export interface BlockListing {
9
+ alias: string;
10
+ name: string;
11
+ params: BlockParamSpec[];
12
+ }
13
+ export declare function defaultBlockParams(params: BlockParamSpec[]): Record<string, unknown>;
14
+ export interface UseBlockListingsResult {
15
+ listings: BlockListing[];
16
+ loading: boolean;
17
+ error: string | null;
18
+ }
19
+ export declare function useBlockListings(): UseBlockListingsResult;
20
+ export interface BlockInsertMenuProps {
21
+ onInsert: (listing: BlockListing) => void;
22
+ onClose: () => void;
23
+ }
24
+ export declare function BlockInsertMenu({ onInsert, onClose }: BlockInsertMenuProps): import("react").JSX.Element;