From caec1ad937affd8af593e520e8b6efd299b8e083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dante=20=C3=81lvarez?= <89805481+danalvrz@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:07:28 -0600 Subject: [PATCH] remove schemaEnhancer --- README.md | 26 +++----------- .../src/components/View.jsx | 4 +-- .../src/components/schema.js | 36 +++++-------------- packages/volto-separator-block/src/index.js | 2 -- .../volto-separator-block/src/theme/main.less | 6 ++-- pnpm-lock.yaml | 20 ++++++----- 6 files changed, 30 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index d651097..53988c5 100644 --- a/README.md +++ b/README.md @@ -19,37 +19,19 @@ The Volto Separator Block allows editors to add a visual separator between block ![Separator-Block](https://github.com/kitconcept/volto-separator-block/raw/master/screencast.gif) -## Block Alignment Enhancer +## Block Schema -This block features by default a block `schemaEnhancer` that provides an alignment option for the separator. This can be disabled by overwriting with your own `schemaEnhancer` +This block features an option to make the line short, for visual variety purpuses. If that is the case, the line's `width` points to the custom property `--short-line-width`, which can be set if desired. -```js - config.blocks.blocksConfig.separator = { - ...config.blocks.blocksConfig.separator, - schemaEnhancer: mySeparatorSchemaEnhancer, - } -``` -or setting it to `null` or `undefined`: +The `schema` can be extended by using with your own `schemaEnhancer`: ```js config.blocks.blocksConfig.separator = { ...config.blocks.blocksConfig.separator, - schemaEnhancer: null, + schemaEnhancer: mySeparatorSchemaEnhancer, } ``` -Also, if you want to keep the default alignment but still add your own `schemaEnhancer` you can compose it along with your own: - -```js -import { composeSchema } from '@plone/volto/helpers'; -import { SeparatorStyleEnhancer } from '@kitconcept/volto-separator-block'; - - config.blocks.blocksConfig.separator = { - ...config.blocks.blocksConfig.separator, - schemaEnhancer: composeSchema(mySeparatorSchemaEnhancer, defaultSeparatorEnhancer), - } -``` - ## Installation To install your project, you must choose the method appropriate to your version of Volto. diff --git a/packages/volto-separator-block/src/components/View.jsx b/packages/volto-separator-block/src/components/View.jsx index f9d7f30..5f9c670 100644 --- a/packages/volto-separator-block/src/components/View.jsx +++ b/packages/volto-separator-block/src/components/View.jsx @@ -9,12 +9,12 @@ const LegacyWrapper = (props) => ( ); const SeparatorView = (props) => { - const { blocksConfig } = props; + const { blocksConfig, data } = props; const isBlockModelv3 = blocksConfig?.separator?.blockModel === 3; return ( -
+
); }; diff --git a/packages/volto-separator-block/src/components/schema.js b/packages/volto-separator-block/src/components/schema.js index 71492b9..5fa0907 100644 --- a/packages/volto-separator-block/src/components/schema.js +++ b/packages/volto-separator-block/src/components/schema.js @@ -1,11 +1,6 @@ -import { addStyling } from '@plone/volto/helpers/Extensions/withBlockSchemaEnhancer'; import { defineMessages } from 'react-intl'; const messages = defineMessages({ - title: { - id: 'Title', - defaultMessage: 'Title', - }, separatorBlock: { id: 'Separator Block', defaultMessage: 'Separator', @@ -17,31 +12,18 @@ const messages = defineMessages({ }); export const SeparatorSchema = (props) => { + const { intl } = props; + return { - title: props.intl.formatMessage(messages.separatorBlock), + title: intl.formatMessage(messages.separatorBlock), block: 'separator', - fieldsets: [ - { - id: 'default', - title: 'Default', + fieldsets: [{ id: 'default', title: 'Default', fields: ['shortLine'] }], + properties: { + shortLine: { + title: intl.formatMessage(messages.shortline), + type: 'boolean', }, - ], - properties: {}, + }, required: [], }; }; - -export const SeparatorStyleEnhancer = ({ schema, intl }) => { - addStyling({ schema, intl }); - - schema.properties.styles.schema.fieldsets[0].fields = [ - 'shortLine', - ...schema.properties.styles.schema.fieldsets[0].fields, - ]; - schema.properties.styles.schema.properties.shortLine = { - title: intl.formatMessage(messages.shortline), - type: 'boolean', - }; - - return schema; -}; diff --git a/packages/volto-separator-block/src/index.js b/packages/volto-separator-block/src/index.js index 0bff2f1..72e4f82 100644 --- a/packages/volto-separator-block/src/index.js +++ b/packages/volto-separator-block/src/index.js @@ -1,5 +1,4 @@ import { defineMessages } from 'react-intl'; -import { SeparatorStyleEnhancer } from './components/schema'; import divideHorizontalSVG from '@plone/volto/icons/divide-horizontal.svg'; import SeparatorView from './components/View'; import SeparatorEdit from './components/Edit'; @@ -20,7 +19,6 @@ const applyConfig = (config) => { group: 'teasers', view: SeparatorView, edit: SeparatorEdit, - schemaEnhancer: SeparatorStyleEnhancer, restricted: false, mostUsed: true, sidebarTab: 1, diff --git a/packages/volto-separator-block/src/theme/main.less b/packages/volto-separator-block/src/theme/main.less index 4177c2b..f605a24 100644 --- a/packages/volto-separator-block/src/theme/main.less +++ b/packages/volto-separator-block/src/theme/main.less @@ -20,10 +20,10 @@ margin-top: -1px; content: ''; } - } - &.has--shortLine--true { - width: var(--short-line-width, 25%); + &.short { + width: var(--short-line-width, 25%); + } } &.has--align--left { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b165556..30d4add 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17120,7 +17120,9 @@ snapshots: source-map: 0.6.1 string-length: 2.0.0 transitivePeerDependencies: + - bufferutil - supports-color + - utf-8-validate '@jest/reporters@26.6.2': dependencies: @@ -17512,7 +17514,7 @@ snapshots: read-package-json-fast: 2.0.3 readdir-scoped-modules: 1.1.0 rimraf: 3.0.2 - semver: 7.6.2 + semver: 7.6.3 ssri: 8.0.1 treeverse: 1.0.4 walk-up-path: 1.0.0 @@ -17542,7 +17544,7 @@ snapshots: npm-pick-manifest: 6.1.1 promise-inflight: 1.0.1 promise-retry: 2.0.1 - semver: 7.6.2 + semver: 7.6.3 which: 2.0.2 transitivePeerDependencies: - bluebird @@ -17582,7 +17584,7 @@ snapshots: cacache: 15.3.0 json-parse-even-better-errors: 2.3.1 pacote: 12.0.3 - semver: 7.6.2 + semver: 7.6.3 transitivePeerDependencies: - bluebird - supports-color @@ -27426,7 +27428,9 @@ snapshots: pretty-format: 24.9.0 throat: 4.1.0 transitivePeerDependencies: + - bufferutil - supports-color + - utf-8-validate jest-jasmine2@26.6.3: dependencies: @@ -29423,7 +29427,7 @@ snapshots: nopt: 5.0.0 npmlog: 6.0.2 rimraf: 3.0.2 - semver: 7.6.2 + semver: 7.6.3 tar: 6.2.1 which: 2.0.2 transitivePeerDependencies: @@ -29517,7 +29521,7 @@ snapshots: npm-install-checks@4.0.0: dependencies: - semver: 7.6.2 + semver: 7.6.3 npm-install-checks@6.3.0: dependencies: @@ -29539,7 +29543,7 @@ snapshots: npm-package-arg@8.1.5: dependencies: hosted-git-info: 4.1.0 - semver: 7.6.2 + semver: 7.6.3 validate-npm-package-name: 3.0.0 npm-packlist@3.0.0: @@ -29558,7 +29562,7 @@ snapshots: npm-install-checks: 4.0.0 npm-normalize-package-bin: 1.0.1 npm-package-arg: 8.1.5 - semver: 7.6.2 + semver: 7.6.3 npm-pick-manifest@8.0.2: dependencies: @@ -35001,7 +35005,7 @@ snapshots: preferred-pm: 3.1.3 pretty-bytes: 5.3.0 readable-stream: 4.5.2 - semver: 7.6.2 + semver: 7.6.3 slash: 3.0.0 strip-ansi: 6.0.1 text-table: 0.2.0