@ryanyahya/opendoc 0.4.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.
- package/.agents/skills/opendoc-apply-comments/SKILL.md +30 -0
- package/.agents/skills/opendoc-apply-comments/agents/openai.yaml +4 -0
- package/.agents/skills/opendoc-create/SKILL.md +63 -0
- package/.agents/skills/opendoc-create/agents/openai.yaml +6 -0
- package/.agents/skills/opendoc-create-template/SKILL.md +50 -0
- package/.agents/skills/opendoc-create-template/agents/openai.yaml +4 -0
- package/.agents/skills/opendoc-create-template/references/structured-reports.md +11 -0
- package/.agents/skills/opendoc-create-theme/SKILL.md +40 -0
- package/.agents/skills/opendoc-create-theme/agents/openai.yaml +4 -0
- package/.agents/skills/opendoc-current-document/SKILL.md +32 -0
- package/.agents/skills/opendoc-current-document/agents/openai.yaml +4 -0
- package/.agents/skills/opendoc-current-document/references/context-fields.md +20 -0
- package/.agents/skills/opendoc-review-document/SKILL.md +60 -0
- package/.agents/skills/opendoc-review-document/agents/openai.yaml +4 -0
- package/AGENTS.md +69 -0
- package/CONTRIBUTING.md +38 -0
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/SECURITY.md +9 -0
- package/THIRD_PARTY.md +49 -0
- package/VALIDATION.md +99 -0
- package/bin/opendoc.mjs +6 -0
- package/dist/assets/Markdown-sNZyjJi7.js +29 -0
- package/dist/assets/OpenDocSerif-Regular-D3OXs9A9.ttf +0 -0
- package/dist/assets/OpenDocSerif-Semibold-CjL9oDRo.ttf +0 -0
- package/dist/assets/geist-latin-ext-wght-italic-XgKbg5n7.woff2 +0 -0
- package/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/assets/geist-latin-wght-italic-dTnRTFFJ.woff2 +0 -0
- package/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/assets/index-DdrZ6ozO.css +1 -0
- package/dist/assets/index-DgNBz7mL.js +39 -0
- package/dist/assets/pdf-B7Emtyld.js +54 -0
- package/dist/assets/pdf.worker.min-Dswkl-cV.mjs +29 -0
- package/dist/assets/wordmark-DsqLlZpb.png +0 -0
- package/dist/index.html +17 -0
- package/docs/APPEARANCE.md +21 -0
- package/docs/ASSETS.md +176 -0
- package/docs/AUTHORING.md +178 -0
- package/docs/HEADLESS.md +120 -0
- package/docs/MEDIA.md +112 -0
- package/docs/PROJECTS.md +55 -0
- package/docs/PROSE.md +15 -0
- package/docs/SELECTION.md +59 -0
- package/docs/TEMPLATES.md +55 -0
- package/docs/THEMES.md +106 -0
- package/node_modules/@formepdf/core/LICENSE +21 -0
- package/node_modules/@formepdf/core/README.md +53 -0
- package/node_modules/@formepdf/core/dist/attachments.d.ts +55 -0
- package/node_modules/@formepdf/core/dist/attachments.js +59 -0
- package/node_modules/@formepdf/core/dist/extract.d.ts +8 -0
- package/node_modules/@formepdf/core/dist/extract.js +56 -0
- package/node_modules/@formepdf/core/dist/index.d.ts +311 -0
- package/node_modules/@formepdf/core/dist/index.js +167 -0
- package/node_modules/@formepdf/core/dist/layout.d.ts +132 -0
- package/node_modules/@formepdf/core/dist/layout.js +240 -0
- package/node_modules/@formepdf/core/dist/shared/browserHelpers.d.ts +19 -0
- package/node_modules/@formepdf/core/dist/shared/browserHelpers.js +128 -0
- package/node_modules/@formepdf/core/package.json +35 -0
- package/node_modules/@formepdf/core/pkg-node/LICENSE +21 -0
- package/node_modules/@formepdf/core/pkg-node/README.md +84 -0
- package/node_modules/@formepdf/core/pkg-node/forme.d.ts +39 -0
- package/node_modules/@formepdf/core/pkg-node/forme.js +394 -0
- package/node_modules/@formepdf/core/pkg-node/forme_bg.wasm +0 -0
- package/node_modules/@formepdf/core/pkg-node/forme_bg.wasm.d.ts +21 -0
- package/node_modules/@formepdf/core/pkg-node/package.json +25 -0
- package/node_modules/@formepdf/react/README.md +70 -0
- package/node_modules/@formepdf/react/dist/charts.d.ts +72 -0
- package/node_modules/@formepdf/react/dist/charts.js +338 -0
- package/node_modules/@formepdf/react/dist/components.d.ts +533 -0
- package/node_modules/@formepdf/react/dist/components.js +608 -0
- package/node_modules/@formepdf/react/dist/expr.d.ts +20 -0
- package/node_modules/@formepdf/react/dist/expr.js +39 -0
- package/node_modules/@formepdf/react/dist/font.d.ts +2 -0
- package/node_modules/@formepdf/react/dist/font.js +1 -0
- package/node_modules/@formepdf/react/dist/index.d.ts +11 -0
- package/node_modules/@formepdf/react/dist/index.js +15 -0
- package/node_modules/@formepdf/react/dist/render.d.ts +12 -0
- package/node_modules/@formepdf/react/dist/render.js +15 -0
- package/node_modules/@formepdf/react/dist/serialize.d.ts +12 -0
- package/node_modules/@formepdf/react/dist/serialize.js +1470 -0
- package/node_modules/@formepdf/react/dist/stylesheet.d.ts +4 -0
- package/node_modules/@formepdf/react/dist/stylesheet.js +5 -0
- package/node_modules/@formepdf/react/dist/template-proxy.d.ts +38 -0
- package/node_modules/@formepdf/react/dist/template-proxy.js +100 -0
- package/node_modules/@formepdf/react/dist/types.d.ts +287 -0
- package/node_modules/@formepdf/react/dist/types.js +1 -0
- package/node_modules/@formepdf/react/package.json +41 -0
- package/node_modules/@formepdf/shared/README.md +7 -0
- package/node_modules/@formepdf/shared/dist/canvas.d.ts +6 -0
- package/node_modules/@formepdf/shared/dist/canvas.js +43 -0
- package/node_modules/@formepdf/shared/dist/charts.d.ts +100 -0
- package/node_modules/@formepdf/shared/dist/charts.js +98 -0
- package/node_modules/@formepdf/shared/dist/encode.d.ts +27 -0
- package/node_modules/@formepdf/shared/dist/encode.js +93 -0
- package/node_modules/@formepdf/shared/dist/font.d.ts +13 -0
- package/node_modules/@formepdf/shared/dist/font.js +52 -0
- package/node_modules/@formepdf/shared/dist/index.d.ts +10 -0
- package/node_modules/@formepdf/shared/dist/index.js +15 -0
- package/node_modules/@formepdf/shared/dist/parser.d.ts +30 -0
- package/node_modules/@formepdf/shared/dist/parser.js +756 -0
- package/node_modules/@formepdf/shared/dist/semantics.d.ts +15 -0
- package/node_modules/@formepdf/shared/dist/semantics.js +44 -0
- package/node_modules/@formepdf/shared/dist/style.d.ts +7 -0
- package/node_modules/@formepdf/shared/dist/style.js +1024 -0
- package/node_modules/@formepdf/shared/dist/types.d.ts +743 -0
- package/node_modules/@formepdf/shared/dist/types.js +2 -0
- package/node_modules/@formepdf/shared/package.json +35 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +111 -0
- package/node_modules/@types/node/assert.d.ts +1078 -0
- package/node_modules/@types/node/async_hooks.d.ts +603 -0
- package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
- package/node_modules/@types/node/buffer.d.ts +1934 -0
- package/node_modules/@types/node/child_process.d.ts +1476 -0
- package/node_modules/@types/node/cluster.d.ts +578 -0
- package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
- package/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
- package/node_modules/@types/node/console.d.ts +452 -0
- package/node_modules/@types/node/constants.d.ts +21 -0
- package/node_modules/@types/node/crypto.d.ts +4545 -0
- package/node_modules/@types/node/dgram.d.ts +600 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
- package/node_modules/@types/node/dns/promises.d.ts +503 -0
- package/node_modules/@types/node/dns.d.ts +923 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +976 -0
- package/node_modules/@types/node/fs/promises.d.ts +1306 -0
- package/node_modules/@types/node/fs.d.ts +4463 -0
- package/node_modules/@types/node/globals.d.ts +172 -0
- package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/node_modules/@types/node/http.d.ts +2097 -0
- package/node_modules/@types/node/http2.d.ts +2843 -0
- package/node_modules/@types/node/https.d.ts +579 -0
- package/node_modules/@types/node/index.d.ts +98 -0
- package/node_modules/@types/node/inspector.d.ts +253 -0
- package/node_modules/@types/node/inspector.generated.d.ts +4052 -0
- package/node_modules/@types/node/module.d.ts +891 -0
- package/node_modules/@types/node/net.d.ts +1076 -0
- package/node_modules/@types/node/os.d.ts +506 -0
- package/node_modules/@types/node/package.json +145 -0
- package/node_modules/@types/node/path.d.ts +200 -0
- package/node_modules/@types/node/perf_hooks.d.ts +968 -0
- package/node_modules/@types/node/process.d.ts +2084 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +152 -0
- package/node_modules/@types/node/readline/promises.d.ts +161 -0
- package/node_modules/@types/node/readline.d.ts +594 -0
- package/node_modules/@types/node/repl.d.ts +428 -0
- package/node_modules/@types/node/sea.d.ts +162 -0
- package/node_modules/@types/node/sqlite.d.ts +722 -0
- package/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +573 -0
- package/node_modules/@types/node/stream.d.ts +1694 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +2265 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +287 -0
- package/node_modules/@types/node/tls.d.ts +1319 -0
- package/node_modules/@types/node/trace_events.d.ts +197 -0
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +98 -0
- package/node_modules/@types/node/tty.d.ts +208 -0
- package/node_modules/@types/node/url.d.ts +984 -0
- package/node_modules/@types/node/util.d.ts +2606 -0
- package/node_modules/@types/node/v8.d.ts +920 -0
- package/node_modules/@types/node/vm.d.ts +1053 -0
- package/node_modules/@types/node/wasi.d.ts +181 -0
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/node_modules/@types/node/web-globals/navigator.d.ts +22 -0
- package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
- package/node_modules/@types/node/worker_threads.d.ts +819 -0
- package/node_modules/@types/node/zlib.d.ts +747 -0
- package/node_modules/@types/react/LICENSE +21 -0
- package/node_modules/@types/react/README.md +15 -0
- package/node_modules/@types/react/canary.d.ts +129 -0
- package/node_modules/@types/react/compiler-runtime.d.ts +4 -0
- package/node_modules/@types/react/experimental.d.ts +184 -0
- package/node_modules/@types/react/global.d.ts +166 -0
- package/node_modules/@types/react/index.d.ts +4378 -0
- package/node_modules/@types/react/jsx-dev-runtime.d.ts +33 -0
- package/node_modules/@types/react/jsx-runtime.d.ts +24 -0
- package/node_modules/@types/react/package.json +210 -0
- package/node_modules/@types/react/ts5.0/canary.d.ts +129 -0
- package/node_modules/@types/react/ts5.0/experimental.d.ts +184 -0
- package/node_modules/@types/react/ts5.0/global.d.ts +166 -0
- package/node_modules/@types/react/ts5.0/index.d.ts +4365 -0
- package/node_modules/@types/react/ts5.0/jsx-dev-runtime.d.ts +33 -0
- package/node_modules/@types/react/ts5.0/jsx-runtime.d.ts +24 -0
- package/node_modules/csstype/LICENSE +19 -0
- package/node_modules/csstype/README.md +291 -0
- package/node_modules/csstype/index.d.ts +22569 -0
- package/node_modules/csstype/index.js.flow +6863 -0
- package/node_modules/csstype/package.json +70 -0
- package/node_modules/entities/LICENSE +11 -0
- package/node_modules/entities/decode.d.ts +1 -0
- package/node_modules/entities/decode.js +3 -0
- package/node_modules/entities/dist/commonjs/decode-codepoint.d.ts +19 -0
- package/node_modules/entities/dist/commonjs/decode-codepoint.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/node_modules/entities/dist/commonjs/decode-codepoint.js.map +1 -0
- package/node_modules/entities/dist/commonjs/decode.d.ts +209 -0
- package/node_modules/entities/dist/commonjs/decode.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/decode.js +511 -0
- package/node_modules/entities/dist/commonjs/decode.js.map +1 -0
- package/node_modules/entities/dist/commonjs/encode.d.ts +22 -0
- package/node_modules/entities/dist/commonjs/encode.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/encode.js +73 -0
- package/node_modules/entities/dist/commonjs/encode.js.map +1 -0
- package/node_modules/entities/dist/commonjs/escape.d.ts +43 -0
- package/node_modules/entities/dist/commonjs/escape.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/escape.js +121 -0
- package/node_modules/entities/dist/commonjs/escape.js.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts +2 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-html.js +10 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-html.js.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts +2 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +10 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-xml.js.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/encode-html.d.ts +8 -0
- package/node_modules/entities/dist/commonjs/generated/encode-html.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/encode-html.js +13 -0
- package/node_modules/entities/dist/commonjs/generated/encode-html.js.map +1 -0
- package/node_modules/entities/dist/commonjs/index.d.ts +96 -0
- package/node_modules/entities/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/index.js +131 -0
- package/node_modules/entities/dist/commonjs/index.js.map +1 -0
- package/node_modules/entities/dist/commonjs/package.json +3 -0
- package/node_modules/entities/dist/esm/decode-codepoint.d.ts +19 -0
- package/node_modules/entities/dist/esm/decode-codepoint.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/decode-codepoint.js +72 -0
- package/node_modules/entities/dist/esm/decode-codepoint.js.map +1 -0
- package/node_modules/entities/dist/esm/decode.d.ts +209 -0
- package/node_modules/entities/dist/esm/decode.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/decode.js +497 -0
- package/node_modules/entities/dist/esm/decode.js.map +1 -0
- package/node_modules/entities/dist/esm/encode.d.ts +22 -0
- package/node_modules/entities/dist/esm/encode.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/encode.js +69 -0
- package/node_modules/entities/dist/esm/encode.js.map +1 -0
- package/node_modules/entities/dist/esm/escape.d.ts +43 -0
- package/node_modules/entities/dist/esm/escape.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/escape.js +117 -0
- package/node_modules/entities/dist/esm/escape.js.map +1 -0
- package/node_modules/entities/dist/esm/generated/decode-data-html.d.ts +2 -0
- package/node_modules/entities/dist/esm/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/generated/decode-data-html.js +7 -0
- package/node_modules/entities/dist/esm/generated/decode-data-html.js.map +1 -0
- package/node_modules/entities/dist/esm/generated/decode-data-xml.d.ts +2 -0
- package/node_modules/entities/dist/esm/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/generated/decode-data-xml.js +7 -0
- package/node_modules/entities/dist/esm/generated/decode-data-xml.js.map +1 -0
- package/node_modules/entities/dist/esm/generated/encode-html.d.ts +8 -0
- package/node_modules/entities/dist/esm/generated/encode-html.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/generated/encode-html.js +10 -0
- package/node_modules/entities/dist/esm/generated/encode-html.js.map +1 -0
- package/node_modules/entities/dist/esm/index.d.ts +96 -0
- package/node_modules/entities/dist/esm/index.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/index.js +107 -0
- package/node_modules/entities/dist/esm/index.js.map +1 -0
- package/node_modules/entities/dist/esm/package.json +3 -0
- package/node_modules/entities/escape.d.ts +1 -0
- package/node_modules/entities/escape.js +3 -0
- package/node_modules/entities/package.json +118 -0
- package/node_modules/entities/readme.md +122 -0
- package/node_modules/entities/src/decode-codepoint.ts +81 -0
- package/node_modules/entities/src/decode.spec.ts +320 -0
- package/node_modules/entities/src/decode.ts +620 -0
- package/node_modules/entities/src/encode.spec.ts +78 -0
- package/node_modules/entities/src/encode.ts +77 -0
- package/node_modules/entities/src/escape.spec.ts +14 -0
- package/node_modules/entities/src/escape.ts +148 -0
- package/node_modules/entities/src/generated/.eslintrc.json +10 -0
- package/node_modules/entities/src/generated/decode-data-html.ts +8 -0
- package/node_modules/entities/src/generated/decode-data-xml.ts +8 -0
- package/node_modules/entities/src/generated/encode-html.ts +17 -0
- package/node_modules/entities/src/index.spec.ts +125 -0
- package/node_modules/entities/src/index.ts +188 -0
- package/node_modules/parse5/LICENSE +19 -0
- package/node_modules/parse5/README.md +38 -0
- package/node_modules/parse5/dist/cjs/common/doctype.d.ts +4 -0
- package/node_modules/parse5/dist/cjs/common/doctype.js +118 -0
- package/node_modules/parse5/dist/cjs/common/error-codes.d.ts +67 -0
- package/node_modules/parse5/dist/cjs/common/error-codes.js +66 -0
- package/node_modules/parse5/dist/cjs/common/foreign-content.d.ts +9 -0
- package/node_modules/parse5/dist/cjs/common/foreign-content.js +237 -0
- package/node_modules/parse5/dist/cjs/common/html.d.ts +289 -0
- package/node_modules/parse5/dist/cjs/common/html.js +528 -0
- package/node_modules/parse5/dist/cjs/common/token.d.ts +84 -0
- package/node_modules/parse5/dist/cjs/common/token.js +24 -0
- package/node_modules/parse5/dist/cjs/common/unicode.d.ts +42 -0
- package/node_modules/parse5/dist/cjs/common/unicode.js +70 -0
- package/node_modules/parse5/dist/cjs/index.d.ts +71 -0
- package/node_modules/parse5/dist/cjs/index.js +54 -0
- package/node_modules/parse5/dist/cjs/package.json +1 -0
- package/node_modules/parse5/dist/cjs/parser/formatting-element-list.d.ts +36 -0
- package/node_modules/parse5/dist/cjs/parser/formatting-element-list.js +114 -0
- package/node_modules/parse5/dist/cjs/parser/index.d.ts +221 -0
- package/node_modules/parse5/dist/cjs/parser/index.js +3240 -0
- package/node_modules/parse5/dist/cjs/parser/open-element-stack.d.ts +53 -0
- package/node_modules/parse5/dist/cjs/parser/open-element-stack.js +328 -0
- package/node_modules/parse5/dist/cjs/serializer/index.d.ts +60 -0
- package/node_modules/parse5/dist/cjs/serializer/index.js +172 -0
- package/node_modules/parse5/dist/cjs/tokenizer/index.d.ts +247 -0
- package/node_modules/parse5/dist/cjs/tokenizer/index.js +2714 -0
- package/node_modules/parse5/dist/cjs/tokenizer/preprocessor.d.ts +36 -0
- package/node_modules/parse5/dist/cjs/tokenizer/preprocessor.js +200 -0
- package/node_modules/parse5/dist/cjs/tree-adapters/default.d.ts +84 -0
- package/node_modules/parse5/dist/cjs/tree-adapters/default.js +176 -0
- package/node_modules/parse5/dist/cjs/tree-adapters/interface.d.ts +255 -0
- package/node_modules/parse5/dist/cjs/tree-adapters/interface.js +2 -0
- package/node_modules/parse5/dist/common/doctype.d.ts +4 -0
- package/node_modules/parse5/dist/common/doctype.js +114 -0
- package/node_modules/parse5/dist/common/error-codes.d.ts +67 -0
- package/node_modules/parse5/dist/common/error-codes.js +63 -0
- package/node_modules/parse5/dist/common/foreign-content.d.ts +9 -0
- package/node_modules/parse5/dist/common/foreign-content.js +228 -0
- package/node_modules/parse5/dist/common/html.d.ts +289 -0
- package/node_modules/parse5/dist/common/html.js +523 -0
- package/node_modules/parse5/dist/common/token.d.ts +84 -0
- package/node_modules/parse5/dist/common/token.js +20 -0
- package/node_modules/parse5/dist/common/unicode.d.ts +42 -0
- package/node_modules/parse5/dist/common/unicode.js +62 -0
- package/node_modules/parse5/dist/index.d.ts +71 -0
- package/node_modules/parse5/dist/index.js +42 -0
- package/node_modules/parse5/dist/parser/formatting-element-list.d.ts +36 -0
- package/node_modules/parse5/dist/parser/formatting-element-list.js +110 -0
- package/node_modules/parse5/dist/parser/index.d.ts +221 -0
- package/node_modules/parse5/dist/parser/index.js +3245 -0
- package/node_modules/parse5/dist/parser/open-element-stack.d.ts +53 -0
- package/node_modules/parse5/dist/parser/open-element-stack.js +324 -0
- package/node_modules/parse5/dist/serializer/index.d.ts +60 -0
- package/node_modules/parse5/dist/serializer/index.js +168 -0
- package/node_modules/parse5/dist/tokenizer/index.d.ts +247 -0
- package/node_modules/parse5/dist/tokenizer/index.js +2710 -0
- package/node_modules/parse5/dist/tokenizer/preprocessor.d.ts +36 -0
- package/node_modules/parse5/dist/tokenizer/preprocessor.js +196 -0
- package/node_modules/parse5/dist/tree-adapters/default.d.ts +84 -0
- package/node_modules/parse5/dist/tree-adapters/default.js +173 -0
- package/node_modules/parse5/dist/tree-adapters/interface.d.ts +255 -0
- package/node_modules/parse5/dist/tree-adapters/interface.js +1 -0
- package/node_modules/parse5/package.json +50 -0
- package/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/undici-types/README.md +6 -0
- package/node_modules/undici-types/agent.d.ts +31 -0
- package/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/undici-types/client.d.ts +108 -0
- package/node_modules/undici-types/connector.d.ts +34 -0
- package/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/undici-types/cookies.d.ts +28 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/node_modules/undici-types/dispatcher.d.ts +256 -0
- package/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/node_modules/undici-types/errors.d.ts +149 -0
- package/node_modules/undici-types/eventsource.d.ts +61 -0
- package/node_modules/undici-types/fetch.d.ts +209 -0
- package/node_modules/undici-types/file.d.ts +39 -0
- package/node_modules/undici-types/filereader.d.ts +54 -0
- package/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/undici-types/handlers.d.ts +15 -0
- package/node_modules/undici-types/header.d.ts +4 -0
- package/node_modules/undici-types/index.d.ts +71 -0
- package/node_modules/undici-types/interceptors.d.ts +17 -0
- package/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/node_modules/undici-types/mock-client.d.ts +25 -0
- package/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/node_modules/undici-types/package.json +55 -0
- package/node_modules/undici-types/patch.d.ts +33 -0
- package/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/undici-types/pool.d.ts +39 -0
- package/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/node_modules/undici-types/readable.d.ts +65 -0
- package/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/undici-types/webidl.d.ts +228 -0
- package/node_modules/undici-types/websocket.d.ts +150 -0
- package/package.json +80 -0
- package/scripts/rebuild-forme.mjs +61 -0
- package/src/app/AppearanceControl.tsx +44 -0
- package/src/app/AssetThemeDefaults.tsx +87 -0
- package/src/app/AssetsBrowser.tsx +273 -0
- package/src/app/CommentDock.tsx +108 -0
- package/src/app/CreateDocumentDialog.tsx +51 -0
- package/src/app/DocumentActions.tsx +69 -0
- package/src/app/DocumentCard.tsx +50 -0
- package/src/app/DocumentViewControl.tsx +31 -0
- package/src/app/DocumentsBrowser.tsx +70 -0
- package/src/app/ExportHistoryDialog.tsx +86 -0
- package/src/app/ExportMenu.tsx +127 -0
- package/src/app/GuideDialog.tsx +80 -0
- package/src/app/InspectionLayer.tsx +77 -0
- package/src/app/LogoUploadDialog.tsx +92 -0
- package/src/app/Markdown.tsx +34 -0
- package/src/app/MaterialsBrowser.tsx +149 -0
- package/src/app/PageNumberInput.tsx +56 -0
- package/src/app/Pdf.tsx +561 -0
- package/src/app/ProjectDialogs.tsx +100 -0
- package/src/app/Reader.tsx +769 -0
- package/src/app/SearchField.tsx +13 -0
- package/src/app/Sidebar.tsx +86 -0
- package/src/app/SkillIndex.tsx +30 -0
- package/src/app/TemplatesBrowser.tsx +149 -0
- package/src/app/ThemesBrowser.tsx +159 -0
- package/src/app/api.ts +47 -0
- package/src/app/appearance.ts +35 -0
- package/src/app/assets.css +139 -0
- package/src/app/catalogPreview.ts +20 -0
- package/src/app/colors.css +167 -0
- package/src/app/comment-dock.css +53 -0
- package/src/app/commentDrafts.ts +67 -0
- package/src/app/componentCorrection.ts +17 -0
- package/src/app/edit-workbench.css +87 -0
- package/src/app/editSession.ts +238 -0
- package/src/app/editorRecovery.ts +25 -0
- package/src/app/export-history.css +31 -0
- package/src/app/export.css +17 -0
- package/src/app/guideLinks.ts +21 -0
- package/src/app/guides.css +40 -0
- package/src/app/main.tsx +221 -0
- package/src/app/materials.css +53 -0
- package/src/app/pdfLoading.ts +12 -0
- package/src/app/pdfSelection.ts +112 -0
- package/src/app/projects.css +63 -0
- package/src/app/reader-toolbar.css +65 -0
- package/src/app/selection.css +150 -0
- package/src/app/sidebar.css +60 -0
- package/src/app/skills.css +7 -0
- package/src/app/style.css +1061 -0
- package/src/app/templates.css +49 -0
- package/src/app/themes.css +80 -0
- package/src/app/ui/Icon.tsx +92 -0
- package/src/app/ui/README.md +27 -0
- package/src/app/ui/fonts.css +36 -0
- package/src/app/ui/index.tsx +223 -0
- package/src/app/ui/ui.css +388 -0
- package/src/app/useReaderPreview.ts +19 -0
- package/src/app/useTextEditing.ts +155 -0
- package/src/assets/adapter.ts +122 -0
- package/src/assets/files.ts +378 -0
- package/src/assets/import-worker.ts +294 -0
- package/src/assets/imports.ts +124 -0
- package/src/assets/index.ts +60 -0
- package/src/assets/store.ts +798 -0
- package/src/assets/usage.ts +118 -0
- package/src/cli/check.ts +25 -0
- package/src/cli/init.ts +119 -0
- package/src/cli/lock.ts +34 -0
- package/src/cli/main.ts +118 -0
- package/src/cli/process.ts +19 -0
- package/src/cli/start.ts +96 -0
- package/src/cli/update.ts +348 -0
- package/src/cli/workspace.ts +94 -0
- package/src/document/index.tsx +641 -0
- package/src/document/page.tsx +53 -0
- package/src/document/text-targets.tsx +162 -0
- package/src/media/files.ts +124 -0
- package/src/media/render.ts +63 -0
- package/src/rendering/resolve-sources.ts +84 -0
- package/src/runtime/jsx-dev-runtime.ts +2 -0
- package/src/runtime/jsx-runtime.ts +2 -0
- package/src/runtime/paths.ts +12 -0
- package/src/server/assets-cli.ts +162 -0
- package/src/server/assets-http.ts +100 -0
- package/src/server/client.ts +50 -0
- package/src/server/clipboard.ts +22 -0
- package/src/server/comments-cli.ts +64 -0
- package/src/server/comments.ts +130 -0
- package/src/server/create-cli.ts +33 -0
- package/src/server/create.ts +228 -0
- package/src/server/dependencies.ts +91 -0
- package/src/server/documents.ts +143 -0
- package/src/server/edits.ts +249 -0
- package/src/server/export-batch.ts +105 -0
- package/src/server/export-errors.ts +2 -0
- package/src/server/export-file.ts +57 -0
- package/src/server/export-inputs.ts +66 -0
- package/src/server/export-preview.ts +69 -0
- package/src/server/export.ts +32 -0
- package/src/server/exports.ts +283 -0
- package/src/server/files.ts +21 -0
- package/src/server/guides.ts +71 -0
- package/src/server/index.ts +432 -0
- package/src/server/materials.ts +39 -0
- package/src/server/media-cli.ts +73 -0
- package/src/server/media-mutations.ts +168 -0
- package/src/server/pptx.ts +160 -0
- package/src/server/preflight.ts +129 -0
- package/src/server/projects-cli.ts +29 -0
- package/src/server/projects.ts +187 -0
- package/src/server/render-error.ts +9 -0
- package/src/server/render-source.ts +24 -0
- package/src/server/render.ts +48 -0
- package/src/server/review-cli.ts +40 -0
- package/src/server/review.ts +161 -0
- package/src/server/selection.ts +23 -0
- package/src/server/source-overrides.ts +97 -0
- package/src/server/templates-cli.ts +51 -0
- package/src/server/templates.ts +186 -0
- package/src/server/text-layout.ts +41 -0
- package/src/server/text-source.ts +307 -0
- package/src/server/themes-cli.ts +59 -0
- package/src/server/themes.ts +215 -0
- package/src/server/ttf2eot.d.ts +3 -0
- package/src/server/worker.ts +166 -0
- package/src/server/workspace.ts +242 -0
- package/src/shared/anchors.ts +69 -0
- package/src/shared/assets.ts +154 -0
- package/src/shared/export.ts +34 -0
- package/src/shared/media.ts +33 -0
- package/src/shared/projects.ts +19 -0
- package/src/shared/selection.ts +94 -0
- package/src/shared/skill-index.ts +14 -0
- package/src/shared/starters.ts +19 -0
- package/src/shared/templates.ts +18 -0
- package/src/shared/themes.ts +24 -0
- package/src/shared/types.ts +39 -0
- package/src/template/index.ts +27 -0
- package/src/themes/index.ts +3 -0
- package/src/themes/neutral.ts +20 -0
- package/src/themes/types.ts +110 -0
- package/starter/assets/brand/wordmark.png +0 -0
- package/starter/assets/fonts/InterUI-LICENSE.txt +93 -0
- package/starter/assets/fonts/InterUI-Medium.ttf +0 -0
- package/starter/assets/fonts/InterUI-Regular.ttf +0 -0
- package/starter/assets/fonts/InterUI-source.json +19 -0
- package/starter/assets/fonts/OpenDocMono-Regular.ttf +0 -0
- package/starter/assets/fonts/OpenDocSans-Italic.ttf +0 -0
- package/starter/assets/fonts/OpenDocSans-Regular.ttf +0 -0
- package/starter/assets/fonts/OpenDocSans-Semibold.ttf +0 -0
- package/starter/assets/fonts/OpenDocSans-SemiboldItalic.ttf +0 -0
- package/starter/assets/fonts/OpenDocSerif-Italic.ttf +0 -0
- package/starter/assets/fonts/OpenDocSerif-Regular.ttf +0 -0
- package/starter/assets/fonts/OpenDocSerif-Semibold.ttf +0 -0
- package/starter/assets/fonts/OpenDocSerif-SemiboldItalic.ttf +0 -0
- package/starter/assets/fonts/SourceCode-LICENSE.md +93 -0
- package/starter/assets/fonts/SourceSans-LICENSE.md +93 -0
- package/starter/assets/fonts/SourceSerif-LICENSE.md +93 -0
- package/starter/assets/fonts/geist/OFL.txt +93 -0
- package/starter/assets/fonts/geist/asset.json +7 -0
- package/starter/assets/fonts/geist/files/1a9874b3be0fc168692a3d2327bccb4d28835653d3b91537a755296a467a83e3.ttf +0 -0
- package/starter/assets/fonts/geist/files/a8eefb873ba9c9020665f8a98302697ce1f3b79ab2deef6ee508c0ca6a82e876.ttf +0 -0
- package/starter/assets/fonts/geist/files/ccce59465ae5c61930ada5453834f60500fbd95084d85db63e0e65fad0125455.ttf +0 -0
- package/starter/assets/fonts/geist/files/f5e95110d70593672515080bee9148463ada0a7f77b89ed65a3d43cb2b0ff83a.pdf +0 -0
- package/starter/assets/fonts/geist/revisions/9a2bc12fb2f23cb27bc227087e63e1407bb804ee0586480bd6b7966ec69fb474.json +60 -0
- package/starter/assets/fonts/inter/OFL.txt +93 -0
- package/starter/assets/fonts/inter/asset.json +7 -0
- package/starter/assets/fonts/inter/files/1b08e7fc267a5c7e1d614100f604b83e7e8a0be241f0f288faa2b3ac93a683ba.ttf +0 -0
- package/starter/assets/fonts/inter/files/5b6f0c6f26e5c554a64cdcc3a9b5d802b7f9aec6206f1dbcfcdcad7b5860a2a9.ttf +0 -0
- package/starter/assets/fonts/inter/files/957db8560d510a198a7d0333fae7b6b444b00c20801581126273978d778eb3c3.pdf +0 -0
- package/starter/assets/fonts/inter/files/b37284b5701b6b168dfc770aa1a4ac492106422fd3ba76bc7641e37434e8019c.ttf +0 -0
- package/starter/assets/fonts/inter/files/c1811d32ac0f6eed1bbf57529f2ecdfc6c717d48a969dd864942436315a1b198.ttf +0 -0
- package/starter/assets/fonts/inter/files/e7a1aaf7eda9f2fad4131725fa556265ec75ca7b2d756260173a040363e8d4f7.ttf +0 -0
- package/starter/assets/fonts/inter/files/ef8f755d933b9310804cc9152f1f18cb2ac460d6b05054ec913d889c9f11f79e.ttf +0 -0
- package/starter/assets/fonts/inter/revisions/600391517c413963b71e278a57c26c40366c81fa3939a6b9755f446206766d12.json +99 -0
- package/starter/assets/fonts/inter/source.json +57 -0
- package/starter/assets/fonts/lato/OFL.txt +93 -0
- package/starter/assets/fonts/lato/asset.json +7 -0
- package/starter/assets/fonts/lato/files/4a6b566dbb28adb473a8789ce5169306f42f0c8a070ac92bae93636f36348b0d.pdf +0 -0
- package/starter/assets/fonts/lato/files/5adeb6b334d8fb99ef053bc052b952773d544315e0e1d668a12c0ce8bd51375c.ttf +0 -0
- package/starter/assets/fonts/lato/files/62c1b7f0d2e74b45960154c3520efc337b553db0961bfdc950d5618334596cc8.ttf +0 -0
- package/starter/assets/fonts/lato/files/71b8b7decbe75a881ed267be539d402bd1e9420b799658aada4e0d1bd5af803c.ttf +0 -0
- package/starter/assets/fonts/lato/files/8a0aace75d33794eece4b28187bfc1df0bbd2888b5d8a56e01788c8d65d16be1.ttf +0 -0
- package/starter/assets/fonts/lato/files/d636e4683231f931eda222d588e944d082bfd3bdba02f928bee461c0f185b251.ttf +0 -0
- package/starter/assets/fonts/lato/files/e399c44efe1387100531d26c7e4800c5d12251b890d6654a3098c7c679cb1786.ttf +0 -0
- package/starter/assets/fonts/lato/revisions/49ccb93400a9d466fab7d9843b1ecf8916ec6d47a475dd79a597a22eb39616bc.json +99 -0
- package/starter/assets/fonts/lato/source.json +57 -0
- package/starter/assets/fonts/merriweather/OFL.txt +93 -0
- package/starter/assets/fonts/merriweather/asset.json +7 -0
- package/starter/assets/fonts/merriweather/files/1c54f91b910454251c4c2b7bd4e472e1abf265fba7ca3c0ef2eee2f41324099e.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/8bde8da2bb7f0265e27ba0481f70bb48d0f98a976c145f2f239c648ddd6532e0.pdf +0 -0
- package/starter/assets/fonts/merriweather/files/90b7db4460fcd1a5ca49575c2668a793f3cd6447664d312a068d690e1c01e6bc.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/afff81272b7653417bb6f8bef57add055b1f9fda36f27eba5f32b40752bd08da.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/e029d3b71e5bae3877c73f4f2b15af28db16593d49b0aed2a328d37ff7075846.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/e9864a6790bf712a04e20f3662b206a1535186ed3e877fd859dd5fb9682335df.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/fa71baebdd20a7d0de2e5e445a5922530fe9e1d740efbe791f113b682d3cb093.ttf +0 -0
- package/starter/assets/fonts/merriweather/revisions/1888e390b3e4f38a3d7cd2dc1bb805aeb6ce13f986a97656f0265fd436bc91d2.json +99 -0
- package/starter/assets/fonts/merriweather/source.json +57 -0
- package/starter/assets/fonts/open-sans/OFL.txt +92 -0
- package/starter/assets/fonts/open-sans/asset.json +7 -0
- package/starter/assets/fonts/open-sans/files/1bc0594a83762b2c25d38915a34464b7fec6088298ca22d151757bf98d6700ec.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/47ed1cfaa7ffca04a04ab850b2938fd52c09d1b44cfa3e2980878e166b0cbd87.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/574939af301f07df8e21cfff279465c5981dd9d9cf62086f7515897df951c6f5.pdf +0 -0
- package/starter/assets/fonts/open-sans/files/6d3884d0d57c1b67e9c50c54eca7b69c535c114e76bd7a9cfda0258588185553.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/733eb93b167e6d45de09aa768f6c0355647c2c26f5416dbc7407a08ed41e81c6.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/75367e6da7d914eaed87883ba51b2a2b5816b5cdbb39f96ec5c81a5b032bfd5a.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/ff4fdc11204e0edd14e9a0bb6c374b847a9093b0ec2c16702e03afca79ac4ef7.ttf +0 -0
- package/starter/assets/fonts/open-sans/revisions/bbbe3a4915b9bccbc883c0decb4097511c43b6bd09ae22a1516aff128c219bc5.json +99 -0
- package/starter/assets/fonts/open-sans/source.json +57 -0
- package/starter/assets/fonts/roboto/OFL.txt +93 -0
- package/starter/assets/fonts/roboto/asset.json +7 -0
- package/starter/assets/fonts/roboto/files/22d45d989248a624252b8382067ac56550212fa675dcdbaf12f03d297dd87a58.pdf +0 -0
- package/starter/assets/fonts/roboto/files/35757eaa996b3359022f47f164a67ee9eac04971af24c5b8fbd4b89e844ff190.ttf +0 -0
- package/starter/assets/fonts/roboto/files/4d3035883c531846bd1ce2dc89f36d932e72dc114f56062c7e3a9cdd74f3d3ea.ttf +0 -0
- package/starter/assets/fonts/roboto/files/be7639306a4fc4a02ce2ae2ff59eb1335e4db4a7379dd0a384ed7cc053817789.ttf +0 -0
- package/starter/assets/fonts/roboto/files/d2920cbb1b60a3fd11fbf22049286e43a6baf522d37fdf1e7c89562319bcfea5.ttf +0 -0
- package/starter/assets/fonts/roboto/files/dece7c71bbe61710787f0839c722c65e87355dd2eb4a823e6b5488121ff81e4b.ttf +0 -0
- package/starter/assets/fonts/roboto/files/f478ba88b0292e685e487901dfbb1401457d32d6ebee4030cdfd5698235bffa8.ttf +0 -0
- package/starter/assets/fonts/roboto/revisions/bda5e2d84c17313373dd2dbf3e64fe0dd450c7e1b59e6929e69557e122fe976e.json +99 -0
- package/starter/assets/fonts/roboto/source.json +57 -0
- package/starter/assets/logos/opendoc/asset.json +6 -0
- package/starter/assets/logos/opendoc/files/831d5ccd9eb6709cc8439ea257c03d81452e81a28a3d1eedbd6a3b7daff687b6.png +0 -0
- package/starter/assets/logos/opendoc/revisions/834dde8926ddb81de687254195a168bb13bfb77803307f1257de1f2228be63b2.json +33 -0
- package/starter/assets/ui-fonts/geist/OFL.txt +93 -0
- package/starter/assets/ui-fonts/geist/geist-latin-ext-wght-italic.woff2 +0 -0
- package/starter/assets/ui-fonts/geist/geist-latin-ext-wght-normal.woff2 +0 -0
- package/starter/assets/ui-fonts/geist/geist-latin-wght-italic.woff2 +0 -0
- package/starter/assets/ui-fonts/geist/geist-latin-wght-normal.woff2 +0 -0
- package/starter/assets/ui-fonts/geist/source.json +26 -0
- package/starter/documents/welcome/assets.json +7 -0
- package/starter/documents/welcome/index.tsx +160 -0
- package/starter/documents/welcome/media/.gitkeep +0 -0
- package/starter/documents/welcome/media/paper-architecture/image.png +0 -0
- package/starter/documents/welcome/media/paper-architecture/meta.json +9 -0
- package/starter/documents/welcome/media/paper-architecture/prompt.txt +1 -0
- package/starter/documents/welcome/media/studio-rhythm/chart.svg +2343 -0
- package/starter/documents/welcome/media/studio-rhythm/data.json +234 -0
- package/starter/documents/welcome/media/studio-rhythm/generation.json +9 -0
- package/starter/documents/welcome/media/studio-rhythm/image.png +0 -0
- package/starter/documents/welcome/media/studio-rhythm/meta.json +11 -0
- package/starter/documents/welcome/media/studio-rhythm/recipe.py +79 -0
- package/starter/documents/welcome/theme.tsx +5 -0
- package/starter/documents/welcome-presentation/assets.json +7 -0
- package/starter/documents/welcome-presentation/index.tsx +166 -0
- package/starter/documents/welcome-presentation/media/.gitkeep +0 -0
- package/starter/documents/welcome-presentation/media/paper-architecture/image.png +0 -0
- package/starter/documents/welcome-presentation/media/paper-architecture/meta.json +9 -0
- package/starter/documents/welcome-presentation/media/paper-architecture/prompt.txt +1 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/chart.svg +1336 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/data.json +234 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/generation.json +9 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/image.png +0 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/meta.json +13 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/recipe.py +49 -0
- package/starter/documents/welcome-presentation/theme.tsx +5 -0
- package/starter/projects.json +17 -0
- package/starter/templates/AGENTS.md +9 -0
- package/starter/templates/_shared/BusinessLogo.tsx +14 -0
- package/starter/templates/_shared/Pricing.tsx +40 -0
- package/starter/templates/_shared/commerce.ts +93 -0
- package/starter/templates/brand-guidelines/AGENTS.md +32 -0
- package/starter/templates/brand-guidelines/index.tsx +62 -0
- package/starter/templates/brand-guidelines/preview.tsx +181 -0
- package/starter/templates/brand-guidelines/starter.tsx +179 -0
- package/starter/templates/brand-guidelines/template.json +15 -0
- package/starter/templates/business-proposal/AGENTS.md +13 -0
- package/starter/templates/business-proposal/README.md +36 -0
- package/starter/templates/business-proposal/data.json +37 -0
- package/starter/templates/business-proposal/examples/long.json +142 -0
- package/starter/templates/business-proposal/examples/sparse.json +17 -0
- package/starter/templates/business-proposal/examples/typical.json +37 -0
- package/starter/templates/business-proposal/index.tsx +59 -0
- package/starter/templates/business-proposal/preview.tsx +47 -0
- package/starter/templates/business-proposal/schema.ts +14 -0
- package/starter/templates/business-proposal/starter.tsx +18 -0
- package/starter/templates/business-proposal/template.json +11 -0
- package/starter/templates/company-profile/AGENTS.md +48 -0
- package/starter/templates/company-profile/index.tsx +69 -0
- package/starter/templates/company-profile/preview.tsx +185 -0
- package/starter/templates/company-profile/starter.tsx +186 -0
- package/starter/templates/company-profile/template.json +15 -0
- package/starter/templates/consulting-report/AGENTS.md +11 -0
- package/starter/templates/consulting-report/README.md +13 -0
- package/starter/templates/consulting-report/RESEARCH.md +10 -0
- package/starter/templates/consulting-report/index.tsx +44 -0
- package/starter/templates/consulting-report/preview.tsx +39 -0
- package/starter/templates/consulting-report/starter.tsx +15 -0
- package/starter/templates/consulting-report/template.json +11 -0
- package/starter/templates/editorial-essay/AGENTS.md +11 -0
- package/starter/templates/editorial-essay/README.md +11 -0
- package/starter/templates/editorial-essay/index.tsx +30 -0
- package/starter/templates/editorial-essay/preview.tsx +26 -0
- package/starter/templates/editorial-essay/starter.tsx +15 -0
- package/starter/templates/editorial-essay/template.json +11 -0
- package/starter/templates/executive-brief/AGENTS.md +9 -0
- package/starter/templates/executive-brief/README.md +11 -0
- package/starter/templates/executive-brief/index.tsx +33 -0
- package/starter/templates/executive-brief/preview.tsx +37 -0
- package/starter/templates/executive-brief/starter.tsx +11 -0
- package/starter/templates/executive-brief/template.json +11 -0
- package/starter/templates/image-story/AGENTS.md +37 -0
- package/starter/templates/image-story/index.tsx +106 -0
- package/starter/templates/image-story/preview.tsx +33 -0
- package/starter/templates/image-story/starter.tsx +24 -0
- package/starter/templates/image-story/template.json +13 -0
- package/starter/templates/invoice/AGENTS.md +13 -0
- package/starter/templates/invoice/README.md +40 -0
- package/starter/templates/invoice/data.json +61 -0
- package/starter/templates/invoice/examples/long.json +241 -0
- package/starter/templates/invoice/examples/sparse.json +33 -0
- package/starter/templates/invoice/examples/typical.json +61 -0
- package/starter/templates/invoice/index.tsx +57 -0
- package/starter/templates/invoice/preview.tsx +12 -0
- package/starter/templates/invoice/schema.ts +45 -0
- package/starter/templates/invoice/starter.tsx +12 -0
- package/starter/templates/invoice/template.json +11 -0
- package/starter/templates/literary-text/AGENTS.md +9 -0
- package/starter/templates/literary-text/README.md +11 -0
- package/starter/templates/literary-text/index.tsx +31 -0
- package/starter/templates/literary-text/preview.tsx +20 -0
- package/starter/templates/literary-text/starter.tsx +11 -0
- package/starter/templates/literary-text/template.json +11 -0
- package/starter/templates/magazine-feature/AGENTS.md +11 -0
- package/starter/templates/magazine-feature/README.md +13 -0
- package/starter/templates/magazine-feature/index.tsx +41 -0
- package/starter/templates/magazine-feature/preview.tsx +34 -0
- package/starter/templates/magazine-feature/starter.tsx +15 -0
- package/starter/templates/magazine-feature/template.json +11 -0
- package/starter/templates/monthly-report/AGENTS.md +11 -0
- package/starter/templates/monthly-report/README.md +24 -0
- package/starter/templates/monthly-report/data.json +131 -0
- package/starter/templates/monthly-report/examples/long.json +519 -0
- package/starter/templates/monthly-report/examples/sparse.json +20 -0
- package/starter/templates/monthly-report/examples/typical.json +37 -0
- package/starter/templates/monthly-report/index.tsx +92 -0
- package/starter/templates/monthly-report/preview.tsx +14 -0
- package/starter/templates/monthly-report/schema.ts +127 -0
- package/starter/templates/monthly-report/starter.tsx +13 -0
- package/starter/templates/monthly-report/template.json +11 -0
- package/starter/templates/pitch-deck/AGENTS.md +32 -0
- package/starter/templates/pitch-deck/index.tsx +46 -0
- package/starter/templates/pitch-deck/preview.tsx +142 -0
- package/starter/templates/pitch-deck/starter.tsx +140 -0
- package/starter/templates/pitch-deck/template.json +15 -0
- package/starter/templates/proposal-deck/AGENTS.md +25 -0
- package/starter/templates/proposal-deck/index.tsx +52 -0
- package/starter/templates/proposal-deck/preview.tsx +172 -0
- package/starter/templates/proposal-deck/starter.tsx +168 -0
- package/starter/templates/proposal-deck/template.json +7 -0
- package/starter/templates/quotation/AGENTS.md +13 -0
- package/starter/templates/quotation/README.md +42 -0
- package/starter/templates/quotation/data.json +64 -0
- package/starter/templates/quotation/examples/long.json +272 -0
- package/starter/templates/quotation/examples/sparse.json +31 -0
- package/starter/templates/quotation/examples/typical.json +64 -0
- package/starter/templates/quotation/index.tsx +51 -0
- package/starter/templates/quotation/preview.tsx +12 -0
- package/starter/templates/quotation/schema.ts +27 -0
- package/starter/templates/quotation/starter.tsx +12 -0
- package/starter/templates/quotation/template.json +11 -0
- package/starter/templates/scientific-paper/AGENTS.md +11 -0
- package/starter/templates/scientific-paper/README.md +13 -0
- package/starter/templates/scientific-paper/index.tsx +47 -0
- package/starter/templates/scientific-paper/preview.tsx +43 -0
- package/starter/templates/scientific-paper/starter.tsx +15 -0
- package/starter/templates/scientific-paper/template.json +11 -0
- package/starter/themes/Specimen.tsx +54 -0
- package/starter/themes/civic-spectrum/components.tsx +92 -0
- package/starter/themes/civic-spectrum/design.md +70 -0
- package/starter/themes/civic-spectrum/index.ts +57 -0
- package/starter/themes/civic-spectrum/preview.tsx +66 -0
- package/starter/themes/field-manual/components.tsx +106 -0
- package/starter/themes/field-manual/design.md +72 -0
- package/starter/themes/field-manual/index.ts +57 -0
- package/starter/themes/field-manual/preview.tsx +82 -0
- package/starter/themes/index.ts +3 -0
- package/starter/themes/mckinsey-consulting/components.tsx +69 -0
- package/starter/themes/mckinsey-consulting/design.md +68 -0
- package/starter/themes/mckinsey-consulting/index.ts +60 -0
- package/starter/themes/mckinsey-consulting/preview.tsx +53 -0
- package/starter/themes/neutral/design.md +35 -0
- package/starter/themes/neutral/index.ts +21 -0
- package/starter/themes/neutral/preview.tsx +4 -0
- package/starter/themes/opendoc-neutral/components.tsx +77 -0
- package/starter/themes/opendoc-neutral/design.md +70 -0
- package/starter/themes/opendoc-neutral/index.ts +54 -0
- package/starter/themes/opendoc-neutral/preview.tsx +43 -0
- package/starter/themes/types.ts +3 -0
- package/tsconfig.workspace.json +24 -0
- package/vendor/formepdf/LICENSE +21 -0
- package/vendor/formepdf/README.md +97 -0
- package/vendor/formepdf/font-subset.patch +228 -0
- package/vendor/formepdf/text-writer.patch +507 -0
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Menu } from '@base-ui/react/menu';
|
|
3
|
+
import { Popover } from '@base-ui/react/popover';
|
|
4
|
+
import { PdfPage } from "./Pdf";
|
|
5
|
+
import { useReaderPreview } from "./useReaderPreview";
|
|
6
|
+
import { useTextEditing } from "./useTextEditing";
|
|
7
|
+
import { CommentDock } from "./CommentDock";
|
|
8
|
+
import { api } from "./api";
|
|
9
|
+
import { ExportMenu } from "./ExportMenu";
|
|
10
|
+
import { SkillIndex } from './SkillIndex';
|
|
11
|
+
import { getBlock, documentFormat, type Comment, type DocumentState } from "../shared/types";
|
|
12
|
+
import { PageNumberInput } from "./PageNumberInput";
|
|
13
|
+
import { commentDraftKey, componentCommentDraftKey, commentDrafts, type CommentDrafts } from "./commentDrafts";
|
|
14
|
+
import type { DocumentSelection, TextAnchor } from "../shared/selection";
|
|
15
|
+
import { anchorForSelection, getTextTarget, resolveCommentAnchor, selectionReason } from "../shared/anchors";
|
|
16
|
+
import { canCorrectComponent } from "./componentCorrection";
|
|
17
|
+
import { sessionForDocument, sourceIdentity } from './editSession';
|
|
18
|
+
import { readOpenEditor, recoverEditor, type EditorBaseline, type OpenEditorRecord } from './editorRecovery';
|
|
19
|
+
import "./selection.css";
|
|
20
|
+
import "./reader-toolbar.css";
|
|
21
|
+
import "./edit-workbench.css";
|
|
22
|
+
|
|
23
|
+
import { Icon } from "./ui/Icon";
|
|
24
|
+
import {
|
|
25
|
+
Button,
|
|
26
|
+
IconButton,
|
|
27
|
+
SelectControl,
|
|
28
|
+
useNotifications,
|
|
29
|
+
} from "./ui";
|
|
30
|
+
|
|
31
|
+
type CorrectionDraft = { selection: DocumentSelection; text: string; linked: number; baseline?: EditorBaseline };
|
|
32
|
+
const openEditors = new Map<string, OpenEditorRecord>();
|
|
33
|
+
|
|
34
|
+
export function Reader({
|
|
35
|
+
state: incomingState,
|
|
36
|
+
generation,
|
|
37
|
+
connected,
|
|
38
|
+
identity,
|
|
39
|
+
options,
|
|
40
|
+
onShowExports,
|
|
41
|
+
}: {
|
|
42
|
+
state: DocumentState;
|
|
43
|
+
generation: number;
|
|
44
|
+
connected: boolean;
|
|
45
|
+
identity: React.ReactNode;
|
|
46
|
+
options: React.ReactNode;
|
|
47
|
+
onShowExports: () => void;
|
|
48
|
+
}) {
|
|
49
|
+
const [responseState, setResponseState] = useState<DocumentState | null>(null);
|
|
50
|
+
const state = responseState && responseState.revision > incomingState.revision ? responseState : incomingState;
|
|
51
|
+
const { id } = state;
|
|
52
|
+
const presentation = documentFormat(state) === 'presentation';
|
|
53
|
+
const pageLabel = presentation ? 'Slide' : 'Page';
|
|
54
|
+
const formatLabel = presentation ? 'Presentation' : 'Document';
|
|
55
|
+
const editing = useTextEditing(state, connected, setResponseState);
|
|
56
|
+
const readerPreview = useReaderPreview(id, editing.preview ?? { artifact: state.artifact });
|
|
57
|
+
const { pdf, artifact, error: pdfError } = readerPreview;
|
|
58
|
+
const [selection, setSelection] = useState<DocumentSelection | null>(null);
|
|
59
|
+
const selected = selection?.blockId ?? null;
|
|
60
|
+
const selectionAnchor = useRef<TextAnchor | undefined>(undefined);
|
|
61
|
+
const [editor, setEditor] = useState<CorrectionDraft | null>(null);
|
|
62
|
+
const [editError, setEditError] = useState('');
|
|
63
|
+
const editPending = editing.saving;
|
|
64
|
+
const undoPending = editing.undoing;
|
|
65
|
+
const editField = useRef<HTMLTextAreaElement>(null);
|
|
66
|
+
const commentField = useRef<HTMLTextAreaElement>(null);
|
|
67
|
+
const editAction = useRef<HTMLButtonElement>(null);
|
|
68
|
+
const commentAction = useRef<HTMLButtonElement>(null);
|
|
69
|
+
const composingText = useRef(false);
|
|
70
|
+
const componentTrigger = useRef<HTMLElement | null>(null);
|
|
71
|
+
const readingPosition = useRef<{ blockId: string; offset: number } | null>(null);
|
|
72
|
+
const previousPreview = useRef({ hash: artifact?.hash, revision: state.revision });
|
|
73
|
+
const [commentsOpen, setCommentsOpen] = useState(false);
|
|
74
|
+
const [commentMode, setCommentMode] = useState<'compose' | 'view'>('compose');
|
|
75
|
+
const [commentEditor, setCommentEditor] = useState<{ id: string; text: string; version: number } | null>(null);
|
|
76
|
+
const [navigation, setNavigation] = useState(false);
|
|
77
|
+
const [navigationMode, setNavigationMode] = useState("pages");
|
|
78
|
+
const [comments, setComments] = useState<Comment[]>([]);
|
|
79
|
+
const [drafts, setDrafts] = useState<CommentDrafts>(() => commentDrafts.read(id));
|
|
80
|
+
const draftKey = componentCommentDraftKey(selection);
|
|
81
|
+
const legacyDraftKey = commentDraftKey(selection);
|
|
82
|
+
const draft = draftKey && Object.hasOwn(drafts, draftKey) ? drafts[draftKey] : drafts[legacyDraftKey] ?? "";
|
|
83
|
+
function setDraft(value: string) {
|
|
84
|
+
if (draftKey) {
|
|
85
|
+
commentDrafts.set(id, legacyDraftKey, '');
|
|
86
|
+
setDrafts(commentDrafts.set(id, draftKey, value));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const [zoom, setZoom] = useState("fit");
|
|
90
|
+
const [readingControlsOpen, setReadingControlsOpen] = useState(false);
|
|
91
|
+
const [availableWidth, setAvailableWidth] = useState(800);
|
|
92
|
+
const [page, setPage] = useState(1);
|
|
93
|
+
const [pageGutter, setPageGutter] = useState(40);
|
|
94
|
+
const notify = useNotifications();
|
|
95
|
+
const [submitting, setSubmitting] = useState(false);
|
|
96
|
+
const [changing, setChanging] = useState<string | null>(null);
|
|
97
|
+
const mutationPending = useRef(false);
|
|
98
|
+
const [commentError, setCommentError] = useState("");
|
|
99
|
+
const scroll = useRef<HTMLDivElement>(null);
|
|
100
|
+
const commentsTrigger = useRef<HTMLButtonElement>(null);
|
|
101
|
+
const navigationTrigger = useRef<HTMLButtonElement>(null);
|
|
102
|
+
const optionsTrigger = useRef<HTMLButtonElement>(null);
|
|
103
|
+
const scrollFrame = useRef<number | null>(null);
|
|
104
|
+
const commentRequest = useRef(0);
|
|
105
|
+
const commentAbort = useRef<AbortController | null>(null);
|
|
106
|
+
const pages = artifact?.pages ?? [];
|
|
107
|
+
const outline = artifact?.outline ?? [];
|
|
108
|
+
const issues = artifact?.issues ?? [];
|
|
109
|
+
const contents = navigationMode === "contents" && outline.length > 0;
|
|
110
|
+
const selectedBlock = getBlock(artifact, selected);
|
|
111
|
+
const editorTarget = editing.target(editor?.selection.targetId);
|
|
112
|
+
const editorWritable = canCorrectComponent(editorTarget);
|
|
113
|
+
const editStale = editing.stale;
|
|
114
|
+
const ready = state.status === "ready" && connected;
|
|
115
|
+
const width =
|
|
116
|
+
zoom === "fit"
|
|
117
|
+
? Math.max(120, Math.min(availableWidth - pageGutter * 2, 920))
|
|
118
|
+
: 595.28 * Number(zoom);
|
|
119
|
+
const safePage = Math.min(page, pages.length || 1);
|
|
120
|
+
const pageWidth = (index: number) => zoom === "fit" ? width : (pages[index]?.width ?? 595.28) * Number(zoom);
|
|
121
|
+
const widestPage = zoom === "fit" ? width : Math.max(...pages.map((item) => item.width), 595.28) * Number(zoom);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const controller = new AbortController();
|
|
124
|
+
const version = ++commentRequest.current;
|
|
125
|
+
commentAbort.current = controller;
|
|
126
|
+
const timer = setTimeout(() => {
|
|
127
|
+
void api<Comment[]>(`/api/documents/${id}/comments`, { signal: controller.signal })
|
|
128
|
+
.then((value) => {
|
|
129
|
+
if (version === commentRequest.current) { setComments(value); setCommentError(""); }
|
|
130
|
+
})
|
|
131
|
+
.catch((error: Error) => {
|
|
132
|
+
if (!controller.signal.aborted && version === commentRequest.current) setCommentError(error.message);
|
|
133
|
+
});
|
|
134
|
+
}, generation === 0 ? 0 : 80);
|
|
135
|
+
return () => { clearTimeout(timer); controller.abort(); };
|
|
136
|
+
}, [id, generation]);
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (!editor && !commentsOpen) return;
|
|
139
|
+
const dismiss = (event: PointerEvent) => {
|
|
140
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
141
|
+
if (target?.closest('.edit-workbench, .comment-dock-panel, .comment-dock-trigger, .component-target, .comment-marker, [aria-controls="reader-comments"]') || mutationPending.current || editPending || editError) return;
|
|
142
|
+
setEditor(null); forgetOpenEditor();
|
|
143
|
+
setCommentEditor(null);
|
|
144
|
+
clearSelection();
|
|
145
|
+
};
|
|
146
|
+
document.addEventListener('pointerdown', dismiss, true);
|
|
147
|
+
return () => document.removeEventListener('pointerdown', dismiss, true);
|
|
148
|
+
}, [!!editor, commentsOpen, editPending, editError]);
|
|
149
|
+
useEffect(() => () => { if (scrollFrame.current !== null) cancelAnimationFrame(scrollFrame.current); }, []);
|
|
150
|
+
useEffect(() => { editField.current?.focus({ preventScroll: true }); }, [editor?.selection.targetId]);
|
|
151
|
+
useEffect(() => { if (commentsOpen && commentMode === 'compose') commentField.current?.focus({ preventScroll: true }); }, [commentsOpen, commentMode, selection?.blockId]);
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
if ((!editor && !(commentsOpen && commentMode === 'compose')) || !selection?.targetId) return;
|
|
154
|
+
const frame = requestAnimationFrame(() => {
|
|
155
|
+
const target = scroll.current?.querySelector<HTMLElement>(`[data-text-target="${CSS.escape(selection.targetId!)}"]`);
|
|
156
|
+
const panel = document.querySelector('.edit-workbench');
|
|
157
|
+
if (target && panel && scroll.current) {
|
|
158
|
+
const box = target.getBoundingClientRect();
|
|
159
|
+
const top = panel.getBoundingClientRect().top;
|
|
160
|
+
if (box.bottom > top - 20) scroll.current.scrollTop += Math.min(box.bottom - top + 20, box.top - scroll.current.getBoundingClientRect().top - 32);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return () => cancelAnimationFrame(frame);
|
|
164
|
+
}, [editor?.selection.targetId, commentsOpen, commentMode, selection?.targetId]);
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
if (!pdf) return;
|
|
167
|
+
if (previousPreview.current.hash === artifact?.hash && previousPreview.current.revision === state.revision) return;
|
|
168
|
+
previousPreview.current = { hash: artifact?.hash, revision: state.revision };
|
|
169
|
+
if (selection) {
|
|
170
|
+
const target = getTextTarget(artifact, selection.targetId);
|
|
171
|
+
const resolved = target ? { ...selection, start: 0, end: target.text.length, quote: target.text,
|
|
172
|
+
page: target.lines[0]?.page ?? selection.page, renderHash: artifact?.hash, revision: state.revision }
|
|
173
|
+
: resolveCommentAnchor(artifact, { blockId: selection.blockId, quote: selection.quote ?? '', anchor: selectionAnchor.current }).selection;
|
|
174
|
+
if (resolved) { setSelection(resolved); selectionAnchor.current = anchorForSelection(artifact, resolved); }
|
|
175
|
+
}
|
|
176
|
+
const anchor = readingPosition.current;
|
|
177
|
+
if (anchor) {
|
|
178
|
+
const frame = requestAnimationFrame(() => {
|
|
179
|
+
const fragmentPage = pages.findIndex(item => item.fragments.some(fragment => fragment.id === anchor.blockId));
|
|
180
|
+
const container = scroll.current;
|
|
181
|
+
const sheet = container?.querySelector<HTMLElement>(`[data-sheet="${fragmentPage + 1}"] .pdf-page`);
|
|
182
|
+
const fragment = pages[fragmentPage]?.fragments.find(item => item.id === anchor.blockId);
|
|
183
|
+
if (container && sheet && fragment) container.scrollTop += sheet.getBoundingClientRect().top + fragment.y * pageWidth(fragmentPage) / pages[fragmentPage].width - container.getBoundingClientRect().top - anchor.offset;
|
|
184
|
+
readingPosition.current = null;
|
|
185
|
+
});
|
|
186
|
+
return () => cancelAnimationFrame(frame);
|
|
187
|
+
}
|
|
188
|
+
}, [pdf, artifact?.hash, state.revision]);
|
|
189
|
+
const restoredEditor = useRef(false);
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (restoredEditor.current || !artifact || state.status !== 'ready') return;
|
|
192
|
+
restoredEditor.current = true;
|
|
193
|
+
try {
|
|
194
|
+
const value = readOpenEditor(openEditors.get(id) ?? JSON.parse(sessionStorage.getItem(`opendoc:open-editor:${id}`) ?? 'null'));
|
|
195
|
+
const target = editing.target(value?.targetId);
|
|
196
|
+
const recovery = value && reconcileEditor(value);
|
|
197
|
+
if (target && recovery) {
|
|
198
|
+
const next = { blockId: target.blockId, targetId: target.id, start: 0, end: target.text.length, quote: target.text, page: target.lines[0]?.page ?? 1, revision: state.revision, renderHash: artifact.hash };
|
|
199
|
+
setSelection(next);
|
|
200
|
+
setEditor({ selection: next, text: recovery.record.text, baseline: recovery.record.baseline, linked: Math.max(1, ...target.runs.map(run => run.source?.linkedOccurrences ?? 1)) });
|
|
201
|
+
rememberOpenEditor(target.id, recovery.record.text, recovery.record.baseline);
|
|
202
|
+
setEditError(recovery.error ?? (recovery.stage ? editing.change(target.id, recovery.record.text) : undefined) ?? '');
|
|
203
|
+
}
|
|
204
|
+
} catch { /* A malformed or unavailable browser draft does not block reading. */ }
|
|
205
|
+
}, [artifact, state.status]);
|
|
206
|
+
useEffect(() => {
|
|
207
|
+
if (!editor?.selection.targetId || state.status !== 'ready' || editPending || editing.savedId || composingText.current) return;
|
|
208
|
+
const result = reconcileEditor({ targetId: editor.selection.targetId, text: editor.text, baseline: editor.baseline });
|
|
209
|
+
if (result.error) { setEditError(result.error); return; }
|
|
210
|
+
if (result.record.text !== editor.text || result.record.baseline?.hash !== editor.baseline?.hash || result.record.baseline?.revision !== editor.baseline?.revision) {
|
|
211
|
+
setEditor({ ...editor, text: result.record.text, baseline: result.record.baseline });
|
|
212
|
+
rememberOpenEditor(editor.selection.targetId, result.record.text, result.record.baseline);
|
|
213
|
+
setEditError('');
|
|
214
|
+
}
|
|
215
|
+
}, [state.status, state.revision, state.artifact?.hash, editing.session?.revision, editing.session?.hash, editor?.selection.targetId, editPending, editing.savedId]);
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (!scroll.current) return;
|
|
218
|
+
const observer = new ResizeObserver((entries) => {
|
|
219
|
+
setAvailableWidth(entries[0].contentRect.width);
|
|
220
|
+
setPageGutter(
|
|
221
|
+
parseFloat(
|
|
222
|
+
getComputedStyle(entries[0].target).getPropertyValue(
|
|
223
|
+
"--sheet-gutter",
|
|
224
|
+
),
|
|
225
|
+
) || 40,
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
observer.observe(scroll.current);
|
|
229
|
+
return () => observer.disconnect();
|
|
230
|
+
}, []);
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
const timer = setTimeout(() => {
|
|
233
|
+
void api("/api/context", {
|
|
234
|
+
method: "POST",
|
|
235
|
+
body: JSON.stringify({
|
|
236
|
+
documentId: id,
|
|
237
|
+
blockId: selected,
|
|
238
|
+
page: safePage,
|
|
239
|
+
selection,
|
|
240
|
+
editing: !!editor || editing.count > 0,
|
|
241
|
+
pendingEdits: editing.count,
|
|
242
|
+
draftPreview: !!editing.preview,
|
|
243
|
+
}),
|
|
244
|
+
}).catch(() => {});
|
|
245
|
+
}, 150);
|
|
246
|
+
return () => clearTimeout(timer);
|
|
247
|
+
}, [id, selection, safePage, artifact?.hash, !!editor, editing.count, !!editing.preview]);
|
|
248
|
+
const goPage = useCallback(
|
|
249
|
+
(number: number) => {
|
|
250
|
+
const next = Math.max(1, Math.min(number, pages.length || 1));
|
|
251
|
+
scroll.current
|
|
252
|
+
?.querySelector(`[data-sheet="${next}"]`)
|
|
253
|
+
?.scrollIntoView({ block: "start" });
|
|
254
|
+
setPage(next);
|
|
255
|
+
},
|
|
256
|
+
[pages.length],
|
|
257
|
+
);
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
const listener = (event: KeyboardEvent) => {
|
|
260
|
+
if (
|
|
261
|
+
event.defaultPrevented ||
|
|
262
|
+
(event.target as HTMLElement)?.closest(
|
|
263
|
+
"input,textarea,select,[role=combobox],[role=listbox],[role=dialog],[contenteditable=true]",
|
|
264
|
+
)
|
|
265
|
+
)
|
|
266
|
+
return;
|
|
267
|
+
if (event.key === "PageDown") {
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
goPage(safePage + 1);
|
|
270
|
+
}
|
|
271
|
+
if (event.key === "PageUp") {
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
goPage(safePage - 1);
|
|
274
|
+
}
|
|
275
|
+
if (event.key === "Escape") {
|
|
276
|
+
if (editor) closeEditor();
|
|
277
|
+
else if (commentsOpen) closeComments();
|
|
278
|
+
else clearSelection();
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
window.addEventListener("keydown", listener);
|
|
282
|
+
return () => window.removeEventListener("keydown", listener);
|
|
283
|
+
}, [goPage, safePage, selection, !!editor, commentsOpen, editPending, ready, editError]);
|
|
284
|
+
function onScroll() {
|
|
285
|
+
if (scrollFrame.current !== null) return;
|
|
286
|
+
scrollFrame.current = requestAnimationFrame(() => {
|
|
287
|
+
scrollFrame.current = null;
|
|
288
|
+
const container = scroll.current;
|
|
289
|
+
if (!container) return;
|
|
290
|
+
const top = container.getBoundingClientRect().top + 20;
|
|
291
|
+
const elements = container.querySelectorAll<HTMLElement>("[data-sheet]");
|
|
292
|
+
// At small zoom levels the last page cannot reach the top of the viewport.
|
|
293
|
+
if (elements.length && container.scrollTop > 0 && container.scrollTop + container.clientHeight >= container.scrollHeight - 2) {
|
|
294
|
+
setPage(Number(elements[elements.length - 1].dataset.sheet));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
// Page positions are ordered. A binary search keeps long-document scrolling cheap.
|
|
298
|
+
let low = 0, high = elements.length - 1;
|
|
299
|
+
while (low < high) {
|
|
300
|
+
const middle = Math.floor((low + high) / 2);
|
|
301
|
+
const element = elements[middle];
|
|
302
|
+
if (element.getBoundingClientRect().bottom < top) low = middle + 1;
|
|
303
|
+
else high = middle;
|
|
304
|
+
}
|
|
305
|
+
const closest = elements[low];
|
|
306
|
+
if (closest) setPage(Number(closest.dataset.sheet));
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function clearSelection() {
|
|
310
|
+
setCommentsOpen(false);
|
|
311
|
+
setCommentEditor(null);
|
|
312
|
+
setSelection(null);
|
|
313
|
+
selectionAnchor.current = undefined;
|
|
314
|
+
window.getSelection()?.removeAllRanges();
|
|
315
|
+
}
|
|
316
|
+
const chooseSelection = useCallback((next: DocumentSelection) => {
|
|
317
|
+
if (editPending || editError) return;
|
|
318
|
+
setCommentsOpen(false);
|
|
319
|
+
const current = { ...next, revision: state.revision, renderHash: artifact?.hash };
|
|
320
|
+
setSelection(current);
|
|
321
|
+
selectionAnchor.current = anchorForSelection(artifact, current);
|
|
322
|
+
setPage(next.page);
|
|
323
|
+
}, [editPending, editError, state.revision, artifact]);
|
|
324
|
+
function selectBlock(block: string, pageNumber: number) {
|
|
325
|
+
chooseSelection({ blockId: block, page: pageNumber });
|
|
326
|
+
}
|
|
327
|
+
function openComments() {
|
|
328
|
+
if (!selection || mutationPending.current || editPending || editError) return;
|
|
329
|
+
setEditor(null); forgetOpenEditor();
|
|
330
|
+
setCommentMode('compose');
|
|
331
|
+
setCommentEditor(null);
|
|
332
|
+
setCommentsOpen(true);
|
|
333
|
+
}
|
|
334
|
+
function closeComments() {
|
|
335
|
+
if (mutationPending.current) return;
|
|
336
|
+
if (commentMode === 'compose') { setCommentsOpen(false); commentAction.current?.focus(); return; }
|
|
337
|
+
clearSelection();
|
|
338
|
+
requestAnimationFrame(() => (componentTrigger.current ?? (commentsTrigger.current?.getClientRects().length ? commentsTrigger.current : optionsTrigger.current))?.focus());
|
|
339
|
+
}
|
|
340
|
+
function showCommentList() {
|
|
341
|
+
if (editPending || editError) return;
|
|
342
|
+
setEditor(null); forgetOpenEditor();
|
|
343
|
+
clearSelection();
|
|
344
|
+
setCommentMode('view');
|
|
345
|
+
setCommentsOpen(true);
|
|
346
|
+
}
|
|
347
|
+
function viewComments(block: string, pageNumber: number) {
|
|
348
|
+
if (editPending || editError) return;
|
|
349
|
+
setEditor(null); forgetOpenEditor();
|
|
350
|
+
selectBlock(block, pageNumber);
|
|
351
|
+
componentTrigger.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
352
|
+
const comment = comments.find(item => item.blockId === block && item.status === 'open');
|
|
353
|
+
const anchor = comment && resolveCommentAnchor(artifact, comment);
|
|
354
|
+
if (anchor?.selection) {
|
|
355
|
+
const next = { ...anchor.selection, revision: state.revision };
|
|
356
|
+
setSelection(next);
|
|
357
|
+
selectionAnchor.current = anchorForSelection(artifact, next);
|
|
358
|
+
}
|
|
359
|
+
setCommentMode('view');
|
|
360
|
+
setCommentEditor(null);
|
|
361
|
+
setCommentsOpen(true);
|
|
362
|
+
}
|
|
363
|
+
function pendingEditorBaseline(targetId: string): EditorBaseline | undefined {
|
|
364
|
+
const session = editing.session;
|
|
365
|
+
const target = editing.target(targetId);
|
|
366
|
+
if (!session || !target || !target.runs.some(run => run.source && session.pending.some(edit => edit.sourceId === sourceIdentity(run.source!)))) return undefined;
|
|
367
|
+
return { hash: session.hash, revision: session.revision, text: target.text };
|
|
368
|
+
}
|
|
369
|
+
function reconcileEditor(value: OpenEditorRecord, typing = false) {
|
|
370
|
+
const target = getTextTarget(state.artifact, value.targetId);
|
|
371
|
+
if (!target || state.status !== 'ready') return { record: value, stage: false, error: target ? 'The document is updating. Your text is kept here.' : 'This component is no longer in the document. Your text is kept here to copy or discard.' };
|
|
372
|
+
const result = recoverEditor(value, { hash: state.artifact!.hash, revision: state.revision, text: target.text }, pendingEditorBaseline(value.targetId), typing);
|
|
373
|
+
const session = sessionForDocument(editing.session, { hash: state.artifact?.hash, revision: state.revision });
|
|
374
|
+
if (result.stage && session && (session.hash !== state.artifact!.hash || session.revision !== state.revision)) return { ...result, stage: false, error: 'Refresh your draft before editing this text.' };
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
377
|
+
function rememberOpenEditor(targetId: string, text: string, baseline?: EditorBaseline) {
|
|
378
|
+
const value = { targetId, text, baseline };
|
|
379
|
+
openEditors.set(id, value);
|
|
380
|
+
try { sessionStorage.setItem(`opendoc:open-editor:${id}`, JSON.stringify(value)); } catch { /* The in-memory editor stays available. */ }
|
|
381
|
+
}
|
|
382
|
+
function forgetOpenEditor() {
|
|
383
|
+
openEditors.delete(id);
|
|
384
|
+
try { sessionStorage.removeItem(`opendoc:open-editor:${id}`); } catch { /* Storage may be unavailable. */ }
|
|
385
|
+
}
|
|
386
|
+
function selectComponent(next: DocumentSelection) {
|
|
387
|
+
if (mutationPending.current || editPending || editError) return;
|
|
388
|
+
setEditor(null); forgetOpenEditor();
|
|
389
|
+
componentTrigger.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
390
|
+
chooseSelection(next);
|
|
391
|
+
}
|
|
392
|
+
function openTextComponent(next: DocumentSelection) {
|
|
393
|
+
if (editPending || editError) return;
|
|
394
|
+
const target = editing.target(next.targetId);
|
|
395
|
+
if (!target) return;
|
|
396
|
+
chooseSelection(next);
|
|
397
|
+
componentTrigger.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
398
|
+
const current = { ...next, start: 0, end: target.text.length, quote: target.text, revision: state.revision, renderHash: artifact?.hash };
|
|
399
|
+
const session = sessionForDocument(editing.session, { hash: state.artifact?.hash, revision: state.revision });
|
|
400
|
+
const baseline = { hash: session?.hash ?? state.artifact!.hash, revision: session?.revision ?? state.revision, text: target.text };
|
|
401
|
+
setEditError('');
|
|
402
|
+
setEditor({ selection: current, text: target.text, baseline,
|
|
403
|
+
linked: Math.max(1, ...target.runs.map(run => run.source?.linkedOccurrences ?? 1)) });
|
|
404
|
+
rememberOpenEditor(target.id, target.text, baseline);
|
|
405
|
+
}
|
|
406
|
+
function changeText(text: string) {
|
|
407
|
+
if (!editor?.selection.targetId) return;
|
|
408
|
+
rememberReadingPosition(editor.selection.blockId);
|
|
409
|
+
const result = reconcileEditor({ targetId: editor.selection.targetId, text, baseline: editor.baseline }, true);
|
|
410
|
+
setEditor({ ...editor, text: result.record.text, baseline: result.record.baseline });
|
|
411
|
+
rememberOpenEditor(editor.selection.targetId, result.record.text, result.record.baseline);
|
|
412
|
+
setEditError(result.error ?? (result.stage ? editing.change(editor.selection.targetId, result.record.text) : undefined) ?? '');
|
|
413
|
+
}
|
|
414
|
+
function resetText() {
|
|
415
|
+
if (!editor?.selection.targetId || state.status !== 'ready') return;
|
|
416
|
+
const pending = pendingEditorBaseline(editor.selection.targetId);
|
|
417
|
+
const target = pending ? editing.target(editor.selection.targetId) : getTextTarget(state.artifact, editor.selection.targetId);
|
|
418
|
+
if (target) {
|
|
419
|
+
const baseline = pending ?? { hash: state.artifact!.hash, revision: state.revision, text: target.text };
|
|
420
|
+
setEditor({ ...editor, text: target.text, baseline }); rememberOpenEditor(target.id, target.text, baseline); setEditError('');
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function closeEditor() {
|
|
424
|
+
if (editPending || editError) return;
|
|
425
|
+
setEditor(null); forgetOpenEditor();
|
|
426
|
+
editAction.current?.focus({ preventScroll: true });
|
|
427
|
+
}
|
|
428
|
+
function rememberReadingPosition(blockId: string) {
|
|
429
|
+
const container = scroll.current;
|
|
430
|
+
const index = pages.findIndex(item => item.fragments.some(fragment => fragment.id === blockId));
|
|
431
|
+
const sheet = container?.querySelector<HTMLElement>(`[data-sheet="${index + 1}"] .pdf-page`);
|
|
432
|
+
const fragment = pages[index]?.fragments.find(item => item.id === blockId);
|
|
433
|
+
if (container && sheet && fragment) readingPosition.current = { blockId, offset: sheet.getBoundingClientRect().top + fragment.y * pageWidth(index) / pages[index].width - container.getBoundingClientRect().top };
|
|
434
|
+
}
|
|
435
|
+
async function saveAll() {
|
|
436
|
+
if (editError || mutationPending.current || composingText.current) return;
|
|
437
|
+
if (selected) rememberReadingPosition(selected);
|
|
438
|
+
const accepted = await editing.save();
|
|
439
|
+
if (accepted) { setEditor(null); forgetOpenEditor(); }
|
|
440
|
+
return accepted;
|
|
441
|
+
}
|
|
442
|
+
function undoChange() {
|
|
443
|
+
if (editPending || undoPending) return;
|
|
444
|
+
if (editing.savedId) { void editing.undoSaved(); return; }
|
|
445
|
+
if (editError) { resetText(); return; }
|
|
446
|
+
if (editing.canUndo) editing.undoDraft();
|
|
447
|
+
else if (!editing.count) { if (state.manualEdit) rememberReadingPosition(state.manualEdit.blockId); void editing.undoSaved(); }
|
|
448
|
+
const target = editing.target(editor?.selection.targetId);
|
|
449
|
+
if (editor && target) { setEditor({ ...editor, text: target.text }); rememberOpenEditor(target.id, target.text, editor.baseline); }
|
|
450
|
+
}
|
|
451
|
+
function redoChange() {
|
|
452
|
+
if (editPending || undoPending || editError) return;
|
|
453
|
+
editing.redoDraft();
|
|
454
|
+
const target = editing.target(editor?.selection.targetId);
|
|
455
|
+
if (editor && target) { setEditor({ ...editor, text: target.text }); rememberOpenEditor(target.id, target.text, editor.baseline); }
|
|
456
|
+
}
|
|
457
|
+
function discardChanges() {
|
|
458
|
+
editing.discard(); setEditor(null); forgetOpenEditor(); setEditError(''); clearSelection();
|
|
459
|
+
}
|
|
460
|
+
useEffect(() => {
|
|
461
|
+
const shortcut = (event: KeyboardEvent) => {
|
|
462
|
+
if (!(event.metaKey || event.ctrlKey) || event.altKey) return;
|
|
463
|
+
if (event.key.toLowerCase() === 's') { event.preventDefault(); void saveAll(); return; }
|
|
464
|
+
if ((event.target as HTMLElement)?.closest('input,textarea,[contenteditable=true]') || commentsOpen) return;
|
|
465
|
+
if (event.key.toLowerCase() === 'z') { event.preventDefault(); if (event.shiftKey) redoChange(); else undoChange(); }
|
|
466
|
+
if (event.key.toLowerCase() === 'y') { event.preventDefault(); redoChange(); }
|
|
467
|
+
};
|
|
468
|
+
document.addEventListener('keydown', shortcut);
|
|
469
|
+
return () => document.removeEventListener('keydown', shortcut);
|
|
470
|
+
}, [editing.session, editing.saving, editing.count, editing.stale, connected, editError, editor, commentsOpen, state.manualEdit]);
|
|
471
|
+
function scrollToBlock(block: string, preferredPage?: number) {
|
|
472
|
+
const found = preferredPage && pages[preferredPage - 1]?.fragments.some(fragment => fragment.id === block)
|
|
473
|
+
? preferredPage - 1 : pages.findIndex((item) => item.fragments.some((fragment) => fragment.id === block));
|
|
474
|
+
if (found < 0) return;
|
|
475
|
+
goPage(found + 1);
|
|
476
|
+
const fragment = pages[found].fragments.find((item) => item.id === block)!;
|
|
477
|
+
const container = scroll.current;
|
|
478
|
+
const sheet = container?.querySelector<HTMLElement>(`[data-sheet="${found + 1}"]`);
|
|
479
|
+
if (container && sheet) {
|
|
480
|
+
const top = sheet.getBoundingClientRect().top - container.getBoundingClientRect().top + container.scrollTop;
|
|
481
|
+
container.scrollTo({ top: top + fragment.y * pageWidth(found) / pages[found].width - 48 });
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function findBlock(block: string) {
|
|
485
|
+
chooseSelection({ blockId: block, page: Math.max(1, pages.findIndex(item => item.fragments.some(fragment => fragment.id === block)) + 1) });
|
|
486
|
+
scrollToBlock(block);
|
|
487
|
+
}
|
|
488
|
+
function goToComment(comment: Comment) {
|
|
489
|
+
const { selection: next } = resolveCommentAnchor(artifact, comment);
|
|
490
|
+
if (!next) return;
|
|
491
|
+
const target = getTextTarget(artifact, next.targetId);
|
|
492
|
+
chooseSelection(target ? { ...next, start: 0, end: target.text.length, quote: target.text } : next);
|
|
493
|
+
setCommentEditor(null);
|
|
494
|
+
scrollToBlock(next.blockId, next.page);
|
|
495
|
+
scroll.current?.focus({ preventScroll: true });
|
|
496
|
+
requestAnimationFrame(() => {
|
|
497
|
+
const sheet = scroll.current?.querySelector(`[data-sheet="${next.page}"]`);
|
|
498
|
+
const selector = target ? `[data-text-target="${CSS.escape(target.id)}"]` : `[data-block-id="${CSS.escape(next.blockId)}"]`;
|
|
499
|
+
sheet?.querySelector<HTMLElement>(selector)?.focus({ preventScroll: true });
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
function navigateFromRail(number: number, block?: string) {
|
|
503
|
+
if (block) scrollToBlock(block);
|
|
504
|
+
else goPage(number);
|
|
505
|
+
setNavigation(false);
|
|
506
|
+
navigationTrigger.current?.focus();
|
|
507
|
+
}
|
|
508
|
+
async function submitComment(event: React.FormEvent) {
|
|
509
|
+
event.preventDefault();
|
|
510
|
+
if (mutationPending.current || !draft.trim() || !selectedBlock || !ready) return;
|
|
511
|
+
mutationPending.current = true;
|
|
512
|
+
++commentRequest.current;
|
|
513
|
+
commentAbort.current?.abort();
|
|
514
|
+
setSubmitting(true);
|
|
515
|
+
try {
|
|
516
|
+
setComments(
|
|
517
|
+
await api(`/api/documents/${id}/comments`, {
|
|
518
|
+
method: "POST",
|
|
519
|
+
body: JSON.stringify({
|
|
520
|
+
blockId: selected,
|
|
521
|
+
text: draft,
|
|
522
|
+
hash: state.artifact?.hash,
|
|
523
|
+
selection: canonicalCommentSelection(),
|
|
524
|
+
}),
|
|
525
|
+
}),
|
|
526
|
+
);
|
|
527
|
+
commentDrafts.clearSubmitted(id, legacyDraftKey, draft);
|
|
528
|
+
setDrafts(commentDrafts.clearSubmitted(id, draftKey, draft));
|
|
529
|
+
clearSelection();
|
|
530
|
+
componentTrigger.current?.focus();
|
|
531
|
+
} catch (e) {
|
|
532
|
+
notify.error((e as Error).message);
|
|
533
|
+
} finally {
|
|
534
|
+
mutationPending.current = false;
|
|
535
|
+
setSubmitting(false);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
async function updateSavedComment(comment: Comment, action: 'edit' | 'delete') {
|
|
539
|
+
if (mutationPending.current || !connected || (action === 'edit' && !commentEditor?.text.trim())) return;
|
|
540
|
+
mutationPending.current = true;
|
|
541
|
+
setChanging(comment.id);
|
|
542
|
+
++commentRequest.current;
|
|
543
|
+
commentAbort.current?.abort();
|
|
544
|
+
try {
|
|
545
|
+
setComments(await api<Comment[]>(`/api/documents/${id}/comments/${comment.id}`, {
|
|
546
|
+
method: action === 'delete' ? 'DELETE' : 'PATCH',
|
|
547
|
+
body: JSON.stringify(action === 'delete' ? { version: comment.version } : { text: commentEditor!.text, version: commentEditor!.version }),
|
|
548
|
+
}));
|
|
549
|
+
clearSelection();
|
|
550
|
+
componentTrigger.current?.focus();
|
|
551
|
+
} catch (error) { notify.error((error as Error).message); }
|
|
552
|
+
finally { mutationPending.current = false; setChanging(null); }
|
|
553
|
+
}
|
|
554
|
+
const unresolvedComments = useMemo(() => comments.filter((comment) => comment.status === "open"), [comments]);
|
|
555
|
+
const commented = useMemo(() => new Set(unresolvedComments.map((comment) => comment.blockId)), [unresolvedComments]);
|
|
556
|
+
function canonicalCommentSelection() {
|
|
557
|
+
if (!selection) return null;
|
|
558
|
+
const target = getTextTarget(state.artifact, selection.targetId);
|
|
559
|
+
const page = (state.artifact?.pages.findIndex(item => item.fragments.some(fragment => fragment.id === selection.blockId)) ?? 0) + 1;
|
|
560
|
+
return { blockId: selection.blockId, page: Math.max(1, page), revision: state.revision, renderHash: state.artifact?.hash,
|
|
561
|
+
...(target ? { targetId: target.id, start: 0, end: target.text.length, quote: target.text } : {}) };
|
|
562
|
+
}
|
|
563
|
+
const undoDisabled = editPending || undoPending || (editing.savedId ? !state.manualEdit?.canUndo || !connected : !editError && !editing.canUndo && (editing.count > 0 || !state.manualEdit?.canUndo || !connected));
|
|
564
|
+
const composingComment = commentsOpen && commentMode === 'compose';
|
|
565
|
+
const showWorkbench = !!selection || !!editor || composingComment || editing.count > 0 || editing.canRedo || editing.saved || !!editing.savedId || !!editing.error;
|
|
566
|
+
const pageControls = <>
|
|
567
|
+
<div className="reader-pagination">
|
|
568
|
+
<IconButton label={`Previous ${pageLabel.toLowerCase()}`} disabled={safePage <= 1} onClick={() => goPage(safePage - 1)}><Icon name="left" size={14} /></IconButton>
|
|
569
|
+
<PageNumberInput label={`${pageLabel} number`} page={safePage} count={pages.length} onNavigate={goPage} />
|
|
570
|
+
<IconButton label={`Next ${pageLabel.toLowerCase()}`} disabled={safePage >= pages.length} onClick={() => goPage(safePage + 1)}><Icon name="right" size={14} /></IconButton>
|
|
571
|
+
</div>
|
|
572
|
+
<SelectControl label="Zoom" value={zoom} onValueChange={setZoom} items={[
|
|
573
|
+
{ value: 'fit', label: 'Fit width' }, { value: '0.75', label: '75%' }, { value: '1', label: '100%' }, { value: '1.25', label: '125%' }, { value: '1.5', label: '150%' },
|
|
574
|
+
]} />
|
|
575
|
+
</>;
|
|
576
|
+
return (
|
|
577
|
+
<div className="reader">
|
|
578
|
+
<header className="reader-toolbar" aria-label={`${formatLabel} toolbar`}>
|
|
579
|
+
<div className="reader-identity">{identity}</div>
|
|
580
|
+
<div className="reader-page-controls">{pageControls}</div>
|
|
581
|
+
<div className="reader-compact-controls">
|
|
582
|
+
<Popover.Root open={readingControlsOpen} onOpenChange={setReadingControlsOpen}>
|
|
583
|
+
<Popover.Trigger ref={navigationTrigger} render={<Button className="reader-reading-trigger" />} aria-label="Reading controls">
|
|
584
|
+
<span>{safePage}<span className="reader-page-total"> / {pages.length || '—'}</span></span><Icon name="down" size={12} />
|
|
585
|
+
</Popover.Trigger>
|
|
586
|
+
<Popover.Portal><Popover.Positioner className="ui-positioner" align="end" sideOffset={8}>
|
|
587
|
+
<Popover.Popup className="ui-menu-popup reader-reading-popup">
|
|
588
|
+
<Popover.Title className="ui-menu-label">Reading controls</Popover.Title>
|
|
589
|
+
<div className="reader-page-controls">{pageControls}</div>
|
|
590
|
+
<Button className="ui-menu-item reader-navigation-option" disabled={!pages.length} aria-expanded={navigation} aria-controls="reader-navigation" onClick={() => { setReadingControlsOpen(false); setNavigation(value => !value); }}><Icon name="sidebar" size={16} />{formatLabel} navigation</Button>
|
|
591
|
+
</Popover.Popup>
|
|
592
|
+
</Popover.Positioner></Popover.Portal>
|
|
593
|
+
</Popover.Root>
|
|
594
|
+
</div>
|
|
595
|
+
<div className="reader-actions">
|
|
596
|
+
<SkillIndex />
|
|
597
|
+
<ExportMenu state={state} connected={connected} ready={ready && !!pdf && !readerPreview.loading && artifact?.hash === state.artifact?.hash} unsaved={editing.count} saving={editPending || undoPending} correctionError={editError || editing.error || (editStale ? 'Refresh your draft before saving and exporting.' : '')} canSave={!!editing.count && ready && !editPending && !undoPending && !editStale && !editError && !editing.savedId} onSave={saveAll} onShowExports={onShowExports} />
|
|
598
|
+
<Menu.Root>
|
|
599
|
+
<Menu.Trigger ref={optionsTrigger} render={<IconButton label={`${formatLabel} options`} />}><Icon name="more" size={18} /></Menu.Trigger>
|
|
600
|
+
<Menu.Portal><Menu.Positioner className="ui-positioner" align="end" sideOffset={8}>
|
|
601
|
+
<Menu.Popup className="ui-menu-popup">
|
|
602
|
+
{state.manualEdit?.canUndo && <Menu.Item className="ui-menu-item" disabled={undoDisabled} onClick={undoChange}><Icon name="undo" size={16} /><span>Undo saved changes</span></Menu.Item>}
|
|
603
|
+
{options}
|
|
604
|
+
</Menu.Popup>
|
|
605
|
+
</Menu.Positioner></Menu.Portal>
|
|
606
|
+
</Menu.Root>
|
|
607
|
+
</div>
|
|
608
|
+
</header>
|
|
609
|
+
{state.status !== "ready" && (
|
|
610
|
+
<div
|
|
611
|
+
className={
|
|
612
|
+
state.status === "error" ? "render-banner error" : "render-banner"
|
|
613
|
+
}
|
|
614
|
+
role="status"
|
|
615
|
+
>
|
|
616
|
+
<strong>
|
|
617
|
+
{state.status === "error"
|
|
618
|
+
? (editing.savedId ? "Source saved. Preview needs attention." : "This draft needs attention.")
|
|
619
|
+
: (editing.savedId ? "Source saved. Updating the preview…" : "Rendering your changes…")}
|
|
620
|
+
</strong>
|
|
621
|
+
<span>
|
|
622
|
+
{artifact
|
|
623
|
+
? "Showing the last successful preview. Export is paused."
|
|
624
|
+
: "Your preview will appear here."}
|
|
625
|
+
</span>
|
|
626
|
+
{state.error && <pre>{state.error}</pre>}
|
|
627
|
+
</div>
|
|
628
|
+
)}
|
|
629
|
+
|
|
630
|
+
{issues.length > 0 && state.status === "ready" && (
|
|
631
|
+
<details className="review-issues">
|
|
632
|
+
<summary>{issues.length} {issues.length === 1 ? "layout note" : "layout notes"} to review</summary>
|
|
633
|
+
<ul>
|
|
634
|
+
{issues.map((issue, index) => (
|
|
635
|
+
<li key={`${issue.code}-${issue.blockId ?? issue.page ?? index}`}>
|
|
636
|
+
{issue.blockId || issue.page ? (
|
|
637
|
+
<Button static className="review-issue-link" onClick={() => issue.blockId ? findBlock(issue.blockId) : goPage(issue.page!)}>
|
|
638
|
+
<span>{issue.message}</span>{issue.page && <span className="issue-page">{pageLabel} {issue.page}</span>}
|
|
639
|
+
</Button>
|
|
640
|
+
) : <p>{issue.message}</p>}
|
|
641
|
+
</li>
|
|
642
|
+
))}
|
|
643
|
+
</ul>
|
|
644
|
+
</details>
|
|
645
|
+
)}
|
|
646
|
+
{pdfError && pdf && <div className="error-banner" role="alert"><span>Could not load the latest PDF. Showing the previous preview.</span><Button className="text-button" onClick={readerPreview.retry}>Try again</Button></div>}
|
|
647
|
+
<div className="reader-body">
|
|
648
|
+
<aside className={`page-rail ${contents ? "contents-rail" : ""} ${navigation ? "navigation-open" : ""}`} id="reader-navigation" aria-label={`${formatLabel} navigation`}>
|
|
649
|
+
<div className="rail-heading">
|
|
650
|
+
{outline.length > 0 ? <SelectControl label="Navigation view" value={contents ? "contents" : "pages"} onValueChange={setNavigationMode} items={[{ value: "pages", label: `${pageLabel}s` }, { value: "contents", label: "Contents" }]} /> : <div className="rail-label">{pageLabel}s</div>}
|
|
651
|
+
<IconButton label="Close navigation" className="navigation-close" onClick={() => { setNavigation(false); navigationTrigger.current?.focus(); }}><Icon name="close" size={16} /></IconButton>
|
|
652
|
+
</div>
|
|
653
|
+
{contents ? (
|
|
654
|
+
<nav className="document-outline" aria-label={`${formatLabel} contents`}>
|
|
655
|
+
{outline.map((entry, index) => <Button static key={`${entry.id}-${index}`} className={`outline-entry level-${Math.min(entry.level, 3)}`} onClick={() => navigateFromRail(entry.page, entry.id)}>
|
|
656
|
+
<span>{entry.title}</span><span className="outline-page">{entry.page}</span>
|
|
657
|
+
</Button>)}
|
|
658
|
+
</nav>
|
|
659
|
+
) : pdf && pages.map((_, index) => (
|
|
660
|
+
<Button static key={index} className={safePage === index + 1 ? "page-thumb active" : "page-thumb"} onClick={() => navigateFromRail(index + 1)} aria-label={`Go to ${pageLabel.toLowerCase()} ${index + 1}`} aria-current={safePage === index + 1 ? "page" : undefined}>
|
|
661
|
+
<PdfPage pdf={pdf} number={index + 1} width={72} artifact={artifact} thumbnail />
|
|
662
|
+
<span>{index + 1}</span>
|
|
663
|
+
</Button>
|
|
664
|
+
))}
|
|
665
|
+
</aside>
|
|
666
|
+
<div
|
|
667
|
+
ref={scroll}
|
|
668
|
+
className="reader-scroll"
|
|
669
|
+
tabIndex={-1}
|
|
670
|
+
onPointerDownCapture={() => {
|
|
671
|
+
if (!editor && !mutationPending.current) clearSelection();
|
|
672
|
+
}}
|
|
673
|
+
onScroll={onScroll}
|
|
674
|
+
>
|
|
675
|
+
{pdfError && !pdf ? (
|
|
676
|
+
<div className="empty-state" role="alert">
|
|
677
|
+
<p>{pdfError}</p>
|
|
678
|
+
<Button onClick={readerPreview.retry}>Try again</Button>
|
|
679
|
+
</div>
|
|
680
|
+
) : pdf ? (
|
|
681
|
+
<div
|
|
682
|
+
className="sheets"
|
|
683
|
+
style={{ minWidth: widestPage + pageGutter * 2 }}
|
|
684
|
+
>
|
|
685
|
+
{pages.map((p, i) => (
|
|
686
|
+
<section data-sheet={i + 1} key={i} className="sheet">
|
|
687
|
+
<div className="sheet-label">
|
|
688
|
+
{pageLabel} {i + 1}{" "}
|
|
689
|
+
<span>
|
|
690
|
+
{presentation ? '16:9' : `${Math.round((p.width / 72) * 25.4)} × ${Math.round((p.height / 72) * 25.4)} mm`}
|
|
691
|
+
</span>
|
|
692
|
+
</div>
|
|
693
|
+
<PdfPage
|
|
694
|
+
pdf={pdf}
|
|
695
|
+
number={i + 1}
|
|
696
|
+
width={pageWidth(i)}
|
|
697
|
+
artifact={artifact}
|
|
698
|
+
selected={selected}
|
|
699
|
+
selection={selection}
|
|
700
|
+
commented={commented}
|
|
701
|
+
onSelect={(block, number) => selectComponent({ blockId: block, page: number })}
|
|
702
|
+
onComment={viewComments}
|
|
703
|
+
onTextClick={selectComponent}
|
|
704
|
+
onNavigate={goPage}
|
|
705
|
+
/>
|
|
706
|
+
</section>
|
|
707
|
+
))}
|
|
708
|
+
</div>
|
|
709
|
+
) : (
|
|
710
|
+
<div className="empty-state">
|
|
711
|
+
<div className="loading-mark" />
|
|
712
|
+
<p>{state.status === "error" ? "The preview will appear after the draft is corrected." : `Preparing your ${pageLabel.toLowerCase()}s…`}</p>
|
|
713
|
+
</div>
|
|
714
|
+
)}
|
|
715
|
+
</div>
|
|
716
|
+
</div>
|
|
717
|
+
<CommentDock pageLabel={pageLabel} open={commentsOpen && commentMode === 'view'} heading={selected ? 'Component comments' : `${formatLabel} comments`} count={unresolvedComments.length}
|
|
718
|
+
items={comments.filter(comment => comment.status !== 'deleted' && (!selected || comment.blockId === selected)).map(comment => {
|
|
719
|
+
const anchor = resolveCommentAnchor(artifact, comment);
|
|
720
|
+
return { comment, page: anchor.selection?.page, kind: getBlock(artifact, comment.blockId)?.kind ?? 'Component', canJump: !!pdf && !!anchor.selection };
|
|
721
|
+
})}
|
|
722
|
+
error={commentError} connected={connected} changing={changing} editing={commentEditor} triggerRef={commentsTrigger}
|
|
723
|
+
onEdit={comment => setCommentEditor({ id: comment.id, text: comment.text, version: comment.version })}
|
|
724
|
+
onEditText={text => setCommentEditor(current => current ? { ...current, text } : null)}
|
|
725
|
+
onSaveEdit={comment => updateSavedComment(comment, 'edit')} onCancelEdit={() => setCommentEditor(null)}
|
|
726
|
+
onDelete={comment => updateSavedComment(comment, 'delete')} onJump={goToComment} onOpen={showCommentList} onClose={closeComments} />
|
|
727
|
+
{showWorkbench && <div className="edit-workbench">
|
|
728
|
+
{(editor || composingComment) && <section className="text-edit-panel" id="selection-panel" role="dialog" aria-modal="false" aria-labelledby="correction-title">
|
|
729
|
+
{composingComment ? <form key="comment" onSubmit={submitComment} onKeyDown={event => {
|
|
730
|
+
if (event.nativeEvent.isComposing) return;
|
|
731
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); closeComments(); }
|
|
732
|
+
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) { event.preventDefault(); if (!submitting) event.currentTarget.requestSubmit(); }
|
|
733
|
+
}}>
|
|
734
|
+
<div className="text-edit-heading"><div><Icon name="comment" size={15} /><h2 id="correction-title">Add comment</h2><span className="text-edit-kind">{selectedBlock?.kind ?? 'Component'}</span></div><IconButton label="Close comment composer" disabled={submitting} onClick={closeComments}><Icon name="close" size={15} /></IconButton></div>
|
|
735
|
+
<textarea ref={commentField} aria-label="Comment" placeholder="Write a comment…" value={draft} maxLength={8000} readOnly={submitting} onChange={event => setDraft(event.target.value)} />
|
|
736
|
+
<div className="text-edit-footer"><span>Feedback for this component</span><Button disabled={submitting} onClick={closeComments}>Cancel</Button><Button className="add-comment" type="submit" disabled={!draft.trim() || !ready || submitting || !selectedBlock}>{submitting ? 'Adding…' : 'Add comment'}</Button></div>
|
|
737
|
+
</form> : editor && <form key="edit" onSubmit={event => { event.preventDefault(); closeEditor(); }} onKeyDown={event => {
|
|
738
|
+
if (event.nativeEvent.isComposing || composingText.current) return;
|
|
739
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); closeEditor(); }
|
|
740
|
+
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) { event.preventDefault(); closeEditor(); }
|
|
741
|
+
}}>
|
|
742
|
+
<div className="text-edit-heading"><div><Icon name="edit" size={15} /><h2 id="correction-title">{editorWritable ? 'Edit text' : 'Selected text'}</h2><span className="text-edit-kind">{selectedBlock?.kind ?? 'Component'}</span></div><IconButton label="Close text editor" disabled={editPending || !!editError} onClick={closeEditor}><Icon name="close" size={15} /></IconButton></div>
|
|
743
|
+
<textarea ref={editField} aria-label="Text correction" value={editor.text} readOnly={!editorWritable || editPending || !!editing.savedId} maxLength={8000} onCompositionStart={() => { composingText.current = true; }} onCompositionEnd={event => { composingText.current = false; changeText(event.currentTarget.value); }} onChange={event => { if (composingText.current) { setEditor({ ...editor, text: event.target.value }); rememberOpenEditor(editor.selection.targetId!, event.target.value, editor.baseline); } else changeText(event.target.value); }} />
|
|
744
|
+
{editor.linked > 1 && <p className="correction-note">This text appears {editor.linked} times. All occurrences change together.</p>}
|
|
745
|
+
{!editorWritable && <p className="correction-note">{selectionReason(artifact, editor.selection)}</p>}
|
|
746
|
+
{editError && <p className="correction-error" role="alert">{editError} <Button className="text-button" disabled={state.status !== 'ready' || !getTextTarget(state.artifact, editor.selection.targetId)} onClick={resetText}>{editor.selection.targetId && pendingEditorBaseline(editor.selection.targetId) ? 'Reset text' : 'Use latest text'}</Button></p>}
|
|
747
|
+
<div className="text-edit-footer"><span>Changes stay in your draft</span><Button type="submit" disabled={editPending || !!editError}>Done</Button></div>
|
|
748
|
+
</form>}
|
|
749
|
+
</section>}
|
|
750
|
+
{(editing.error || editStale || !connected || editing.persistenceFailed) && <div className="edit-session-notice" role="status">
|
|
751
|
+
<p>{editing.error || (editStale ? 'The document changed. Refresh your draft to keep edits that still match.' : !connected ? 'Offline. Your draft is kept here until you reconnect.' : 'Browser storage is full. Save your draft before reloading or closing this tab.')}</p>
|
|
752
|
+
{editing.error && !editStale && <IconButton label="Dismiss editing message" onClick={editing.dismissError}><Icon name="close" size={14} /></IconButton>}
|
|
753
|
+
{editStale && <Button disabled={!ready || editPending} onClick={editing.refresh}>Refresh draft</Button>}
|
|
754
|
+
</div>}
|
|
755
|
+
<div className="edit-session-bar" role="toolbar" aria-label="Component actions">
|
|
756
|
+
<div className="selection-actions">
|
|
757
|
+
<IconButton ref={editAction} label="Edit selected text" aria-pressed={!!editor} aria-controls="selection-panel" disabled={!selection?.targetId || !canCorrectComponent(editing.target(selection.targetId)) || editPending || submitting || !!editError || !!editing.savedId} onClick={() => { if (editor) closeEditor(); else if (selection) openTextComponent(selection); }}><Icon name="edit" size={16} /></IconButton>
|
|
758
|
+
<IconButton ref={commentAction} label="Comment on selection" aria-pressed={composingComment} aria-controls="selection-panel" disabled={!selectedBlock || editPending || submitting || !!editError} onClick={composingComment ? closeComments : openComments}><Icon name="comment" size={16} /></IconButton>
|
|
759
|
+
</div>
|
|
760
|
+
<div className="edit-session-status" role="status"><Icon name={editing.saved ? 'check' : 'edit'} size={15} /><span>{editPending ? 'Saving changes…' : editing.saved ? 'All changes saved' : editing.count ? `${editing.count} unsaved ${editing.count === 1 ? 'change' : 'changes'}` : 'No unsaved changes'}</span>{(editing.previewing || readerPreview.loading) && editing.count > 0 && !editPending && <span className="draft-preview-status">Updating preview…</span>}</div>
|
|
761
|
+
<div className="edit-history"><IconButton label={!editing.savedId && (editing.canUndo || editing.count) ? 'Undo change' : 'Undo saved changes'} disabled={undoDisabled} onClick={undoChange}><Icon name="undo" size={16} /></IconButton><IconButton label="Redo change" disabled={!editing.canRedo || editPending || undoPending || !!editError} onClick={redoChange}><Icon name="redo" size={16} /></IconButton></div>
|
|
762
|
+
<Button className="discard-edits" disabled={editPending || undoPending || !!editing.savedId || (!editing.count && !editing.canRedo && !editError)} onClick={discardChanges}>Discard</Button>
|
|
763
|
+
<Button className="save-edits" disabled={!editing.count || !ready || editPending || undoPending || editStale || !!editError || !!editing.savedId} onClick={() => void saveAll()}>Save all<kbd aria-hidden="true">{navigator.platform.includes('Mac') ? '⌘' : 'Ctrl'} S</kbd></Button>
|
|
764
|
+
</div>
|
|
765
|
+
</div>}
|
|
766
|
+
|
|
767
|
+
</div>
|
|
768
|
+
);
|
|
769
|
+
}
|