@embedpdf/vue 3.0.0-next.15 → 3.0.0-next.16

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 (41) hide show
  1. package/dist/{DocumentScope.vue_vue_type_script_setup_true_lang-CtTu1FGX.js → DocumentScope.vue_vue_type_script_setup_true_lang-C-7yeEGh.js} +4 -3
  2. package/dist/DocumentScope.vue_vue_type_script_setup_true_lang-C-7yeEGh.js.map +1 -0
  3. package/dist/{DocumentScope.vue_vue_type_script_setup_true_lang-loLSm4lV.cjs → DocumentScope.vue_vue_type_script_setup_true_lang-czzeUzPl.cjs} +3 -2
  4. package/dist/DocumentScope.vue_vue_type_script_setup_true_lang-czzeUzPl.cjs.map +1 -0
  5. package/dist/annotation/text-box.d.cts +2 -1
  6. package/dist/annotation/text-box.d.ts +2 -1
  7. package/dist/annotation.cjs +1 -1
  8. package/dist/annotation.js +1 -1
  9. package/dist/attachment.cjs +22 -0
  10. package/dist/attachment.cjs.map +1 -0
  11. package/dist/attachment.d.cts +34 -0
  12. package/dist/attachment.d.ts +34 -0
  13. package/dist/attachment.js +17 -0
  14. package/dist/attachment.js.map +1 -0
  15. package/dist/{composables-BuHvnUlo.cjs → composables-Bi6QvJpj.cjs} +18 -43
  16. package/dist/{composables-BuHvnUlo.cjs.map → composables-Bi6QvJpj.cjs.map} +1 -1
  17. package/dist/{composables-CIkhKwAg.js → composables-DK3lwh38.js} +19 -44
  18. package/dist/{composables-CIkhKwAg.js.map → composables-DK3lwh38.js.map} +1 -1
  19. package/dist/index.cjs +25 -2
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +2 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +14 -3
  24. package/dist/index.js.map +1 -1
  25. package/dist/outline.cjs +22 -0
  26. package/dist/outline.cjs.map +1 -0
  27. package/dist/outline.d.cts +36 -0
  28. package/dist/outline.d.ts +36 -0
  29. package/dist/outline.js +17 -0
  30. package/dist/outline.js.map +1 -0
  31. package/dist/page-edit.cjs +3 -0
  32. package/dist/page-edit.cjs.map +1 -1
  33. package/dist/page-edit.d.cts +14 -2
  34. package/dist/page-edit.d.ts +14 -2
  35. package/dist/page-edit.js +5 -2
  36. package/dist/page-edit.js.map +1 -1
  37. package/dist/runtime.cjs +1 -1
  38. package/dist/runtime.js +1 -1
  39. package/package.json +40 -30
  40. package/dist/DocumentScope.vue_vue_type_script_setup_true_lang-CtTu1FGX.js.map +0 -1
  41. package/dist/DocumentScope.vue_vue_type_script_setup_true_lang-loLSm4lV.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { epdfThemeVariables, browserClock } from "@embedpdf/web";
1
+ import { epdfThemeVariables, browserPrinter, browserClock } from "@embedpdf/web";
2
2
  import { defineComponent, shallowRef, toRaw, watch, onMounted, onUnmounted, computed, renderSlot, openBlock, createElementBlock, Fragment, createCommentVNode, onScopeDispose, unref } from "vue";
3
3
  import { isLocalEngine, createKernel, viewerSettingsOf } from "@embedpdf/core";
4
4
  import { d as devWarn } from "./dev-CtMlvxjZ.js";
@@ -73,7 +73,8 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
73
73
  engine,
74
74
  plugins: initial.plugins,
75
75
  settings: settingsOf(),
76
- clock: browserClock()
76
+ clock: browserClock(),
77
+ printer: browserPrinter()
77
78
  });
