-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clone the repo (2.24.0) but the editor has error when I tried on storybook #225
Comments
You will need to use
|
I have the same issue and the |
I am unable to reproduce a situation where a custom store is needed. More than likely you are using different versions of the |
I've run into the same problem and unfortunately only adding the custom store as described above helped. I've tried two different approaches (using Vite and CRA) and both led to the same issue around the stores. I've also confirmed that the workaround works for both Vite and CRA, so it makes me think that it's indeed a bug in
import IsolatedBlockEditor from '@automattic/isolated-block-editor';
import './App.css';
import '@automattic/isolated-block-editor/build-browser/core.css';
const settings = {
iso: {
moreMenu: false,
},
};
function App() {
return (
<div className="App">
<h1>Editor!</h1>
<IsolatedBlockEditor
settings={ settings }
onLoad={ ( parser, rawHandler ) => {
console.log( 'parser: ', parser )
console.log( 'rawHandler: ', rawHandler )
} }
onSaveContent={ ( content ) => {
console.log( 'onContentSave' )
} }
onError={ () => {
console.log( 'error' )
} }
></IsolatedBlockEditor>
</div>
);
}
export default App;
Specifically, the error is on line 18 in isolated-block-editor/build-module/components/with-registry-provider/interface-store/selectors.js Line 17 in 141fc37
Now, add the workaround with custom stores and the error goes away: import IsolatedBlockEditor from '@automattic/isolated-block-editor';
import reducer from '@wordpress/preferences/build-module/store/reducer';
import * as selectors from '@wordpress/preferences/build-module/store/selectors';
import * as actions from '@wordpress/preferences/build-module/store/actions';
import './App.css';
import '@automattic/isolated-block-editor/build-browser/core.css';
const settings = {
iso: {
moreMenu: false,
customStores: [
{
name: 'core/preferences',
config: {
reducer: reducer,
selectors: selectors,
actions: actions,
},
}
],
},
};
function App() {
return (
<div className="App">
<h1>Editor!</h1>
<IsolatedBlockEditor
settings={ settings }
onLoad={ ( parser, rawHandler ) => {
console.log( 'parser: ', parser )
console.log( 'rawHandler: ', rawHandler )
} }
onSaveContent={ ( content ) => {
console.log( 'onContentSave' )
} }
onError={ () => {
console.log( 'error' )
} }
></IsolatedBlockEditor>
</div>
);
}
export default App; (well, the styles are affected by the default centered text, but the editor is working as expected overall) Hope this helps! Would love to avoid using the custom store workaround, but I was not able to pinpoint what's the root issue here. Only the editor and sass are installed so I'd assume that the correct dependencies are pulled in (can share the |
The issue originally reported here is that the storybook doesn't work ( @klimeryk that build setup isn't directly supported. As detailed in the readme (https://github.com/Automattic/isolated-block-editor#bundling-and-wordpress) you either need to load Gutenberg yourself, or you can use the included bundle. Your setup does not appear to be doing those things. I'm not actually able to get your example to work at all (different errors to do with React). I don't think this is a bug, just a problem with how things are built. |
Weird, it's definitely working on my side (queue the "let's ship your machine to production then" joke 🙃). I'm exploring this package for a personal project, so no worries 🙇 Thanks for having a look! |
Then I got error like this ( I tried all examples )
The text was updated successfully, but these errors were encountered: