@kardalum/plugin-sdk 0.20.0 → 0.21.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 (323) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/admin-section-registry.d.ts +33 -1
  3. package/dist/admin-section-registry.js +67 -0
  4. package/dist/capabilities.js +46 -1
  5. package/dist/consent-entry.d.ts +11 -0
  6. package/dist/consent-entry.js +18 -0
  7. package/dist/content-library.d.ts +17 -0
  8. package/dist/content-list-extensions.d.ts +50 -0
  9. package/dist/content-list-extensions.js +11 -0
  10. package/dist/content-picker/page-picker-sheet.d.ts +2 -0
  11. package/dist/content-picker/page-picker-sheet.js +1 -1
  12. package/dist/content-picker/page-picker.d.ts +18 -0
  13. package/dist/content-picker/page-picker.js +20 -0
  14. package/dist/datatype-validation.js +10 -2
  15. package/dist/datatypes-entry.d.ts +1 -0
  16. package/dist/datatypes-entry.js +2 -0
  17. package/dist/entitlement-types.d.ts +18 -1
  18. package/dist/host-entry.d.ts +7 -1
  19. package/dist/host-entry.js +14 -1
  20. package/dist/index.d.ts +35 -7
  21. package/dist/index.js +46 -5
  22. package/dist/mail.d.ts +6 -2
  23. package/dist/manifest-entry.d.ts +22 -4
  24. package/dist/manifest-entry.js +25 -1
  25. package/dist/manifest-schema.d.ts +570 -31
  26. package/dist/manifest-schema.js +240 -12
  27. package/dist/manifest.d.ts +757 -32
  28. package/dist/manifest.js +8 -4
  29. package/dist/plugin-context.d.ts +47 -0
  30. package/dist/plugin-context.js +27 -0
  31. package/dist/plugin-permissions.d.ts +18 -0
  32. package/dist/plugin-permissions.js +25 -0
  33. package/dist/plugin-screen-context.d.ts +152 -11
  34. package/dist/plugin-screen-context.js +30 -0
  35. package/dist/providers.d.ts +47 -2
  36. package/dist/render-page.d.ts +15 -0
  37. package/dist/render-page.js +20 -0
  38. package/dist/richtext/block-panel.d.ts +12 -1
  39. package/dist/richtext/block-panel.js +27 -21
  40. package/dist/richtext/button-view.d.ts +11 -0
  41. package/dist/richtext/button-view.js +45 -0
  42. package/dist/richtext/content-guard.d.ts +4 -0
  43. package/dist/richtext/content-guard.js +27 -0
  44. package/dist/richtext/editor-handle.d.ts +34 -0
  45. package/dist/richtext/editor-handle.js +225 -0
  46. package/dist/richtext/extensions.d.ts +6 -0
  47. package/dist/richtext/extensions.js +16 -0
  48. package/dist/richtext/insert-menu.d.ts +6 -1
  49. package/dist/richtext/insert-menu.js +38 -18
  50. package/dist/richtext/item-attributes.d.ts +6 -0
  51. package/dist/richtext/item-attributes.js +19 -0
  52. package/dist/richtext/item-panel.d.ts +25 -0
  53. package/dist/richtext/item-panel.js +118 -0
  54. package/dist/richtext/item-view.d.ts +58 -0
  55. package/dist/richtext/item-view.js +172 -0
  56. package/dist/richtext/mark-form.d.ts +10 -0
  57. package/dist/richtext/mark-form.js +38 -0
  58. package/dist/richtext/paste-choice.d.ts +9 -0
  59. package/dist/richtext/paste-choice.js +13 -0
  60. package/dist/richtext/plugin-items.d.ts +72 -0
  61. package/dist/richtext/plugin-items.js +562 -0
  62. package/dist/richtext/plugin-mark-tooltips.d.ts +5 -0
  63. package/dist/richtext/plugin-mark-tooltips.js +44 -0
  64. package/dist/richtext/plugin-toolbar.d.ts +57 -0
  65. package/dist/richtext/plugin-toolbar.js +186 -0
  66. package/dist/richtext/rich-item-icons.d.ts +5 -0
  67. package/dist/richtext/rich-item-icons.js +42 -0
  68. package/dist/richtext/rich-items.d.ts +42 -0
  69. package/dist/richtext/rich-items.js +68 -0
  70. package/dist/richtext/rich-text-view-host.d.ts +24 -0
  71. package/dist/richtext/rich-text-view-host.js +11 -0
  72. package/dist/richtext/toolbar-button.d.ts +16 -0
  73. package/dist/richtext/toolbar-button.js +9 -0
  74. package/dist/richtext/url-paste.d.ts +20 -0
  75. package/dist/richtext/url-paste.js +82 -0
  76. package/dist/richtext-html-entry.d.ts +5 -0
  77. package/dist/richtext-html-entry.js +11 -0
  78. package/dist/sdk-strings.d.ts +59 -0
  79. package/dist/sdk-strings.js +64 -0
  80. package/dist/service-contract.d.ts +17 -0
  81. package/dist/service-contract.js +39 -0
  82. package/dist/services.d.ts +114 -0
  83. package/dist/services.js +1 -0
  84. package/dist/structured-storage-types.d.ts +124 -4
  85. package/dist/tailwind.js +10 -5
  86. package/dist/template-reads.d.ts +16 -0
  87. package/dist/template-reads.js +21 -0
  88. package/dist/testing-entry.d.ts +38 -0
  89. package/dist/testing-entry.js +173 -0
  90. package/dist/text-entry.d.ts +1 -1
  91. package/dist/text-entry.js +3 -2
  92. package/dist/tokens/system-dark.css +1 -0
  93. package/dist/tokens/tailwind-theme.css +2 -0
  94. package/dist/tokens/tokens.css +4 -0
  95. package/dist/tokens/tokens.json +5 -1
  96. package/dist/uploads.d.ts +43 -0
  97. package/dist/uploads.js +1 -0
  98. package/dist/user-library.d.ts +51 -0
  99. package/dist/user-library.js +15 -0
  100. package/dist/view-helpers.d.ts +18 -0
  101. package/dist/view-helpers.js +64 -0
  102. package/dist/views/content-list-view.js +207 -8
  103. package/dist/views/content-picker-view.js +1 -1
  104. package/dist/views/rich-text-view.d.ts +2 -0
  105. package/dist/views/rich-text-view.js +182 -24
  106. package/dist/views/unreadable-rich-text.d.ts +17 -0
  107. package/dist/views/unreadable-rich-text.js +40 -0
  108. package/dist/visitors.d.ts +81 -0
  109. package/dist/visitors.js +1 -0
  110. package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.d.ts +21 -0
  111. package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.js +39 -0
  112. package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.d.ts +2 -0
  113. package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.js +31 -0
  114. package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +127 -8
  115. package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +82 -7
  116. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +5 -1
  117. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +2 -2
  118. package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +7 -0
  119. package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +11 -0
  120. package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +1 -1
  121. package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +18 -0
  122. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +80 -0
  123. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +41 -2
  124. package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.d.ts +213 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.js +234 -0
  126. package/node_modules/@kardalum/api-schemas/dist/contribution-issues.d.ts +11 -0
  127. package/node_modules/@kardalum/api-schemas/dist/contribution-issues.js +14 -0
  128. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +50 -13
  129. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +19 -10
  130. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +77 -0
  131. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +37 -0
  132. package/node_modules/@kardalum/api-schemas/dist/experimental-points.d.ts +19 -0
  133. package/node_modules/@kardalum/api-schemas/dist/experimental-points.js +250 -0
  134. package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.d.ts +29 -0
  135. package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.js +31 -0
  136. package/node_modules/@kardalum/api-schemas/dist/html-scan.d.ts +22 -0
  137. package/node_modules/@kardalum/api-schemas/dist/html-scan.js +122 -0
  138. package/node_modules/@kardalum/api-schemas/dist/html-start-tags.d.ts +48 -0
  139. package/node_modules/@kardalum/api-schemas/dist/html-start-tags.js +381 -0
  140. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +52 -14
  141. package/node_modules/@kardalum/api-schemas/dist/index.js +53 -9
  142. package/node_modules/@kardalum/api-schemas/dist/json-depth.d.ts +3 -0
  143. package/node_modules/@kardalum/api-schemas/dist/json-depth.js +20 -0
  144. package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +4 -2
  145. package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +6 -1
  146. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +178 -2
  147. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +10 -0
  148. package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +3 -3
  149. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +16 -0
  150. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +4 -0
  151. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +7 -0
  153. package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +51 -2
  154. package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.d.ts +87 -0
  155. package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.js +44 -0
  156. package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.d.ts +11 -0
  157. package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.js +61 -0
  158. package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +4 -2
  159. package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +12 -2
  160. package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.d.ts +136 -0
  161. package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.js +254 -0
  162. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.d.ts +22 -0
  163. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.js +66 -0
  164. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.d.ts +130 -0
  165. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.js +173 -0
  166. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.d.ts +16 -0
  167. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.js +112 -0
  168. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.d.ts +70 -0
  169. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.js +380 -0
  170. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.d.ts +3 -0
  171. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.js +68 -0
  172. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +18 -0
  173. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +18 -0
  174. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +5 -2
  175. package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +10 -2
  176. package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +48 -1
  177. package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +5 -2
  178. package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +6 -4
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-events.d.ts +24 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-events.js +53 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-guards.d.ts +112 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-guards.js +118 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +12 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +3 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +2 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +3 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +67 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +15 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.d.ts +138 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.js +110 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +80 -15
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +67 -23
  193. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +10 -3
  194. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +33 -8
  195. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +2 -1
  196. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +7 -1
  197. package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +1 -1
  198. package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +43 -7
  199. package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +36 -5
  200. package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.d.ts +638 -0
  201. package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.js +533 -0
  202. package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.d.ts +36 -0
  203. package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.js +32 -0
  204. package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.d.ts +193 -0
  205. package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.js +123 -0
  206. package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.d.ts +209 -0
  207. package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.js +372 -0
  208. package/node_modules/@kardalum/api-schemas/dist/plugin-services.d.ts +90 -0
  209. package/node_modules/@kardalum/api-schemas/dist/plugin-services.js +204 -0
  210. package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +10 -0
  211. package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +10 -1
  212. package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +171 -4
  213. package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +406 -42
  214. package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.d.ts +69 -0
  215. package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.js +149 -0
  216. package/node_modules/@kardalum/api-schemas/dist/plugin-styles.d.ts +5 -0
  217. package/node_modules/@kardalum/api-schemas/dist/plugin-styles.js +13 -0
  218. package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.d.ts +96 -0
  219. package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.js +185 -0
  220. package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.d.ts +213 -0
  221. package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.js +131 -0
  222. package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.d.ts +54 -0
  223. package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.js +154 -0
  224. package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.d.ts +37 -0
  225. package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.js +124 -0
  226. package/node_modules/@kardalum/api-schemas/dist/render-cache.d.ts +126 -0
  227. package/node_modules/@kardalum/api-schemas/dist/render-cache.js +263 -0
  228. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +303 -0
  229. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +61 -0
  230. package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.d.ts +14 -0
  231. package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.js +108 -0
  232. package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +66 -1
  233. package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +465 -7
  234. package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +15 -118
  235. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +110 -0
  236. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +36 -0
  237. package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.d.ts +64 -0
  238. package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.js +38 -0
  239. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +9 -2
  240. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +7 -2
  241. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +26 -0
  242. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +19 -0
  243. package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.d.ts +724 -0
  244. package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.js +408 -0
  245. package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +5 -3
  246. package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +3 -1
  247. package/node_modules/@kardalum/api-schemas/dist/site-consent.d.ts +77 -0
  248. package/node_modules/@kardalum/api-schemas/dist/site-consent.js +122 -0
  249. package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +4 -0
  250. package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +28 -0
  251. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +33 -0
  252. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -1
  253. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +14 -0
  254. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +2 -0
  255. package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.d.ts +482 -0
  256. package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.js +380 -0
  257. package/node_modules/@kardalum/api-schemas/dist/visitor-groups.d.ts +109 -0
  258. package/node_modules/@kardalum/api-schemas/dist/visitor-groups.js +62 -0
  259. package/node_modules/@kardalum/api-schemas/package.json +1 -0
  260. package/node_modules/@kardalum/design-tokens/dist/build-css.js +9 -1
  261. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +1 -0
  262. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +2 -0
  263. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
  264. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
  265. package/node_modules/@kardalum/design-tokens/dist/tokens.css +4 -0
  266. package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -0
  267. package/node_modules/@kardalum/design-tokens/dist/tokens.json +5 -1
  268. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +4 -0
  269. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +17 -0
  270. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +9 -0
  271. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +1 -1
  272. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +276 -19
  273. package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
  274. package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +23 -0
  275. package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.d.ts +17 -0
  276. package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.js +39 -0
  277. package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.d.ts +23 -0
  278. package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.js +351 -0
  279. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +2 -0
  280. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
  281. package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +21 -8
  282. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +1 -1
  283. package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +23 -10
  284. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +3 -2
  285. package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +2 -0
  286. package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +2 -0
  287. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +30 -2
  288. package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +6 -2
  289. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +6 -0
  290. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +6 -0
  291. package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +2 -0
  292. package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +24 -6
  293. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +15 -0
  294. package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.d.ts +2 -0
  295. package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.js +173 -0
  296. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +1 -1
  297. package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +14 -4
  298. package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.d.ts +3 -0
  299. package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.js +35 -0
  300. package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.d.ts +3 -0
  301. package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.js +71 -0
  302. package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +44 -11
  303. package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +7 -0
  304. package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.d.ts +3 -0
  305. package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.js +36 -0
  306. package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.d.ts +3 -0
  307. package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.js +33 -0
  308. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -0
  309. package/node_modules/@kardalum/plugin-package/dist/index.js +5 -0
  310. package/node_modules/@kardalum/plugin-package/dist/public-suffix.d.ts +7 -0
  311. package/node_modules/@kardalum/plugin-package/dist/public-suffix.js +23 -0
  312. package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.d.ts +1 -0
  313. package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.js +27 -0
  314. package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.d.ts +2 -0
  315. package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.js +28 -0
  316. package/node_modules/@kardalum/plugin-package/package.json +4 -0
  317. package/node_modules/@kardalum/ui/dist/components/select.d.ts +6 -0
  318. package/node_modules/@kardalum/ui/dist/components/select.js +7 -0
  319. package/node_modules/@kardalum/ui/dist/components/textarea.d.ts +6 -0
  320. package/node_modules/@kardalum/ui/dist/components/textarea.js +7 -0
  321. package/node_modules/@kardalum/ui/dist/index.d.ts +2 -0
  322. package/node_modules/@kardalum/ui/dist/index.js +2 -0
  323. package/package.json +15 -3
