@webiny/website-builder-sdk 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.eb81deee7e
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/BindingsApi.js +29 -36
- package/BindingsApi.js.map +1 -1
- package/BindingsProcessor.js +34 -43
- package/BindingsProcessor.js.map +1 -1
- package/BindingsProcessor.test.js +82 -77
- package/BindingsProcessor.test.js.map +1 -1
- package/BindingsResolver.d.ts +5 -2
- package/BindingsResolver.js +99 -122
- package/BindingsResolver.js.map +1 -1
- package/BindingsResolver.test.js +399 -362
- package/BindingsResolver.test.js.map +1 -1
- package/ComponentInputTraverser.js +32 -49
- package/ComponentInputTraverser.js.map +1 -1
- package/ComponentManifestToAstConverter.js +20 -21
- package/ComponentManifestToAstConverter.js.map +1 -1
- package/ComponentRegistry.d.ts +9 -0
- package/ComponentRegistry.js +38 -22
- package/ComponentRegistry.js.map +1 -1
- package/ComponentResolver.d.ts +3 -2
- package/ComponentResolver.js +39 -29
- package/ComponentResolver.js.map +1 -1
- package/ComponentResolver.test.d.ts +1 -0
- package/ComponentResolver.test.js +81 -0
- package/ComponentResolver.test.js.map +1 -0
- package/ConstraintEvaluator.d.ts +36 -0
- package/ConstraintEvaluator.js +288 -0
- package/ConstraintEvaluator.js.map +1 -0
- package/ConstraintEvaluator.test.d.ts +1 -0
- package/ConstraintEvaluator.test.js +1634 -0
- package/ConstraintEvaluator.test.js.map +1 -0
- package/ContentSdk.d.ts +17 -3
- package/ContentSdk.js +113 -90
- package/ContentSdk.js.map +1 -1
- package/DocumentStore.d.ts +1 -1
- package/DocumentStore.js +47 -59
- package/DocumentStore.js.map +1 -1
- package/DocumentStoreManager.js +17 -16
- package/DocumentStoreManager.js.map +1 -1
- package/EditingSdk.d.ts +2 -2
- package/EditingSdk.js +92 -124
- package/EditingSdk.js.map +1 -1
- package/ElementFactory.d.ts +2 -3
- package/ElementFactory.js +164 -163
- package/ElementFactory.js.map +1 -1
- package/ElementFactory.objectListDefaults.test.d.ts +1 -0
- package/ElementFactory.objectListDefaults.test.js +423 -0
- package/ElementFactory.objectListDefaults.test.js.map +1 -0
- package/ElementFactory.test.d.ts +1 -0
- package/ElementFactory.test.js +353 -0
- package/ElementFactory.test.js.map +1 -0
- package/Environment.js +18 -19
- package/Environment.js.map +1 -1
- package/FunctionConverter.js +8 -7
- package/FunctionConverter.js.map +1 -1
- package/HashObject.js +11 -12
- package/HashObject.js.map +1 -1
- package/HotkeyManager.js +41 -48
- package/HotkeyManager.js.map +1 -1
- package/IBindingsUpdater.js +0 -3
- package/IRedirects.js +0 -3
- package/InheritanceProcessor.d.ts +2 -2
- package/InheritanceProcessor.js +99 -139
- package/InheritanceProcessor.js.map +1 -1
- package/InheritanceProcessor.test.js +178 -178
- package/InheritanceProcessor.test.js.map +1 -1
- package/InheritedValueResolver.d.ts +18 -1
- package/InheritedValueResolver.js +18 -20
- package/InheritedValueResolver.js.map +1 -1
- package/InputBindingsProcessor.d.ts +23 -2
- package/InputBindingsProcessor.js +200 -289
- package/InputBindingsProcessor.js.map +1 -1
- package/InputBindingsProcessorTokens.test.d.ts +1 -0
- package/InputBindingsProcessorTokens.test.js +400 -0
- package/InputBindingsProcessorTokens.test.js.map +1 -0
- package/InputsBindingsProcessor.test.js +334 -313
- package/InputsBindingsProcessor.test.js.map +1 -1
- package/InputsUpdater.d.ts +1 -1
- package/InputsUpdater.js +23 -26
- package/InputsUpdater.js.map +1 -1
- package/LiveSdk.d.ts +2 -2
- package/LiveSdk.js +12 -13
- package/LiveSdk.js.map +1 -1
- package/Logger.d.ts +2 -1
- package/Logger.js +9 -8
- package/Logger.js.map +1 -1
- package/MouseTracker.js +77 -83
- package/MouseTracker.js.map +1 -1
- package/NullSdk.d.ts +4 -3
- package/NullSdk.js +22 -14
- package/NullSdk.js.map +1 -1
- package/PreviewDocument.d.ts +1 -0
- package/PreviewDocument.js +30 -30
- package/PreviewDocument.js.map +1 -1
- package/PreviewSdk.d.ts +4 -3
- package/PreviewSdk.js +19 -17
- package/PreviewSdk.js.map +1 -1
- package/PreviewViewport.d.ts +0 -1
- package/PreviewViewport.js +50 -82
- package/PreviewViewport.js.map +1 -1
- package/README.md +10 -2
- package/ResizeObserver.js +24 -31
- package/ResizeObserver.js.map +1 -1
- package/StylesBindingsProcessor.d.ts +12 -2
- package/StylesBindingsProcessor.js +62 -79
- package/StylesBindingsProcessor.js.map +1 -1
- package/StylesUpdater.d.ts +1 -1
- package/StylesUpdater.js +20 -25
- package/StylesUpdater.js.map +1 -1
- package/Theme.js +30 -32
- package/Theme.js.map +1 -1
- package/ViewportManager.d.ts +2 -0
- package/ViewportManager.js +89 -97
- package/ViewportManager.js.map +1 -1
- package/assertBindingShapes.d.ts +31 -0
- package/assertBindingShapes.js +64 -0
- package/assertBindingShapes.js.map +1 -0
- package/assertBindingShapes.test.d.ts +1 -0
- package/assertBindingShapes.test.js +131 -0
- package/assertBindingShapes.test.js.map +1 -0
- package/asset/deliveryUrl.d.ts +41 -0
- package/asset/deliveryUrl.js +34 -0
- package/asset/deliveryUrl.js.map +1 -0
- package/asset/deliveryUrl.test.d.ts +1 -0
- package/asset/deliveryUrl.test.js +127 -0
- package/asset/deliveryUrl.test.js.map +1 -0
- package/asset/geometry.d.ts +7 -0
- package/asset/geometry.js +10 -0
- package/asset/geometry.js.map +1 -0
- package/asset/imageSrcSet.d.ts +63 -0
- package/asset/imageSrcSet.js +98 -0
- package/asset/imageSrcSet.js.map +1 -0
- package/asset/imageSrcSet.test.d.ts +1 -0
- package/asset/imageSrcSet.test.js +103 -0
- package/asset/imageSrcSet.test.js.map +1 -0
- package/asset/index.d.ts +5 -0
- package/asset/index.js +5 -0
- package/asset/normalize.d.ts +24 -0
- package/asset/normalize.js +106 -0
- package/asset/normalize.js.map +1 -0
- package/asset/normalize.test.d.ts +1 -0
- package/asset/normalize.test.js +263 -0
- package/asset/normalize.test.js.map +1 -0
- package/asset/types.d.ts +2 -0
- package/asset/types.js +0 -0
- package/constants.d.ts +1 -0
- package/constants.js +7 -5
- package/constants.js.map +1 -1
- package/contentEntry/ContentEntryBindingsResolver.d.ts +30 -0
- package/contentEntry/ContentEntryBindingsResolver.js +45 -0
- package/contentEntry/ContentEntryBindingsResolver.js.map +1 -0
- package/contentEntry/ContentEntryCache.d.ts +46 -0
- package/contentEntry/ContentEntryCache.js +50 -0
- package/contentEntry/ContentEntryCache.js.map +1 -0
- package/contentEntry/resolveContentEntry.d.ts +74 -0
- package/contentEntry/resolveContentEntry.js +53 -0
- package/contentEntry/resolveContentEntry.js.map +1 -0
- package/contentEntry/resolveContentEntry.test.d.ts +1 -0
- package/contentEntry/resolveContentEntry.test.js +213 -0
- package/contentEntry/resolveContentEntry.test.js.map +1 -0
- package/createComponent.d.ts +5 -0
- package/createComponent.js +32 -0
- package/createComponent.js.map +1 -0
- package/createElement.js +5 -6
- package/createElement.js.map +1 -1
- package/createInput.d.ts +132 -16
- package/createInput.js +92 -111
- package/createInput.js.map +1 -1
- package/createTheme.js +2 -3
- package/createTheme.js.map +1 -1
- package/dataProviders/ApiClient.d.ts +10 -5
- package/dataProviders/ApiClient.js +40 -49
- package/dataProviders/ApiClient.js.map +1 -1
- package/dataProviders/DefaultDataProvider.d.ts +7 -3
- package/dataProviders/DefaultDataProvider.js +91 -45
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/GET_EXPERIMENT_PAUSED.d.ts +1 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.js +17 -0
- package/dataProviders/GET_EXPERIMENT_PAUSED.js.map +1 -0
- package/dataProviders/GET_PAGE_BY_ID.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_ID.js +4 -1
- package/dataProviders/GET_PAGE_BY_ID.js.map +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.d.ts +1 -1
- package/dataProviders/GET_PAGE_BY_PATH.js +4 -1
- package/dataProviders/GET_PAGE_BY_PATH.js.map +1 -1
- package/dataProviders/GET_PAGE_EXPERIMENT.d.ts +1 -0
- package/dataProviders/GET_PAGE_EXPERIMENT.js +32 -0
- package/dataProviders/GET_PAGE_EXPERIMENT.js.map +1 -0
- package/dataProviders/GET_VARIANT_CONTENT.d.ts +1 -0
- package/dataProviders/GET_VARIANT_CONTENT.js +24 -0
- package/dataProviders/GET_VARIANT_CONTENT.js.map +1 -0
- package/dataProviders/LIST_PUBLISHED_PAGES.d.ts +1 -1
- package/dataProviders/LIST_PUBLISHED_PAGES.js +17 -5
- package/dataProviders/LIST_PUBLISHED_PAGES.js.map +1 -1
- package/dataProviders/NullDataProvider.d.ts +16 -4
- package/dataProviders/NullDataProvider.js +30 -13
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/RedirectsProvider.js +24 -27
- package/dataProviders/RedirectsProvider.js.map +1 -1
- package/defaultBreakpoints.js +43 -22
- package/defaultBreakpoints.js.map +1 -1
- package/documentOperations/$addElementReferenceToParent.d.ts +1 -1
- package/documentOperations/$addElementReferenceToParent.js +30 -26
- package/documentOperations/$addElementReferenceToParent.js.map +1 -1
- package/documentOperations/AddElement.js +8 -7
- package/documentOperations/AddElement.js.map +1 -1
- package/documentOperations/AddToParent.d.ts +2 -2
- package/documentOperations/AddToParent.js +14 -13
- package/documentOperations/AddToParent.js.map +1 -1
- package/documentOperations/IDocumentOperation.js +0 -3
- package/documentOperations/RemoveElement.js +10 -7
- package/documentOperations/RemoveElement.js.map +1 -1
- package/documentOperations/SetGlobalInputBinding.js +23 -22
- package/documentOperations/SetGlobalInputBinding.js.map +1 -1
- package/documentOperations/SetGlobalStyleBinding.js +23 -23
- package/documentOperations/SetGlobalStyleBinding.js.map +1 -1
- package/documentOperations/SetInputBindingOverride.js +30 -29
- package/documentOperations/SetInputBindingOverride.js.map +1 -1
- package/documentOperations/SetStyleBindingOverride.js +30 -31
- package/documentOperations/SetStyleBindingOverride.js.map +1 -1
- package/documentOperations/index.js +9 -8
- package/documentOperations/index.js.map +1 -1
- package/experiments/PostHogAnalyticsProvider.d.ts +31 -0
- package/experiments/PostHogAnalyticsProvider.js +28 -0
- package/experiments/PostHogAnalyticsProvider.js.map +1 -0
- package/experiments/analyticsProvider.d.ts +4 -0
- package/experiments/analyticsProvider.js +11 -0
- package/experiments/analyticsProvider.js.map +1 -0
- package/experiments/bucketing.d.ts +27 -0
- package/experiments/bucketing.js +91 -0
- package/experiments/bucketing.js.map +1 -0
- package/experiments/bucketing.test.d.ts +1 -0
- package/experiments/bucketing.test.js +183 -0
- package/experiments/bucketing.test.js.map +1 -0
- package/experiments/index.d.ts +5 -0
- package/experiments/index.js +5 -0
- package/experiments/render.d.ts +79 -0
- package/experiments/render.js +149 -0
- package/experiments/render.js.map +1 -0
- package/experiments/types.d.ts +108 -0
- package/experiments/types.js +4 -0
- package/experiments/types.js.map +1 -0
- package/findMatchingAstNode.js +11 -13
- package/findMatchingAstNode.js.map +1 -1
- package/generateElementId.d.ts +1 -1
- package/generateElementId.js +2 -2
- package/generateElementId.js.map +1 -1
- package/headersProvider.js +4 -3
- package/headersProvider.js.map +1 -1
- package/image/geometry.d.ts +54 -0
- package/image/geometry.js +112 -0
- package/image/geometry.js.map +1 -0
- package/image/geometry.test.d.ts +1 -0
- package/image/geometry.test.js +190 -0
- package/image/geometry.test.js.map +1 -0
- package/image/index.d.ts +3 -0
- package/image/index.js +3 -0
- package/image/presets.d.ts +6 -0
- package/image/presets.js +20 -0
- package/image/presets.js.map +1 -0
- package/image/types.d.ts +10 -0
- package/image/types.js +0 -0
- package/index.d.ts +12 -1
- package/index.js +11 -3
- package/jsonPatch.d.ts +1 -1
- package/jsonPatch.js +5 -9
- package/jsonPatch.js.map +1 -1
- package/messages.js +12 -11
- package/messages.js.map +1 -1
- package/messenger/MessageOrigin.js +12 -11
- package/messenger/MessageOrigin.js.map +1 -1
- package/messenger/Messenger.js +59 -70
- package/messenger/Messenger.js.map +1 -1
- package/messenger/index.js +0 -2
- package/package.json +19 -22
- package/registerComponentGroup.js +5 -6
- package/registerComponentGroup.js.map +1 -1
- package/tokenBinding.d.ts +26 -0
- package/tokenBinding.js +15 -0
- package/tokenBinding.js.map +1 -0
- package/tokenBinding.test.d.ts +1 -0
- package/tokenBinding.test.js +165 -0
- package/tokenBinding.test.js.map +1 -0
- package/types/ShorthandCssProperties.js +0 -3
- package/types/WebsiteBuilderTheme.d.ts +54 -45
- package/types/WebsiteBuilderTheme.js +0 -3
- package/types.d.ts +294 -13
- package/types.js +0 -3
- package/IBindingsUpdater.js.map +0 -1
- package/IRedirects.js.map +0 -1
- package/documentOperations/IDocumentOperation.js.map +0 -1
- package/index.js.map +0 -1
- package/lexical/createDefaultLexicalTheme.d.ts +0 -2
- package/lexical/createDefaultLexicalTheme.js +0 -84
- package/lexical/createDefaultLexicalTheme.js.map +0 -1
- package/lexical/createLexicalTheme.d.ts +0 -2
- package/lexical/createLexicalTheme.js +0 -7
- package/lexical/createLexicalTheme.js.map +0 -1
- package/lexical/deepMerge.d.ts +0 -1
- package/lexical/deepMerge.js +0 -23
- package/lexical/deepMerge.js.map +0 -1
- package/messenger/index.js.map +0 -1
- package/types/LexicalEditorTheme.d.ts +0 -2
- package/types/LexicalEditorTheme.js +0 -3
- package/types/LexicalEditorTheme.js.map +0 -1
- package/types/ShorthandCssProperties.js.map +0 -1
- package/types/WebsiteBuilderTheme.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"messenger/Messenger.js","sources":["../../src/messenger/Messenger.ts"],"sourcesContent":["import { isMatch } from \"matcher\";\nimport type { MessageOrigin } from \"./MessageOrigin.js\";\nimport { logger } from \"../Logger.js\";\n\nexport type Message<T = any> = {\n type: string;\n payload: T;\n};\n\ntype Handler<T = any> = (payload: T, logicalType: string, wildcardMatch?: string) => void;\n\nconst ignored = [\n \"preview.mouse.move\",\n \"preview.component.register\",\n \"preview.scroll\",\n \"preview.viewport\",\n \"preview.viewport.change.start\",\n \"preview.viewport.change.end\"\n];\n\nexport class Messenger {\n private listeners = new Map<string, Set<Handler>>();\n private readonly pattern: string;\n private readonly prefixGlob: string;\n\n constructor(\n private source: MessageOrigin,\n private target: MessageOrigin,\n // Pattern to filter events this Messenger handles.\n pattern: string\n ) {\n this.pattern = pattern;\n this.prefixGlob = pattern.replace(/\\*+$/, \"\");\n this.handleMessage = this.handleMessage.bind(this);\n this.source.window.addEventListener(\"message\", this.handleMessage);\n }\n\n private handleMessage(event: MessageEvent) {\n const { type, payload } = event.data || {};\n if (!this.target.matches(event)) {\n return;\n }\n\n if (!type || !isMatch(type, this.pattern)) {\n return;\n }\n\n const logicalType = this.stripPrefix(type);\n\n if (!this.isIgnored(logicalType)) {\n logger.debug(\n {\n type,\n payload\n },\n `${this.getTime()} --> [${this.source.origin}][${logicalType}]`\n );\n }\n\n const handlers = this.listeners.get(logicalType);\n if (handlers) {\n handlers.forEach(fn => fn(payload, logicalType));\n }\n }\n\n private stripPrefix(fullType: string): string {\n return fullType.startsWith(this.prefixGlob)\n ? fullType.slice(this.prefixGlob.length)\n : fullType;\n }\n\n private isIgnored(logicalType: string): boolean {\n return ignored.includes(logicalType);\n }\n\n on<T = any>(logicalType: string, handler: Handler<T>) {\n if (!this.listeners.has(logicalType)) {\n this.listeners.set(logicalType, new Set());\n }\n this.listeners.get(logicalType)!.add(handler);\n return () => {\n const listeners = this.listeners.get(logicalType);\n if (listeners) {\n listeners.delete(handler);\n }\n };\n }\n\n send<T = any>(logicalType: string, payload?: T) {\n const fullType = this.prefixGlob + logicalType;\n\n if (!this.isIgnored(logicalType)) {\n logger.debug(\n {\n type: fullType,\n payload\n },\n `${this.getTime()} <-- [${this.source.origin}][${logicalType}]`\n );\n }\n\n this.target.window.postMessage({ type: fullType, payload }, this.target.origin);\n }\n\n dispose() {\n this.source.window.removeEventListener(\"message\", this.handleMessage);\n this.listeners.clear();\n }\n\n getTime() {\n const date = new Date();\n return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`;\n }\n}\n"],"names":["ignored","Messenger","source","target","pattern","Map","event","type","payload","isMatch","logicalType","logger","handlers","fn","fullType","handler","Set","listeners","date","Date"],"mappings":";;AAWA,MAAMA,UAAU;IACZ;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC;IAKT,YACYC,MAAqB,EACrBC,MAAqB,EAE7BC,OAAe,CACjB;aAJUF,MAAM,GAANA;aACAC,MAAM,GAANA;aANJ,SAAS,GAAG,IAAIE;QAUpB,IAAI,CAAC,OAAO,GAAGD;QACf,IAAI,CAAC,UAAU,GAAGA,QAAQ,OAAO,CAAC,QAAQ;QAC1C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI;QACjD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,WAAW,IAAI,CAAC,aAAa;IACrE;IAEQ,cAAcE,KAAmB,EAAE;QACvC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGF,MAAM,IAAI,IAAI,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAACA,QACrB;QAGJ,IAAI,CAACC,QAAQ,CAACE,QAAQF,MAAM,IAAI,CAAC,OAAO,GACpC;QAGJ,MAAMG,cAAc,IAAI,CAAC,WAAW,CAACH;QAErC,IAAI,CAAC,IAAI,CAAC,SAAS,CAACG,cAChBC,OAAO,KAAK,CACR;YACIJ;YACAC;QACJ,GACA,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAEE,YAAY,CAAC,CAAC;QAIvE,MAAME,WAAW,IAAI,CAAC,SAAS,CAAC,GAAG,CAACF;QACpC,IAAIE,UACAA,SAAS,OAAO,CAACC,CAAAA,KAAMA,GAAGL,SAASE;IAE3C;IAEQ,YAAYI,QAAgB,EAAU;QAC1C,OAAOA,SAAS,UAAU,CAAC,IAAI,CAAC,UAAU,IACpCA,SAAS,KAA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1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/website-builder-sdk",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.eb81deee7e",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/webiny/webiny-js.git"
|
|
@@ -12,36 +12,31 @@
|
|
|
12
12
|
"author": "Pavel Denisjuk",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"
|
|
15
|
+
"@webiny/sdk": "0.0.0-unstable.eb81deee7e",
|
|
16
|
+
"@webiny/theme-common": "0.0.0-unstable.eb81deee7e",
|
|
17
|
+
"csstype": "3.2.3",
|
|
16
18
|
"deep-equal": "2.2.3",
|
|
17
19
|
"deepmerge": "4.3.1",
|
|
18
20
|
"fast-json-patch": "3.1.1",
|
|
19
21
|
"fast-json-stable-stringify": "2.1.0",
|
|
20
22
|
"is-hotkey": "0.2.0",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"nanoid": "
|
|
26
|
-
"
|
|
27
|
-
"pino": "
|
|
28
|
-
"pino-pretty": "9.4.0"
|
|
23
|
+
"lodash": "4.18.1",
|
|
24
|
+
"matcher": "6.0.0",
|
|
25
|
+
"mobx": "7.0.3",
|
|
26
|
+
"nanoid": "6.0.1",
|
|
27
|
+
"nanoid-dictionary": "5.0.0",
|
|
28
|
+
"pino": "10.3.1",
|
|
29
|
+
"pino-pretty": "13.1.3"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/deep-equal": "1.0.4",
|
|
32
33
|
"@types/is-hotkey": "0.1.10",
|
|
33
|
-
"@
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"typescript": "5.3.3"
|
|
34
|
+
"@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
|
|
35
|
+
"typescript": "7.0.2",
|
|
36
|
+
"vitest": "4.1.11"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
|
-
"access": "public"
|
|
40
|
-
"directory": "dist"
|
|
41
|
-
},
|
|
42
|
-
"scripts": {
|
|
43
|
-
"build": "yarn webiny run build",
|
|
44
|
-
"watch": "yarn webiny run watch"
|
|
39
|
+
"access": "public"
|
|
45
40
|
},
|
|
46
41
|
"adio": {
|
|
47
42
|
"ignore": {
|
|
@@ -50,5 +45,7 @@
|
|
|
50
45
|
]
|
|
51
46
|
}
|
|
52
47
|
},
|
|
53
|
-
"
|
|
48
|
+
"webiny": {
|
|
49
|
+
"publishFrom": "dist"
|
|
50
|
+
}
|
|
54
51
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { contentSdk } from "./ContentSdk.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
editingSdk.registerComponentGroup(group);
|
|
2
|
+
const registerComponentGroup = (group)=>{
|
|
3
|
+
const editingSdk = contentSdk.getEditingSdk();
|
|
4
|
+
if (!editingSdk) return;
|
|
5
|
+
editingSdk.registerComponentGroup(group);
|
|
8
6
|
};
|
|
7
|
+
export { registerComponentGroup };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=registerComponentGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"registerComponentGroup.js","sources":["../src/registerComponentGroup.ts"],"sourcesContent":["import type { ComponentGroup } from \"./types.js\";\nimport { contentSdk } from \"./ContentSdk.js\";\n\nexport const registerComponentGroup = (group: ComponentGroup) => {\n const editingSdk = contentSdk.getEditingSdk();\n\n if (!editingSdk) {\n return;\n }\n\n editingSdk.registerComponentGroup(group);\n};\n"],"names":["registerComponentGroup","group","editingSdk","contentSdk"],"mappings":";AAGO,MAAMA,yBAAyB,CAACC;IACnC,MAAMC,aAAaC,WAAW,aAAa;IAE3C,IAAI,CAACD,YACD;IAGJA,WAAW,sBAAsB,CAACD;AACtC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TokenReference, ValueBinding } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Design token references in element styles — see the Theme design brief, section 7.1.
|
|
4
|
+
*
|
|
5
|
+
* Content stores a *structured* reference, never a resolved value and never a raw CSS variable
|
|
6
|
+
* string. Storing `var(--wby-color-surface-page)` would bake the naming convention into customer
|
|
7
|
+
* data, making a prefix change a data migration; and Admin needs the structured form to show which
|
|
8
|
+
* token is selected when a picker is reopened.
|
|
9
|
+
*
|
|
10
|
+
* The renderer converts a reference to `var(--wby-…)` at output time. That conversion lives here so
|
|
11
|
+
* there is exactly one place that knows the mapping.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isTokenBinding: (binding: ValueBinding | undefined) => binding is ValueBinding & {
|
|
14
|
+
token: TokenReference;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Emits the CSS value for a reference.
|
|
18
|
+
*
|
|
19
|
+
* The stored fallback is emitted as the `var()` second argument. That matters when no theme is
|
|
20
|
+
* active — a variable that resolves to nothing makes the browser drop the whole declaration, so
|
|
21
|
+
* content authored under a theme would visibly lose its colour the moment the theme is deactivated.
|
|
22
|
+
* With a fallback it keeps rendering the value it had when it was picked.
|
|
23
|
+
*/
|
|
24
|
+
export declare const tokenToCssValue: (reference: TokenReference) => string;
|
|
25
|
+
/** Builds a reference, capturing the currently resolved value as the fallback. */
|
|
26
|
+
export declare const createTokenReference: (path: string, fallback?: string) => TokenReference;
|
package/tokenBinding.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { toCssVariableName } from "@webiny/theme-common/naming/cssVariable.js";
|
|
2
|
+
const isTokenBinding = (binding)=>Boolean(binding?.token?.path);
|
|
3
|
+
const tokenToCssValue = (reference)=>{
|
|
4
|
+
const variable = toCssVariableName(reference.path);
|
|
5
|
+
return reference.fallback ? `var(${variable}, ${reference.fallback})` : `var(${variable})`;
|
|
6
|
+
};
|
|
7
|
+
const createTokenReference = (path, fallback)=>fallback ? {
|
|
8
|
+
path,
|
|
9
|
+
fallback
|
|
10
|
+
} : {
|
|
11
|
+
path
|
|
12
|
+
};
|
|
13
|
+
export { createTokenReference, isTokenBinding, tokenToCssValue };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=tokenBinding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenBinding.js","sources":["../src/tokenBinding.ts"],"sourcesContent":["import { toCssVariableName } from \"@webiny/theme-common/naming/cssVariable.js\";\nimport type { TokenReference, ValueBinding } from \"~/types.js\";\n\n/**\n * Design token references in element styles — see the Theme design brief, section 7.1.\n *\n * Content stores a *structured* reference, never a resolved value and never a raw CSS variable\n * string. Storing `var(--wby-color-surface-page)` would bake the naming convention into customer\n * data, making a prefix change a data migration; and Admin needs the structured form to show which\n * token is selected when a picker is reopened.\n *\n * The renderer converts a reference to `var(--wby-…)` at output time. That conversion lives here so\n * there is exactly one place that knows the mapping.\n */\n\nexport const isTokenBinding = (\n binding: ValueBinding | undefined\n): binding is ValueBinding & { token: TokenReference } => {\n return Boolean(binding?.token?.path);\n};\n\n/**\n * Emits the CSS value for a reference.\n *\n * The stored fallback is emitted as the `var()` second argument. That matters when no theme is\n * active — a variable that resolves to nothing makes the browser drop the whole declaration, so\n * content authored under a theme would visibly lose its colour the moment the theme is deactivated.\n * With a fallback it keeps rendering the value it had when it was picked.\n */\nexport const tokenToCssValue = (reference: TokenReference): string => {\n const variable = toCssVariableName(reference.path);\n\n return reference.fallback ? `var(${variable}, ${reference.fallback})` : `var(${variable})`;\n};\n\n/** Builds a reference, capturing the currently resolved value as the fallback. */\nexport const createTokenReference = (path: string, fallback?: string): TokenReference => {\n return fallback ? { path, fallback } : { path };\n};\n"],"names":["isTokenBinding","binding","Boolean","tokenToCssValue","reference","variable","toCssVariableName","createTokenReference","path","fallback"],"mappings":";AAeO,MAAMA,iBAAiB,CAC1BC,UAEOC,QAAQD,SAAS,OAAO;AAW5B,MAAME,kBAAkB,CAACC;IAC5B,MAAMC,WAAWC,kBAAkBF,UAAU,IAAI;IAEjD,OAAOA,UAAU,QAAQ,GAAG,CAAC,IAAI,EAAEC,SAAS,EAAE,EAAED,UAAU,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAEC,SAAS,CAAC,CAAC;AAC9F;AAGO,MAAME,uBAAuB,CAACC,MAAcC,WACxCA,WAAW;QAAED;QAAMC;IAAS,IAAI;QAAED;IAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { BindingsResolver } from "./BindingsResolver.js";
|
|
3
|
+
import { StylesBindingsProcessor } from "./StylesBindingsProcessor.js";
|
|
4
|
+
import { createTokenReference, isTokenBinding, tokenToCssValue } from "./tokenBinding.js";
|
|
5
|
+
describe("token bindings", ()=>{
|
|
6
|
+
it("recognises a token binding and nothing else", ()=>{
|
|
7
|
+
expect(isTokenBinding({
|
|
8
|
+
token: {
|
|
9
|
+
path: "color.surface.page"
|
|
10
|
+
}
|
|
11
|
+
})).toBe(true);
|
|
12
|
+
expect(isTokenBinding({
|
|
13
|
+
static: "#fff"
|
|
14
|
+
})).toBe(false);
|
|
15
|
+
expect(isTokenBinding({
|
|
16
|
+
expression: "$state.x"
|
|
17
|
+
})).toBe(false);
|
|
18
|
+
expect(isTokenBinding(void 0)).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
it("derives the CSS variable from the token path", ()=>{
|
|
21
|
+
expect(tokenToCssValue({
|
|
22
|
+
path: "color.action.primary.background"
|
|
23
|
+
})).toBe("var(--wby-color-action-primary-background)");
|
|
24
|
+
});
|
|
25
|
+
it("emits the stored fallback, so content survives the theme being deactivated", ()=>{
|
|
26
|
+
expect(tokenToCssValue({
|
|
27
|
+
path: "color.surface.page",
|
|
28
|
+
fallback: "#F8FAFC"
|
|
29
|
+
})).toBe("var(--wby-color-surface-page, #F8FAFC)");
|
|
30
|
+
});
|
|
31
|
+
it("captures the resolved value as the fallback when a reference is created", ()=>{
|
|
32
|
+
expect(createTokenReference("color.surface.page", "#F8FAFC")).toEqual({
|
|
33
|
+
path: "color.surface.page",
|
|
34
|
+
fallback: "#F8FAFC"
|
|
35
|
+
});
|
|
36
|
+
expect(createTokenReference("color.surface.page")).toEqual({
|
|
37
|
+
path: "color.surface.page"
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe("BindingsResolver with token bindings", ()=>{
|
|
42
|
+
const resolve = (bindings)=>{
|
|
43
|
+
const resolver = new BindingsResolver({});
|
|
44
|
+
const [resolved] = resolver.resolveElement({
|
|
45
|
+
element: {
|
|
46
|
+
type: "Webiny/Element",
|
|
47
|
+
id: "el-1",
|
|
48
|
+
component: {
|
|
49
|
+
name: "Test"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
elementBindings: bindings,
|
|
53
|
+
inputAst: []
|
|
54
|
+
});
|
|
55
|
+
return resolved;
|
|
56
|
+
};
|
|
57
|
+
it("renders a token reference as a CSS variable", ()=>{
|
|
58
|
+
const resolved = resolve({
|
|
59
|
+
styles: {
|
|
60
|
+
backgroundColor: {
|
|
61
|
+
token: {
|
|
62
|
+
path: "color.surface.page"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
expect(resolved.styles.backgroundColor).toBe("var(--wby-color-surface-page)");
|
|
68
|
+
});
|
|
69
|
+
it("renders a literal unchanged", ()=>{
|
|
70
|
+
const resolved = resolve({
|
|
71
|
+
styles: {
|
|
72
|
+
backgroundColor: {
|
|
73
|
+
static: "#123456"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
expect(resolved.styles.backgroundColor).toBe("#123456");
|
|
78
|
+
});
|
|
79
|
+
it("renders references and literals side by side in the same element", ()=>{
|
|
80
|
+
const resolved = resolve({
|
|
81
|
+
styles: {
|
|
82
|
+
backgroundColor: {
|
|
83
|
+
token: {
|
|
84
|
+
path: "color.surface.page",
|
|
85
|
+
fallback: "#FFF"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
borderTopColor: {
|
|
89
|
+
static: "#123456"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
expect(resolved.styles.backgroundColor).toBe("var(--wby-color-surface-page, #FFF)");
|
|
94
|
+
expect(resolved.styles.borderTopColor).toBe("#123456");
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe("StylesBindingsProcessor with token bindings", ()=>{
|
|
98
|
+
const bindings = {
|
|
99
|
+
styles: {
|
|
100
|
+
backgroundColor: {
|
|
101
|
+
token: {
|
|
102
|
+
path: "color.surface.page",
|
|
103
|
+
fallback: "#FFF"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
borderTopColor: {
|
|
107
|
+
static: "#123456"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const processor = ()=>new StylesBindingsProcessor("el-1", [
|
|
112
|
+
"desktop",
|
|
113
|
+
"mobile"
|
|
114
|
+
], bindings);
|
|
115
|
+
it("flattens a token binding to its CSS variable so the preview renders", ()=>{
|
|
116
|
+
expect(processor().toDeepStyles(bindings.styles)).toEqual({
|
|
117
|
+
backgroundColor: "var(--wby-color-surface-page, #FFF)",
|
|
118
|
+
borderTopColor: "#123456"
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
it("reports which properties came from tokens", ()=>{
|
|
122
|
+
expect(processor().toTokenMap(bindings.styles)).toEqual({
|
|
123
|
+
backgroundColor: {
|
|
124
|
+
path: "color.surface.page",
|
|
125
|
+
fallback: "#FFF"
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
it("writes a token reference rather than a literal when one is supplied", ()=>{
|
|
130
|
+
const update = processor().createUpdate({
|
|
131
|
+
backgroundColor: "var(--wby-color-surface-raised)"
|
|
132
|
+
}, "desktop", {
|
|
133
|
+
backgroundColor: {
|
|
134
|
+
path: "color.surface.raised"
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const document = {
|
|
138
|
+
bindings: {
|
|
139
|
+
"el-1": {}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
update.applyToDocument(document);
|
|
143
|
+
expect(document.bindings["el-1"].styles.backgroundColor).toEqual({
|
|
144
|
+
token: {
|
|
145
|
+
path: "color.surface.raised"
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
it("replaces a reference with a literal when no token is supplied", ()=>{
|
|
150
|
+
const update = processor().createUpdate({
|
|
151
|
+
backgroundColor: "#00FF00"
|
|
152
|
+
}, "desktop");
|
|
153
|
+
const document = {
|
|
154
|
+
bindings: {
|
|
155
|
+
"el-1": {}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
update.applyToDocument(document);
|
|
159
|
+
expect(document.bindings["el-1"].styles.backgroundColor).toEqual({
|
|
160
|
+
static: "#00FF00"
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
//# sourceMappingURL=tokenBinding.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenBinding.test.js","sources":["../src/tokenBinding.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { BindingsResolver } from \"./BindingsResolver.js\";\nimport { StylesBindingsProcessor } from \"./StylesBindingsProcessor.js\";\nimport { createTokenReference, isTokenBinding, tokenToCssValue } from \"./tokenBinding.js\";\nimport type { DocumentElementBindings } from \"./types.js\";\n\ndescribe(\"token bindings\", () => {\n it(\"recognises a token binding and nothing else\", () => {\n expect(isTokenBinding({ token: { path: \"color.surface.page\" } })).toBe(true);\n expect(isTokenBinding({ static: \"#fff\" })).toBe(false);\n expect(isTokenBinding({ expression: \"$state.x\" })).toBe(false);\n expect(isTokenBinding(undefined)).toBe(false);\n });\n\n it(\"derives the CSS variable from the token path\", () => {\n expect(tokenToCssValue({ path: \"color.action.primary.background\" })).toBe(\n \"var(--wby-color-action-primary-background)\"\n );\n });\n\n it(\"emits the stored fallback, so content survives the theme being deactivated\", () => {\n expect(tokenToCssValue({ path: \"color.surface.page\", fallback: \"#F8FAFC\" })).toBe(\n \"var(--wby-color-surface-page, #F8FAFC)\"\n );\n });\n\n it(\"captures the resolved value as the fallback when a reference is created\", () => {\n expect(createTokenReference(\"color.surface.page\", \"#F8FAFC\")).toEqual({\n path: \"color.surface.page\",\n fallback: \"#F8FAFC\"\n });\n expect(createTokenReference(\"color.surface.page\")).toEqual({\n path: \"color.surface.page\"\n });\n });\n});\n\ndescribe(\"BindingsResolver with token bindings\", () => {\n const resolve = (bindings: DocumentElementBindings) => {\n const resolver = new BindingsResolver({});\n const [resolved] = resolver.resolveElement({\n element: {\n type: \"Webiny/Element\",\n id: \"el-1\",\n component: { name: \"Test\" } as never\n },\n elementBindings: bindings,\n inputAst: []\n });\n return resolved;\n };\n\n it(\"renders a token reference as a CSS variable\", () => {\n const resolved = resolve({\n styles: { backgroundColor: { token: { path: \"color.surface.page\" } } }\n });\n\n expect(resolved.styles.backgroundColor).toBe(\"var(--wby-color-surface-page)\");\n });\n\n it(\"renders a literal unchanged\", () => {\n const resolved = resolve({ styles: { backgroundColor: { static: \"#123456\" } } });\n\n expect(resolved.styles.backgroundColor).toBe(\"#123456\");\n });\n\n it(\"renders references and literals side by side in the same element\", () => {\n const resolved = resolve({\n styles: {\n backgroundColor: { token: { path: \"color.surface.page\", fallback: \"#FFF\" } },\n borderTopColor: { static: \"#123456\" }\n }\n });\n\n expect(resolved.styles.backgroundColor).toBe(\"var(--wby-color-surface-page, #FFF)\");\n expect(resolved.styles.borderTopColor).toBe(\"#123456\");\n });\n});\n\ndescribe(\"StylesBindingsProcessor with token bindings\", () => {\n const bindings: DocumentElementBindings = {\n styles: {\n backgroundColor: { token: { path: \"color.surface.page\", fallback: \"#FFF\" } },\n borderTopColor: { static: \"#123456\" }\n }\n };\n\n const processor = () => new StylesBindingsProcessor(\"el-1\", [\"desktop\", \"mobile\"], bindings);\n\n it(\"flattens a token binding to its CSS variable so the preview renders\", () => {\n expect(processor().toDeepStyles(bindings.styles)).toEqual({\n backgroundColor: \"var(--wby-color-surface-page, #FFF)\",\n borderTopColor: \"#123456\"\n });\n });\n\n it(\"reports which properties came from tokens\", () => {\n expect(processor().toTokenMap(bindings.styles)).toEqual({\n backgroundColor: { path: \"color.surface.page\", fallback: \"#FFF\" }\n });\n });\n\n it(\"writes a token reference rather than a literal when one is supplied\", () => {\n const update = processor().createUpdate(\n { backgroundColor: \"var(--wby-color-surface-raised)\" },\n \"desktop\",\n { backgroundColor: { path: \"color.surface.raised\" } }\n );\n\n const document = { bindings: { \"el-1\": {} } } as never;\n update.applyToDocument(document);\n\n expect((document as any).bindings[\"el-1\"].styles.backgroundColor).toEqual({\n token: { path: \"color.surface.raised\" }\n });\n });\n\n it(\"replaces a reference with a literal when no token is supplied\", () => {\n const update = processor().createUpdate({ backgroundColor: \"#00FF00\" }, \"desktop\");\n\n const document = { bindings: { \"el-1\": {} } } as never;\n update.applyToDocument(document);\n\n // No stale `token` left behind — a binding holds one or the other, never both.\n expect((document as any).bindings[\"el-1\"].styles.backgroundColor).toEqual({\n static: \"#00FF00\"\n });\n });\n});\n"],"names":["describe","it","expect","isTokenBinding","undefined","tokenToCssValue","createTokenReference","resolve","bindings","resolver","BindingsResolver","resolved","processor","StylesBindingsProcessor","update","document"],"mappings":";;;;AAMAA,SAAS,kBAAkB;IACvBC,GAAG,+CAA+C;QAC9CC,OAAOC,eAAe;YAAE,OAAO;gBAAE,MAAM;YAAqB;QAAE,IAAI,IAAI,CAAC;QACvED,OAAOC,eAAe;YAAE,QAAQ;QAAO,IAAI,IAAI,CAAC;QAChDD,OAAOC,eAAe;YAAE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SAAiB,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC;YACtE,QAAQ;QACZ;IACJ;AACJ"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { LexicalEditorTheme } from "./LexicalEditorTheme.js";
|
|
2
1
|
export type Breakpoint = {
|
|
3
2
|
name: string;
|
|
4
3
|
title: string;
|
|
@@ -9,14 +8,12 @@ export type Breakpoint = {
|
|
|
9
8
|
};
|
|
10
9
|
export type WebsiteBuilderTheme = {
|
|
11
10
|
css?: string;
|
|
12
|
-
cssVariables?: Record<string, string>;
|
|
13
11
|
fonts?: string[];
|
|
14
12
|
breakpoints: Breakpoint[];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
lexical: LexicalEditorTheme;
|
|
13
|
+
colors: ColorStyle[];
|
|
14
|
+
fontSizes?: FontSizes;
|
|
15
|
+
typography: Typography;
|
|
16
|
+
allowCustomColors?: boolean;
|
|
20
17
|
};
|
|
21
18
|
type KnownKeys = "desktop" | "tablet" | "mobile";
|
|
22
19
|
type BreakpointBase = Omit<Breakpoint, "name">;
|
|
@@ -26,27 +23,33 @@ type Breakpoints = KnownBreakpoints & {
|
|
|
26
23
|
[K in string as K extends KnownKeys ? never : K]: BreakpointBase;
|
|
27
24
|
};
|
|
28
25
|
};
|
|
29
|
-
export type
|
|
26
|
+
export type ColorStyle = {
|
|
27
|
+
id: string;
|
|
28
|
+
label: string;
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
30
31
|
export type TypographyStyle = {
|
|
31
32
|
id: string;
|
|
32
|
-
|
|
33
|
+
label: string;
|
|
33
34
|
tag: string;
|
|
34
35
|
className: string;
|
|
35
36
|
};
|
|
36
|
-
export type Typography =
|
|
37
|
+
export type Typography = Record<string, TypographyStyle[]>;
|
|
38
|
+
export type FontSizes = string[];
|
|
37
39
|
export type WebsiteBuilderThemeInput = {
|
|
38
40
|
/**
|
|
39
41
|
* CSS to include in the editor.
|
|
40
42
|
*/
|
|
41
43
|
css?: string;
|
|
42
|
-
/**
|
|
43
|
-
* CSS variables to define in the editor.
|
|
44
|
-
*/
|
|
45
|
-
cssVariables?: Record<string, string>;
|
|
46
44
|
/**
|
|
47
45
|
* Fonts to load when the editor loads.
|
|
48
46
|
*/
|
|
49
47
|
fonts?: string[];
|
|
48
|
+
/**
|
|
49
|
+
* Font sizes to use in the editor.
|
|
50
|
+
* Define this if you want to see a font size dropdown in the editor.
|
|
51
|
+
*/
|
|
52
|
+
fontSizes?: FontSizes;
|
|
50
53
|
/**
|
|
51
54
|
* {
|
|
52
55
|
* title: "Desktop",
|
|
@@ -57,36 +60,42 @@ export type WebsiteBuilderThemeInput = {
|
|
|
57
60
|
* }
|
|
58
61
|
*/
|
|
59
62
|
breakpoints?: Breakpoints;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
63
|
+
/**
|
|
64
|
+
* [
|
|
65
|
+
* {
|
|
66
|
+
* id: "primary",
|
|
67
|
+
* label: "Primary",
|
|
68
|
+
* value: "#000000"
|
|
69
|
+
* },
|
|
70
|
+
* ]
|
|
71
|
+
*/
|
|
72
|
+
colors?: ColorStyle[];
|
|
73
|
+
/**
|
|
74
|
+
* headings: [
|
|
75
|
+
* {
|
|
76
|
+
* id: "heading1",
|
|
77
|
+
* name: "Heading 1",
|
|
78
|
+
* tag: "h1"
|
|
79
|
+
* },
|
|
80
|
+
* ],
|
|
81
|
+
* paragraphs: [
|
|
82
|
+
* {
|
|
83
|
+
* id: "paragraph1",
|
|
84
|
+
* name: "Paragraph 1",
|
|
85
|
+
* tag: "p",
|
|
86
|
+
* ],
|
|
87
|
+
* quotes: [
|
|
88
|
+
* {
|
|
89
|
+
* id: "quote",
|
|
90
|
+
* name: "Quote",
|
|
91
|
+
* tag: "blockquote"
|
|
92
|
+
* }
|
|
93
|
+
* ]
|
|
94
|
+
*/
|
|
95
|
+
typography?: Typography;
|
|
96
|
+
/**
|
|
97
|
+
* Allow custom color selection (ChromePicker) in the Lexical editor's font color toolbar action.
|
|
98
|
+
*/
|
|
99
|
+
allowCustomColors?: boolean;
|
|
91
100
|
};
|
|
92
101
|
export {};
|