78
79
  } catch (error) {
79
80
  bootError.value = error;
@@ -188,4 +189,4 @@ export {
188
189
  _sfc_main$3 as c,
189
190
  epdfTheme as e
190
191
  };
191
- //# sourceMappingURL=DocumentScope.vue_vue_type_script_setup_true_lang-CtTu1FGX.js.map
192
+ //# sourceMappingURL=DocumentScope.vue_vue_type_script_setup_true_lang-C-7yeEGh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentScope.vue_vue_type_script_setup_true_lang-C-7yeEGh.js","sources":["../src/theme.ts","../src/runtime/Viewer.vue","../src/runtime/KernelProvider.vue","../src/runtime/DocumentGate.vue","../src/runtime/DocumentScope.vue"],"sourcesContent":["/**\n * `epdfTheme()`: a theme written with setting names, as a style for the\n * element around your viewer. The variables and their lookup are framework-free\n * (`@embedpdf/web`); this only types the result as Vue's style.\n */\nimport type { CSSProperties } from 'vue';\nimport { epdfThemeVariables, type EpdfTheme } from '@embedpdf/web';\n\nexport type { EpdfTheme } from '@embedpdf/web';\n\n/**\n * The CSS variables of a theme, for a `:style` binding: `<div :style=\"epdfTheme({ accent })\">`.\n * Everything inside the element follows them, and a CSS variable wins over any setting.\n */\nexport function epdfTheme(theme: EpdfTheme): CSSProperties {\n return epdfThemeVariables(theme) as CSSProperties;\n}\n","<!--\n <Viewer>: owns the kernel. It creates and starts the kernel when it mounts\n (never on the server) and destroys it when it unmounts; the components inside\n read it through composables. `engine`, `plugins` and `initialDocuments` are\n read once; `identity`, `scope`, `accent` and `page` are the viewer's settings\n and follow the props.\n-->\n<script setup lang=\"ts\">\nimport { computed, onMounted, onUnmounted, shallowRef, toRaw, watch } from 'vue';\nimport { createKernel, isLocalEngine, viewerSettingsOf } from '@embedpdf/core';\nimport { browserClock, browserPrinter } from '@embedpdf/web';\nimport type {\n AnyPlugin,\n Engine,\n EngineFactory,\n Identity,\n InitialDocument,\n Kernel,\n ViewerPageSettings,\n ViewerSettings,\n} from '@embedpdf/core';\nimport { devWarn } from '../dev';\nimport { provideViewer } from './kernel';\n\nconst props = defineProps<{\n /**\n * The engine, as an instance or a function. An instance is borrowed: the\n * viewer uses it and never destroys it (a module-level `localEngine()`\n * shared by every viewer). A function is the viewer's own: it calls it when\n * it mounts and destroys the engine when it unmounts. Read once.\n */\n engine: Engine | EngineFactory;\n /** The plugins, created once next to the engine. Read once. */\n plugins: AnyPlugin[];\n /** Documents to open when the viewer starts, with optional tab names. Read once. */\n initialDocuments?: InitialDocument[];\n /**\n * Who the user is, for every document opened without an `identity` of its\n * own (which replaces this one). Documents opened after a change use the new\n * value; open ones keep theirs. The local engine only: the cloud engine reads\n * it from the document's token.\n */\n identity?: Identity;\n /**\n * What the user may do, as permissions, in every document opened without a\n * `scope` of its own. Left out, they may do everything. Changes reach the\n * documents opened after them, as `identity`.\n */\n scope?: readonly string[];\n /** The color every part without a color of its own follows. CSS `--epdf-accent` wins over it. */\n accent?: string;\n /** How pages look: `background` before the picture arrives, and the `shadow` under each page. */\n page?: Partial<ViewerPageSettings>;\n}>();\n\nconst emit = defineEmits<{\n /**\n * The kernel has started: before the default slot mounts and before\n * `initialDocuments` open. The door for code outside Vue components\n * (register commands, subscribe to events).\n */\n ready: [kernel: Kernel];\n}>();\n\ndefineSlots<{\n /** The viewer's content, mounted once the kernel has started. */\n default?(): unknown;\n /** Shown while the kernel starts; the composables already work in it. */\n fallback?(): unknown;\n /** Shown when the kernel couldn't be created or started. Without it, a failed start shows nothing. */\n error?(props: { error: unknown }): unknown;\n}>();\n\n/**\n * The viewer's settings as the props give them: a prop left out is its\n * default. Values reach the kernel raw: a reactive copy would be another object\n * to it, and can't be sent to a worker.\n */\nconst settingsOf = (): ViewerSettings =>\n viewerSettingsOf({\n identity: toRaw(props.identity),\n scope: toRaw(props.scope),\n accent: props.accent,\n page: toRaw(props.page),\n });\n\nconst kernel = shallowRef<Kernel | null>(null);\nconst phase = shallowRef<'booting' | 'ready' | 'error'>('booting');\nconst bootError = shallowRef<unknown>(null);\n// Goes up on every kernel change; every reader's computed depends on it.\nconst revision = shallowRef(0);\n\nprovideViewer({\n get kernel() {\n return kernel.value;\n },\n track: () => {\n void revision.value;\n },\n});\n\n// Read once: a changed engine or plugin list can't mean \"rebuild the\n// workspace\", which would drop every open document. Raw, because the kernel\n// knows a plugin's token by identity, and a reactive copy is another object.\nconst initial = {\n engine: toRaw(props.engine),\n plugins: toRaw(props.plugins),\n initialDocuments: toRaw(props.initialDocuments),\n};\nwatch(\n () => props.plugins,\n () =>\n devWarn(\n 'viewer-plugins-init-only',\n '<Viewer> plugins are read once, when it mounts; a new list is ignored. ' +\n 'Create the list once, next to the engine, not inline in the template.',\n ),\n);\nwatch(\n () => props.engine,\n (engine) => {\n // An inline `:engine=\"() => localEngine()\"` is a new function on every\n // render; only another engine instance is worth a warning.\n if (typeof engine === 'function') return;\n devWarn(\n 'viewer-engine-init-only',\n '<Viewer> engine is read once, when it mounts; another engine is ignored. ' +\n 'To use another engine, mount a new <Viewer>, for example with a new `key`.',\n );\n },\n);\n\nlet teardown: (() => void) | null = null;\n\nonMounted(() => {\n // A function is the viewer's own engine: called now, destroyed on unmount.\n // An instance is borrowed. Construction is synchronous and inert either way,\n // so warming up a local engine overlaps its boot with the plugins' start.\n const ownsEngine = typeof initial.engine === 'function';\n const engine: Engine = ownsEngine\n ? (initial.engine as EngineFactory)()\n : (initial.engine as Engine);\n if (isLocalEngine(engine)) engine.warmup();\n let created: Kernel;\n try {\n created = createKernel({\n engine,\n plugins: initial.plugins,\n settings: settingsOf(),\n clock: browserClock(),\n printer: browserPrinter(),\n });\n } catch (error) {\n // A plan or dependency error shows in the `error` slot.\n bootError.value = error;\n phase.value = 'error';\n if (ownsEngine) void engine.destroy();\n return;\n }\n const stopTracking = created.subscribe(() => {\n revision.value += 1;\n });\n // The kernel is on the binding from now on, so the fallback can use it.\n kernel.value = created;\n let alive = true;\n created.start().then(\n () => {\n if (!alive) return;\n emit('ready', created);\n phase.value = 'ready';\n // Every tab appears at once, in order; the `active` entry (else the\n // first) is selected; a failure shows as that document's status.\n created.documents.openAll(initial.initialDocuments ?? []);\n },\n (error: unknown) => {\n if (!alive) return;\n bootError.value = error;\n phase.value = 'error';\n },\n );\n teardown = () => {\n alive = false;\n stopTracking();\n // The kernel first (it closes every document's handle), then the engine\n // the viewer owns.\n void created.destroy().then(() => {\n if (ownsEngine) void engine.destroy();\n });\n };\n});\n\n// After the content has unmounted, so its own cleanups still reach a live kernel.\nonUnmounted(() => teardown?.());\n\n// Props compare by value: an inline `:page=\"{ shadow: 'none' }\"` is a new\n// object on every render, and settings that didn't change change nothing.\nwatch(settingsOf, (settings) => kernel.value?.updateSettings(settings));\n\ndefineExpose({\n /** The started kernel; null before it starts and after a failed start. */\n kernel: computed(() => (phase.value === 'ready' ? kernel.value : null)),\n});\n</script>\n\n<template>\n <slot v-if=\"phase === 'error'\" name=\"error\" :error=\"bootError\" />\n <template v-else-if=\"kernel\">\n <slot v-if=\"phase === 'ready'\" />\n <slot v-else name=\"fallback\" />\n </template>\n</template>\n","<!--\n <KernelProvider :kernel>: gives its content a kernel someone else created and\n owns, so every composable inside works against that kernel. The full viewer's\n Vue wrapper puts the components it shows in the viewer inside one. It never\n starts or destroys the kernel; <Viewer> is the component that owns one. The\n kernel is read once: for another one, mount a new provider (a new `key`).\n-->\n<script setup lang=\"ts\">\nimport { onScopeDispose, shallowRef, toRaw, watch } from 'vue';\nimport type { Kernel } from '@embedpdf/core';\nimport { devWarn } from '../dev';\nimport { provideViewer } from './kernel';\n\nconst props = defineProps<{\n /** The kernel, created and started by its owner. Read once. */\n kernel: Kernel;\n}>();\n\ndefineSlots<{ default?(): unknown }>();\n\n// Read once, as `<Viewer>` reads its engine: the composables inside took this kernel when they\n// were set up, and a new one under them would leave them reading the old one. Raw, because a\n// reactive copy of the kernel is another object.\nconst kernel = toRaw(props.kernel);\nwatch(\n () => props.kernel,\n () =>\n devWarn(\n 'kernel-provider-kernel-init-only',\n '<KernelProvider> kernel is read once, when it mounts; another kernel is ignored. ' +\n 'To give its content another kernel, mount a new <KernelProvider>, for example with a new `key`.',\n ),\n);\n\n// Goes up on every change the kernel announces; every reader's computed depends on it.\nconst revision = shallowRef(0);\nonScopeDispose(\n kernel.subscribe(() => {\n revision.value += 1;\n }),\n);\n\nprovideViewer({\n kernel,\n track: () => {\n void revision.value;\n },\n});\n</script>\n\n<template>\n <slot />\n</template>\n","<!--\n <DocumentGate>: renders its content only while this subtree has a ready\n document, the structural way to say \"this UI is defined over a document\".\n Workspace UI (toolbars, commands) lives outside it; document UI (the Stage,\n panels) inside. A document that waits for its password, or failed, renders\n the `#locked` or `#error` slot with it, or else `#fallback`. It decides\n whether; <DocumentScope> decides which document.\n-->\n<script setup lang=\"ts\">\nimport type { DocumentInfo, FailedDocumentInfo, LockedDocumentInfo } from '@embedpdf/core';\nimport { useDocument } from './documents';\n\ndefineSlots<{\n /** Rendered while the document is ready. */\n default?(): unknown;\n /** Shown while this subtree has no document: none is open, or it's still opening. */\n fallback?(): unknown;\n /** Shown while the document waits for its password; `#fallback` without it. */\n locked?(props: { document: LockedDocumentInfo }): unknown;\n /** Shown when the document couldn't be opened, with why; `#fallback` without it. */\n error?(props: { document: FailedDocumentInfo }): unknown;\n}>();\n\nconst current = useDocument((document: DocumentInfo) => document);\n</script>\n\n<template>\n <slot v-if=\"current.status === 'ready'\" />\n <slot\n v-else-if=\"current.status === 'locked' && $slots.locked\"\n name=\"locked\"\n :document=\"current as LockedDocumentInfo\"\n />\n <slot\n v-else-if=\"current.status === 'error' && $slots.error\"\n name=\"error\"\n :document=\"current as FailedDocumentInfo\"\n />\n <slot v-else name=\"fallback\" />\n</template>\n","<!--\n <DocumentScope :id>: binds its content to one document, for panes and\n comparisons. The composables inside talk to that document instead of the\n active one, and `useDocuments()` calls without an id use it.\n-->\n<script setup lang=\"ts\">\nimport { provideDocumentScope } from './kernel';\n\nconst props = defineProps<{\n /** The document's id. */\n id: string;\n}>();\n\ndefineSlots<{ default?(): unknown }>();\n\nprovideDocumentScope(() => props.id);\n</script>\n\n<template>\n <slot />\n</template>\n"],"names":["_renderSlot","_createElementBlock","_Fragment","_unref","$slots"],"mappings":";;;;;;AAcO,SAAS,UAAU,OAAiC;AACzD,SAAO,mBAAmB,KAAK;AACjC;;;;;;;;;;;;;;ACQA,UAAM,QAAQ;AA+Bd,UAAM,OAAO;AAuBb,UAAM,aAAa,MACjB,iBAAiB;AAAA,MACf,UAAU,MAAM,MAAM,QAAQ;AAAA,MAC9B,OAAO,MAAM,MAAM,KAAK;AAAA,MACxB,QAAQ,MAAM;AAAA,MACd,MAAM,MAAM,MAAM,IAAI;AAAA,IAAA,CACvB;AAEH,UAAM,SAAS,WAA0B,IAAI;AAC7C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,MACA,OAAO,MAAM;AACX,aAAK,SAAS;AAAA,MAChB;AAAA,IAAA,CACD;;aAICA,WAAQ,KAAA,QAAA,SAAA;AAAA;;;;;;AC5BV,UAAM,UAAU,YAAY,CAAC,aAA2B,QAAQ;;AAIlD,aAAAG,MAAA,OAAA,EAAQ,WAAM,UAA1BH,WAA0C,KAAA,QAAA,WAAA,CAAA,GAAA,QAAA,QAAA,CAAA,IAE7BG,MAAA,OAAA,EAAQ,WAAM,YAAiBC,KAAAA,OAAO,SADnDJ,WAIE,KAAA,QAAA,UAAA;AAAA,QADC,UAAUG,MAAA,OAAA;AAAA,MAAA,wBAGAA,MAAA,OAAA,EAAQ,WAAM,WAAgBC,KAAAA,OAAO,QADlDJ,WAIE,KAAA,QAAA,SAAA;AAAA,QADC,UAAUG,MAAA,OAAA;AAAA,MAAA,wBAEbH,WAA+B,KAAA,QAAA,YAAA,CAAA,GAAA,QAAA,QAAA,CAAA;AAAA;;;;;;;;;AC9BjC,UAAM,QAAQ;AAOd,yBAAqB,MAAM,MAAM,EAAE;;aAIjCA,WAAQ,KAAA,QAAA,SAAA;AAAA;;;"}
@@ -74,7 +74,8 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
74
74
  engine,
75
75
  plugins: initial.plugins,
76
76
  settings: settingsOf(),
77
- clock: web.browserClock()
77
+ clock: web.browserClock(),
78
+ printer: web.browserPrinter()
78
79
  });