@@ -2,8 +2,36 @@
2
2
  // over the document, never a regular expression and never recursion, so a hostile 10,000-deep
3
3
  // value ends at `tooDeep` instead of overflowing the stack. The type lists are the node and mark
4
4
  // types the server's TipTap renderer handles; a type outside them is refused here.
5
+ // M35 C4a (design D2, D6.1): the four plugin item types are always on the lists, whatever is installed,
6
+ // with fixed rules for their attributes and their placement; an empty text node is refused; the save
7
+ // depth bound is its own constant (C4a-D1), so the deepest value admitted fits MySQL's JSON column.
8
+ import { PLUGIN_ID_MAX, MANIFEST_ID_SEGMENT_MAX } from "./plugin-id-rules.js";
9
+ import { EDITOR_SLOT_ID_MAX } from "./plugin-editor-extensions.js";
10
+ /** How deep the readers walk (plain text, the client, the server converter): 100 node levels. */
5
11
  export const RICH_TEXT_MAX_DEPTH = 100;
12
+ /** C4a-D1: how deep a saved value may be, in node levels from the document (1). */
13
+ export const RICH_TEXT_SAVE_DEPTH_MAX = 36;
6
14
  export const RICH_TEXT_MAX_NODES = 20_000;
15
+ export const RICH_TEXT_ITEM_NODE_TYPES = ["pluginBlock", "pluginInline", "pluginWrapper"];
16
+ export const RICH_TEXT_PLUGIN_MARK_TYPE = "pluginMark";
17
+ /** Block, inline and wrapper items in one value. */
18
+ export const RICH_TEXT_ITEMS_MAX = 500;
19
+ /** Plugin marks in one value. */
20
+ export const RICH_TEXT_PLUGIN_MARKS_MAX = 2000;
21
+ /** A wrapper inside a wrapper, at most this deep. */
22
+ export const RICH_TEXT_WRAPPER_DEPTH_MAX = 4;
23
+ /** One item's `data` as UTF-8 JSON. */
24
+ export const RICH_TEXT_ITEM_DATA_BYTES_MAX = 65_536;
25
+ /** One item's `data` nested at most this many levels (the data object itself is 1). */
26
+ export const RICH_TEXT_ITEM_DATA_DEPTH_MAX = 16;
27
+ /** The short text, in UTF-16 units. */
28
+ export const RICH_TEXT_ITEM_TEXT_MAX = 200;
29
+ export const RICH_TEXT_ITEM_ID_MAX = 24;
30
+ export const RICH_TEXT_ITEM_VERSION_MAX = 1000;
31
+ export const RICH_TEXT_ITEM_DATA_KEY_MAX = 40;
32
+ /** The bounds of a walk over a whole value's JSON (canonicalRichTextJson, richTextWithinBounds). */
33
+ export const RICH_TEXT_JSON_DEPTH_MAX = 240;
34
+ export const RICH_TEXT_JSON_ELEMENTS_MAX = 1_048_576;
7
35
  export const RICH_TEXT_NODE_TYPES = [
8
36
  "doc",
9
37
  "text",
@@ -22,19 +50,208 @@ export const RICH_TEXT_NODE_TYPES = [
22
50
  "tableHeader",
23
51
  "tableCell",
24
52
  "kardalumBlock",
53
+ ...RICH_TEXT_ITEM_NODE_TYPES,
25
54
  ];
26
- export const RICH_TEXT_MARK_TYPES = ["bold", "italic", "strike", "code", "underline", "link", "textStyleClass"];
55
+ export const RICH_TEXT_MARK_TYPES = ["bold", "italic", "strike", "code", "underline", "link", "textStyleClass", RICH_TEXT_PLUGIN_MARK_TYPE];
56
+ /** Nodes whose content holds blocks: where a block item or a wrapper may stand (design D2's specs). */
57
+ const BLOCK_PARENTS = new Set(["doc", "blockquote", "listItem", "tableCell", "tableHeader", "pluginWrapper"]);
58
+ /** Nodes whose content is inline, outside a code block: where an inline item may stand. */
59
+ const INLINE_PARENTS = new Set(["paragraph", "heading"]);
60
+ /** The block nodes a wrapper may hold. */
61
+ const BLOCK_NODES = new Set(["paragraph", "heading", "bulletList", "orderedList", "blockquote", "codeBlock", "horizontalRule", "image", "table", "kardalumBlock", "pluginBlock", "pluginWrapper"]);
62
+ const ITEM_NODE_KEYS = {
63
+ pluginBlock: new Set(["type", "attrs"]),
64
+ pluginInline: new Set(["type", "attrs", "marks"]),
65
+ pluginWrapper: new Set(["type", "attrs", "content"]),
66
+ };
67
+ const NODE_ATTR_KEYS = new Set(["plugin", "name", "v", "id", "data", "text", "editorial"]);
68
+ const MARK_ATTR_KEYS = new Set(["plugin", "name", "v", "id", "data", "editorial"]);
69
+ const MARK_KEYS = new Set(["type", "attrs"]);
27
70
  function isRecord(value) {
28
71
  return typeof value === "object" && value !== null && !Array.isArray(value);
29
72
  }
73
+ export function isItemNodeType(value) {
74
+ return value === "pluginBlock" || value === "pluginInline" || value === "pluginWrapper";
75
+ }
76
+ const isLower = (code) => code >= 0x61 && code <= 0x7a;
77
+ const isDigit = (code) => code >= 0x30 && code <= 0x39;
78
+ /** A plugin id, as isPluginManifestId answers it (a test pins the two), by a linear scan. */
79
+ export function isPluginIdText(value) {
80
+ if (value.length < 3 || value.length > PLUGIN_ID_MAX)
81
+ return false;
82
+ let segments = 1;
83
+ let segmentStart = true;
84
+ for (let index = 0; index < value.length; index += 1) {
85
+ const code = value.charCodeAt(index);
86
+ if (code === 0x2e) {
87
+ if (segmentStart)
88
+ return false;
89
+ segments += 1;
90
+ if (segments > MANIFEST_ID_SEGMENT_MAX)
91
+ return false;
92
+ segmentStart = true;
93
+ continue;
94
+ }
95
+ if (segmentStart) {
96
+ if (!isLower(code))
97
+ return false;
98
+ segmentStart = false;
99
+ continue;
100
+ }
101
+ if (!isLower(code) && !isDigit(code) && code !== 0x2d)
102
+ return false;
103
+ }
104
+ return !segmentStart && segments >= 2;
105
+ }
106
+ /** An item or mark name: isEditorSlotId's rule (1 to 40 lower-case letters, digits and "-", a letter first). */
107
+ export function isItemNameText(value) {
108
+ if (value.length < 1 || value.length > EDITOR_SLOT_ID_MAX)
109
+ return false;
110
+ for (let index = 0; index < value.length; index += 1) {
111
+ const code = value.charCodeAt(index);
112
+ if (index === 0 ? !isLower(code) : !isLower(code) && !isDigit(code) && code !== 0x2d)
113
+ return false;
114
+ }
115
+ return true;
116
+ }
117
+ /** An attribute key, and so a top-level `data` key: 1 to 40 lower-case letters, digits and "_", a letter first,
118
+ * never `constructor` or `prototype`, so a partial reads `item.data.serves`. */
119
+ export function isItemDataKey(value) {
120
+ if (value.length < 1 || value.length > RICH_TEXT_ITEM_DATA_KEY_MAX || value === "constructor" || value === "prototype")
121
+ return false;
122
+ for (let index = 0; index < value.length; index += 1) {
123
+ const code = value.charCodeAt(index);
124
+ if (index === 0 ? !isLower(code) : !isLower(code) && !isDigit(code) && code !== 0x5f)
125
+ return false;
126
+ }
127
+ return true;
128
+ }
129
+ function isIdText(value) {
130
+ if (value.length < 1 || value.length > RICH_TEXT_ITEM_ID_MAX)
131
+ return false;
132
+ for (let index = 0; index < value.length; index += 1) {
133
+ const code = value.charCodeAt(index);
134
+ const letter = isLower(code) || (code >= 0x41 && code <= 0x5a);
135
+ if (!letter && !isDigit(code) && code !== 0x5f && code !== 0x2d)
136
+ return false;
137
+ }
138
+ return true;
139
+ }
140
+ /** A control character, or a bidi embedding, override or isolate control (design D6.1). ZWJ and ZWNJ pass. */
141
+ function isRefusedTextCode(code) {
142
+ return code <= 0x1f || (code >= 0x7f && code <= 0x9f) || (code >= 0x202a && code <= 0x202e) || (code >= 0x2066 && code <= 0x2069);
143
+ }
144
+ export function isItemShortText(value) {
145
+ if (typeof value !== "string" || value.length > RICH_TEXT_ITEM_TEXT_MAX)
146
+ return false;
147
+ for (let index = 0; index < value.length; index += 1)
148
+ if (isRefusedTextCode(value.charCodeAt(index)))
149
+ return false;
150
+ return true;
151
+ }
152
+ /** A short text made from an attribute's value (design D6.3): the refused characters removed, cut at
153
+ * RICH_TEXT_ITEM_TEXT_MAX units, never in half of a surrogate pair. The input is cut to eight times the bound first. */
154
+ export function itemShortTextOf(raw) {
155
+ const bounded = raw.length > RICH_TEXT_ITEM_TEXT_MAX * 8 ? raw.slice(0, RICH_TEXT_ITEM_TEXT_MAX * 8) : raw;
156
+ let out = "";
157
+ for (let index = 0; index < bounded.length && out.length < RICH_TEXT_ITEM_TEXT_MAX; index += 1) {
158
+ const code = bounded.charCodeAt(index);
159
+ if (isRefusedTextCode(code))
160
+ continue;
161
+ if (code >= 0xd800 && code <= 0xdbff) {
162
+ if (out.length + 2 > RICH_TEXT_ITEM_TEXT_MAX || index + 1 >= bounded.length)
163
+ break;
164
+ out += bounded.slice(index, index + 2);
165
+ index += 1;
166
+ continue;
167
+ }
168
+ out += bounded[index];
169
+ }
170
+ return out;
171
+ }
172
+ /** UTF-8 bytes of a string, by a character loop (no TextEncoder, no Buffer: this package runs everywhere). */
173
+ export function utf8Length(value) {
174
+ let bytes = 0;
175
+ for (let index = 0; index < value.length; index += 1) {
176
+ const code = value.charCodeAt(index);
177
+ if (code < 0x80)
178
+ bytes += 1;
179
+ else if (code < 0x800)
180
+ bytes += 2;
181
+ else if (code >= 0xd800 && code <= 0xdbff && index + 1 < value.length) {
182
+ bytes += 4;
183
+ index += 1;
184
+ }
185
+ else
186
+ bytes += 3;
187
+ }
188
+ return bytes;
189
+ }
190
+ /** An item's `data`: a plain object of attribute keys, no `__proto__` own key at any level, at most
191
+ * RICH_TEXT_ITEM_DATA_DEPTH_MAX levels and RICH_TEXT_ITEM_DATA_BYTES_MAX bytes. The walk bounds the
192
+ * depth before JSON.stringify measures the bytes, so the stringify cannot recurse past it. */
193
+ function dataProblem(data) {
194
+ if (!isRecord(data))
195
+ return true;
196
+ for (const key of Object.keys(data))
197
+ if (!isItemDataKey(key))
198
+ return true;
199
+ const stack = [{ value: data, depth: 1 }];
200
+ let elements = 0;
201
+ while (stack.length > 0) {
202
+ const { value, depth } = stack.pop();
203
+ elements += 1;
204
+ if (elements > RICH_TEXT_ITEM_DATA_BYTES_MAX)
205
+ return true;
206
+ if (value === null || typeof value !== "object")
207
+ continue;
208
+ if (depth > RICH_TEXT_ITEM_DATA_DEPTH_MAX)
209
+ return true;
210
+ if (Array.isArray(value)) {
211
+ for (const member of value)
212
+ stack.push({ value: member, depth: depth + 1 });
213
+ continue;
214
+ }
215
+ for (const key of Object.keys(value)) {
216
+ if (key === "__proto__")
217
+ return true;
218
+ stack.push({ value: value[key], depth: depth + 1 });
219
+ }
220
+ }
221
+ return utf8Length(JSON.stringify(data)) > RICH_TEXT_ITEM_DATA_BYTES_MAX;
222
+ }
223
+ function itemAttrsProblem(attrs, isMark) {
224
+ if (!isRecord(attrs))
225
+ return true;
226
+ const allowed = isMark ? MARK_ATTR_KEYS : NODE_ATTR_KEYS;
227
+ for (const key of Object.keys(attrs))
228
+ if (!allowed.has(key))
229
+ return true;
230
+ const { plugin, name, v, id, editorial } = attrs;
231
+ if (typeof plugin !== "string" || !isPluginIdText(plugin))
232
+ return true;
233
+ if (typeof name !== "string" || !isItemNameText(name))
234
+ return true;
235
+ if (typeof v !== "number" || !Number.isInteger(v) || v < 1 || v > RICH_TEXT_ITEM_VERSION_MAX)
236
+ return true;
237
+ if (id !== undefined && id !== null && (typeof id !== "string" || !isIdText(id)))
238
+ return true;
239
+ if (editorial !== undefined && typeof editorial !== "boolean")
240
+ return true;
241
+ if (!isMark && !isItemShortText(attrs.text))
242
+ return true;
243
+ return dataProblem(attrs.data);
244
+ }
30
245
  export function richTextShapeProblem(value) {
31
246
  if (!isRecord(value) || value.type !== "doc")
32
247
  return "notDocument";
33
- const stack = [{ node: value, depth: 1 }];
248
+ const stack = [{ node: value, depth: 1, parent: "", first: true, inCode: false, wrappers: 0 }];
34
249
  let count = 0;
250
+ let items = 0;
251
+ let marks = 0;
35
252
  while (stack.length > 0) {
36
- const { node, depth } = stack.pop();
37
- if (depth > RICH_TEXT_MAX_DEPTH)
253
+ const { node, depth, parent, first, inCode, wrappers } = stack.pop();
254
+ if (depth > RICH_TEXT_SAVE_DEPTH_MAX)
38
255
  return "tooDeep";
39
256
  count += 1;
40
257
  if (count > RICH_TEXT_MAX_NODES)
@@ -48,7 +265,8 @@ export function richTextShapeProblem(value) {
48
265
  if (type === "doc" && depth > 1)
49
266
  return "unknownNode";
50
267
  if (type === "text") {
51
- if (typeof node.text !== "string" || node.content !== undefined)
268
+ // M35 C4a: an empty text node is refused; ProseMirror's nodeFromJSON throws on it and TipTap then opens an empty document.
269
+ if (typeof node.text !== "string" || node.text.length === 0 || node.content !== undefined)
52
270
  return "badText";
53
271
  }
54
272
  else if (node.text !== undefined) {
@@ -56,15 +274,61 @@ export function richTextShapeProblem(value) {
56
274
  }
57
275
  if (node.attrs !== undefined && !isRecord(node.attrs))
58
276
  return "badAttrs";
277
+ let nextWrappers = wrappers;
278
+ if (isItemNodeType(type)) {
279
+ items += 1;
280
+ if (items > RICH_TEXT_ITEMS_MAX)
281
+ return "tooManyItems";
282
+ for (const key of Object.keys(node))
283
+ if (!ITEM_NODE_KEYS[type].has(key))
284
+ return "badItem";
285
+ if (itemAttrsProblem(node.attrs, false))
286
+ return "badItem";
287
+ if (type === "pluginInline" ? !INLINE_PARENTS.has(parent) || inCode : !BLOCK_PARENTS.has(parent))
288
+ return "badItem";
289
+ // A list item's content is `paragraph block*`: a block item or a wrapper stands only after its paragraph.
290
+ if (type !== "pluginInline" && parent === "listItem" && first)
291
+ return "badItem";
292
+ if (type === "pluginWrapper") {
293
+ nextWrappers = wrappers + 1;
294
+ if (nextWrappers > RICH_TEXT_WRAPPER_DEPTH_MAX)
295
+ return "badItem";
296
+ const content = node.content;
297
+ if (!Array.isArray(content) || content.length === 0)
298
+ return "badItem";
299
+ for (const child of content)
300
+ if (!isRecord(child) || typeof child.type !== "string" || !BLOCK_NODES.has(child.type))
301
+ return "badItem";
302
+ }
303
+ }
59
304
  if (node.marks !== undefined) {
60
305
  // A `marks` that is not an array cannot hold a known mark, so it answers unknownMark.
61
306
  if (!Array.isArray(node.marks))
62
307
  return "unknownMark";
308
+ // Read once a node, so a long marks list is walked twice at most, never once a plugin mark.
309
+ const hasCode = node.marks.some((mark) => isRecord(mark) && mark.type === "code");
63
310
  for (const mark of node.marks) {
64
311
  if (!isRecord(mark) || typeof mark.type !== "string" || !RICH_TEXT_MARK_TYPES.includes(mark.type))
65
312
  return "unknownMark";
66
313
  if (mark.attrs !== undefined && !isRecord(mark.attrs))
67
314
  return "badAttrs";
315
+ if (mark.type === RICH_TEXT_PLUGIN_MARK_TYPE) {
316
+ marks += 1;
317
+ if (marks > RICH_TEXT_PLUGIN_MARKS_MAX)
318
+ return "tooManyItems";
319
+ // On text only, and only where an inline item may stand: text the schema places directly in a block parent
320
+ // is refused by the editor, so the shape check never admits a plugin mark there.
321
+ if (type !== "text" || inCode || !INLINE_PARENTS.has(parent))
322
+ return "badItem";
323
+ // The Code mark excludes every other mark (`excludes: "_"`), so the schema refuses a plugin mark beside it.
324
+ if (hasCode)
325
+ return "badItem";
326
+ for (const key of Object.keys(mark))
327
+ if (!MARK_KEYS.has(key))
328
+ return "badItem";
329
+ if (itemAttrsProblem(mark.attrs, true))
330
+ return "badItem";
331
+ }
68
332
  }
69
333
  }
70
334
  if (node.content !== undefined) {
@@ -74,9 +338,203 @@ export function richTextShapeProblem(value) {
74
338
  // children already pass the limit is refused before a long `content` array is pushed.
75
339
  if (count + stack.length + node.content.length > RICH_TEXT_MAX_NODES)
76
340
  return "tooLarge";
77
- for (const child of node.content)
78
- stack.push({ node: child, depth: depth + 1 });
341
+ // Pushed last child first, so children are popped (and items counted) in document order.
342
+ for (let index = node.content.length - 1; index >= 0; index -= 1) {
343
+ stack.push({ node: node.content[index], depth: depth + 1, parent: type, first: index === 0, inCode: inCode || type === "codeBlock", wrappers: nextWrappers });
344
+ }
79
345
  }
80
346
  }
81
347
  return null;
82
348
  }
349
+ /** M35 C4a: whether a value's JSON stays within RICH_TEXT_JSON_DEPTH_MAX levels and RICH_TEXT_JSON_ELEMENTS_MAX
350
+ * elements, so a copy (structuredClone) or a canonical form of it cannot recurse past them. */
351
+ export function richTextWithinBounds(value) {
352
+ const stack = [{ value, depth: 1 }];
353
+ let elements = 0;
354
+ while (stack.length > 0) {
355
+ const { value: current, depth } = stack.pop();
356
+ elements += 1;
357
+ if (elements > RICH_TEXT_JSON_ELEMENTS_MAX || depth > RICH_TEXT_JSON_DEPTH_MAX)
358
+ return false;
359
+ if (current === null || typeof current !== "object")
360
+ continue;
361
+ for (const member of Array.isArray(current) ? current : Object.values(current))
362
+ stack.push({ value: member, depth: depth + 1 });
363
+ }
364
+ return true;
365
+ }
366
+ /** M35 C4a (design D6.2, section 5): a value's JSON with every object's keys sorted and every item node's `urls`
367
+ * left out, so two values equal by value give one string whatever order a database kept their keys in.
368
+ * An explicit stack; null past the bounds of richTextWithinBounds. */
369
+ export function canonicalRichTextJson(value) {
370
+ const out = [];
371
+ const stack = [{ value, depth: 1 }];
372
+ let elements = 0;
373
+ while (stack.length > 0) {
374
+ const top = stack.pop();
375
+ if (typeof top === "string") {
376
+ out.push(top);
377
+ continue;
378
+ }
379
+ elements += 1;
380
+ if (elements > RICH_TEXT_JSON_ELEMENTS_MAX || top.depth > RICH_TEXT_JSON_DEPTH_MAX)
381
+ return null;
382
+ const current = top.value;
383
+ if (current === null || typeof current === "boolean" || typeof current === "number" || typeof current === "string") {
384
+ out.push(JSON.stringify(current));
385
+ continue;
386
+ }
387
+ if (Array.isArray(current)) {
388
+ out.push("[");
389
+ stack.push("]");
390
+ for (let index = current.length - 1; index >= 0; index -= 1) {
391
+ stack.push({ value: current[index] === undefined ? null : current[index], depth: top.depth + 1 });
392
+ if (index > 0)
393
+ stack.push(",");
394
+ }
395
+ continue;
396
+ }
397
+ if (typeof current === "object") {
398
+ const record = current;
399
+ const dropUrls = isItemNodeType(record.type);
400
+ const keys = Object.keys(record).filter((key) => record[key] !== undefined && typeof record[key] !== "function" && !(dropUrls && key === "urls")).sort();
401
+ out.push("{");
402
+ stack.push("}");
403
+ for (let index = keys.length - 1; index >= 0; index -= 1) {
404
+ stack.push({ value: record[keys[index]], depth: top.depth + 1 });
405
+ stack.push(`${JSON.stringify(keys[index])}:`);
406
+ if (index > 0)
407
+ stack.push(",");
408
+ }
409
+ continue;
410
+ }
411
+ out.push("null");
412
+ }
413
+ return out.join("");
414
+ }
415
+ const KIND_OF = { pluginBlock: "block", pluginInline: "inline", pluginWrapper: "wrapper" };
416
+ /** M35 C4a: every item and plugin mark of a value, in document order (a wrapper before its children, an inline
417
+ * item's own marks after it), by an explicit stack bounded as richTextShapeProblem is. An item whose attrs are
418
+ * not an object is passed with empty attrs. Answers false when a bound stopped the walk. */
419
+ export function forEachRichTextItem(doc, visit) {
420
+ const stack = [{ node: doc, depth: 1 }];
421
+ let count = 0;
422
+ while (stack.length > 0) {
423
+ const { node, depth } = stack.pop();
424
+ count += 1;
425
+ if (depth > RICH_TEXT_MAX_DEPTH || count > RICH_TEXT_MAX_NODES)
426
+ return false;
427
+ if (!isRecord(node))
428
+ continue;
429
+ if (isItemNodeType(node.type))
430
+ visit({ kind: KIND_OF[node.type], host: node, attrs: isRecord(node.attrs) ? node.attrs : {} });
431
+ if (Array.isArray(node.marks)) {
432
+ for (const mark of node.marks) {
433
+ if (isRecord(mark) && mark.type === RICH_TEXT_PLUGIN_MARK_TYPE)
434
+ visit({ kind: "mark", host: mark, attrs: isRecord(mark.attrs) ? mark.attrs : {} });
435
+ }
436
+ }
437
+ if (Array.isArray(node.content)) {
438
+ if (count + stack.length + node.content.length > RICH_TEXT_MAX_NODES)
439
+ return false;
440
+ for (let index = node.content.length - 1; index >= 0; index -= 1)
441
+ stack.push({ node: node.content[index], depth: depth + 1 });
442
+ }
443
+ }
444
+ return true;
445
+ }
446
+ const EMPTY_DOC = Object.freeze({ type: "doc", content: Object.freeze([]) });
447
+ // The package's lib has no structuredClone; both callers have bounded the value first, so a JSON round trip is safe.
448
+ const cloneJson = (value) => JSON.parse(JSON.stringify(value));
449
+ /** M35 C4b (design D18): whether a value holds an item or plugin mark whose stored `editorial` is true. Null when the
450
+ * walk stopped at its bounds, so a caller cannot tell. */
451
+ function editorialState(doc) {
452
+ let found = false;
453
+ const whole = forEachRichTextItem(doc, (visit) => {
454
+ if (visit.attrs.editorial === true)
455
+ found = true;
456
+ });
457
+ return whole && richTextWithinBounds(doc) ? found : null;
458
+ }
459
+ export function hasEditorialItems(doc) {
460
+ return editorialState(doc) !== false;
461
+ }
462
+ function isEditorialMark(mark) {
463
+ return isRecord(mark) && mark.type === RICH_TEXT_PLUGIN_MARK_TYPE && isRecord(mark.attrs) && mark.attrs.editorial === true;
464
+ }
465
+ /** M35 C4b (design D18, C4b-D4): the value every public reader serves. An editorial block or inline item is removed, an
466
+ * editorial wrapper is replaced by its content, and an editorial plugin mark is dropped from its text, which stays. A
467
+ * container of blocks left empty by the strip holds one empty paragraph.
468
+ * The value itself when it holds none; an empty document when it is past the walk's bounds (no stored value is: the
469
+ * save's bounds are tighter). The stored flag decides alone, so a plugin switched off or uninstalled changes nothing. */
470
+ export function withoutEditorialItems(doc) {
471
+ const state = editorialState(doc);
472
+ if (state === null)
473
+ return { type: "doc", content: [] };
474
+ if (!state)
475
+ return doc;
476
+ const copy = cloneJson(doc);
477
+ if (!Array.isArray(copy.content))
478
+ return copy;
479
+ const lists = [{ list: copy.content, parent: copy.type }];
480
+ while (lists.length > 0) {
481
+ const { list, parent } = lists.pop();
482
+ const before = list.length;
483
+ // `pending` is a stack in reverse document order, so an unwrapped wrapper's children are read next, in order.
484
+ const pending = list.splice(0, list.length).reverse();
485
+ while (pending.length > 0) {
486
+ const node = pending.pop();
487
+ if (!isRecord(node)) {
488
+ list.push(node);
489
+ continue;
490
+ }
491
+ const editorial = isItemNodeType(node.type) && isRecord(node.attrs) && node.attrs.editorial === true;
492
+ if (editorial && node.type === "pluginWrapper") {
493
+ const children = Array.isArray(node.content) ? node.content : [];
494
+ for (let index = children.length - 1; index >= 0; index -= 1)
495
+ pending.push(children[index]);
496
+ continue;
497
+ }
498
+ if (editorial)
499
+ continue;
500
+ if (Array.isArray(node.marks) && node.marks.some(isEditorialMark)) {
501
+ const kept = node.marks.filter((mark) => !isEditorialMark(mark));
502
+ if (kept.length > 0)
503
+ node.marks = kept;
504
+ else
505
+ delete node.marks;
506
+ }
507
+ list.push(node);
508
+ if (Array.isArray(node.content))
509
+ lists.push({ list: node.content, parent: node.type });
510
+ }
511
+ // A container of blocks the strip emptied (a blockquote, a table cell or a kept wrapper whose only child was an
512
+ // editorial item) takes one empty paragraph, as the editor's schema needs; a paragraph may stay empty. The list is
513
+ // already walked, so the paragraph is never read again.
514
+ if (before > 0 && list.length === 0 && typeof parent === "string" && BLOCK_PARENTS.has(parent))
515
+ list.push({ type: "paragraph" });
516
+ }
517
+ return copy;
518
+ }
519
+ /** M35 C4b (design D16, C4b-D8): the editor handle's `document`: a frozen copy in which another plugin's editorial items
520
+ * and marks keep only their plugin, name and id (a wrapper keeps its content, which is the page's text). */
521
+ export function redactForeignEditorial(doc, ownPlugin) {
522
+ if (!richTextWithinBounds(doc))
523
+ return EMPTY_DOC;
524
+ const copy = cloneJson(doc);
525
+ forEachRichTextItem(copy, (visit) => {
526
+ if (visit.attrs.editorial !== true || visit.attrs.plugin === ownPlugin)
527
+ return;
528
+ visit.host.attrs = { plugin: visit.attrs.plugin, name: visit.attrs.name, id: typeof visit.attrs.id === "string" ? visit.attrs.id : null, editorial: true };
529
+ });
530
+ const stack = [copy];
531
+ while (stack.length > 0) {
532
+ const current = stack.pop();
533
+ if (current === null || typeof current !== "object" || Object.isFrozen(current))
534
+ continue;
535
+ Object.freeze(current);
536
+ for (const member of Object.values(current))
537
+ stack.push(member);
538
+ }
539
+ return copy;
540
+ }