@silexlabs/silex 3.7.0 → 3.9.0-canary.2
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/README.md +115 -78
- package/common/examples/plugin.js +6 -0
- package/common/silex-plugins/config.test.ts +71 -0
- package/common/silex-plugins/config.ts +25 -0
- package/common/silex-plugins/index.ts +2 -0
- package/common/silex-plugins/plugin.test.ts +57 -0
- package/common/silex-plugins/plugin.ts +65 -0
- package/dist/client/css/admin.css +25 -12
- package/dist/client/css/all.min.css +5 -5
- package/dist/client/index.html +2 -2
- package/dist/client/js/main.js +3108 -2940
- package/dist/client/js/main.js.LICENSE.txt +6 -4
- package/dist/client/webfonts/fa-brands-400.woff2 +0 -0
- package/dist/client/webfonts/fa-regular-400.woff2 +0 -0
- package/dist/client/webfonts/fa-solid-900.woff2 +0 -0
- package/dist/client/webfonts/fa-v4compatibility.woff2 +0 -0
- package/dist/server/common/externs.js +2 -0
- package/dist/server/common/silex-plugins/config.js +25 -0
- package/dist/server/common/silex-plugins/index.js +18 -0
- package/dist/server/common/silex-plugins/plugin.js +41 -0
- package/dist/server/server/api/api.js +9 -9
- package/dist/server/server/api/connectorApi.js +35 -35
- package/dist/server/server/api/publicationApi.js +19 -19
- package/dist/server/server/api/websiteApi.js +46 -46
- package/dist/server/server/config.js +19 -19
- package/dist/server/server/connectors/FsHosting.js +6 -6
- package/dist/server/server/connectors/FsStorage.js +35 -35
- package/dist/server/server/connectors/connectors.js +3 -3
- package/dist/server/server/expose.js +18 -8
- package/dist/server/server/express.js +3 -3
- package/dist/server/server/index.js +29 -19
- package/dist/server/server/jobs.js +4 -4
- package/dist/{plugins/server/plugins/server → server/server/plugins}/DownloadConnector.js +23 -28
- package/dist/{plugins/server/plugins/server → server/server/plugins}/FtpConnector.js +42 -117
- package/dist/{plugins/server/plugins/server → server/server/plugins}/GitlabConnector.js +80 -271
- package/dist/{plugins/server/plugins/server → server/server/plugins}/GitlabHostingConnector.js +11 -134
- package/dist/server/server/plugins/PublicationOptimizer.js +2 -0
- package/dist/{plugins/server/plugins/server → server/server/plugins}/SslPlugin.js +3 -32
- package/dist/{plugins/server/plugins/server → server/server/plugins}/StaticPlugin.js +4 -21
- package/dist/server/server/utils/BackwardCompat.js +2 -0
- package/dist/server/server/utils/websiteDataSerialization.js +10 -10
- package/{src/ts/client → editor}/api.ts +2 -2
- package/{src/ts/client → editor}/assetUrl.test.ts +6 -33
- package/{src/ts/client → editor}/assetUrl.ts +2 -2
- package/{src/ts/client → editor}/config.ts +3 -3
- package/{src/css/theme-modern.scss → editor/css/design-system.scss} +29 -14
- package/{src → editor}/css/index.scss +1 -3
- package/{src → editor}/css/project-bar.scss +5 -0
- package/{src/ts/client → editor}/expose.ts +3 -3
- package/{src/ts/client → editor}/grapesjs/LoginDialog.ts +3 -3
- package/{src/ts/client → editor}/grapesjs/PublicationManager.ts +3 -3
- package/{src/ts/client → editor}/grapesjs/PublicationUi.ts +1 -1
- package/{src/ts/client → editor}/grapesjs/cms/index.ts +1 -1
- package/{src/ts/client → editor}/grapesjs/cms/page-settings.ts +1 -1
- package/{src/ts/client → editor}/grapesjs/cms/publication.ts +1 -1
- package/{src/ts/client → editor}/grapesjs/eleventy.ts +1 -1
- package/{src/ts/client → editor}/grapesjs/index.ts +5 -3
- package/{src/ts/client → editor}/grapesjs/internal-links.ts +2 -2
- package/{src/ts/client → editor}/grapesjs/resize-panel.ts +2 -1
- package/{src/ts/client → editor}/grapesjs/settings-sections.ts +1 -1
- package/{src/ts/client → editor}/grapesjs/settings.ts +2 -2
- package/{src/ts/client → editor}/grapesjs/storage.ts +1 -1
- package/editor/grapesjs/website-info.ts +52 -0
- package/{src/ts/client → editor}/index.ts +1 -1
- package/{src/ts/client → editor}/publication-transformers.test.ts +10 -10
- package/{src/ts/client → editor}/publication-transformers.ts +1 -1
- package/{src/ts/client → editor}/publish-fonts.ts +2 -2
- package/grapesjs-plugins/expression-input/.husky/pre-commit +2 -0
- package/grapesjs-plugins/expression-input/.prettierrc.json +7 -0
- package/grapesjs-plugins/expression-input/.vscode/extensions.json +9 -0
- package/grapesjs-plugins/expression-input/CHANGELOG.md +47 -0
- package/grapesjs-plugins/expression-input/LICENSE +661 -0
- package/grapesjs-plugins/expression-input/README.md +59 -0
- package/grapesjs-plugins/expression-input/babel.config.js +3 -0
- package/grapesjs-plugins/expression-input/commitlint.config.js +1 -0
- package/grapesjs-plugins/expression-input/dev/README.md +1 -0
- package/grapesjs-plugins/expression-input/dev/expression-input.html +148 -0
- package/grapesjs-plugins/expression-input/dev/input-chain.html +88 -0
- package/grapesjs-plugins/expression-input/dev/popin-form.html +83 -0
- package/grapesjs-plugins/expression-input/docs/expression-input.md +173 -0
- package/grapesjs-plugins/expression-input/docs/popin-form.md +228 -0
- package/grapesjs-plugins/expression-input/eslint.config.mjs +71 -0
- package/grapesjs-plugins/expression-input/package.json +84 -0
- package/grapesjs-plugins/expression-input/playwright.config.ts +6 -0
- package/grapesjs-plugins/expression-input/rollup.config.js +39 -0
- package/grapesjs-plugins/expression-input/src/expression-input.ts +339 -0
- package/grapesjs-plugins/expression-input/src/index.ts +3 -0
- package/grapesjs-plugins/expression-input/src/input-chain.ts +216 -0
- package/grapesjs-plugins/expression-input/src/popin-form.ts +189 -0
- package/grapesjs-plugins/expression-input/src/popin-overlay.ts +188 -0
- package/grapesjs-plugins/expression-input/src/styles.ts +374 -0
- package/grapesjs-plugins/expression-input/src/test/popin-form_test.ts +47 -0
- package/grapesjs-plugins/expression-input/tsconfig.json +34 -0
- package/grapesjs-plugins/expression-input/web-dev-server.config.js +25 -0
- package/grapesjs-plugins/expression-input/web-test-runner.config.js +124 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/.editorconfig +5 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/.husky/pre-commit +4 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/LICENSE +661 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/README.md +158 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/babel.config.js +3 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/eslint.config.mjs +20 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/index.html +353 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/jest.config.cjs +11 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/package-lock.json +12500 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/package.json +75 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/public/simple-selector.html +12 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/StylableElement.ts +15 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/capabilities.ts +49 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/commands.ts +89 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/components/complex-selector.ts +187 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/components/compound-selector.ts +241 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/components/current-selector-display.ts +289 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/components/inline-select.ts +199 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/components/resize-input.ts +19 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/components/simple-selector.ts +537 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/i18n/en.ts +75 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/i18n/fr.ts +75 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/index.ts +47 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/ComplexSelector.test.ts +380 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/ComplexSelector.ts +231 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/CompoundSelector.test.ts +232 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/CompoundSelector.ts +128 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/GrapesJsSelectors.test.ts +1077 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/GrapesJsSelectors.ts +653 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/Operator.test.ts +45 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/Operator.ts +129 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/PseudoClass.test.ts +31 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/PseudoClass.ts +159 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/SimpleSelector.test.ts +181 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/model/SimpleSelector.ts +379 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/plugin.ts +225 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/styles.ts +40 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/src/test-data.json +3546 -0
- package/grapesjs-plugins/grapesjs-advanced-selector/tsconfig.json +37 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/.eslintrc.json +31 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/LICENSE +17 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/README.md +129 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/_index.html +37 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/package-lock.json +9023 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/package.json +46 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/src/index.js +97 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/test/index.test.js +198 -0
- package/grapesjs-plugins/grapesjs-ai-capabilities/tsconfig.json +29 -0
- package/grapesjs-plugins/grapesjs-css-variables/.eslintrc.json +31 -0
- package/grapesjs-plugins/grapesjs-css-variables/LICENSE +661 -0
- package/grapesjs-plugins/grapesjs-css-variables/README.md +172 -0
- package/grapesjs-plugins/grapesjs-css-variables/TEST_SCENARIOS.md +181 -0
- package/grapesjs-plugins/grapesjs-css-variables/_index.html +93 -0
- package/grapesjs-plugins/grapesjs-css-variables/package-lock.json +9020 -0
- package/grapesjs-plugins/grapesjs-css-variables/package.json +46 -0
- package/grapesjs-plugins/grapesjs-css-variables/src/capabilities.js +133 -0
- package/grapesjs-plugins/grapesjs-css-variables/src/index.js +37 -0
- package/grapesjs-plugins/grapesjs-css-variables/src/locale/en.js +22 -0
- package/grapesjs-plugins/grapesjs-css-variables/src/locale/fr.js +22 -0
- package/grapesjs-plugins/grapesjs-css-variables/src/modal.js +692 -0
- package/grapesjs-plugins/grapesjs-css-variables/src/style-manager.js +461 -0
- package/grapesjs-plugins/grapesjs-css-variables/src/types.js +8 -0
- package/grapesjs-plugins/grapesjs-css-variables/src/variables.js +439 -0
- package/grapesjs-plugins/grapesjs-data-source/.husky/pre-commit +4 -0
- package/grapesjs-plugins/grapesjs-data-source/.nvmrc +1 -0
- package/grapesjs-plugins/grapesjs-data-source/LICENSE +661 -0
- package/grapesjs-plugins/grapesjs-data-source/README.md +674 -0
- package/grapesjs-plugins/grapesjs-data-source/__mocks__/directus-schema.json +67137 -0
- package/grapesjs-plugins/grapesjs-data-source/__mocks__/directus-test-schema.json +8393 -0
- package/grapesjs-plugins/grapesjs-data-source/__mocks__/graphql-mocks.js +7 -0
- package/grapesjs-plugins/grapesjs-data-source/__mocks__/simple-schema.json +493 -0
- package/grapesjs-plugins/grapesjs-data-source/__mocks__/squidex-schema.json +6656 -0
- package/grapesjs-plugins/grapesjs-data-source/__mocks__/strapi-schema.json +7986 -0
- package/grapesjs-plugins/grapesjs-data-source/_index.html +110 -0
- package/grapesjs-plugins/grapesjs-data-source/babel.config.js +7 -0
- package/grapesjs-plugins/grapesjs-data-source/eslint.config.mjs +47 -0
- package/grapesjs-plugins/grapesjs-data-source/example.graphql +355 -0
- package/grapesjs-plugins/grapesjs-data-source/example.graphql.json +5666 -0
- package/grapesjs-plugins/grapesjs-data-source/example.page.json +1 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/base/graphql-response.json +6 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/base/graphql-types.json +2095 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/base/preview.html +5 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/base/website.json +79 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/countries-lists/graphql-response.json +1056 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/countries-lists/graphql-types.json +2095 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/countries-lists/preview.html +36 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/countries-lists/website.json +422 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/example.graphql-result.json +18718 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/example.graphql-types.json +1955 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/graphql-modules.json +191 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/modules.html +45 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/visibility-truthy/graphql-response.json +1056 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/visibility-truthy/graphql-types.json +2095 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/visibility-truthy/preview.html +31 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/visibility-truthy/website.json +261 -0
- package/grapesjs-plugins/grapesjs-data-source/integration-tests/website-modules.json +650 -0
- package/grapesjs-plugins/grapesjs-data-source/jest.config.js +21 -0
- package/grapesjs-plugins/grapesjs-data-source/package-lock.json +13182 -0
- package/grapesjs-plugins/grapesjs-data-source/package.json +77 -0
- package/grapesjs-plugins/grapesjs-data-source/src/api.ts +386 -0
- package/grapesjs-plugins/grapesjs-data-source/src/capabilities.ts +80 -0
- package/grapesjs-plugins/grapesjs-data-source/src/commands.ts +269 -0
- package/grapesjs-plugins/grapesjs-data-source/src/datasources/GraphQL.ts +1039 -0
- package/grapesjs-plugins/grapesjs-data-source/src/datasources/graphql-introspection-query.ts +112 -0
- package/grapesjs-plugins/grapesjs-data-source/src/datasources/graphql.test.ts +657 -0
- package/grapesjs-plugins/grapesjs-data-source/src/filters/index.ts +102 -0
- package/grapesjs-plugins/grapesjs-data-source/src/filters/liquid.test.ts +27 -0
- package/grapesjs-plugins/grapesjs-data-source/src/filters/liquid.ts +985 -0
- package/grapesjs-plugins/grapesjs-data-source/src/index.ts +103 -0
- package/grapesjs-plugins/grapesjs-data-source/src/integration.test.ts +504 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/ExpressionTree.ts +251 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/completion.ts +213 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/dataSourceManager.ts +315 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/dataSourceRegistry.test.ts +170 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/dataSourceRegistry.ts +117 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/expressionEvaluator.ts +241 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/previewDataLoader.ts +196 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/queryBuilder.ts +118 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/state.test.ts +76 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/state.ts +243 -0
- package/grapesjs-plugins/grapesjs-data-source/src/model/token.ts +336 -0
- package/grapesjs-plugins/grapesjs-data-source/src/storage.test.ts +81 -0
- package/grapesjs-plugins/grapesjs-data-source/src/storage.ts +55 -0
- package/grapesjs-plugins/grapesjs-data-source/src/test-data.ts +154 -0
- package/grapesjs-plugins/grapesjs-data-source/src/types.ts +299 -0
- package/grapesjs-plugins/grapesjs-data-source/src/utils.test.ts +46 -0
- package/grapesjs-plugins/grapesjs-data-source/src/utils.ts +367 -0
- package/grapesjs-plugins/grapesjs-data-source/src/view/canvas.ts +718 -0
- package/grapesjs-plugins/grapesjs-data-source/src/view/custom-states-editor.ts +371 -0
- package/grapesjs-plugins/grapesjs-data-source/src/view/defaultStyles.ts +432 -0
- package/grapesjs-plugins/grapesjs-data-source/src/view/index.ts +168 -0
- package/grapesjs-plugins/grapesjs-data-source/src/view/properties-editor.ts +249 -0
- package/grapesjs-plugins/grapesjs-data-source/src/view/settings.ts +1551 -0
- package/grapesjs-plugins/grapesjs-data-source/src/view/state-editor.ts +528 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/.editorconfig +16 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/.env.example +7 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/.eslintignore +3 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/.eslintrc +27 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/README.md +57 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/config/admin.js +13 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/config/api.js +7 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/config/database.js +92 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/config/middlewares.js +12 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/config/server.js +10 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/database/migrations/.gitkeep +0 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/favicon.png +0 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/jsconfig.json +8 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/package.json +31 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/public/robots.txt +3 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/public/uploads/.gitkeep +0 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/admin/app.example.js +39 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/admin/webpack.config.example.js +9 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/api/.gitkeep +0 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/api/post/content-types/post/schema.json +26 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/api/post/controllers/post.js +9 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/api/post/routes/post.js +9 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/api/post/services/post.js +9 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/extensions/.gitkeep +0 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/src/index.js +20 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/types/generated/components.d.ts +5 -0
- package/grapesjs-plugins/grapesjs-data-source/strapi/types/generated/contentTypes.d.ts +723 -0
- package/grapesjs-plugins/grapesjs-data-source/tmp/countries-lists.html +1 -0
- package/grapesjs-plugins/grapesjs-data-source/tsconfig.cjs.json +8 -0
- package/grapesjs-plugins/grapesjs-data-source/tsconfig.json +49 -0
- package/grapesjs-plugins/grapesjs-filter-styles/README.md +137 -0
- package/grapesjs-plugins/grapesjs-filter-styles/eslint.config.mjs +35 -0
- package/grapesjs-plugins/grapesjs-filter-styles/package-lock.json +8927 -0
- package/grapesjs-plugins/grapesjs-filter-styles/package.json +40 -0
- package/grapesjs-plugins/grapesjs-filter-styles/src/index.js +283 -0
- package/grapesjs-plugins/grapesjs-filter-styles/tsconfig.json +26 -0
- package/grapesjs-plugins/grapesjs-fonts/.eslintrc.json +31 -0
- package/grapesjs-plugins/grapesjs-fonts/LICENSE +9 -0
- package/grapesjs-plugins/grapesjs-fonts/README.md +231 -0
- package/grapesjs-plugins/grapesjs-fonts/_index.html +95 -0
- package/grapesjs-plugins/grapesjs-fonts/package-lock.json +9024 -0
- package/grapesjs-plugins/grapesjs-fonts/package.json +46 -0
- package/grapesjs-plugins/grapesjs-fonts/src/capabilities.js +61 -0
- package/grapesjs-plugins/grapesjs-fonts/src/commands.js +100 -0
- package/grapesjs-plugins/grapesjs-fonts/src/fonts.js +396 -0
- package/grapesjs-plugins/grapesjs-fonts/src/index.js +34 -0
- package/grapesjs-plugins/grapesjs-fonts/src/locale/en.js +19 -0
- package/grapesjs-plugins/grapesjs-fonts/src/locale/fr.js +21 -0
- package/grapesjs-plugins/grapesjs-fonts/src/locale/ptbr.js +18 -0
- package/grapesjs-plugins/grapesjs-fonts/tsconfig.json +29 -0
- package/grapesjs-plugins/grapesjs-keymaps-dialog/README.md +116 -0
- package/grapesjs-plugins/grapesjs-keymaps-dialog/package.json +46 -0
- package/grapesjs-plugins/grapesjs-keymaps-dialog/src/KeymapsDialog.ts +208 -0
- package/grapesjs-plugins/grapesjs-keymaps-dialog/src/KeymapsDialogManager.ts +78 -0
- package/grapesjs-plugins/grapesjs-keymaps-dialog/src/index.ts +70 -0
- package/grapesjs-plugins/grapesjs-keymaps-dialog/tsconfig.json +29 -0
- package/grapesjs-plugins/grapesjs-loading/.eslintrc.json +22 -0
- package/grapesjs-plugins/grapesjs-loading/README.md +140 -0
- package/grapesjs-plugins/grapesjs-loading/_index.html +90 -0
- package/grapesjs-plugins/grapesjs-loading/eslint.config.mjs +20 -0
- package/grapesjs-plugins/grapesjs-loading/grapesjs-loading.gif +0 -0
- package/grapesjs-plugins/grapesjs-loading/package.json +50 -0
- package/grapesjs-plugins/grapesjs-loading/src/index.ts +54 -0
- package/grapesjs-plugins/grapesjs-loading/tsconfig.json +20 -0
- package/grapesjs-plugins/grapesjs-notifications/LICENSE +661 -0
- package/grapesjs-plugins/grapesjs-notifications/README.md +295 -0
- package/grapesjs-plugins/grapesjs-notifications/_index.html +95 -0
- package/grapesjs-plugins/grapesjs-notifications/package-lock.json +8187 -0
- package/grapesjs-plugins/grapesjs-notifications/package.json +58 -0
- package/grapesjs-plugins/grapesjs-notifications/src/Notification.ts +117 -0
- package/grapesjs-plugins/grapesjs-notifications/src/NotificationManager.ts +93 -0
- package/grapesjs-plugins/grapesjs-notifications/src/Storage.ts +26 -0
- package/grapesjs-plugins/grapesjs-notifications/src/capabilities.ts +33 -0
- package/grapesjs-plugins/grapesjs-notifications/src/commands.ts +5 -0
- package/grapesjs-plugins/grapesjs-notifications/src/index.ts +126 -0
- package/grapesjs-plugins/grapesjs-notifications/src/locale/en.js +8 -0
- package/grapesjs-plugins/grapesjs-notifications/src/view.ts +127 -0
- package/grapesjs-plugins/grapesjs-notifications/tsconfig.json +30 -0
- package/grapesjs-plugins/grapesjs-storage-rate-limit/LICENSE +213 -0
- package/grapesjs-plugins/grapesjs-storage-rate-limit/README.md +119 -0
- package/grapesjs-plugins/grapesjs-storage-rate-limit/jest.config.js +197 -0
- package/grapesjs-plugins/grapesjs-storage-rate-limit/package-lock.json +10752 -0
- package/grapesjs-plugins/grapesjs-storage-rate-limit/package.json +44 -0
- package/grapesjs-plugins/grapesjs-storage-rate-limit/src/index.js +90 -0
- package/grapesjs-plugins/grapesjs-storage-rate-limit/src/index.test.js +122 -0
- package/grapesjs-plugins/grapesjs-symbols/.eslintrc.cjs +20 -0
- package/grapesjs-plugins/grapesjs-symbols/.husky/pre-commit +5 -0
- package/grapesjs-plugins/grapesjs-symbols/.nvmrc +1 -0
- package/grapesjs-plugins/grapesjs-symbols/LICENSE +661 -0
- package/grapesjs-plugins/grapesjs-symbols/README.md +228 -0
- package/grapesjs-plugins/grapesjs-symbols/_index.html +104 -0
- package/grapesjs-plugins/grapesjs-symbols/es5.html +119 -0
- package/grapesjs-plugins/grapesjs-symbols/es6.html +107 -0
- package/grapesjs-plugins/grapesjs-symbols/eslint.config.mjs +72 -0
- package/grapesjs-plugins/grapesjs-symbols/jest.config.js +12 -0
- package/grapesjs-plugins/grapesjs-symbols/package-lock.json +6867 -0
- package/grapesjs-plugins/grapesjs-symbols/package.json +73 -0
- package/grapesjs-plugins/grapesjs-symbols/rollup.config.mjs +26 -0
- package/grapesjs-plugins/grapesjs-symbols/src/SymbolsCommands.test.ts +147 -0
- package/grapesjs-plugins/grapesjs-symbols/src/SymbolsCommands.ts +144 -0
- package/grapesjs-plugins/grapesjs-symbols/src/capabilities.ts +50 -0
- package/grapesjs-plugins/grapesjs-symbols/src/events.ts +8 -0
- package/grapesjs-plugins/grapesjs-symbols/src/id-utils.ts +158 -0
- package/grapesjs-plugins/grapesjs-symbols/src/index.ts +46 -0
- package/grapesjs-plugins/grapesjs-symbols/src/test-utils.ts +51 -0
- package/grapesjs-plugins/grapesjs-symbols/src/utils.test.ts +118 -0
- package/grapesjs-plugins/grapesjs-symbols/src/utils.ts +90 -0
- package/grapesjs-plugins/grapesjs-symbols/src/view/SymbolsView.ts +251 -0
- package/grapesjs-plugins/grapesjs-symbols/src/view/traits.ts +101 -0
- package/grapesjs-plugins/grapesjs-symbols/tsconfig.json +35 -0
- package/grapesjs-plugins/grapesjs-symbols/tsconfig.test.json +12 -0
- package/grapesjs-plugins/grapesjs-version-flow/LICENSE +661 -0
- package/grapesjs-plugins/grapesjs-version-flow/README.md +422 -0
- package/grapesjs-plugins/grapesjs-version-flow/_index.html +494 -0
- package/grapesjs-plugins/grapesjs-version-flow/babel.config.js +9 -0
- package/grapesjs-plugins/grapesjs-version-flow/package-lock.json +11832 -0
- package/grapesjs-plugins/grapesjs-version-flow/package.json +77 -0
- package/grapesjs-plugins/grapesjs-version-flow/prompts/initial.txt +116 -0
- package/grapesjs-plugins/grapesjs-version-flow/src/event-system.js +48 -0
- package/grapesjs-plugins/grapesjs-version-flow/src/index.js +87 -0
- package/grapesjs-plugins/grapesjs-version-flow/src/locale/en.js +26 -0
- package/grapesjs-plugins/grapesjs-version-flow/src/locale/fr.js +26 -0
- package/grapesjs-plugins/grapesjs-version-flow/src/modal-ui.js +562 -0
- package/grapesjs-plugins/grapesjs-version-flow/src/style-manager.js +240 -0
- package/grapesjs-plugins/grapesjs-version-flow/src/upgrade-engine.js +237 -0
- package/grapesjs-plugins/grapesjs-version-flow/src/version-manager.js +117 -0
- package/grapesjs-plugins/grapesjs-version-flow/tests/index.test.js +241 -0
- package/grapesjs-plugins/grapesjs-version-flow/tests/integration.test.js +227 -0
- package/grapesjs-plugins/grapesjs-version-flow/tests/setup.js +67 -0
- package/grapesjs-plugins/grapesjs-version-flow/tests/upgrade-engine.test.js +360 -0
- package/grapesjs-plugins/grapesjs-version-flow/tests/version-manager.test.js +168 -0
- package/grapesjs-plugins/grapesjs-version-flow/tests/version-storage.test.js +203 -0
- package/grapesjs-plugins/grapesjs-version-flow/tsconfig.json +26 -0
- package/package.json +127 -159
- package/{src/ts/server → server}/api/api.ts +6 -6
- package/{src/ts/server → server}/api/connectorApi.ts +5 -5
- package/{src/ts/server → server}/api/publicationApi.ts +7 -7
- package/{src/ts/server → server}/api/websiteApi.ts +7 -8
- package/{src/ts/server → server}/config.ts +14 -12
- package/{src/ts/server → server}/connectors/FsHosting.ts +4 -4
- package/{src/ts/server → server}/connectors/FsStorage.test.ts +2 -2
- package/{src/ts/server → server}/connectors/FsStorage.ts +8 -8
- package/{src/ts/server → server}/connectors/connectors.ts +3 -3
- package/server/deploy/.nvmrc +1 -0
- package/server/deploy/.silex.js +220 -0
- package/server/deploy/client-config.js +17 -0
- package/server/deploy/client-plugins/.gitkeep +0 -0
- package/server/deploy/client-plugins/onboarding.js +67 -0
- package/server/deploy/example.env +25 -0
- package/server/deploy/onboarding.json +22 -0
- package/server/deploy/picto-silex@3x.png +0 -0
- package/server/deploy/server-plugins/dashboard.js +74 -0
- package/server/deploy/server-plugins/onboarding.js +212 -0
- package/server/deploy/silex-platform.yml +75 -0
- package/{src/ts/server → server}/events.ts +2 -2
- package/{src/ts/server → server}/expose.ts +1 -1
- package/{src/ts/server → server}/express.ts +2 -2
- package/{src/ts/server → server}/index.ts +7 -7
- package/{src/ts/server → server}/jobs.test.ts +1 -1
- package/{src/ts/server → server}/jobs.ts +1 -1
- package/server/plugins/DownloadConnector.publish.test.ts +32 -0
- package/server/plugins/DownloadConnector.test.ts +70 -0
- package/{src/ts/plugins/server → server/plugins}/DownloadConnector.ts +22 -10
- package/{src/ts/plugins/server → server/plugins}/FtpConnector.test.ts +3 -3
- package/{src/ts/plugins/server → server/plugins}/FtpConnector.ts +7 -7
- package/{src/ts/plugins/server → server/plugins}/GitlabConnector.ts +9 -26
- package/{src/ts/plugins/server → server/plugins}/GitlabHostingConnector.ts +5 -5
- package/{src/ts/plugins/server → server/plugins}/SslPlugin.ts +2 -2
- package/{src/ts/plugins/server → server/plugins}/StaticPlugin.ts +2 -2
- package/{src/ts/server → server}/utils/BackwardCompat.ts +1 -1
- package/{src/ts/server → server}/utils/websiteDataSerialization.test.ts +2 -2
- package/{src/ts/server → server}/utils/websiteDataSerialization.ts +3 -3
- package/.silex.js +0 -76
- package/dist/client/client/api.d.ts +0 -101
- package/dist/client/client/assetUrl.d.ts +0 -60
- package/dist/client/client/config.d.ts +0 -110
- package/dist/client/client/events.d.ts +0 -23
- package/dist/client/client/expose.d.ts +0 -10
- package/dist/client/client/grapesjs/LoginDialog.d.ts +0 -15
- package/dist/client/client/grapesjs/PublicationManager.d.ts +0 -117
- package/dist/client/client/grapesjs/PublicationUi.d.ts +0 -59
- package/dist/client/client/grapesjs/blocks.d.ts +0 -1
- package/dist/client/client/grapesjs/body-remap.d.ts +0 -15
- package/dist/client/client/grapesjs/breadcrumbs.d.ts +0 -1
- package/dist/client/client/grapesjs/cms/DataSource.d.ts +0 -43
- package/dist/client/client/grapesjs/cms/blocks.d.ts +0 -2
- package/dist/client/client/grapesjs/cms/buttons.d.ts +0 -2
- package/dist/client/client/grapesjs/cms/collection-pages.d.ts +0 -4
- package/dist/client/client/grapesjs/cms/config.d.ts +0 -9
- package/dist/client/client/grapesjs/cms/filters.d.ts +0 -3
- package/dist/client/client/grapesjs/cms/index.d.ts +0 -43
- package/dist/client/client/grapesjs/cms/liquid.d.ts +0 -73
- package/dist/client/client/grapesjs/cms/page-settings.d.ts +0 -6
- package/dist/client/client/grapesjs/cms/publication.d.ts +0 -60
- package/dist/client/client/grapesjs/cms/site-settings.d.ts +0 -3
- package/dist/client/client/grapesjs/cms/states.d.ts +0 -8
- package/dist/client/client/grapesjs/cms/traits.d.ts +0 -8
- package/dist/client/client/grapesjs/core-commands.d.ts +0 -3
- package/dist/client/client/grapesjs/css-props.d.ts +0 -6
- package/dist/client/client/grapesjs/flex.d.ts +0 -3
- package/dist/client/client/grapesjs/footer.d.ts +0 -2
- package/dist/client/client/grapesjs/img.d.ts +0 -6
- package/dist/client/client/grapesjs/index.d.ts +0 -9
- package/dist/client/client/grapesjs/internal-links.d.ts +0 -1
- package/dist/client/client/grapesjs/keymaps.d.ts +0 -123
- package/dist/client/client/grapesjs/li.d.ts +0 -7
- package/dist/client/client/grapesjs/new-page-dialog.d.ts +0 -2
- package/dist/client/client/grapesjs/openImport.d.ts +0 -9
- package/dist/client/client/grapesjs/page-panel.d.ts +0 -13
- package/dist/client/client/grapesjs/project-bar.d.ts +0 -21
- package/dist/client/client/grapesjs/resize-panel.d.ts +0 -1
- package/dist/client/client/grapesjs/rich-text.d.ts +0 -4
- package/dist/client/client/grapesjs/sectors.d.ts +0 -12
- package/dist/client/client/grapesjs/semantic.d.ts +0 -1
- package/dist/client/client/grapesjs/settings-sections.d.ts +0 -19
- package/dist/client/client/grapesjs/settings.d.ts +0 -16
- package/dist/client/client/grapesjs/storage.d.ts +0 -3
- package/dist/client/client/grapesjs/symbolDialogs.d.ts +0 -4
- package/dist/client/client/grapesjs/upload-progress.d.ts +0 -2
- package/dist/client/client/grapesjs/view-buttons.d.ts +0 -2
- package/dist/client/client/index.d.ts +0 -10
- package/dist/client/client/publication-transformers.d.ts +0 -42
- package/dist/client/client/publish-custom-code-block.d.ts +0 -4
- package/dist/client/client/publish-fonts.d.ts +0 -4
- package/dist/client/client/utils.d.ts +0 -23
- package/dist/client/constants.d.ts +0 -35
- package/dist/client/page.d.ts +0 -2
- package/dist/client/types.d.ts +0 -365
- package/dist/client/webfonts/fa-brands-400.ttf +0 -0
- package/dist/client/webfonts/fa-regular-400.ttf +0 -0
- package/dist/client/webfonts/fa-solid-900.ttf +0 -0
- package/dist/client/webfonts/fa-v4compatibility.ttf +0 -0
- package/dist/plugins/client/client/events.d.ts +0 -23
- package/dist/plugins/client/client/events.js +0 -43
- package/dist/plugins/client/client/events.js.map +0 -1
- package/dist/plugins/client/plugins/client/template.d.ts +0 -2
- package/dist/plugins/client/plugins/client/template.js +0 -234
- package/dist/plugins/client/plugins/client/template.js.map +0 -1
- package/dist/plugins/client/plugins/client/website-info.d.ts +0 -1
- package/dist/plugins/client/plugins/client/website-info.js +0 -72
- package/dist/plugins/client/plugins/client/website-info.js.map +0 -1
- package/dist/plugins/client/types.d.ts +0 -365
- package/dist/plugins/client/types.js +0 -83
- package/dist/plugins/client/types.js.map +0 -1
- package/dist/plugins/server/constants.d.ts +0 -35
- package/dist/plugins/server/constants.js +0 -79
- package/dist/plugins/server/constants.js.map +0 -1
- package/dist/plugins/server/page.d.ts +0 -2
- package/dist/plugins/server/page.js +0 -35
- package/dist/plugins/server/page.js.map +0 -1
- package/dist/plugins/server/plugins/server/Cache.d.ts +0 -2
- package/dist/plugins/server/plugins/server/Cache.js +0 -36
- package/dist/plugins/server/plugins/server/Cache.js.map +0 -1
- package/dist/plugins/server/plugins/server/DownloadConnector.d.ts +0 -29
- package/dist/plugins/server/plugins/server/DownloadConnector.js.map +0 -1
- package/dist/plugins/server/plugins/server/FtpConnector.d.ts +0 -86
- package/dist/plugins/server/plugins/server/FtpConnector.js.map +0 -1
- package/dist/plugins/server/plugins/server/GitlabConnector.d.ts +0 -172
- package/dist/plugins/server/plugins/server/GitlabConnector.js.map +0 -1
- package/dist/plugins/server/plugins/server/GitlabHostingConnector.d.ts +0 -23
- package/dist/plugins/server/plugins/server/GitlabHostingConnector.js.map +0 -1
- package/dist/plugins/server/plugins/server/PublicationOptimizer.js +0 -14
- package/dist/plugins/server/plugins/server/PublicationOptimizer.js.map +0 -1
- package/dist/plugins/server/plugins/server/SslPlugin.d.ts +0 -1
- package/dist/plugins/server/plugins/server/SslPlugin.js.map +0 -1
- package/dist/plugins/server/plugins/server/StaticPlugin.d.ts +0 -8
- package/dist/plugins/server/plugins/server/StaticPlugin.js.map +0 -1
- package/dist/plugins/server/server/config.d.ts +0 -59
- package/dist/plugins/server/server/config.js +0 -181
- package/dist/plugins/server/server/config.js.map +0 -1
- package/dist/plugins/server/server/connectors/FsHosting.d.ts +0 -14
- package/dist/plugins/server/server/connectors/FsHosting.js +0 -66
- package/dist/plugins/server/server/connectors/FsHosting.js.map +0 -1
- package/dist/plugins/server/server/connectors/FsStorage.d.ts +0 -44
- package/dist/plugins/server/server/connectors/FsStorage.js +0 -303
- package/dist/plugins/server/server/connectors/FsStorage.js.map +0 -1
- package/dist/plugins/server/server/connectors/connectors.d.ts +0 -86
- package/dist/plugins/server/server/connectors/connectors.js +0 -126
- package/dist/plugins/server/server/connectors/connectors.js.map +0 -1
- package/dist/plugins/server/server/events.d.ts +0 -26
- package/dist/plugins/server/server/events.js +0 -31
- package/dist/plugins/server/server/events.js.map +0 -1
- package/dist/plugins/server/server/jobs.d.ts +0 -12
- package/dist/plugins/server/server/jobs.js +0 -79
- package/dist/plugins/server/server/jobs.js.map +0 -1
- package/dist/plugins/server/server/utils/validation.d.ts +0 -7
- package/dist/plugins/server/server/utils/validation.js +0 -37
- package/dist/plugins/server/server/utils/validation.js.map +0 -1
- package/dist/plugins/server/server/utils/websiteDataSerialization.d.ts +0 -24
- package/dist/plugins/server/server/utils/websiteDataSerialization.js +0 -136
- package/dist/plugins/server/server/utils/websiteDataSerialization.js.map +0 -1
- package/dist/plugins/server/types.d.ts +0 -365
- package/dist/plugins/server/types.js +0 -87
- package/dist/plugins/server/types.js.map +0 -1
- package/dist/server/server/cli.js +0 -71
- package/src/css/grapesjs-light.scss +0 -180
- package/src/ts/plugins/client/template.ts +0 -246
- package/src/ts/plugins/client/website-info.ts +0 -84
- package/src/ts/server/cli.ts +0 -67
- /package/{src/ts → common}/constants.ts +0 -0
- /package/{src/ts → common}/externs.ts +0 -0
- /package/{src/ts → common}/page.ts +0 -0
- /package/{src/ts → common}/types.ts +0 -0
- /package/dist/server/{constants.js → common/constants.js} +0 -0
- /package/dist/server/{page.js → common/page.js} +0 -0
- /package/dist/server/{types.js → common/types.js} +0 -0
- /package/dist/server/{plugins/server → server/plugins}/Cache.js +0 -0
- /package/{src → editor}/css/_mixins.scss +0 -0
- /package/{src → editor}/css/_variables.scss +0 -0
- /package/{src → editor}/css/dialog.scss +0 -0
- /package/{src → editor}/css/dialogs.scss +0 -0
- /package/{src → editor}/css/fonts.scss +0 -0
- /package/{src → editor}/css/footer.scss +0 -0
- /package/{src → editor}/css/grapesjs-plugins.scss +0 -0
- /package/{src → editor}/css/grapesjs.scss +0 -0
- /package/{src → editor}/css/loader.scss +0 -0
- /package/{src → editor}/css/page-panel.scss +0 -0
- /package/{src → editor}/css/panels.scss +0 -0
- /package/{src → editor}/css/silex.scss +0 -0
- /package/{src → editor}/css/theme-base.scss +0 -0
- /package/{src → editor}/css/website-info.scss +0 -0
- /package/{src/ts/client → editor}/events.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/blocks.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/body-remap.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/breadcrumbs.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/DataSource.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/blocks.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/buttons.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/collection-pages.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/config.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/filters.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/liquid.mock.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/liquid.test.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/liquid.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/publication.test.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/site-settings.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/states.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/cms/traits.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/core-commands.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/css-props.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/flex.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/footer.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/img.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/internal-links.test.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/keymaps.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/li.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/new-page-dialog.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/openImport.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/page-panel.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/project-bar.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/rich-text.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/sectors.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/semantic.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/static-plugins.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/symbolDialogs.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/upload-progress.ts +0 -0
- /package/{src/ts/client → editor}/grapesjs/view-buttons.ts +0 -0
- /package/{src → editor}/html/debug.pug +0 -0
- /package/{src → editor}/html/index.pug +0 -0
- /package/{src → editor}/html/templates/includes.pug +0 -0
- /package/{src → editor}/html/templates/workspace.pug +0 -0
- /package/{src/ts/client → editor}/publish-custom-code-block.ts +0 -0
- /package/{src/ts/client → editor}/utils.ts +0 -0
- /package/{dist/plugins/server/plugins/server/PublicationOptimizer.d.ts → grapesjs-plugins/expression-input/docs/.nojekyll} +0 -0
- /package/{src/ts/plugins/server → server/plugins}/Cache.ts +0 -0
- /package/{src/ts/plugins/server → server/plugins}/PublicationOptimizer.ts +0 -0
- /package/{src/ts/server → server}/utils/validation.ts +0 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
3
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { Component, Editor } from 'grapesjs'
|
|
19
|
+
import { Expression, StateId, State } from '../types'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @fileoverview This file contains the model for components states
|
|
23
|
+
* A state is a value which can be used in expressions
|
|
24
|
+
* If exported it will be available in the context of child components
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
// Keys to store the states in the component
|
|
28
|
+
const EXPORTED_STATES_KEY = 'publicStates'
|
|
29
|
+
const PRIVATE_STATES_KEY = 'privateStates'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Persistant ID is used to identify a component reliably
|
|
33
|
+
* It will be stored with the website data
|
|
34
|
+
*/
|
|
35
|
+
const PERSISTANT_ID_KEY = 'id-plugin-data-source'
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Override the prefix of state names
|
|
39
|
+
*/
|
|
40
|
+
export const COMPONENT_NAME_PREFIX = 'nameForDataSource'
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Types
|
|
44
|
+
*/
|
|
45
|
+
export interface StoredState {
|
|
46
|
+
label?: string
|
|
47
|
+
hidden?: boolean
|
|
48
|
+
expression: Expression
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface StoredStateWithId extends StoredState {
|
|
52
|
+
id: StateId
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type PersistantId = string
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the persistant ID of a component
|
|
59
|
+
*/
|
|
60
|
+
export function getPersistantId(component: Component): PersistantId | null {
|
|
61
|
+
return component.get(PERSISTANT_ID_KEY) ?? null
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get the persistant ID of a component and create it if it does not exist
|
|
66
|
+
*/
|
|
67
|
+
export function getOrCreatePersistantId(component: Component): PersistantId {
|
|
68
|
+
const persistantId = component.get(PERSISTANT_ID_KEY)
|
|
69
|
+
if(persistantId) return persistantId
|
|
70
|
+
const newPersistantId = `${component.ccid}-${Math.round(Math.random() * 10000)}` as PersistantId
|
|
71
|
+
component.set(PERSISTANT_ID_KEY, newPersistantId)
|
|
72
|
+
return newPersistantId
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Find a component by its persistant ID in the current page
|
|
77
|
+
*/
|
|
78
|
+
export function getComponentByPersistentId(id: PersistantId, editor: Editor): Component | null {
|
|
79
|
+
const pages = editor.Pages.getAll()
|
|
80
|
+
for(const page of pages) {
|
|
81
|
+
const body = page.getMainComponent()
|
|
82
|
+
const component = getChildByPersistantId(id, body)
|
|
83
|
+
if(component) return component
|
|
84
|
+
}
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Find a component by its persistant ID in
|
|
90
|
+
*/
|
|
91
|
+
export function getChildByPersistantId(id: PersistantId, parent: Component): Component | null {
|
|
92
|
+
if(getPersistantId(parent) === id) return parent
|
|
93
|
+
for(const child of parent.components()) {
|
|
94
|
+
const component = getChildByPersistantId(id, child)
|
|
95
|
+
if(component) return component
|
|
96
|
+
}
|
|
97
|
+
return null
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Find a component by its persistant ID in the current page
|
|
102
|
+
*/
|
|
103
|
+
export function getParentByPersistentId(id: PersistantId, component: Component | undefined): Component | null {
|
|
104
|
+
if(!component) return null
|
|
105
|
+
if(getPersistantId(component) === id) return component
|
|
106
|
+
return getParentByPersistentId(id, component.parent())
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get the display name of a state
|
|
111
|
+
*/
|
|
112
|
+
export function getStateDisplayName(child: Component, state: State): string {
|
|
113
|
+
const component = getParentByPersistentId(state.componentId, child)
|
|
114
|
+
//const name = component?.getName() ?? '[Not found]'
|
|
115
|
+
const prefix = component?.get(COMPONENT_NAME_PREFIX) ?? '' // `${name}'s`
|
|
116
|
+
return `${prefix ? prefix + ' ' : ''}${state.label || state.storedStateId}`
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Callbacks called when a state is changed
|
|
121
|
+
* @returns A function to remove the callback
|
|
122
|
+
*/
|
|
123
|
+
const _callbacks: ((state: StoredState | null, component: Component) => void)[] = []
|
|
124
|
+
export function onStateChange(callback: (state: StoredState | null, component: Component) => void): () => void {
|
|
125
|
+
_callbacks.push(callback)
|
|
126
|
+
return () => {
|
|
127
|
+
const index = _callbacks.indexOf(callback)
|
|
128
|
+
if(index >= 0) _callbacks.splice(index, 1)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function fireChange(state: StoredState | null, component: Component) {
|
|
132
|
+
_callbacks.forEach(callback => callback(state, component))
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* List all exported states
|
|
137
|
+
*/
|
|
138
|
+
export function getStateIds(component: Component, exported: boolean = true, before?: StateId): StateId[] {
|
|
139
|
+
try {
|
|
140
|
+
const states = component.get(exported ? EXPORTED_STATES_KEY : PRIVATE_STATES_KEY) as StoredStateWithId[] ?? []
|
|
141
|
+
const allStates = states
|
|
142
|
+
.sort((a, b) => Number(b.hidden ?? false) - Number(a.hidden ?? false)) // Hidden states first
|
|
143
|
+
.map(state => state.id)
|
|
144
|
+
if(before) {
|
|
145
|
+
const index = allStates.indexOf(before)
|
|
146
|
+
if(index < 0) return allStates
|
|
147
|
+
return allStates.slice(0, index)
|
|
148
|
+
}
|
|
149
|
+
return allStates
|
|
150
|
+
} catch(e) {
|
|
151
|
+
// this happens when the old deprecated state system is used
|
|
152
|
+
console.error('Error while getting state ids', e)
|
|
153
|
+
return []
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* List all exported states
|
|
159
|
+
*/
|
|
160
|
+
export function getStates(component: Component, exported: boolean = true): StoredState[] {
|
|
161
|
+
const states = component.get(exported ? EXPORTED_STATES_KEY : PRIVATE_STATES_KEY) as StoredStateWithId[] ?? []
|
|
162
|
+
return states.map(state => ({
|
|
163
|
+
label: state.label,
|
|
164
|
+
hidden: state.hidden,
|
|
165
|
+
expression: state.expression,
|
|
166
|
+
}))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Get the name of a state variable
|
|
171
|
+
* Useful to generate code
|
|
172
|
+
*/
|
|
173
|
+
export function getStateVariableName(componentId: string, stateId: StateId): string {
|
|
174
|
+
return `state_${ componentId }_${ stateId }`
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Get a state
|
|
179
|
+
*/
|
|
180
|
+
export function getState(component: Component, id: StateId, exported: boolean = true): StoredState | null {
|
|
181
|
+
const states = component.get(exported ? EXPORTED_STATES_KEY : PRIVATE_STATES_KEY) as StoredStateWithId[] ?? []
|
|
182
|
+
const state = states.find(state => state.id === id) ?? null
|
|
183
|
+
if(!state) {
|
|
184
|
+
return null
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
label: state.label,
|
|
188
|
+
hidden: state.hidden,
|
|
189
|
+
expression: state.expression,
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Set a state
|
|
195
|
+
* The state will be updated or created at the end of the list
|
|
196
|
+
* Note: index is not used in this project anymore (maybe in apps using this plugins)
|
|
197
|
+
*/
|
|
198
|
+
export function setState(component: Component, id: StateId, state: StoredState, exported = true, index = -1): void {
|
|
199
|
+
const key = exported ? EXPORTED_STATES_KEY : PRIVATE_STATES_KEY
|
|
200
|
+
const states = component.get(key) as StoredStateWithId[] ?? []
|
|
201
|
+
const existing = states.find(s => s.id === id) ?? null
|
|
202
|
+
if(existing) {
|
|
203
|
+
component.set(key, states.map(s => s.id !== id ? s : {
|
|
204
|
+
id,
|
|
205
|
+
...state,
|
|
206
|
+
}))
|
|
207
|
+
} else {
|
|
208
|
+
component.set(key, [
|
|
209
|
+
...states,
|
|
210
|
+
{
|
|
211
|
+
id,
|
|
212
|
+
...state,
|
|
213
|
+
},
|
|
214
|
+
])
|
|
215
|
+
}
|
|
216
|
+
// Set the index if needed
|
|
217
|
+
if(index >= 0) {
|
|
218
|
+
const states = [...component.get(key) as StoredStateWithId[]]
|
|
219
|
+
const state = states.find(s => s.id === id)
|
|
220
|
+
if(state && index < states.length) {
|
|
221
|
+
states.splice(states.indexOf(state), 1)
|
|
222
|
+
states.splice(index, 0, state)
|
|
223
|
+
component.set(key, states)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Notify the change
|
|
227
|
+
fireChange({
|
|
228
|
+
label: state.label,
|
|
229
|
+
hidden: state.hidden,
|
|
230
|
+
expression: state.expression,
|
|
231
|
+
}, component)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Remove a state
|
|
236
|
+
*/
|
|
237
|
+
export function removeState(component: Component, id: StateId, exported: boolean = true): void {
|
|
238
|
+
const key = exported ? EXPORTED_STATES_KEY : PRIVATE_STATES_KEY
|
|
239
|
+
const states = component.get(key) as StoredStateWithId[] ?? []
|
|
240
|
+
const newStates = states.filter(s => s.id !== id)
|
|
241
|
+
component.set(key, newStates)
|
|
242
|
+
fireChange(null, component)
|
|
243
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { Component } from 'grapesjs'
|
|
2
|
+
import { Expression, Field, FieldArgument, Filter, Options, Property, PropertyOptions, StoredToken, Token, Type } from '../types'
|
|
3
|
+
import { getFilters, getManager } from './dataSourceManager'
|
|
4
|
+
import { NOTIFICATION_GROUP } from '../utils'
|
|
5
|
+
import { getParentByPersistentId, getState } from './state'
|
|
6
|
+
import { TemplateResult, html } from 'lit'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Add missing methonds to the filter
|
|
10
|
+
* When filters are stored they lose their methods
|
|
11
|
+
* @throws Error if the filter is not found
|
|
12
|
+
*/
|
|
13
|
+
export function getFilterFromToken(token: Filter, filters: Filter[]): Filter {
|
|
14
|
+
if(token.type !== 'filter') throw new Error('Token is not a filter')
|
|
15
|
+
const filter = filters.find(filter => filter.id === token.id)
|
|
16
|
+
if (!filter) {
|
|
17
|
+
console.error('Filter not found', token)
|
|
18
|
+
throw new Error(`Filter ${token.id} not found`)
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...token,
|
|
22
|
+
...filter,
|
|
23
|
+
// Keep the options as they are stored
|
|
24
|
+
options: token.options,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get the token from its stored form
|
|
30
|
+
* @throws Error if the token type is not found
|
|
31
|
+
*/
|
|
32
|
+
export function fromStored<T extends Token = Token>(token: StoredToken, componentId: string | null): T {
|
|
33
|
+
// Handle invalid tokens - return null or throw a descriptive error
|
|
34
|
+
if (!token || typeof token !== 'object') {
|
|
35
|
+
console.error('Invalid token: not an object', token)
|
|
36
|
+
throw new Error('Invalid token: expected an object')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!token.type) {
|
|
40
|
+
console.error('Invalid token: missing type property', token)
|
|
41
|
+
throw new Error('Invalid token: missing type property')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
switch (token.type) {
|
|
45
|
+
case 'filter': {
|
|
46
|
+
if ((token as Filter).optionsForm) return token as T
|
|
47
|
+
const original = getFilters().find(filter => filter.id === token.id) as T | undefined
|
|
48
|
+
if (!original) {
|
|
49
|
+
console.error('Filter not found', token)
|
|
50
|
+
throw new Error(`Filter ${token.id} not found`)
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
...original,
|
|
54
|
+
...token,
|
|
55
|
+
type: 'filter',
|
|
56
|
+
} as unknown as T
|
|
57
|
+
}
|
|
58
|
+
case 'property': {
|
|
59
|
+
if ((token as Property).optionsForm) return token as T
|
|
60
|
+
const field = propertyToField(token, componentId)
|
|
61
|
+
if (!field) {
|
|
62
|
+
console.error('Field not found for token', token)
|
|
63
|
+
throw new Error(`Field ${token.fieldId} not found`)
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...getTokenOptions(field) ?? {},
|
|
67
|
+
...token,
|
|
68
|
+
type: 'property',
|
|
69
|
+
propType: 'field',
|
|
70
|
+
} as unknown as T
|
|
71
|
+
}
|
|
72
|
+
case 'state':
|
|
73
|
+
return token as T
|
|
74
|
+
default:
|
|
75
|
+
console.error('Unknown token type (reading type)', token)
|
|
76
|
+
throw new Error('Unknown token type')
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get the type corresponding to a token
|
|
82
|
+
*/
|
|
83
|
+
export function tokenToField(token: Token, prev: Field | null, component: Component): Field | null {
|
|
84
|
+
switch (token.type) {
|
|
85
|
+
case 'filter': {
|
|
86
|
+
try {
|
|
87
|
+
const filter = getFilterFromToken(token, getFilters())
|
|
88
|
+
try {
|
|
89
|
+
if (filter.validate(prev)) {
|
|
90
|
+
return filter.output(prev, filter.options ?? {})
|
|
91
|
+
}
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.warn('Filter validate error:', e, {token, prev})
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
96
|
+
return null
|
|
97
|
+
} catch {
|
|
98
|
+
// FIXME: notify user
|
|
99
|
+
console.error('Error while getting filter result type', {token, prev, component})
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
case 'property':
|
|
104
|
+
try {
|
|
105
|
+
return propertyToField(token, component.getId())
|
|
106
|
+
} catch {
|
|
107
|
+
// FIXME: notify user
|
|
108
|
+
console.error('Error while getting property result type', {token, component})
|
|
109
|
+
return null
|
|
110
|
+
}
|
|
111
|
+
case 'state': {
|
|
112
|
+
const parent = getParentByPersistentId(token.componentId, component)
|
|
113
|
+
if (!parent) {
|
|
114
|
+
console.warn('Component not found for state', token)
|
|
115
|
+
const manager = getManager()
|
|
116
|
+
manager.editor.runCommand('notifications:add', {
|
|
117
|
+
type: 'error',
|
|
118
|
+
group: NOTIFICATION_GROUP,
|
|
119
|
+
message: `Component not found for state: ${token.storedStateId}`,
|
|
120
|
+
componentId: component.getId(),
|
|
121
|
+
})
|
|
122
|
+
return null
|
|
123
|
+
}
|
|
124
|
+
const expression = getState(parent, token.storedStateId, token.exposed)?.expression
|
|
125
|
+
if (!expression) {
|
|
126
|
+
console.warn('State is not defined on component', { component: parent, token })
|
|
127
|
+
const manager = getManager()
|
|
128
|
+
manager.editor.runCommand('notifications:add', {
|
|
129
|
+
type: 'error',
|
|
130
|
+
group: NOTIFICATION_GROUP,
|
|
131
|
+
message: `State '${token.storedStateId}' is not defined on component '${parent.getName() || parent.get('id')}'`,
|
|
132
|
+
componentId: parent.getId(),
|
|
133
|
+
})
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const field = getExpressionResultType(expression, parent)
|
|
138
|
+
return field ? {
|
|
139
|
+
...field,
|
|
140
|
+
kind: token.forceKind ?? field.kind,
|
|
141
|
+
} : null
|
|
142
|
+
} catch {
|
|
143
|
+
// FIXME: notify user
|
|
144
|
+
console.error('Error while getting expression result type in tokenToField', {expression, parent, component, token, prev})
|
|
145
|
+
return null
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
default:
|
|
149
|
+
console.error('Unknown token type (reading type)', token)
|
|
150
|
+
throw new Error('Unknown token type')
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Get the type corresponding to a property
|
|
156
|
+
* @throws Error if the type is not found
|
|
157
|
+
*/
|
|
158
|
+
export function propertyToField(property: Property, componentId: string | null): Field {
|
|
159
|
+
const manager = getManager()
|
|
160
|
+
const allTypes = manager.cachedTypes.length > 0 ? manager.cachedTypes : []
|
|
161
|
+
|
|
162
|
+
const typeNames: string[] = []
|
|
163
|
+
|
|
164
|
+
// Check each typeId and handle missing types
|
|
165
|
+
for (const typeId of property.typeIds) {
|
|
166
|
+
const type: Type | undefined = allTypes.find(type => type.id === typeId && (!property.dataSourceId || type.dataSourceId === property.dataSourceId))
|
|
167
|
+
if (!type) {
|
|
168
|
+
// Show notification for missing type, similar to main branch DataTree.getType
|
|
169
|
+
manager.editor.runCommand('notifications:add', {
|
|
170
|
+
type: 'error',
|
|
171
|
+
group: NOTIFICATION_GROUP,
|
|
172
|
+
message: `Type not found ${property.dataSourceId ?? ''}.${typeId}`,
|
|
173
|
+
componentId,
|
|
174
|
+
})
|
|
175
|
+
console.error(`Type not found ${property.dataSourceId ?? ''}.${typeId}`)
|
|
176
|
+
// Continue processing other types instead of throwing
|
|
177
|
+
} else {
|
|
178
|
+
typeNames.push(type.label)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const args = property.options ? Object.entries(property.options).map(([name, value]) => ({
|
|
183
|
+
typeId: 'JSON', // FIXME: Why is this hardcoded?
|
|
184
|
+
name,
|
|
185
|
+
defaultValue: value, // FIXME: Why is this value, it should keep the initial default
|
|
186
|
+
})) : undefined
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
id: property.fieldId,
|
|
190
|
+
label: typeNames.length > 0 ? typeNames.join(', ') : property.label,
|
|
191
|
+
typeIds: property.typeIds,
|
|
192
|
+
kind: property.kind,
|
|
193
|
+
dataSourceId: property.dataSourceId,
|
|
194
|
+
arguments: args,
|
|
195
|
+
previewIndex: property.previewIndex,
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Evaluate the types of each token in an expression
|
|
201
|
+
*/
|
|
202
|
+
export function expressionToFields(expression: Expression, component: Component): Field[] {
|
|
203
|
+
// Resolve type of the expression 1 step at a time
|
|
204
|
+
let prev: Field | null = null
|
|
205
|
+
const unknownField: Field = {
|
|
206
|
+
id: 'unknown',
|
|
207
|
+
label: 'unknown',
|
|
208
|
+
typeIds: [],
|
|
209
|
+
kind: 'scalar',
|
|
210
|
+
}
|
|
211
|
+
return expression.map((token) => {
|
|
212
|
+
try {
|
|
213
|
+
const field = tokenToField(fromStored(token, component.getId()), prev, component)
|
|
214
|
+
if (!field) {
|
|
215
|
+
console.warn('Type not found for token in expressionToFields', { token, expression })
|
|
216
|
+
return unknownField
|
|
217
|
+
}
|
|
218
|
+
prev = field
|
|
219
|
+
return field
|
|
220
|
+
} catch {
|
|
221
|
+
// FIXME: notify user
|
|
222
|
+
console.error('Error while getting expression result type in expressionToFields', {expression, component, token, prev})
|
|
223
|
+
return unknownField
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Evaluate an expression to a type
|
|
230
|
+
* This is used to validate expressions and for autocompletion
|
|
231
|
+
* @throws Error if the token type is not found
|
|
232
|
+
*/
|
|
233
|
+
export function getExpressionResultType(expression: Expression, component: Component): Field | null {
|
|
234
|
+
// Resolve type of the expression 1 step at a time
|
|
235
|
+
return expression.reduce((prev: Field | null, token: StoredToken) => {
|
|
236
|
+
return tokenToField(fromStored(token, component.getId()), prev, component)
|
|
237
|
+
}, null)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get the options of a token
|
|
242
|
+
*/
|
|
243
|
+
export function getTokenOptions(field: Field): { optionsForm: (selected: Component, input: Field | null, options: Options) => TemplateResult, options: Options } | null {
|
|
244
|
+
if (field.arguments && field.arguments.length > 0) {
|
|
245
|
+
return {
|
|
246
|
+
optionsForm: optionsToOptionsForm(field.arguments.map((arg) => ({ name: arg.name, value: arg.defaultValue }))),
|
|
247
|
+
options: field.arguments.reduce((options: Record<string, unknown>, arg: FieldArgument) => {
|
|
248
|
+
options[arg.name] = arg.defaultValue
|
|
249
|
+
return options
|
|
250
|
+
}, {}),
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return null
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Get the options of a token or a field
|
|
258
|
+
*/
|
|
259
|
+
export function optionsToOptionsForm(arr: { name: string, value: unknown }[]): (selected: Component, input: Field | null, options: Options) => TemplateResult {
|
|
260
|
+
return (selected: Component, input: Field | null, options: Options) => {
|
|
261
|
+
return html`
|
|
262
|
+
${arr.map((obj) => {
|
|
263
|
+
const value = options[obj.name] ?? obj.value ?? ''
|
|
264
|
+
return html`<label>${obj.name}</label><input type="text" name=${obj.name} .value=${value}>`
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
`
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Utility function to shallow compare two objects
|
|
273
|
+
* Used to compare options of tree items
|
|
274
|
+
*/
|
|
275
|
+
export function getOptionObject(option1: PropertyOptions | undefined, option2: PropertyOptions | undefined): { error: boolean, result: PropertyOptions | undefined } {
|
|
276
|
+
// Handle the case where one or both are undefined or empty
|
|
277
|
+
if(!option1 && !option2) return { error: false, result: undefined }
|
|
278
|
+
if(isEmpty(option1) && isEmpty(option2)) return { error: false, result: undefined }
|
|
279
|
+
// Handle the case where one is undefined or empty and the other is not
|
|
280
|
+
if(!option1 || !option2) return { error: true, result: undefined }
|
|
281
|
+
if(isEmpty(option1) || isEmpty(option2)) return { error: true, result: undefined }
|
|
282
|
+
|
|
283
|
+
const keys1 = Object.keys(option1)
|
|
284
|
+
const keys2 = Object.keys(option2)
|
|
285
|
+
|
|
286
|
+
if (keys1.length !== keys2.length) {
|
|
287
|
+
return { error: true, result: undefined }
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
for (const key of keys1) {
|
|
291
|
+
if (option1[key] !== option2[key]) {
|
|
292
|
+
return { error: true, result: undefined }
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return { error: false, result: option1 }
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function isJson(str: string) {
|
|
300
|
+
if(typeof str !== 'string') return false
|
|
301
|
+
if(str.length === 0) return false
|
|
302
|
+
try {
|
|
303
|
+
JSON.parse(str)
|
|
304
|
+
} catch {
|
|
305
|
+
return false
|
|
306
|
+
}
|
|
307
|
+
return true
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function isEmpty(value: unknown): boolean {
|
|
311
|
+
if(value === null || typeof value === 'undefined') return true
|
|
312
|
+
const isString = typeof value === 'string'
|
|
313
|
+
const isJsonString = isString && isJson(value)
|
|
314
|
+
if (isString && !isJsonString) return value === ''
|
|
315
|
+
const json = isJsonString ? JSON.parse(value) : value
|
|
316
|
+
if (json === null) return true
|
|
317
|
+
if (Array.isArray(json)) return json.length === 0
|
|
318
|
+
if (typeof json === 'object') return Object.values(json).filter(v => !!v).length === 0
|
|
319
|
+
return false
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function buildArgs(options: PropertyOptions | undefined): string {
|
|
323
|
+
const args = options ? `(${Object
|
|
324
|
+
.keys(options)
|
|
325
|
+
.map(key => ({ key, value: options![key] }))
|
|
326
|
+
.filter(({ value }) => !isEmpty(value))
|
|
327
|
+
.map(({ key, value }) => {
|
|
328
|
+
//return typeof value === 'string' && !isJson(value) ? `${key}: "${value}"` : `${key}: ${value}`
|
|
329
|
+
return `${key}: ${value}`
|
|
330
|
+
})
|
|
331
|
+
.join(', ')
|
|
332
|
+
})` : ''
|
|
333
|
+
// Valid args for GraphQL canot be just ()
|
|
334
|
+
const validArgs = args === '()' ? '' : args
|
|
335
|
+
return validArgs
|
|
336
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import { jest } from '@jest/globals'
|
|
5
|
+
import { Editor } from 'grapesjs'
|
|
6
|
+
import storage from './storage'
|
|
7
|
+
import { resetDataSources, refreshDataSources } from './model/dataSourceManager'
|
|
8
|
+
import { getAllDataSources, addDataSource } from './model/dataSourceRegistry'
|
|
9
|
+
|
|
10
|
+
// FIXME: Workaround to avoid import of lit-html which breakes unit tests
|
|
11
|
+
jest.mock('lit', () => ({
|
|
12
|
+
html: jest.fn(),
|
|
13
|
+
render: jest.fn(),
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
// Mock the dataSourceManager to avoid complex initialization
|
|
17
|
+
jest.mock('./model/dataSourceManager', () => ({
|
|
18
|
+
resetDataSources: jest.fn(),
|
|
19
|
+
refreshDataSources: jest.fn()
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
// Mock the dataSourceRegistry
|
|
23
|
+
jest.mock('./model/dataSourceRegistry', () => ({
|
|
24
|
+
getAllDataSources: jest.fn(),
|
|
25
|
+
addDataSource: jest.fn(),
|
|
26
|
+
}))
|
|
27
|
+
|
|
28
|
+
const config1 = { readonly: true, id: 'config1', label: 'Config 1', url: 'http://config1.com', type: 'graphql' as const } // from the config
|
|
29
|
+
const config2 = { readonly: true, id: 'config2', label: 'Config 2', url: 'http://config2.com', type: 'graphql' as const } // from the config
|
|
30
|
+
const website1 = { readonly: false, id: 'website1', label: 'Website 1', url: 'http://website1.com', type: 'graphql' as const } // from the website
|
|
31
|
+
const website2 = { id: 'website2', label: 'Website 2', url: 'http://website2.com', type: 'graphql' as const } // from the website (readonly undefined)
|
|
32
|
+
jest.mock('./datasources/GraphQL', () => jest.fn().mockImplementation((x) => ({ connect: jest.fn(), id: 'website1DataSource', ...x })))
|
|
33
|
+
|
|
34
|
+
describe('storage', () => {
|
|
35
|
+
let editor: Editor
|
|
36
|
+
let onStore: Function
|
|
37
|
+
let onLoad: Function
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
const callbacks = new Map<string, Function>()
|
|
40
|
+
editor = {
|
|
41
|
+
on: (event, callback) => callbacks.set(event, callback),
|
|
42
|
+
} as any as Editor
|
|
43
|
+
|
|
44
|
+
// Mock the getAllDataSources to return our test data
|
|
45
|
+
;(getAllDataSources as jest.Mock).mockReturnValue([config1, config2, website1, website2])
|
|
46
|
+
|
|
47
|
+
storage(editor)
|
|
48
|
+
expect(callbacks.get('storage:start:store')).toBeDefined()
|
|
49
|
+
onStore = callbacks.get('storage:start:store')!
|
|
50
|
+
expect(callbacks.get('storage:end:load')).toBeDefined()
|
|
51
|
+
onLoad = callbacks.get('storage:end:load')!
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('should store data sources from the website only', () => {
|
|
55
|
+
const previousDataSource = { id: 'whatever data'}
|
|
56
|
+
const data = { dataSources: [previousDataSource] }
|
|
57
|
+
onStore(data)
|
|
58
|
+
expect(data.dataSources).toHaveLength(2)
|
|
59
|
+
expect(data.dataSources[0]).not.toEqual(previousDataSource)
|
|
60
|
+
expect(data.dataSources[0].id).toEqual('website1')
|
|
61
|
+
expect(data.dataSources[1].id).toEqual('website2')
|
|
62
|
+
})
|
|
63
|
+
it('should load data sources from website and keep those from the config', async () => {
|
|
64
|
+
const newWebsite1 = { readonly: false, id: 'newWebsite1', label: 'New Website 1', url: 'http://new1.com', type: 'graphql' as const }
|
|
65
|
+
const newWebsite2 = { id: 'newWebsite2', label: 'New Website 2', url: 'http://new2.com', type: 'graphql' as const }
|
|
66
|
+
const newWebsite3 = { readonly: true, id: 'newWebsite3', label: 'New Website 3', url: 'http://new3.com', type: 'graphql' as const }
|
|
67
|
+
|
|
68
|
+
const data = { dataSources: [
|
|
69
|
+
newWebsite1,
|
|
70
|
+
newWebsite2,
|
|
71
|
+
newWebsite3,
|
|
72
|
+
] }
|
|
73
|
+
await onLoad(data)
|
|
74
|
+
|
|
75
|
+
// Check that resetDataSources was called with config data sources only
|
|
76
|
+
expect(resetDataSources).toHaveBeenCalledWith([config1, config2])
|
|
77
|
+
|
|
78
|
+
// Check that addDataSource was called for each new data source
|
|
79
|
+
expect(addDataSource).toHaveBeenCalledTimes(3)
|
|
80
|
+
})
|
|
81
|
+
})
|