@kardalum/plugin-sdk 0.0.0-stage → 0.16.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 (332) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/LICENSE +202 -0
  3. package/README.md +80 -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 +29 -0
  15. package/dist/capabilities.js +67 -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 +94 -0
  40. package/dist/license-verdict-keys.d.ts +18 -0
  41. package/dist/license-verdict-keys.js +26 -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 +476 -0
  47. package/dist/manifest-schema.js +823 -0
  48. package/dist/manifest.d.ts +611 -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 +447 -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 +82 -0
  55. package/dist/plugin-context.js +77 -0
  56. package/dist/plugin-screen-context.d.ts +71 -0
  57. package/dist/plugin-screen-context.js +41 -0
  58. package/dist/read-all-pages.d.ts +23 -0
  59. package/dist/read-all-pages.js +30 -0
  60. package/dist/register-built-ins.d.ts +1 -0
  61. package/dist/register-built-ins.js +41 -0
  62. package/dist/registry.d.ts +4 -0
  63. package/dist/registry.js +17 -0
  64. package/dist/rendition-eligibility.d.ts +24 -0
  65. package/dist/rendition-eligibility.js +40 -0
  66. package/dist/richtext/block-panel.d.ts +27 -0
  67. package/dist/richtext/block-panel.js +232 -0
  68. package/dist/richtext/extensions.d.ts +19 -0
  69. package/dist/richtext/extensions.js +56 -0
  70. package/dist/richtext/insert-menu.d.ts +24 -0
  71. package/dist/richtext/insert-menu.js +142 -0
  72. package/dist/richtext/kardalum-block.d.ts +33 -0
  73. package/dist/richtext/kardalum-block.js +282 -0
  74. package/dist/richtext/style-listbox.d.ts +10 -0
  75. package/dist/richtext/style-listbox.js +69 -0
  76. package/dist/richtext/text-style-class.d.ts +18 -0
  77. package/dist/richtext/text-style-class.js +36 -0
  78. package/dist/simple-storage-value-provider.d.ts +9 -0
  79. package/dist/simple-storage-value-provider.js +96 -0
  80. package/dist/structured-storage-types.d.ts +61 -0
  81. package/dist/structured-storage-types.js +11 -0
  82. package/dist/tailwind.d.ts +1 -0
  83. package/dist/tailwind.js +5 -0
  84. package/dist/tokens/system-dark.css +75 -0
  85. package/dist/tokens/tokens.css +239 -0
  86. package/dist/tokens/tokens.json +212 -0
  87. package/dist/tokens.d.ts +1 -0
  88. package/dist/tokens.js +11 -0
  89. package/dist/ui-entry.d.ts +5 -0
  90. package/dist/ui-entry.js +42 -0
  91. package/dist/views/content-list-preview.d.ts +1 -0
  92. package/dist/views/content-list-preview.js +14 -0
  93. package/dist/views/content-list-settings-view.d.ts +1 -0
  94. package/dist/views/content-list-settings-view.js +97 -0
  95. package/dist/views/content-list-view.d.ts +19 -0
  96. package/dist/views/content-list-view.js +248 -0
  97. package/dist/views/crop-view.d.ts +55 -0
  98. package/dist/views/crop-view.js +161 -0
  99. package/dist/views/date-range-view.d.ts +6 -0
  100. package/dist/views/date-range-view.js +55 -0
  101. package/dist/views/file-upload-view.d.ts +43 -0
  102. package/dist/views/file-upload-view.js +104 -0
  103. package/dist/views/html-code-editor.d.ts +10 -0
  104. package/dist/views/html-code-editor.js +101 -0
  105. package/dist/views/html-view.d.ts +3 -0
  106. package/dist/views/html-view.js +53 -0
  107. package/dist/views/image-view.d.ts +3 -0
  108. package/dist/views/image-view.js +372 -0
  109. package/dist/views/rich-text-view.d.ts +2 -0
  110. package/dist/views/rich-text-view.js +429 -0
  111. package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
  112. package/node_modules/@kardalum/api-schemas/README.md +56 -0
  113. package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
  114. package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
  115. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +17 -0
  116. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +25 -0
  117. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +93 -0
  118. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +88 -0
  119. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
  120. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
  121. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
  122. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
  123. package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
  124. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +542 -0
  126. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +357 -0
  127. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
  128. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
  129. package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
  130. package/node_modules/@kardalum/api-schemas/dist/content-path.js +260 -0
  131. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
  132. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
  133. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +152 -0
  134. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
  135. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
  136. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
  137. package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
  138. package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
  139. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +352 -0
  140. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +133 -0
  141. package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
  142. package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
  143. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +37 -0
  144. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
  145. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
  146. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
  147. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +298 -0
  148. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
  149. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
  150. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
  151. package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
  152. package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
  153. package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
  154. package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
  155. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +113 -0
  156. package/node_modules/@kardalum/api-schemas/dist/index.js +64 -0
  157. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
  158. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
  159. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
  160. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
  161. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +682 -0
  162. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +269 -0
  163. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +177 -0
  164. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +222 -0
  165. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
  166. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
  167. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
  168. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
  169. package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
  170. package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
  171. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
  172. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
  173. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
  174. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
  175. package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
  176. package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
  177. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
  178. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +249 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +84 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +172 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +196 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
  193. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
  194. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
  195. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +391 -0
  196. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +413 -0
  197. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +29 -0
  198. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +100 -0
  199. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
  200. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
  201. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
  202. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
  203. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
  204. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
  205. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +314 -0
  206. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +338 -0
  207. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
  208. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
  209. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
  210. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
  211. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
  212. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
  213. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +96 -0
  214. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +75 -0
  215. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
  216. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
  217. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
  218. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
  219. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +138 -0
  220. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +105 -0
  221. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
  222. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
  223. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +47 -0
  224. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +27 -0
  225. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
  226. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
  227. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
  228. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
  229. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
  230. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
  231. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
  232. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
  233. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +97 -0
  234. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +73 -0
  235. package/node_modules/@kardalum/api-schemas/package.json +35 -0
  236. package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
  237. package/node_modules/@kardalum/design-tokens/README.md +29 -0
  238. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
  239. package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
  240. package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
  241. package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
  242. package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
  243. package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
  244. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
  245. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
  246. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
  247. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
  248. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
  249. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
  250. package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
  251. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
  252. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
  253. package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
  254. package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
  255. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
  256. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
  257. package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
  258. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
  259. package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
  260. package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
  261. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
  262. package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
  263. package/node_modules/@kardalum/design-tokens/package.json +42 -0
  264. package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
  265. package/node_modules/@kardalum/plugin-package/README.md +71 -0
  266. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
  267. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
  268. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
  269. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
  270. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
  271. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
  272. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
  273. package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
  274. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
  275. package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
  276. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
  277. package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
  278. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -0
  279. package/node_modules/@kardalum/plugin-package/dist/index.js +8 -0
  280. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
  281. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
  282. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
  283. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
  284. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
  285. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
  286. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -0
  287. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +57 -0
  288. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +43 -0
  289. package/node_modules/@kardalum/plugin-package/dist/types.js +15 -0
  290. package/node_modules/@kardalum/plugin-package/package.json +54 -0
  291. package/node_modules/@kardalum/ui/LICENSE +202 -0
  292. package/node_modules/@kardalum/ui/README.md +35 -0
  293. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
  294. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
  295. package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
  296. package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
  297. package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
  298. package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
  299. package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
  300. package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
  301. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
  302. package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
  303. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
  304. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
  305. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
  306. package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
  307. package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
  308. package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
  309. package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
  310. package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
  311. package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
  312. package/node_modules/@kardalum/ui/dist/components/property-field.js +89 -0
  313. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
  314. package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
  315. package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
  316. package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
  317. package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
  318. package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
  319. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
  320. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
  321. package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
  322. package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
  323. package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
  324. package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
  325. package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
  326. package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
  327. package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
  328. package/node_modules/@kardalum/ui/dist/index.js +18 -0
  329. package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
  330. package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
  331. package/node_modules/@kardalum/ui/package.json +63 -0
  332. package/package.json +146 -4