79
80
  } catch (error) {
80
81
  bootError.value = error;
@@ -187,4 +188,4 @@ exports._sfc_main$1 = _sfc_main;
187
188
  exports._sfc_main$2 = _sfc_main$2;
188
189
  exports._sfc_main$3 = _sfc_main$3;
189
190
  exports.epdfTheme = epdfTheme;
190
- //# sourceMappingURL=DocumentScope.vue_vue_type_script_setup_true_lang-loLSm4lV.cjs.map
191
+ //# sourceMappingURL=DocumentScope.vue_vue_type_script_setup_true_lang-czzeUzPl.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentScope.vue_vue_type_script_setup_true_lang-czzeUzPl.cjs","sources":["../src/theme.ts","../src/runtime/Viewer.vue","../src/runtime/KernelProvider.vue","../src/runtime/DocumentGate.vue","../src/runtime/DocumentScope.vue"],"sourcesContent":["/**\n * `epdfTheme()`: a theme written with setting names, as a style for the\n * element around your viewer. The variables and their lookup are framework-free\n * (`@embedpdf/web`); this only types the result as Vue's style.\n */\nimport type { CSSProperties } from 'vue';\nimport { epdfThemeVariables, type EpdfTheme } from '@embedpdf/web';\n\nexport type { EpdfTheme } from '@embedpdf/web';\n\n/**\n * The CSS variables of a theme, for a `:style` binding: `<div :style=\"epdfTheme({ accent })\">`.\n * Everything inside the element follows them, and a CSS variable wins over any setting.\n */\nexport function epdfTheme(theme: EpdfTheme): CSSProperties {\n return epdfThemeVariables(theme) as CSSProperties;\n}\n","<!--\n <Viewer>: owns the kernel. It creates and starts the kernel when it mounts\n (never on the server) and destroys it when it unmounts; the components inside\n read it through composables. `engine`, `plugins` and `initialDocuments` are\n read once; `identity`, `scope`, `accent` and `page` are the viewer's settings\n and follow the props.\n-->\n<script setup lang=\"ts\">\nimport { computed, onMounted, onUnmounted, shallowRef, toRaw, watch } from 'vue';\nimport { createKernel, isLocalEngine, viewerSettingsOf } from '@embedpdf/core';\nimport { browserClock, browserPrinter } from '@embedpdf/web';\nimport type {\n AnyPlugin,\n Engine,\n EngineFactory,\n Identity,\n InitialDocument,\n Kernel,\n ViewerPageSettings,\n ViewerSettings,\n} from '@embedpdf/core';\nimport { devWarn } from '../dev';\nimport { provideViewer } from './kernel';\n\nconst props = defineProps<{\n /**\n * The engine, as an instance or a function. An instance is borrowed: the\n * viewer uses it and never destroys it (a module-level `localEngine()`\n * shared by every viewer). A function is the viewer's own: it calls it when\n * it mounts and destroys the engine when it unmounts. Read once.\n */\n engine: Engine | EngineFactory;\n /** The plugins, created once next to the engine. Read once. */\n plugins: AnyPlugin[];\n /** Documents to open when the viewer starts, with optional tab names. Read once. */\n initialDocuments?: InitialDocument[];\n /**\n * Who the user is, for every document opened without an `identity` of its\n * own (which replaces this one). Documents opened after a change use the new\n * value; open ones keep theirs. The local engine only: the cloud engine reads\n * it from the document's token.\n */\n identity?: Identity;\n /**\n * What the user may do, as permissions, in every document opened without a\n * `scope` of its own. Left out, they may do everything. Changes reach the\n * documents opened after them, as `identity`.\n */\n scope?: readonly string[];\n /** The color every part without a color of its own follows. CSS `--epdf-accent` wins over it. */\n accent?: string;\n /** How pages look: `background` before the picture arrives, and the `shadow` under each page. */\n page?: Partial<ViewerPageSettings>;\n}>();\n\nconst emit = defineEmits<{\n /**\n * The kernel has started: before the default slot mounts and before\n * `initialDocuments` open. The door for code outside Vue components\n * (register commands, subscribe to events).\n */\n ready: [kernel: Kernel];\n}>();\n\ndefineSlots<{\n /** The viewer's content, mounted once the kernel has started. */\n default?(): unknown;\n /** Shown while the kernel starts; the composables already work in it. */\n fallback?(): unknown;\n /** Shown when the kernel couldn't be created or started. Without it, a failed start shows nothing. */\n error?(props: { error: unknown }): unknown;\n}>();\n\n/**\n * The viewer's settings as the props give them: a prop left out is its\n * default. Values reach the kernel raw: a reactive copy would be another object\n * to it, and can't be sent to a worker.\n */\nconst settingsOf = (): ViewerSettings =>\n viewerSettingsOf({\n identity: toRaw(props.identity),\n scope: toRaw(props.scope),\n accent: props.accent,\n page: toRaw(props.page),\n });\n\nconst kernel = shallowRef<Kernel | null>(null);\nconst phase = shallowRef<'booting' | 'ready' | 'error'>('booting');\nconst bootError = shallowRef<unknown>(null);\n// Goes up on every kernel change; every reader's computed depends on it.\nconst revision = shallowRef(0);\n\nprovideViewer({\n get kernel() {\n return kernel.value;\n },\n track: () => {\n void revision.value;\n },\n});\n\n// Read once: a changed engine or plugin list can't mean \"rebuild the\n// workspace\", which would drop every open document. Raw, because the kernel\n// knows a plugin's token by identity, and a reactive copy is another object.\nconst initial = {\n engine: toRaw(props.engine),\n plugins: toRaw(props.plugins),\n initialDocuments: toRaw(props.initialDocuments),\n};\nwatch(\n () => props.plugins,\n () =>\n devWarn(\n 'viewer-plugins-init-only',\n '<Viewer> plugins are read once, when it mounts; a new list is ignored. ' +\n 'Create the list once, next to the engine, not inline in the template.',\n ),\n);\nwatch(\n () => props.engine,\n (engine) => {\n // An inline `:engine=\"() => localEngine()\"` is a new function on every\n // render; only another engine instance is worth a warning.\n if (typeof engine === 'function') return;\n devWarn(\n 'viewer-engine-init-only',\n '<Viewer> engine is read once, when it mounts; another engine is ignored. ' +\n 'To use another engine, mount a new <Viewer>, for example with a new `key`.',\n );\n },\n);\n\nlet teardown: (() => void) | null = null;\n\nonMounted(() => {\n // A function is the viewer's own engine: called now, destroyed on unmount.\n // An instance is borrowed. Construction is synchronous and inert either way,\n // so warming up a local engine overlaps its boot with the plugins' start.\n const ownsEngine = typeof initial.engine === 'function';\n const engine: Engine = ownsEngine\n ? (initial.engine as EngineFactory)()\n : (initial.engine as Engine);\n if (isLocalEngine(engine)) engine.warmup();\n let created: Kernel;\n try {\n created = createKernel({\n engine,\n plugins: initial.plugins,\n settings: settingsOf(),\n clock: browserClock(),\n printer: browserPrinter(),\n });\n } catch (error) {\n // A plan or dependency error shows in the `error` slot.\n bootError.value = error;\n phase.value = 'error';\n if (ownsEngine) void engine.destroy();\n return;\n }\n const stopTracking = created.subscribe(() => {\n revision.value += 1;\n });\n // The kernel is on the binding from now on, so the fallback can use it.\n kernel.value = created;\n let alive = true;\n created.start().then(\n () => {\n if (!alive) return;\n emit('ready', created);\n phase.value = 'ready';\n // Every tab appears at once, in order; the `active` entry (else the\n // first) is selected; a failure shows as that document's status.\n created.documents.openAll(initial.initialDocuments ?? []);\n },\n (error: unknown) => {\n if (!alive) return;\n bootError.value = error;\n phase.value = 'error';\n },\n );\n teardown = () => {\n alive = false;\n stopTracking();\n // The kernel first (it closes every document's handle), then the engine\n // the viewer owns.\n void created.destroy().then(() => {\n if (ownsEngine) void engine.destroy();\n });\n };\n});\n\n// After the content has unmounted, so its own cleanups still reach a live kernel.\nonUnmounted(() => teardown?.());\n\n// Props compare by value: an inline `:page=\"{ shadow: 'none' }\"` is a new\n// object on every render, and settings that didn't change change nothing.\nwatch(settingsOf, (settings) => kernel.value?.updateSettings(settings));\n\ndefineExpose({\n /** The started kernel; null before it starts and after a failed start. */\n kernel: computed(() => (phase.value === 'ready' ? kernel.value : null)),\n});\n</script>\n\n<template>\n <slot v-if=\"phase === 'error'\" name=\"error\" :error=\"bootError\" />\n <template v-else-if=\"kernel\">\n <slot v-if=\"phase === 'ready'\" />\n <slot v-else name=\"fallback\" />\n </template>\n</template>\n","<!--\n <KernelProvider :kernel>: gives its content a kernel someone else created and\n owns, so every composable inside works against that kernel. The full viewer's\n Vue wrapper puts the components it shows in the viewer inside one. It never\n starts or destroys the kernel; <Viewer> is the component that owns one. The\n kernel is read once: for another one, mount a new provider (a new `key`).\n-->\n<script setup lang=\"ts\">\nimport { onScopeDispose, shallowRef, toRaw, watch } from 'vue';\nimport type { Kernel } from '@embedpdf/core';\nimport { devWarn } from '../dev';\nimport { provideViewer } from './kernel';\n\nconst props = defineProps<{\n /** The kernel, created and started by its owner. Read once. */\n kernel: Kernel;\n}>();\n\ndefineSlots<{ default?(): unknown }>();\n\n// Read once, as `<Viewer>` reads its engine: the composables inside took this kernel when they\n// were set up, and a new one under them would leave them reading the old one. Raw, because a\n// reactive copy of the kernel is another object.\nconst kernel = toRaw(props.kernel);\nwatch(\n () => props.kernel,\n () =>\n devWarn(\n 'kernel-provider-kernel-init-only',\n '<KernelProvider> kernel is read once, when it mounts; another kernel is ignored. ' +\n 'To give its content another kernel, mount a new <KernelProvider>, for example with a new `key`.',\n ),\n);\n\n// Goes up on every change the kernel announces; every reader's computed depends on it.\nconst revision = shallowRef(0);\nonScopeDispose(\n kernel.subscribe(() => {\n revision.value += 1;\n }),\n);\n\nprovideViewer({\n kernel,\n track: () => {\n void revision.value;\n },\n});\n</script>\n\n<template>\n <slot />\n</template>\n","<!--\n <DocumentGate>: renders its content only while this subtree has a ready\n document, the structural way to say \"this UI is defined over a document\".\n Workspace UI (toolbars, commands) lives outside it; document UI (the Stage,\n panels) inside. A document that waits for its password, or failed, renders\n the `#locked` or `#error` slot with it, or else `#fallback`. It decides\n whether; <DocumentScope> decides which document.\n-->\n<script setup lang=\"ts\">\nimport type { DocumentInfo, FailedDocumentInfo, LockedDocumentInfo } from '@embedpdf/core';\nimport { useDocument } from './documents';\n\ndefineSlots<{\n /** Rendered while the document is ready. */\n default?(): unknown;\n /** Shown while this subtree has no document: none is open, or it's still opening. */\n fallback?(): unknown;\n /** Shown while the document waits for its password; `#fallback` without it. */\n locked?(props: { document: LockedDocumentInfo }): unknown;\n /** Shown when the document couldn't be opened, with why; `#fallback` without it. */\n error?(props: { document: FailedDocumentInfo }): unknown;\n}>();\n\nconst current = useDocument((document: DocumentInfo) => document);\n</script>\n\n<template>\n <slot v-if=\"current.status === 'ready'\" />\n <slot\n v-else-if=\"current.status === 'locked' && $slots.locked\"\n name=\"locked\"\n :document=\"current as LockedDocumentInfo\"\n />\n <slot\n v-else-if=\"current.status === 'error' && $slots.error\"\n name=\"error\"\n :document=\"current as FailedDocumentInfo\"\n />\n <slot v-else name=\"fallback\" />\n</template>\n","<!--\n <DocumentScope :id>: binds its content to one document, for panes and\n comparisons. The composables inside talk to that document instead of the\n active one, and `useDocuments()` calls without an id use it.\n-->\n<script setup lang=\"ts\">\nimport { provideDocumentScope } from './kernel';\n\nconst props = defineProps<{\n /** The document's id. */\n id: string;\n}>();\n\ndefineSlots<{ default?(): unknown }>();\n\nprovideDocumentScope(() => props.id);\n</script>\n\n<template>\n <slot />\n</template>\n"],"names":["epdfThemeVariables","viewerSettingsOf","toRaw","shallowRef","provideViewer","watch","devWarn","onMounted","isLocalEngine","createKernel","browserClock","browserPrinter","onUnmounted","computed","_renderSlot","_createElementBlock","_Fragment","onScopeDispose","useDocument","_unref","$slots","provideDocumentScope"],"mappings":";;;;;;;AAcO,SAAS,UAAU,OAAiC;AACzD,SAAOA,IAAAA,mBAAmB,KAAK;AACjC;;;;;;;;;;;;;;ACQA,UAAM,QA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AA,QAAA,SAAA;AAAA;;;;;;;;"}
@@ -22,6 +22,7 @@ export declare function provideLookScale(scale: Readonly<Ref<number>>): void;
22
22
  * ```
23
23
  *
24
24
  * `ref` goes on your element (render nothing inside it: the editor owns what's
25
- * in it); `style` and `editing` are refs.
25
+ * in it); `style` and `editing` are refs. `style` fills the element's parent at
26
+ * a legible size: draw the box's frame on the parent.
26
27
  */
27
28
  export declare function useRichTextEditor(annotation: MaybeRefOrGetter<Annotation>): RichTextEditor;
@@ -22,6 +22,7 @@ export declare function provideLookScale(scale: Readonly<Ref<number>>): void;
22
22
  * ```
23
23
  *
24
24
  * `ref` goes on your element (render nothing inside it: the editor owns what's
25
- * in it); `style` and `editing` are refs.
25
+ * in it); `style` and `editing` are refs. `style` fills the element's parent at
26
+ * a legible size: draw the box's frame on the parent.
26
27
  */
