Skip to content

Commit

Permalink
Add shim to keep working with value instead of initialValue
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Nov 6, 2023
1 parent 9b8ed55 commit 13e94a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/volto-slate/src/slate-react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Slate as OrigSlate } from '@slate-react';

// Components
export { Editable, DefaultPlaceholder } from '@slate-react';

export { DefaultElement } from '@slate-react';
export { DefaultLeaf } from '@slate-react';

// Hooks
export { useEditor } from '@slate-react';
export { useSlateStatic } from '@slate-react';
export { useFocused } from '@slate-react';
export { useReadOnly } from '@slate-react';
export { useSelected } from '@slate-react';
export { useSlate, useSlateWithV } from '@slate-react';
export { useSlateSelector } from '@slate-react';
export { useSlateSelection } from '@slate-react';

// Plugin
export { ReactEditor } from '@slate-react';
export { withReact } from '@slate-react';

export const Slate = (props) => {
const initialValue = props.initialValue || props.value;
return OrigSlate({ ...props, initialValue });
};
3 changes: 3 additions & 0 deletions razzle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ const defaultModify = ({
// avoids including lodash multiple times.
// semantic-ui-react uses lodash-es, everything else uses lodash
'lodash-es': path.dirname(require.resolve('lodash')),
// workaround for backwards-incompatible change in slate-react
'@slate-react': path.dirname(require.resolve('slate-react')),
'slate-react$': `${registry.voltoPath}/packages/volto-slate/src/slate-react`,
};

const [addonsThemeLoaderVariablesPath, addonsThemeLoaderMainPath] =
Expand Down

0 comments on commit 13e94a1

Please sign in to comment.