@@ -0,0 +1,429 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { EditorContent, useEditor } from "@tiptap/react";
4
+ import { NodeSelection } from "@tiptap/pm/state";
5
+ import { Code2, Image as ImageIcon, Link as LinkIcon, List as ListIcon, Quote as QuoteIcon } from "lucide-react";
6
+ import { cn, usePropertyFieldControl } from "@kardalum/ui";
7
+ import { MANAGE_API, usePluginApi, usePluginValue } from "../plugin-context.js";
8
+ import { buildRichtextExtensions } from "../richtext/extensions.js";
9
+ import { MediaPicker } from "../media/media-picker.js";
10
+ import { BlockInsertMenu, defaultBlockParams } from "../richtext/insert-menu.js";
11
+ import { BlockPanel, BlockPreviewPopover } from "../richtext/block-panel.js";
12
+ import { StyleListbox } from "../richtext/style-listbox.js";
13
+ // The rich content editor (S197 spec §3): one TipTap editor definition
14
+ // (buildRichtextExtensions), mounted here with a fixed compact toolbar per
15
+ // the mockup's screen 3 — the same commands the on-page bubble toolbar
16
+ // offers, plus "Edit on page" (a later task wires the navigation; this
17
+ // task ships it as a disabled placeholder, spec-listed toolbar chrome).
18
+ //
19
+ // Tailwind's base reset strips default heading/list/quote styling, so a
20
+ // few targeted descendant overrides keep formatting visually
21
+ // distinguishable without pulling in a typography plugin just for this.
22
+ const CONTENT_CLASSES = "text-sm text-text-primary [&_h1]:text-xl [&_h1]:font-bold [&_h2]:text-lg [&_h2]:font-bold " +
23
+ "[&_h3]:font-bold [&_strong]:font-bold [&_em]:italic [&_ul]:list-disc [&_ul]:ps-6 " +
24
+ "[&_ol]:list-decimal [&_ol]:ps-6 [&_p]:min-h-[1.25em] " +
25
+ "[&_a]:text-primary-700 [&_a]:underline " +
26
+ "[&_blockquote]:border-s-2 [&_blockquote]:border-border-default [&_blockquote]:ps-3 [&_blockquote]:italic [&_blockquote]:text-text-secondary";
27
+ // Source view (Item 3, S197 QA-wave B): a light prettification, not a real
28
+ // formatter — no dependency is worth pulling in just to indent nested
29
+ // markup. TipTap's own getHTML() emits one unbroken string with no
30
+ // whitespace between block elements at all (`<p>a</p><p>b</p>`); parsing it
31
+ // back and re-joining each TOP-LEVEL node's own outerHTML with a newline is
32
+ // enough to make screen-3-style content ("a paragraph, a block chip's div,
33
+ // another paragraph") scannable, without touching what's inside any one
34
+ // block (a kardalumBlock's own data-params JSON stays on one line, which is
35
+ // exactly what should NOT get reformatted).
36
+ function prettifyHtml(html) {
37
+ const doc = new DOMParser().parseFromString(`<body>${html}</body>`, "text/html");
38
+ return Array.from(doc.body.childNodes)
39
+ .map((node) => (node instanceof Element ? node.outerHTML : (node.textContent ?? "")))
40
+ .map((chunk) => chunk.trim())
41
+ .filter((chunk) => chunk.length > 0)
42
+ .join("\n");
43
+ }
44
+ function useTextStyles() {
45
+ const fetchApi = usePluginApi();
46
+ const [styles, setStyles] = useState([]);
47
+ const [loading, setLoading] = useState(true);
48
+ useEffect(() => {
49
+ let cancelled = false;
50
+ setLoading(true);
51
+ fetchApi(`${MANAGE_API}/render/text-styles`)
52
+ .then(async (response) => {
53
+ // The endpoint doesn't exist yet (a later task ships it) — a 404,
54
+ // any other error status, and a genuinely empty declared list all
55
+ // render the same "no styles" state, so treat them identically.
56
+ if (!response.ok)
57
+ throw new Error(`Failed to load text styles (${response.status})`);
58
+ const body = await response.json();
59
+ if (!cancelled)
60
+ setStyles(Array.isArray(body) ? body : []);
61
+ })
62
+ .catch(() => {
63
+ if (!cancelled)
64
+ setStyles([]);
65
+ })
66
+ .finally(() => {
67
+ if (!cancelled)
68
+ setLoading(false);
69
+ });
70
+ return () => {
71
+ cancelled = true;
72
+ };
73
+ }, [fetchApi]);
74
+ return { styles, loading };
75
+ }
76
+ // Roving tabindex over the toolbar's top-level buttons (WAI-ARIA toolbar
77
+ // pattern): one stop in the page Tab order, arrow keys move focus among
78
+ // buttons, Home/End jump to the ends. Disabled buttons (Block, Edit on
79
+ // page — both placeholders this task) are skipped entirely, matching
80
+ // native disabled-control behavior — they can never hold focus.
81
+ function useToolbarRovingTabIndex(focusableKeys) {
82
+ const [activeKey, setActiveKey] = useState(focusableKeys[0] ?? null);
83
+ const refs = useRef(new Map());
84
+ useEffect(() => {
85
+ if (activeKey !== null && !focusableKeys.includes(activeKey)) {
86
+ setActiveKey(focusableKeys[0] ?? null);
87
+ }
88
+ }, [focusableKeys, activeKey]);
89
+ function registerRef(key) {
90
+ return (el) => {
91
+ if (el)
92
+ refs.current.set(key, el);
93
+ else
94
+ refs.current.delete(key);
95
+ };
96
+ }
97
+ function focusIndex(index) {
98
+ const key = focusableKeys[index];
99
+ if (key === undefined)
100
+ return;
101
+ setActiveKey(key);
102
+ refs.current.get(key)?.focus();
103
+ }
104
+ function handleKeyDown(event) {
105
+ if (focusableKeys.length === 0)
106
+ return;
107
+ const currentIndex = activeKey !== null ? focusableKeys.indexOf(activeKey) : 0;
108
+ let nextIndex = currentIndex;
109
+ switch (event.key) {
110
+ case "ArrowRight":
111
+ nextIndex = (currentIndex + 1) % focusableKeys.length;
112
+ break;
113
+ case "ArrowLeft":
114
+ nextIndex = (currentIndex - 1 + focusableKeys.length) % focusableKeys.length;
115
+ break;
116
+ case "Home":
117
+ nextIndex = 0;
118
+ break;
119
+ case "End":
120
+ nextIndex = focusableKeys.length - 1;
121
+ break;
122
+ default:
123
+ return;
124
+ }
125
+ event.preventDefault();
126
+ focusIndex(nextIndex);
127
+ }
128
+ return { activeKey, setActiveKey, registerRef, handleKeyDown };
129
+ }
130
+ function ToolbarButton({ itemKey, label, ariaLabel, title, active, disabled, expanded, hasPopup, isRovingActive, registerRef, onFocus, onClick, }) {
131
+ return (_jsx("button", { ref: registerRef, type: "button", "data-testid": `rt-toolbar-${itemKey}`, "aria-label": ariaLabel, "aria-pressed": active, "aria-haspopup": hasPopup, "aria-expanded": hasPopup ? expanded : undefined, title: title, disabled: disabled, tabIndex: disabled ? -1 : isRovingActive ? 0 : -1, onFocus: onFocus, onClick: onClick, className: cn("inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium text-text-secondary hover:bg-background-hover disabled:pointer-events-none disabled:opacity-50", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600", active && "bg-primary-100 text-primary-800"), children: label }));
132
+ }
133
+ function ToolbarSeparator() {
134
+ return _jsx("span", { "aria-hidden": "true", className: "mx-1 inline-block h-4 w-px bg-border-default" });
135
+ }
136
+ // Prompt-free link input (spec-listed toolbar command): a small popover
137
+ // form instead of window.prompt(), so the flow stays keyboard/a11y
138
+ // reachable and themeable, unlike a native prompt dialog.
139
+ function LinkPopover({ initialHref, hasLink, onApply, onRemove, onClose }) {
140
+ const [href, setHref] = useState(initialHref);
141
+ const inputRef = useRef(null);
142
+ useEffect(() => {
143
+ inputRef.current?.focus();
144
+ inputRef.current?.select();
145
+ }, []);
146
+ return (_jsxs("div", { className: "w-64 p-2", onKeyDown: (event) => {
147
+ if (event.key === "Escape") {
148
+ event.preventDefault();
149
+ onClose();
150
+ }
151
+ }, children: [_jsx("label", { htmlFor: "rt-link-href", className: "mb-1 block text-xs font-medium text-text-secondary", children: "Link URL" }), _jsx("input", { ref: inputRef, id: "rt-link-href", type: "url", value: href, placeholder: "https://", onChange: (event) => setHref(event.target.value), onKeyDown: (event) => {
152
+ if (event.key === "Enter") {
153
+ event.preventDefault();
154
+ if (href.trim())
155
+ onApply(href.trim());
156
+ }
157
+ }, className: "mb-2 w-full rounded-md border border-border-default bg-background-elevated px-2 py-1 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600" }), _jsxs("div", { className: "flex justify-end gap-2", children: [hasLink && (_jsx("button", { type: "button", onClick: onRemove, className: "rounded-md px-2 py-1 text-xs text-danger-600 hover:bg-background-hover", children: "Remove link" })), _jsx("button", { type: "button", disabled: !href.trim(), onClick: () => onApply(href.trim()), className: "rounded-md bg-primary-600 px-2 py-1 text-xs font-medium text-white hover:bg-primary-700 disabled:opacity-50", children: "Apply" })] })] }));
158
+ }
159
+ // S197 Task 12: bubbles up so a mount that HAS routing (content-editor.tsx,
160
+ // admin-ui) can navigate to /content/:id/edit-on-page — same "plain DOM
161
+ // CustomEvent, no framework-specific callback" idiom the block chip's own
162
+ // "preview" button already uses (kardalum-block.ts's own doc comment), for
163
+ // the identical reason: this package has no router of its own, and the
164
+ // mount that does is a separate React tree entirely (a plugin view has no
165
+ // ambient route context, and even ContentEditor itself renders this view
166
+ // with a fixed, prop-less signature).
167
+ const EDIT_ON_PAGE_EVENT = "kardalum:edit-on-page";
168
+ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
169
+ const { styles: textStyles, loading: textStylesLoading } = useTextStyles();
170
+ const [openPopover, setOpenPopover] = useState(null);
171
+ const [pickerOpen, setPickerOpen] = useState(false);
172
+ const activeStyleKey = editor.getAttributes("textStyleClass").styleKey ?? null;
173
+ const allItemKeys = [
174
+ "bold",
175
+ "italic",
176
+ "link",
177
+ "h2",
178
+ "h3",
179
+ "blockquote",
180
+ "bulletList",
181
+ "style",
182
+ "image",
183
+ "block",
184
+ "source",
185
+ "editOnPage",
186
+ ];
187
+ // Every other command is disabled in source mode (editing raw HTML has no
188
+ // "toggle bold" equivalent) — Source itself is the only tab stop then, so
189
+ // the roving tabindex's own focusable set shrinks to match, same as the
190
+ // doc comment above useToolbarRovingTabIndex describes for disabled items.
191
+ const focusableKeys = sourceMode ? ["source"] : allItemKeys;
192
+ const { activeKey, setActiveKey, registerRef, handleKeyDown } = useToolbarRovingTabIndex(focusableKeys);
193
+ function closePopover() {
194
+ setOpenPopover(null);
195
+ }
196
+ // Entering source mode with a popover open would otherwise leave it
197
+ // visually stuck open behind a now-disabled trigger button.
198
+ useEffect(() => {
199
+ if (sourceMode) {
200
+ setOpenPopover(null);
201
+ setPickerOpen(false);
202
+ }
203
+ }, [sourceMode]);
204
+ // The picked/uploaded item (S197 Task 2 contract) becomes a mediaId-backed
205
+ // image node — src is the item's path-relative downloadUrl, alt starts
206
+ // empty (there is no filename to fall back to once MediaPicker reports
207
+ // only {id, downloadUrl, alt}).
208
+ function handleMediaPick(item) {
209
+ editor.chain().focus().setImage({ src: item.downloadUrl, alt: item.alt ?? "", mediaId: item.id }).run();
210
+ setPickerOpen(false);
211
+ }
212
+ const linkAttrs = editor.getAttributes("link");
213
+ return (_jsxs("div", { role: "toolbar", "aria-label": "Formatting", "aria-orientation": "horizontal", onKeyDown: handleKeyDown,
214
+ // gap-1/p-2 (not the mockup's literal .15rem/.4rem: the token scale's
215
+ // nearest whole steps; gap-0.5/p-1.5 generate no CSS at all under this
216
+ // project's replaced spacing scale, see the admin UI conventions).
217
+ className: "relative flex flex-wrap items-center gap-1 border-b border-border-default bg-background-subtle p-2", children: [_jsx(ToolbarButton, { itemKey: "bold", label: _jsx("span", { className: "font-bold", children: "B" }), ariaLabel: "Bold", active: editor.isActive("bold"), disabled: sourceMode, isRovingActive: activeKey === "bold", registerRef: registerRef("bold"), onFocus: () => setActiveKey("bold"), onClick: () => editor.chain().focus().toggleBold().run() }), _jsx(ToolbarButton, { itemKey: "italic", label: _jsx("span", { className: "italic", children: "I" }), ariaLabel: "Italic", active: editor.isActive("italic"), disabled: sourceMode, isRovingActive: activeKey === "italic", registerRef: registerRef("italic"), onFocus: () => setActiveKey("italic"), onClick: () => editor.chain().focus().toggleItalic().run() }), _jsxs("div", { className: "relative", children: [_jsx(ToolbarButton, { itemKey: "link", label: _jsxs(_Fragment, { children: [_jsx(LinkIcon, { "aria-hidden": "true", className: "size-4" }), "Link"] }), active: editor.isActive("link"), disabled: sourceMode, hasPopup: "dialog", expanded: openPopover === "link", isRovingActive: activeKey === "link", registerRef: registerRef("link"), onFocus: () => setActiveKey("link"), onClick: () => setOpenPopover((current) => (current === "link" ? null : "link")) }), openPopover === "link" && (_jsx("div", { className: "absolute start-0 top-full z-10 mt-1 rounded-md border border-border-default bg-background-elevated shadow-lg", children: _jsx(LinkPopover, { initialHref: linkAttrs.href ?? "", hasLink: editor.isActive("link"), onApply: (href) => {
218
+ editor.chain().focus().extendMarkRange("link").setLink({ href }).run();
219
+ closePopover();
220
+ }, onRemove: () => {
221
+ editor.chain().focus().unsetLink().run();
222
+ closePopover();
223
+ }, onClose: closePopover }) }))] }), _jsx(ToolbarSeparator, {}), _jsx(ToolbarButton, { itemKey: "h2", label: "H2", ariaLabel: "Heading 2", active: editor.isActive("heading", { level: 2 }), disabled: sourceMode, isRovingActive: activeKey === "h2", registerRef: registerRef("h2"), onFocus: () => setActiveKey("h2"), onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run() }), _jsx(ToolbarButton, { itemKey: "h3", label: "H3", ariaLabel: "Heading 3", active: editor.isActive("heading", { level: 3 }), disabled: sourceMode, isRovingActive: activeKey === "h3", registerRef: registerRef("h3"), onFocus: () => setActiveKey("h3"), onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run() }), _jsx(ToolbarButton, { itemKey: "blockquote", label: _jsx(QuoteIcon, { "aria-hidden": "true", className: "size-4" }), ariaLabel: "Quote", active: editor.isActive("blockquote"), disabled: sourceMode, isRovingActive: activeKey === "blockquote", registerRef: registerRef("blockquote"), onFocus: () => setActiveKey("blockquote"), onClick: () => editor.chain().focus().toggleBlockquote().run() }), _jsx(ToolbarButton, { itemKey: "bulletList", label: _jsxs(_Fragment, { children: [_jsx(ListIcon, { "aria-hidden": "true", className: "size-4" }), "List"] }), ariaLabel: "Bulleted list", active: editor.isActive("bulletList"), disabled: sourceMode, isRovingActive: activeKey === "bulletList", registerRef: registerRef("bulletList"), onFocus: () => setActiveKey("bulletList"), onClick: () => editor.chain().focus().toggleBulletList().run() }), _jsx(ToolbarSeparator, {}), _jsxs("div", { className: "relative", children: [_jsx(ToolbarButton, { itemKey: "style", label: "Aa Style \u25BE", disabled: sourceMode, hasPopup: "listbox", expanded: openPopover === "style", isRovingActive: activeKey === "style", registerRef: registerRef("style"), onFocus: () => setActiveKey("style"), onClick: () => setOpenPopover((current) => (current === "style" ? null : "style")) }), openPopover === "style" && (_jsx("div", { className: "absolute start-0 top-full z-10 mt-1 rounded-md border border-border-default bg-background-elevated shadow-lg", children: _jsx(StyleListbox, { styles: textStyles, loading: textStylesLoading, activeStyleKey: activeStyleKey, onSelect: (styleKey) => editor.chain().focus().setTextStyle(styleKey).run(), onClear: () => editor.chain().focus().unsetTextStyle().run(), onClose: closePopover }) }))] }), _jsx(ToolbarButton, { itemKey: "image", label: _jsxs(_Fragment, { children: [_jsx(ImageIcon, { "aria-hidden": "true", className: "size-4" }), "Image"] }), disabled: sourceMode, hasPopup: "dialog", expanded: pickerOpen, isRovingActive: activeKey === "image", registerRef: registerRef("image"), onFocus: () => setActiveKey("image"), onClick: () => setPickerOpen(true) }), pickerOpen && _jsx(MediaPicker, { collectAlt: true, onPick: handleMediaPick, onClose: () => setPickerOpen(false) }), _jsxs("div", { className: "relative", children: [_jsx(ToolbarButton, { itemKey: "block", label: "\u25EB Block \u25BE", disabled: sourceMode, hasPopup: "listbox", expanded: openPopover === "block", isRovingActive: activeKey === "block", registerRef: registerRef("block"), onFocus: () => setActiveKey("block"), onClick: () => setOpenPopover((current) => (current === "block" ? null : "block")) }), openPopover === "block" && (_jsx("div", { className: "absolute start-0 top-full z-10 mt-1 rounded-md border border-border-default bg-background-elevated shadow-lg", children: _jsx(BlockInsertMenu, { onInsert: (listing) => {
224
+ editor
225
+ .chain()
226
+ .focus()
227
+ .insertContent({
228
+ type: "kardalumBlock",
229
+ attrs: { partial: listing.alias, params: defaultBlockParams(listing.params) },
230
+ })
231
+ .run();
232
+ }, onClose: closePopover }) }))] }), _jsx(ToolbarSeparator, {}), _jsx(ToolbarButton, { itemKey: "source", label: _jsxs(_Fragment, { children: [_jsx(Code2, { "aria-hidden": "true", className: "size-4" }), "Source"] }), ariaLabel: "Toggle HTML source view", active: sourceMode, isRovingActive: activeKey === "source", registerRef: registerRef("source"), onFocus: () => setActiveKey("source"), onClick: onToggleSource }), _jsx(ToolbarSeparator, {}), _jsx(ToolbarButton, { itemKey: "editOnPage", label: _jsx("span", { className: "text-primary-700", children: "\u2922 Edit on page" }), disabled: sourceMode, isRovingActive: activeKey === "editOnPage", registerRef: registerRef("editOnPage"), onFocus: () => setActiveKey("editOnPage"), onClick: () => containerRef.current?.dispatchEvent(new CustomEvent(EDIT_ON_PAGE_EVENT, { bubbles: true })) })] }));
233
+ }
234
+ function RichTextEditor({ editable }) {
235
+ const { value, onChange } = usePluginValue();
236
+ // Guards the sync effect below against reacting to the update it just
237
+ // caused itself — without this, every keystroke would round-trip
238
+ // through setContent and reset the cursor.
239
+ const isInternalUpdate = useRef(false);
240
+ // The host renders this inside a PropertyField, but TipTap's editable
241
+ // surface is a contenteditable <div role="textbox"> — not a labelable
242
+ // element, so the field's <label for> can never name it. editorProps
243
+ // .attributes is the only way to get aria onto that exact node, so the
244
+ // field's identity is stamped there instead (WCAG 4.1.2; axe reports
245
+ // the gap as `aria-input-field-name`).
246
+ const field = usePropertyFieldControl();
247
+ const editor = useEditor({
248
+ extensions: buildRichtextExtensions(),
249
+ content: value ?? "",
250
+ editable,
251
+ // @tiptap/react 3.31 no longer re-renders the owning component on every
252
+ // transaction by default — without this the toolbar's isActive()/
253
+ // getAttributes() reads (bold state, the active heading level, the
254
+ // current link href) would go stale the instant the selection moves.
255
+ shouldRerenderOnTransaction: true,
256
+ editorProps: {
257
+ attributes: {
258
+ // ProseMirror's editable surface is a plain contenteditable div
259
+ // with NO role of its own — which makes it a `generic` element,
260
+ // and aria-labelledby is *prohibited* on generic (axe flags the
261
+ // field's own label as "needs review": aria-prohibited-attr). The
262
+ // element genuinely IS a multi-line text field, so declaring that
263
+ // is both the honest mapping and what makes the name legitimate.
264
+ role: "textbox",
265
+ "aria-multiline": "true",
266
+ ...(field.id ? { id: field.id } : {}),
267
+ ...(field["aria-labelledby"] ? { "aria-labelledby": field["aria-labelledby"] } : {}),
268
+ ...(field["aria-describedby"] ? { "aria-describedby": field["aria-describedby"] } : {}),
269
+ ...(field["aria-invalid"] ? { "aria-invalid": "true" } : {}),
270
+ },
271
+ },
272
+ onUpdate: ({ editor: updated }) => {
273
+ const json = updated.getJSON();
274
+ // Non-edit 'update' events must not arm the echo guard below (they
275
+ // would swallow the next genuine external value change). The one
276
+ // programmatic emitter here — setEditable — is silenced at the
277
+ // source (emitUpdate: false, see the effect below), so any doc that
278
+ // still equals the external value is TipTap's own construction-time
279
+ // normalization pass, not an edit.
280
+ if (JSON.stringify(json) === JSON.stringify(value ?? {}))
281
+ return;
282
+ isInternalUpdate.current = true;
283
+ onChange(json);
284
+ },
285
+ });
286
+ // Item 3 (S197 QA-wave B): the HTML source view. `null` means "not in
287
+ // source mode" — the textarea's own in-progress edits live here, entirely
288
+ // separate from `value`/onChange, until the toggle-back below commits
289
+ // them. Typing in source deliberately does NOT flow through onChange (the
290
+ // spec's own choice of the two offered): a half-typed `<p` mid-edit is not
291
+ // valid content to hand the rest of the app as "the current value," and
292
+ // there is no debounce that makes an in-progress HTML string safe to
293
+ // parse. Commit happens on toggling back to the rich view; blurring the
294
+ // textarea without toggling back does NOT commit (the other choice the
295
+ // spec allows) — staying in source mode until the user explicitly asks to
296
+ // leave it means a click elsewhere never silently discards or applies an
297
+ // edit the user hasn't finished. Declared before the value-sync effect
298
+ // below (not just before its own toggle handler) because that effect
299
+ // needs to read the refs declared here.
300
+ const [sourceHtml, setSourceHtml] = useState(null);
301
+ const sourceMode = sourceHtml !== null;
302
+ // The HTML sourceHtml was last (re-)seeded with — sourceHtml !== this
303
+ // means the user has typed something, i.e. the buffer is "dirty". Used
304
+ // only by the external value-sync effect below to decide whether an
305
+ // external change can safely replace the buffer or must leave it (and
306
+ // the user's in-progress edits) alone. A ref, not state: nothing here
307
+ // needs to re-render on its own.
308
+ const sourceSeedRef = useRef(null);
309
+ // Whether an external value change arrived while the buffer was dirty —
310
+ // shown as a small notice; cleared on toggle-back (the buffer commits,
311
+ // resolving the conflict) or on a later external change against a
312
+ // by-then-pristine buffer (re-seeded silently instead).
313
+ const [sourceStale, setSourceStale] = useState(false);
314
+ // Ref mirrors of sourceMode/sourceHtml so the sync effect below can read
315
+ // their CURRENT values without needing them in its dependency array
316
+ // (which would otherwise re-run that effect on every keystroke).
317
+ const sourceModeRef = useRef(sourceMode);
318
+ sourceModeRef.current = sourceMode;
319
+ const sourceHtmlRef = useRef(sourceHtml);
320
+ sourceHtmlRef.current = sourceHtml;
321
+ function handleToggleSource() {
322
+ if (!editor)
323
+ return;
324
+ if (sourceHtml === null) {
325
+ const seeded = prettifyHtml(editor.getHTML());
326
+ sourceSeedRef.current = seeded;
327
+ setSourceHtml(seeded);
328
+ setSourceStale(false);
329
+ return;
330
+ }
331
+ // setContent's default emitUpdate: true fires the same onUpdate path a
332
+ // live edit would (JSON.stringify guard included) — no separate commit
333
+ // plumbing needed, this is the exact mechanism the external value-sync
334
+ // effect below already relies on. If an external change arrived while
335
+ // this buffer was dirty (sourceStale), this is the "informed overwrite"
336
+ // the notice warned about — the user's buffer wins, same as any other
337
+ // edit made after seeing the notice.
338
+ editor.commands.setContent(sourceHtml);
339
+ sourceSeedRef.current = null;
340
+ setSourceHtml(null);
341
+ setSourceStale(false);
342
+ }
343
+ useEffect(() => {
344
+ if (!editor)
345
+ return;
346
+ if (isInternalUpdate.current) {
347
+ isInternalUpdate.current = false;
348
+ return;
349
+ }
350
+ const current = JSON.stringify(editor.getJSON());
351
+ const next = JSON.stringify(value ?? {});
352
+ if (current === next)
353
+ return;
354
+ // An external value change while the source textarea is open (review
355
+ // fix, S197 QA-wave B): without this branch, the live editor doc would
356
+ // silently update underneath the still-open textarea, and toggling
357
+ // back would setContent() the STALE buffer over it, re-emitting the
358
+ // stale content as a fresh edit and clobbering the external change.
359
+ // Refs (not state) so this effect doesn't need sourceMode/sourceHtml
360
+ // in its deps — it only needs their CURRENT values when `value`
361
+ // actually changes.
362
+ if (sourceModeRef.current) {
363
+ const pristine = sourceHtmlRef.current === sourceSeedRef.current;
364
+ if (!pristine) {
365
+ // The user has unsaved edits in the buffer — keep them (their
366
+ // choice to make, not this effect's), just flag that leaving
367
+ // source view now will overwrite the external change.
368
+ setSourceStale(true);
369
+ return;
370
+ }
371
+ // No local edits yet — safe to re-seed from the fresh external doc,
372
+ // same as the non-source branch below but keeping the textarea's
373
+ // displayed HTML in sync too.
374
+ editor.commands.setContent(value ?? "");
375
+ const reseeded = prettifyHtml(editor.getHTML());
376
+ sourceSeedRef.current = reseeded;
377
+ setSourceHtml(reseeded);
378
+ setSourceStale(false);
379
+ return;
380
+ }
381
+ editor.commands.setContent(value ?? "");
382
+ }, [value, editor]);
383
+ useEffect(() => {
384
+ // emitUpdate: false — setEditable's unconditional 'update' event is
385
+ // not an edit; silencing it at the source keeps onUpdate's arming
386
+ // logic honest (review fix, Editor.ts:307-313 in @tiptap/core 3.31).
387
+ editor?.setEditable(editable, false);
388
+ }, [editable, editor]);
389
+ // The block chip's "preview ⤢" button (kardalum-block.ts) is plain DOM with
390
+ // no React tree of its own — it dispatches a bubbling
391
+ // "kardalum:preview-block" CustomEvent instead of fetching directly, since
392
+ // only this mount has the authenticated fetchApi and somewhere to render
393
+ // a popover. Listening on the wrapper (rather than threading a callback
394
+ // through buildRichtextExtensions' options) keeps the extension mount-
395
+ // agnostic — a vanilla mount can dispatch/listen for the same event with
396
+ // no React involved either.
397
+ const wrapperRef = useRef(null);
398
+ const [previewRequest, setPreviewRequest] = useState(null);
399
+ useEffect(() => {
400
+ const wrapper = wrapperRef.current;
401
+ if (!wrapper)
402
+ return;
403
+ function handlePreviewRequest(event) {
404
+ const { partial, params, anchor } = event.detail;
405
+ setPreviewRequest({ partial, params, anchorRect: anchor.getBoundingClientRect() });
406
+ }
407
+ wrapper.addEventListener("kardalum:preview-block", handlePreviewRequest);
408
+ return () => wrapper.removeEventListener("kardalum:preview-block", handlePreviewRequest);
409
+ }, []);
410
+ // The param panel (screen 1's right-hand settings panel) is shown exactly
411
+ // while the editor's current selection is a NodeSelection on a
412
+ // kardalumBlock, see block-panel.tsx's doc comment for why that's the
413
+ // right signal rather than separate open/close state.
414
+ const selection = editor?.state.selection;
415
+ const blockSelection = editor && selection instanceof NodeSelection && selection.node.type.name === "kardalumBlock" ? selection : null;
416
+ return (_jsxs("div", { ref: wrapperRef, className: cn(editable && "overflow-hidden rounded-md border border-border-default bg-background-elevated"), children: [_jsxs("div", { inert: editable && Boolean(blockSelection) ? true : undefined, children: [editable && editor && (_jsx(RichTextToolbar, { editor: editor, containerRef: wrapperRef, sourceMode: sourceMode, onToggleSource: handleToggleSource })), sourceMode ? (_jsxs(_Fragment, { children: [sourceStale && (_jsx("div", { role: "alert", "data-testid": "rt-source-stale-notice", className: "border-b border-warning-100 bg-warning-100 px-5 py-2 text-xs text-warning-800", children: "Content changed elsewhere. Leaving source view will overwrite it." })), _jsx("textarea", { "data-testid": "rt-source-textarea", "aria-label": "HTML source", value: sourceHtml, onChange: (event) => setSourceHtml(event.target.value), spellCheck: false, className: "block min-h-72 w-full resize-y border-0 bg-background-elevated px-5 py-4 font-mono text-xs text-text-primary focus-visible:outline-none" })] })) : (_jsx(EditorContent, { editor: editor, className: cn(CONTENT_CLASSES, editable &&
417
+ // min-h-72 (18rem) matches the mockup's .rtbody proportions (S197
418
+ // screen 3) — the editor grows with content past that floor, it
419
+ // never shrinks below a real working height. px-5/py-4 are the
420
+ // token scale's closest steps to the mockup's literal 1.3rem/
421
+ // 1.1rem .rtbody padding (design-tokens has no 1.1/1.3rem step).
422
+ "min-h-72 px-5 py-4 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-600 focus-within:ring-offset-2 focus-within:ring-offset-background-base") }))] }), editable && editor && blockSelection && (_jsx(BlockPanel, { editor: editor, pos: blockSelection.from, partial: blockSelection.node.attrs.partial, params: blockSelection.node.attrs.params ?? {} })), previewRequest && (_jsx(BlockPreviewPopover, { partial: previewRequest.partial, params: previewRequest.params, anchorRect: previewRequest.anchorRect, onClose: () => setPreviewRequest(null) }))] }));
423
+ }
424
+ export function RichTextInputView() {
425
+ return _jsx(RichTextEditor, { editable: true });
426
+ }
427
+ export function RichTextReadOnlyView() {
428
+ return _jsx(RichTextEditor, { editable: false });
429
+ }
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.