27
28
  export declare function useRichTextEditor(annotation: MaybeRefOrGetter<Annotation>): RichTextEditor;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const pluginAnnotation = require("@embedpdf/plugin-annotation");
4
- const composables = require("./composables-BuHvnUlo.cjs");
4
+ const composables = require("./composables-Bi6QvJpj.cjs");
5
5
  exports.AnnotationDraftMenu = composables._sfc_main;
6
6
  exports.AnnotationLayer = composables._sfc_main$1;
7
7
  exports.AnnotationMenu = composables._sfc_main$2;
@@ -1,5 +1,5 @@
1
1
  export * from "@embedpdf/plugin-annotation";
2
- import { _, a, b, c, f, u, d, e, g, h, i, j, k, l, m, n, o, p } from "./composables-CIkhKwAg.js";
2
+ import { _, a, b, c, f, u, d, e, g, h, i, j, k, l, m, n, o, p } from "./composables-DK3lwh38.js";
3
3
  export {
4
4
  _ as AnnotationDraftMenu,
5
5
  a as AnnotationLayer,
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const pluginAttachment = require("@embedpdf/plugin-attachment");
4
+ const capabilities = require("./capabilities-DVNJmgy7.cjs");
5
+ const state = require("./state-M22NDJQo.cjs");
6
+ function useAttachment() {
7
+ return capabilities.useCapability(pluginAttachment.AttachmentToken);
8
+ }
9
+ const useAttachmentState = state.stateComposable(pluginAttachment.attachmentState);
10
+ function useAttachmentEvent(select, handler) {
11
+ capabilities.useCapabilityEvent(pluginAttachment.AttachmentToken, select, handler);
12
+ }
13
+ exports.useAttachment = useAttachment;
14
+ exports.useAttachmentEvent = useAttachmentEvent;
15
+ exports.useAttachmentState = useAttachmentState;
16
+ Object.keys(pluginAttachment).forEach((k) => {
17
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
18
+ enumerable: true,
19
+ get: () => pluginAttachment[k]
20
+ });
21
+ });
22
+ //# sourceMappingURL=attachment.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment.cjs","sources":["../src/attachment.ts"],"sourcesContent":["/**\n * @embedpdf/vue/attachment: the Vue view of `@embedpdf/plugin-attachment`.\n * Reading the state reads the document's attachments; the plugin keeps them\n * live off the document's event stream, lists the pages' files with them, and\n * shows your own adds and removes at once.\n *\n * const attachment = useAttachment();\n * const { files, canAdd } = useAttachmentState();\n * const { bytes, name, mimeType } = await attachment.download(file);\n */\n\n// One line per feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-attachment';\nimport type { EventHook } from '@embedpdf/core';\nimport { AttachmentToken, attachmentState } from '@embedpdf/plugin-attachment';\nimport type { AttachmentCapability } from '@embedpdf/plugin-attachment';\n\nimport { useCapability, useCapabilityEvent } from './runtime/capabilities';\nimport { stateComposable } from './state';\n\n/**\n * The attachment API (add, remove, download, reveal) of the nearest\n * `<DocumentScope>`'s document, else the active one. The object never\n * changes; outside a document every method throws `not-ready`.\n */\nexport function useAttachment(): AttachmentCapability {\n return useCapability(AttachmentToken);\n}\n\n/**\n * The files the document carries, the load state, and whether you may add and\n * save files, as refs (the page's State table, declared once in\n * `attachmentState`). With a selector, one ref for the value it picks, which\n * updates only when that value changes.\n */\nexport const useAttachmentState = stateComposable(attachmentState);\n\n/** Subscribe to one attachment event while the component lives: `useAttachmentEvent((attachment) => attachment.onChanged, handler)`. */\nexport function useAttachmentEvent<Event>(\n select: (attachment: AttachmentCapability) => EventHook<Event>,\n handler: (event: Event) => void,\n): void {\n useCapabilityEvent(AttachmentToken, select, handler);\n}\n"],"names":["useCapability","AttachmentToken","stateComposable","attachmentState","useCapabilityEvent"],"mappings":";;;;;AAyBO,SAAS,gBAAsC;AACpD,SAAOA,aAAAA,cAAcC,iBAAAA,eAAe;AACtC;AAQO,MAAM,qBAAqBC,MAAAA,gBAAgBC,iBAAAA,eAAe;AAG1D,SAAS,mBACd,QACA,SACM;AACNC,kCAAmBH,iBAAAA,iBAAiB,QAAQ,OAAO;AACrD;;;;;;;;;;"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @embedpdf/vue/attachment: the Vue view of `@embedpdf/plugin-attachment`.
3
+ * Reading the state reads the document's attachments; the plugin keeps them
4
+ * live off the document's event stream, lists the pages' files with them, and
5
+ * shows your own adds and removes at once.
6
+ *
7
+ * const attachment = useAttachment();
8
+ * const { files, canAdd } = useAttachmentState();
9
+ * const { bytes, name, mimeType } = await attachment.download(file);
10
+ */
11
+ export * from '@embedpdf/plugin-attachment';
12
+ import type { EventHook } from '@embedpdf/core';
13
+ import type { AttachmentCapability } from '@embedpdf/plugin-attachment';
14
+ /**
15
+ * The attachment API (add, remove, download, reveal) of the nearest
16
+ * `<DocumentScope>`'s document, else the active one. The object never
17
+ * changes; outside a document every method throws `not-ready`.
18
+ */
19
+ export declare function useAttachment(): AttachmentCapability;
20
+ /**
21
+ * The files the document carries, the load state, and whether you may add and
22
+ * save files, as refs (the page's State table, declared once in
23
+ * `attachmentState`). With a selector, one ref for the value it picks, which
24
+ * updates only when that value changes.
25
+ */
26
+ export declare const useAttachmentState: import("./state.cjs").StateComposable<{
27
+ files: readonly import("@embedpdf/plugin-attachment").AttachedFile[];
28
+ selected: readonly import("@embedpdf/plugin-attachment").AttachedFile[];
29
+ status: import("@embedpdf/core").ResourceStatus;
30
+ canAdd: boolean;
31
+ canDownload: boolean;
32
+ }>;
33
+ /** Subscribe to one attachment event while the component lives: `useAttachmentEvent((attachment) => attachment.onChanged, handler)`. */
34
+ export declare function useAttachmentEvent<Event>(select: (attachment: AttachmentCapability) => EventHook<Event>, handler: (event: Event) => void): void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @embedpdf/vue/attachment: the Vue view of `@embedpdf/plugin-attachment`.
3
+ * Reading the state reads the document's attachments; the plugin keeps them
4
+ * live off the document's event stream, lists the pages' files with them, and
5
+ * shows your own adds and removes at once.
6
+ *
7
+ * const attachment = useAttachment();
8
+ * const { files, canAdd } = useAttachmentState();
9
+ * const { bytes, name, mimeType } = await attachment.download(file);
10
+ */
11
+ export * from '@embedpdf/plugin-attachment';
12
+ import type { EventHook } from '@embedpdf/core';
13
+ import type { AttachmentCapability } from '@embedpdf/plugin-attachment';
14
+ /**
15
+ * The attachment API (add, remove, download, reveal) of the nearest
16
+ * `<DocumentScope>`'s document, else the active one. The object never
17
+ * changes; outside a document every method throws `not-ready`.
18
+ */
19
+ export declare function useAttachment(): AttachmentCapability;
20
+ /**
21
+ * The files the document carries, the load state, and whether you may add and
22
+ * save files, as refs (the page's State table, declared once in
23
+ * `attachmentState`). With a selector, one ref for the value it picks, which
24
+ * updates only when that value changes.
25
+ */
26
+ export declare const useAttachmentState: import("./state.js").StateComposable<{
27
+ files: readonly import("@embedpdf/plugin-attachment").AttachedFile[];
28
+ selected: readonly import("@embedpdf/plugin-attachment").AttachedFile[];
29
+ status: import("@embedpdf/core").ResourceStatus;
30
+ canAdd: boolean;
31
+ canDownload: boolean;
32
+ }>;
33
+ /** Subscribe to one attachment event while the component lives: `useAttachmentEvent((attachment) => attachment.onChanged, handler)`. */
34
+ export declare function useAttachmentEvent<Event>(select: (attachment: AttachmentCapability) => EventHook<Event>, handler: (event: Event) => void): void;
@@ -0,0 +1,17 @@
1
+ import { AttachmentToken, attachmentState } from "@embedpdf/plugin-attachment";
2
+ export * from "@embedpdf/plugin-attachment";
3
+ import { a as useCapability, b as useCapabilityEvent } from "./capabilities-C7YzgPCX.js";
4
+ import { a as stateComposable } from "./state-DZg8q3v6.js";
5
+ function useAttachment() {
6
+ return useCapability(AttachmentToken);
7
+ }
8
+ const useAttachmentState = stateComposable(attachmentState);
9
+ function useAttachmentEvent(select, handler) {
10
+ useCapabilityEvent(AttachmentToken, select, handler);
11
+ }
12
+ export {
13
+ useAttachment,
14
+ useAttachmentEvent,
15
+ useAttachmentState
16
+ };
17
+ //# sourceMappingURL=attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment.js","sources":["../src/attachment.ts"],"sourcesContent":["/**\n * @embedpdf/vue/attachment: the Vue view of `@embedpdf/plugin-attachment`.\n * Reading the state reads the document's attachments; the plugin keeps them\n * live off the document's event stream, lists the pages' files with them, and\n * shows your own adds and removes at once.\n *\n * const attachment = useAttachment();\n * const { files, canAdd } = useAttachmentState();\n * const { bytes, name, mimeType } = await attachment.download(file);\n */\n\n// One line per feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-attachment';\nimport type { EventHook } from '@embedpdf/core';\nimport { AttachmentToken, attachmentState } from '@embedpdf/plugin-attachment';\nimport type { AttachmentCapability } from '@embedpdf/plugin-attachment';\n\nimport { useCapability, useCapabilityEvent } from './runtime/capabilities';\nimport { stateComposable } from './state';\n\n/**\n * The attachment API (add, remove, download, reveal) of the nearest\n * `<DocumentScope>`'s document, else the active one. The object never\n * changes; outside a document every method throws `not-ready`.\n */\nexport function useAttachment(): AttachmentCapability {\n return useCapability(AttachmentToken);\n}\n\n/**\n * The files the document carries, the load state, and whether you may add and\n * save files, as refs (the page's State table, declared once in\n * `attachmentState`). With a selector, one ref for the value it picks, which\n * updates only when that value changes.\n */\nexport const useAttachmentState = stateComposable(attachmentState);\n\n/** Subscribe to one attachment event while the component lives: `useAttachmentEvent((attachment) => attachment.onChanged, handler)`. */\nexport function useAttachmentEvent<Event>(\n select: (attachment: AttachmentCapability) => EventHook<Event>,\n handler: (event: Event) => void,\n): void {\n useCapabilityEvent(AttachmentToken, select, handler);\n}\n"],"names":[],"mappings":";;;;AAyBO,SAAS,gBAAsC;AACpD,SAAO,cAAc,eAAe;AACtC;AAQO,MAAM,qBAAqB,gBAAgB,eAAe;AAG1D,SAAS,mBACd,QACA,SACM;AACN,qBAAmB,iBAAiB,QAAQ,OAAO;AACrD;"}
@@ -245,9 +245,11 @@ function useRichTextEditor(annotation) {
245
245
  const item = capabilities.useOptionalSelector(
246
246
  host.AnnotationToken,
247
247
  (host2) => {
248
- const key = core.annotationKey(vue.toValue(annotation).ref);
249
248
  const { transform } = page$1.value;
250
- return host2.listTextItems(page$1.value.ref, { zoom: transform.zoom, rotation: transform.rotation }).find((text) => text.ref !== null && core.annotationKey(text.ref) === key) ?? null;
249
+ return host2.getTextItem(vue.toValue(annotation).ref, {
250
+ zoom: transform.zoom,
251
+ rotation: transform.rotation
252
+ });
251
253
  },
252
254
  null
253
255
  );
@@ -255,14 +257,14 @@ function useRichTextEditor(annotation) {
255
257
  const scale = vue.computed(
256
258
  () => web.textBoxEditorScaleOf(item.value, page$1.value.transform, lookScale.value)
257
259
  );
258
- const element = useTextBoxEditor(item, scale);
260
+ const own = vue.computed(() => item.value ? web.ownTextBoxOf(item.value, scale.value) : null);
261
+ const element = useTextBoxEditor(item, () => {
262
+ var _a;
263
+ return ((_a = own.value) == null ? void 0 : _a.scale) ?? scale.value;
264
+ });
259
265
  const style = vue.computed(() => {
260
- const text = item.value;
261
- if (!text) return NO_STYLE;
262
- return {
263
- ...web.textBoxStyleOf(text.css, scale.value),
264
- ...text.editing ? { pointerEvents: "auto" } : {}
265
- };
266
+ var _a;
267
+ return ((_a = own.value) == null ? void 0 : _a.style) ?? NO_STYLE;
266
268
  });
267
269
  return {
268
270
  ref: (target) => {
@@ -338,46 +340,19 @@ const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
338
340
  },
339
341
  setup(__props) {
340
342
  const props = __props;
341
- const plate = vue.computed(() => web.textPlateInPixels(props.item, props.page.transform));
342
- const element = useTextBoxEditor(
343
- () => props.item,
344
- () => plate.value.scale
345
- );
346
343
  const chrome = useAnnotationSettings((settings) => settings.chrome);
347
344
  const accent = documents.useViewerSettings((settings) => settings.accent);
348
345
  const outline = vue.computed(() => web.annotationChromePaint(chrome.value, accent.value).textOutline);
349
- const style = vue.computed(() => {
350
- const { item } = props;
351
- const { left, top, width, height, scale } = plate.value;
352
- return {
353
- position: "absolute",
354
- left: `${left}px`,
355
- top: `${top}px`,
356
- width: `${width}px`,
357
- // Fixed to the plate: the box never grows with its text; it scrolls while
358
- // typing and clips otherwise, where the baked appearance clips.
359
- height: `${height}px`,
360
- ...web.textBoxStyleOf(item.css, scale),
361
- boxSizing: "border-box",
362
- // The box's fill and border are the vector scene's, under this layer.
363
- background: "transparent",
364
- whiteSpace: "pre-wrap",
365
- overflowWrap: "break-word",
366
- overflowY: item.editing ? "auto" : "hidden",
367
- overflowX: "hidden",
368
- outline: item.editing ? `1px solid ${outline.value}` : "none",
369
- cursor: item.editing ? "text" : "default",
370
- // A plain text box turns about its centre, as the baked appearance does.
371
- ...item.rot ? { transform: `rotate(${item.rot}deg)`, transformOrigin: "center" } : {},
372
- // Not typing: clicks fall through to the shapes (select, move, resize).
373
- pointerEvents: item.editing ? "auto" : "none"
374
- };
375
- });
346
+ const box = vue.computed(() => web.freeTextBoxOf(props.item, props.page.transform, outline.value));
347
+ const element = useTextBoxEditor(
348
+ () => props.item,
349
+ () => box.value.scale
350
+ );
376
351
  return (_ctx, _cache) => {
377
352
  return vue.openBlock(), vue.createElementBlock("div", {
378
353
  ref_key: "element",
379
354
  ref: element,
380
- style: vue.normalizeStyle(style.value)
355
+ style: vue.normalizeStyle(box.value.style)
381
356
  }, null, 4);
382
357
  };
383
358
  }
@@ -1000,4 +975,4 @@ exports.useCommentThreads = useCommentThreads;
1000
975
  exports.useComments = useComments;
1001
976
  exports.useFilePickerProvider = useFilePickerProvider;
1002
977
  exports.useRichTextEditor = useRichTextEditor;
1003
- //# sourceMappingURL=composables-BuHvnUlo.cjs.map
978
+ //# sourceMappingURL=composables-Bi6QvJpj.cjs.map