worldofvipul
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: custom gutenberg block editor/** * WordPress dependencies */ import '@wordpress/editor'; // This shouldn't be necessary import '@wordpress/format-library'; import { useSelect, useDispatch } from '@wordpress/data'; import { useEffect, useState, useMemo } from '@wordpress/element'; import { serialize, parse } from '@wordpress/blocks'; import { uploadMedia } from '@wordpress/media-utils'; import { BlockBreadcrumb, BlockEditorKeyboardShortcuts, BlockEditorProvider, BlockList, BlockTools, BlockInspector, WritingFlow, ObserveTyping, } from '@wordpress/block-editor'; /** * Internal dependencies */ import Sidebar from '../sidebar'; function BlockEditor({ settings: _settings }) { const [blocks, updateBlocks] = useState([]); const { createInfoNotice } = useDispatch('core/notices'); const canUserCreateMedia = useSelect((select) => { const _canUserCreateMedia = select('core').canUser('create', 'media'); return _canUserCreateMedia || _canUserCreateMedia !== false; }, []); const settings = useMemo(() => { if (!canUserCreateMedia) { return _settings; } return { ..._settings, mediaUpload({ onError, ...rest }) { uploadMedia({ wpAllowedMimeTypes: _settings.allowedMimeTypes, onError: ({ message }) => onError(message), ...rest, }); }, }; }, [canUserCreateMedia, _settings]); useEffect(() => { const storedBlocks = window.localStorage.getItem('vbCbBlocks'); if (storedBlocks?.length) { handleUpdateBlocks(() => parse(storedBlocks)); createInfoNotice('Blocks loaded', { type: 'snackbar', isDismissible: true, }); } }, []); /** * Wrapper for updating blocks. Required as
onInput
callback passed to *BlockEditorProvider
is now called with more than 1 argument. Therefore * attempting to setState directly viaupdateBlocks
will trigger an error * in React. * * @param blocks * @param _blocks */ function handleUpdateBlocks(_blocks) { updateBlocks(_blocks); } function handlePersistBlocks(newBlocks) { updateBlocks(newBlocks); window.localStorage.setItem('vbCbBlocks', serialize(newBlocks)); } return ( <div className="vb-block-editor"> <BlockEditorProvider value={blocks} onInput={handleUpdateBlocks} onChange={handlePersistBlocks} settings={settings} > <BlockBreadcrumb /> <Sidebar.InspectorFill> <BlockInspector /> </Sidebar.InspectorFill> <div className="editor-styles-wrapper"> <BlockEditorKeyboardShortcuts.Register /> <BlockTools> <WritingFlow> <ObserveTyping> <BlockList className="vb-block-editor__block-list" /> </ObserveTyping> </WritingFlow> </BlockTools> </div> </BlockEditorProvider> </div> ); } export default BlockEditor;this is the code where i made custom editor, when using this hook in console, it comes null even if page has block – wp.data.select(“core/block-editor”).getBlock(clientId)
Forum: Developing with WordPress
In reply to: Gutenberg Richtext generating “” in editorI fixed this issue, i found that this character is coming in core blocks rich text element also, the issue in my code is i used span tag with display block css.
Forum: Developing with WordPress
In reply to: Gutenberg Richtext generating “” in editor@benniledl , Hi thanks for replay.
I have tried to remove all things and rewrite code but still its coming, also i have checked this file to notepad++ for zero width, but no issue found it is UTF without BOM, one thing i marked that when i remove placeholder text and put default text in attributes its not showing this character.
also i tried to use fresh richtext element from wordpress sample code but i found same issue.
- This reply was modified 1 year, 9 months ago by worldofvipul.
Forum: Developing with WordPress
In reply to: custom gutenberg blocks plugin issueHi
Thanks For the replay.I already read all that documentation, but that is not helped me.
I just want to know then when I am registering a block with custom style handles (https://prnt.sc/MU__r-LtIXom ) why only editor CSS is loading in the iframe template editor (https://prnt.sc/-6LlZ7vo3hY0)Thanks
Vipul JForum: Plugins
In reply to: [ForumWP – Forum & Discussion Board] page template option not displayingHello @nsinelnikov
I am aware of that topics, I am not able to see the template selection option in my backend panel.
I already share screenshot here.
Thanks
Vipul- This reply was modified 3 years, 3 months ago by worldofvipul.