diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cae802139..de6ad9eaa 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,6 +2,11 @@ name: Publish on: workflow_dispatch: + inputs: + site_mode: + description: Site mode can be either "production", "testing" or "development". + required: true + default: testing jobs: publish: @@ -22,14 +27,25 @@ jobs: aws-access-key-id: ${{ secrets.ACCESS_KEY }} aws-secret-access-key: ${{ secrets.SECRET_KEY }} aws-region: us-east-1 - + - name: Build Packages run: pnpm build - + - name: Build Site timeout-minutes: 60 working-directory: site - run: /usr/bin/time --verbose pnpm build + run: | + m="${{github.event.inputs.site_mode}}" + if [ "$m" = "production" ]; then + /usr/bin/time --verbose pnpm build:prod + elif [ "$m" = "testing" ]; then + /usr/bin/time --verbose pnpm build:test + elif [ "$m" = "development" ]; then + /usr/bin/time --verbose pnpm build:dev + else + echo "Invalid site mode: $m" + exit 1 + fi - name: Sync bucket run: | @@ -38,4 +54,3 @@ jobs: - name: Invalidate CLOUDFRONT cache run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_DISTRIBUTION_ID }} --paths '/*' - diff --git a/packages/combobox-container-html-element/demo/index.html b/packages/combobox-container-html-element/demo/index.html index f467ce22b..c905256f4 100644 --- a/packages/combobox-container-html-element/demo/index.html +++ b/packages/combobox-container-html-element/demo/index.html @@ -43,7 +43,7 @@ box-sizing: border-box; margin-top: 0.4em; max-height: 10.5em; - overflow-y: scroll; + overflow-y: auto; position: absolute; width: 100%; z-index: 1; diff --git a/packages/document-server-types/lib/types.d.ts b/packages/document-server-types/lib/types.d.ts index 4803a3984..b2919b075 100644 --- a/packages/document-server-types/lib/types.d.ts +++ b/packages/document-server-types/lib/types.d.ts @@ -806,7 +806,7 @@ export interface DocEditorConfigEditorConfigCustomization { /** * {@link https://api.onlyoffice.com/editors/config/editor/customization#logo ONLYOFFICE Reference} */ - logo: DocEditorConfigEditorConfigCustomizationLogo + logo?: DocEditorConfigEditorConfigCustomizationLogo /** * {@link https://api.onlyoffice.com/editors/config/editor/customization#macros ONLYOFFICE Reference} diff --git a/packages/openapi-declaration/lib/main.ts b/packages/openapi-declaration/lib/main.ts index 83396ce1a..584d74ac4 100644 --- a/packages/openapi-declaration/lib/main.ts +++ b/packages/openapi-declaration/lib/main.ts @@ -58,12 +58,12 @@ export class ProcessPath extends Transform { } else { const u = m.toUpperCase() s.tags.forEach((t) => { - const a = t.split("/") + const a = t.split("/").map((s) => s.trim()) a.forEach((t, i) => { // todo: support overloading, ex portal and Portal. // temp solution const g = a.slice(0, i + 1).join("/") - const s = g.split("/").map(slug).join("/") + const s = g.split("/").map((v) => slug(v)).join("/") let ct = this._cache.groups[s] if (ct === undefined) { ct = { @@ -230,7 +230,7 @@ function populateRequestHero(req: REST.RequestDeclaration, m: string, p: string, if (s.tags !== undefined) { const [t] = s.tags if (t !== undefined) { - a = t.split("/") + a = t.split("/").map((s) => s.trim()) } else { console.warn("first tag is missing") } diff --git a/packages/remark-document-builder/lib/main.test.ts b/packages/remark-document-builder/lib/main.test.ts index 8f53a77f9..53b9a580b 100644 --- a/packages/remark-document-builder/lib/main.test.ts +++ b/packages/remark-document-builder/lib/main.test.ts @@ -21,7 +21,7 @@ test("does nothing if no option is specified", async () => { }) test("does nothing if no language is specified", async () => { - const c = "``` use-document-builder\n\n```" + const c = "``` document-builder\n\n```" const f = await unified() .use(remarkParse) .use(remarkDocumentBuilder) @@ -33,18 +33,18 @@ test("does nothing if no language is specified", async () => { }) test("does not exposes the data property if not language is specified", async () => { - const c = "``` use-document-builder\n\n```" + const c = "``` document-builder\n\n```" const f = await unified() .use(remarkParse) .use(remarkDocumentBuilder) .use(remarkRehype) .use(rehypeStringify) .process(c) - is(f.value, '
') + is(f.value, '
') }) test("populates hProperties if a language is specified", async () => { - const c = "```js use-document-builder\n\n```" + const c = "```js document-builder\n\n```" const f = await unified() .use(remarkParse) .use(remarkDocumentBuilder) @@ -66,11 +66,11 @@ test("populates hProperties if a language is specified", async () => { return } - is(p.dataUseDocumentBuilder, true) + is(p.dataDocumentBuilder, "true") }) test("does not overrides hProperties if they already exist", async () => { - const c = "```js use-document-builder\n\n```" + const c = "```js document-builder\n\n```" const f = await unified() .use(remarkParse) .use(() => { @@ -103,14 +103,14 @@ test("does not overrides hProperties if they already exist", async () => { }) test("exposes the data property if a language is specified", async () => { - const c = "```js use-document-builder\n\n```" + const c = "```js document-builder\n\n```" const f = await unified() .use(remarkParse) .use(remarkDocumentBuilder) .use(remarkRehype) .use(rehypeStringify) .process(c) - is(f.value, '
') + is(f.value, '
') }) test.run() diff --git a/packages/remark-document-builder/lib/main.ts b/packages/remark-document-builder/lib/main.ts index 32da75319..8d3bdeb25 100644 --- a/packages/remark-document-builder/lib/main.ts +++ b/packages/remark-document-builder/lib/main.ts @@ -3,7 +3,7 @@ import {visit} from "unist-util-visit" declare module "hast" { interface Properties { - dataUseDocumentBuilder?: boolean + dataDocumentBuilder?: string } } @@ -20,7 +20,7 @@ export function remarkDocumentBuilder(): Transform { let has = false for (const el of node.meta.split(" ")) { - if (el === "use-document-builder") { + if (el === "document-builder") { has = true break } @@ -42,7 +42,7 @@ export function remarkDocumentBuilder(): Transform { d.hProperties = p } - p.dataUseDocumentBuilder = true + p.dataDocumentBuilder = "true" }) } } diff --git a/packages/site-config/lib/main.ts b/packages/site-config/lib/main.ts index 9c454b9d4..a41b6382c 100644 --- a/packages/site-config/lib/main.ts +++ b/packages/site-config/lib/main.ts @@ -5,12 +5,14 @@ import yaml from "yaml" export interface InputConfig { baseUrl?: string + analytics?: boolean server?: InputServer playground?: InputPlayground } export interface Configurable { baseUrl: string + analytics: boolean server: ServerConfigurable playground: PlaygroundConfigurable } @@ -19,6 +21,7 @@ export class Config implements Configurable { static shared: Configurable baseUrl = "" + analytics = false server = new ServerConfig() playground = new PlaygroundConfig() @@ -82,6 +85,10 @@ export class Config implements Configurable { co.baseUrl = ic.baseUrl } + if (ic.analytics !== undefined) { + co.analytics = ic.analytics + } + if (ic.server) { co.server = ServerConfig.fromInput(ic.server) } @@ -102,6 +109,12 @@ export class Config implements Configurable { co.baseUrl = a.baseUrl } + if (b.analytics !== undefined) { + co.analytics = b.analytics + } else if (a.analytics !== undefined) { + co.analytics = a.analytics + } + co.server = ServerConfig.merge(a.server, b.server) co.playground = PlaygroundConfig.merge(a.playground, b.playground) diff --git a/packages/site-document-editor-playground/lib/main.css b/packages/site-document-editor-playground/lib/main.css index b5a691a89..b4eaac558 100644 --- a/packages/site-document-editor-playground/lib/main.css +++ b/packages/site-document-editor-playground/lib/main.css @@ -1,39 +1,42 @@ .de-playground { background-color: var(--color-background-muted); padding-bottom: 140px; - padding-top: 32px; + padding-top: var(--base-size-32); } .de-playground__inner { box-sizing: border-box; display: flex; flex-direction: column; + margin: 0 auto; max-width: 1440px; - padding-left: 24px; - padding-right: 24px; + padding-left: var(--base-size-24); + padding-right: var(--base-size-24); width: 100%; } .de-playground__heading { - font-size: 32px; - font-weight: 700; - line-height: 1.25; - margin-bottom: 32px; - margin-top: 22px; + font-size: var(--text-display-font-size-default); + font-weight: var(--text-display-font-weight-default); + line-height: var(--text-display-line-height-default); + margin-bottom: var(--base-size-32); + margin-top: var(--base-size-24); } .de-playground__islands { display: grid; - grid-gap: 16px; + grid-gap: var(--base-size-16); grid-template-columns: repeat(11, 1fr); grid-template-rows: 1fr min-content min-content min-content min-content; } .de-playground__island { background-color: var(--color-background-default); - border-radius: 4px; - border: 1px solid var(--color-scale-gray-5); - padding: 12px; + border-color: var(--color-border-muted); + border-radius: var(--size-border-radius-small); + border-style: solid; + border-width: var(--size-border-width-thin); + padding: var(--base-size-12); } .de-playground__scenarios { @@ -67,7 +70,7 @@ } .de-playground__container { - margin-top: 18px; + margin-top: var(--base-size-20); } .de-playground__container:empty { @@ -75,7 +78,7 @@ } .de-playground__function-property { - margin-top: 18px; + margin-top: var(--base-size-20); } .de-playground__function-property:first-of-type { @@ -83,7 +86,7 @@ } .de-playground__function-property output pre { - margin-top: 9px; + margin-top: var(--base-size-8); } .de-playground document-editor-playground { @@ -96,14 +99,14 @@ } .de-playground document-editor { - border-radius: 3px; + border-radius: var(--size-border-radius-small); display: block; height: inherit; overflow: hidden; } .de-playground .form-control { - margin-top: 18px; + margin-top: var(--base-size-20); } .de-playground .form-control:first-of-type { @@ -111,7 +114,7 @@ } .de-playground .form-control__label a { - color: var(--color-foreground-anchor); + color: var(--color-foreground-link); } .de-playground .form-control__label a:focus-visible, diff --git a/packages/site-page/lib/main.css b/packages/site-page/lib/main.css index 7c18dbedd..84d5ec33e 100644 --- a/packages/site-page/lib/main.css +++ b/packages/site-page/lib/main.css @@ -182,7 +182,7 @@ .page .chapter__navigation { max-height: calc(100vh - var(--page-header-content-height)); - overflow-y: scroll; + overflow-y: auto; position: sticky; top: var(--page-header-content-height); } diff --git a/packages/ui-code-editor/lib/main.css b/packages/ui-code-editor/lib/main.css index da39a0974..a7154b714 100644 --- a/packages/ui-code-editor/lib/main.css +++ b/packages/ui-code-editor/lib/main.css @@ -15,7 +15,7 @@ margin-top: 0; min-height: var(--code-editor-min-height); min-width: 100%; - overflow: scroll; + overflow: auto; padding: var(--base-size-12) var(--base-size-16); tab-size: 2; white-space: nowrap; diff --git a/packages/ui-content/lib/main.css b/packages/ui-content/lib/main.css index 5cb74bc9f..93e544173 100644 --- a/packages/ui-content/lib/main.css +++ b/packages/ui-content/lib/main.css @@ -109,7 +109,7 @@ grid-template-columns: var(--base-size-16) 1fr var(--base-size-16); margin-bottom: 0; margin-top: var(--base-size-20); - overflow: scroll; + overflow: auto; padding-bottom: var(--base-size-12); padding-top: var(--base-size-12); tab-size: 2; diff --git a/packages/ui-select/lib/main.css b/packages/ui-select/lib/main.css index 2ec0d21b6..e27820948 100644 --- a/packages/ui-select/lib/main.css +++ b/packages/ui-select/lib/main.css @@ -59,7 +59,7 @@ border-width: var(--size-border-width-thin); color: var(--color-control-default-foreground-active); max-height: var(--select-listbox-max-height); - overflow-y: scroll; + overflow-y: auto; padding-bottom: var(--base-size-8); padding-top: var(--base-size-8); position: absolute; diff --git a/site/assets/main.css b/site/assets/main.css index a574c1c12..0d6f770b6 100644 --- a/site/assets/main.css +++ b/site/assets/main.css @@ -84,8 +84,12 @@ table { width: auto !important; } -/* todo: temp solution */ -document-builder { +.content document-builder-container { + display: block; + margin-top: var(--base-size-20); +} + +.content document-builder { display: block; height: 550px; } diff --git a/site/assets/main.ts b/site/assets/main.ts index c813c8b2d..4fa7b8ed1 100644 --- a/site/assets/main.ts +++ b/site/assets/main.ts @@ -26,6 +26,12 @@ function main(): void { sp.client = c sp.play() } + + const bc = document.querySelector("document-builder-container") + if (bc) { + bc.client = c + bc.play() + } } function onError(...args: unknown[]): void { diff --git a/site/components/document-builder-container/element.ts b/site/components/document-builder-container/element.ts index dc2e07560..c59db1466 100644 --- a/site/components/document-builder-container/element.ts +++ b/site/components/document-builder-container/element.ts @@ -1,4 +1,4 @@ -import {type DocumentEditorConfig} from "@onlyoffice/document-editor-html-element" +import {type Client} from "@onlyoffice/server-client" declare global { interface Window { @@ -35,9 +35,11 @@ export class DocumentBuilderContainer extends HTMLElement { return "document-builder-container" } - async connectedCallback(): Promise { - const ce = this.querySelector("code") - if (!(ce && ce.textContent)) { + client: Client | undefined + + async play(): Promise { + const cl = this.client + if (!cl) { return } @@ -52,44 +54,12 @@ export class DocumentBuilderContainer extends HTMLElement { return } - const cu = new URL("/config", "http://0.0.0.0:4000/") - cu.searchParams.set("fileType", db.config.document.fileType) - - const cr = await fetch(cu) - const cs = await cr.json() as DocumentEditorConfig - cs.editorConfig = { - customization: { - compactHeader: true, - compactToolbar: true, - hideRightMenu: true, - hideRulers: true, - integrationMode: "embed", - toolbarHideFileName: true, - toolbarNoTabs: true - } + if (!db.config) { + return } - db.documentServerUrl = "http://0.0.0.0:3000/" - db.config = cs - db.setAttribute("command", ce.textContent) - - db.addEventListener("documenteditorappready", () => { - console.log("Document Editor is ready") - }) - db.addEventListener("documentbuilderready", () => { - console.log("Document Builder is ready") - }) - db.addEventListener("documenteditorerror", (e) => { - console.error(`Document Editor: ${e.message}`) - }) - db.addEventListener("documentbuildererror", (e) => { - console.error(`Document Builder: ${e.message}`) - }) - db.addEventListener("error", (e) => { - console.error(`Unknown error: ${e.message}`) - }) - - this.insertBefore(tc, this.firstChild) + [db.config] = await cl.documentEditor.sign(db.config) + this.insertBefore(db, this.firstChild) } } diff --git a/site/components/document-builder-container/hast.ts b/site/components/document-builder-container/hast.ts index 1c5558265..9b26af542 100644 --- a/site/components/document-builder-container/hast.ts +++ b/site/components/document-builder-container/hast.ts @@ -1,12 +1,12 @@ import {type Element} from "hast" -interface DocumentBuilderContainerElement extends Element {} +export interface DocumentBuilderContainerElement extends Element {} export function documentBuilderContainer(): DocumentBuilderContainerElement { return { type: "element", tagName: "document-builder-container", properties: {}, - children: [] + children: [], } } diff --git a/site/components/document-builder-container/rehype.ts b/site/components/document-builder-container/rehype.ts index 404ad6bf5..28ffc712b 100644 --- a/site/components/document-builder-container/rehype.ts +++ b/site/components/document-builder-container/rehype.ts @@ -1,5 +1,6 @@ import {documentBuilder} from "@onlyoffice/document-builder-hast-element" import {fileType} from "@onlyoffice/document-builder-utils" +import {Config} from "@onlyoffice/site-config" import {template} from "@onlyoffice/template-hast-element" import {toText} from "hast-util-to-text" import {type Root} from "hast" @@ -12,6 +13,8 @@ interface Transform { export function rehypeDocumentBuilderContainer(): Transform { return function transform(tree) { + const c = Config.shared + visit(tree, "element", (node, index, parent) => { if (!( node.tagName === "pre" && @@ -26,13 +29,13 @@ export function rehypeDocumentBuilderContainer(): Transform { code && code.type === "element" && code.tagName === "code" && - code.properties.dataUseDocumentBuilder + "dataDocumentBuilder" in code.properties )) { return } - const c = toText(code, {whitespace: "pre-wrap"}) - const t = fileType(c) + const s = toText(code, {whitespace: "pre-wrap"}) + const t = fileType(s) if (!t) { // todo?: throw error return @@ -41,12 +44,33 @@ export function rehypeDocumentBuilderContainer(): Transform { const dc = documentBuilderContainer() const te = template() const db = documentBuilder() - db.data.config = {document: {fileType: t}} + db.data.documentServerUrl = c.playground.documentEditor.documentServerUrl + db.data.config = { + document: { + fileType: t, + key: "", + title: "", + url: "", + }, + editorConfig: { + customization: { + compactHeader: true, + compactToolbar: true, + hideRightMenu: true, + hideRulers: true, + integrationMode: "embed", + toolbarHideFileName: true, + toolbarNoTabs: true, + }, + callbackUrl: "", + }, + } + db.data.command = s.trim() te.children = [db] dc.children = [node, te] parent.children[index] = dc - delete code.properties.dataUseDocumentBuilder + delete code.properties.dataDocumentBuilder }) } } diff --git a/site/components/tree/tree.css b/site/components/tree/tree.css index 70b8ecd7e..29a634587 100644 --- a/site/components/tree/tree.css +++ b/site/components/tree/tree.css @@ -30,10 +30,7 @@ .tree__twig { display: flex; - overflow-x: hidden; pointer-events: none; - text-overflow: ellipsis; - white-space: nowrap; } .tree__twig ~ .tree__limb { diff --git a/site/config.production.yml b/site/config.production.yml index 53783cb1d..334f809a3 100644 --- a/site/config.production.yml +++ b/site/config.production.yml @@ -1,4 +1,5 @@ baseUrl: https://api.onlyoffice.com/ +analytics: true server: baseUrl: https://api.teamlab.info/ diff --git a/site/config.testing.yml b/site/config.testing.yml new file mode 100644 index 000000000..56cf300fa --- /dev/null +++ b/site/config.testing.yml @@ -0,0 +1,9 @@ +baseUrl: https://api2.teamlab.info/ +analytics: false + +server: + baseUrl: https://api.teamlab.info/ + +playground: + documentEditor: + documentServerUrl: https://api.docs.teamlab.info/ diff --git a/site/config.yml b/site/config.yml index 1c396fa76..9c107d554 100644 --- a/site/config.yml +++ b/site/config.yml @@ -1,4 +1,5 @@ baseUrl: http://localhost:8080/ +analytics: false server: baseUrl: http://localhost:4000/ diff --git a/site/internal/google-tag-manager.tsx b/site/internal/google-tag-manager.tsx new file mode 100644 index 000000000..f04630a9c --- /dev/null +++ b/site/internal/google-tag-manager.tsx @@ -0,0 +1,20 @@ +import {type JSX, h} from "preact" + +export function GoogleTagManagerScript(): JSX.Element { + return +} + +export function GoogleTagManagerNoscript(): JSX.Element { + return