Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
RichTextContainer.Content = ( { value, format, tagName: Tag, ...props } ) => {
let content;
switch ( format ) {
case 'string':
content = { value };
break;
case 'element':
// NOTE: In removing this, ensure to remove also every related
// function from `format.js`, including the `dom-react` dependency.
deprecated( 'RichText `element` format', {
version: '3.5',
plugin: 'Gutenberg',
alternative: 'the compatible `children` format',
} );
content = value;
break;
case 'children':
content = { children.toHTML( value ) };
break;
}
if ( Tag ) {
return { content };
}
export function initializeEditor( id, postType, postId, settings, overridePost ) {
const target = document.getElementById( id );
const reboot = reinitializeEditor.bind( null, postType, postId, target, settings, overridePost );
// Global deprecations which cannot otherwise be injected into known usage.
deprecated( 'paragraphs block class set is-small-text, ..., is-large-text', {
version: '3.6',
alternative: 'has-small-font-size, ..., has-large-font-size class set',
plugin: 'Gutenberg',
hint: 'If paragraphs using this classes are opened in the editor new classes are automatically applied the post just needs to be saved. This is a global warning, shown regardless of whether the classes are used in the current post.',
} );
dispatch( 'core/nux' ).triggerGuide( [
'core/editor.inserter',
'core/editor.settings',
'core/editor.preview',
'core/editor.publish',
] );
render(
,
target
export function toAsyncIterable( object ) {
if ( isAsyncIterable( object ) ) {
deprecated( 'Writing Resolvers as async generators', {
alternative: 'resolvers as generators with controls',
plugin: 'Gutenberg',
version: 4.2,
} );
return object;
}
return ( async function* () {
// Normalize as iterable...
if ( ! isIterable( object ) ) {
object = [ object ];
}
for ( const maybeAction of object ) {
yield maybeAction;
}
export function getBlockValidAlignments( blockName ) {
// Explicitly defined array set of valid alignments
const blockAlign = getBlockSupport( blockName, 'align' );
if ( Array.isArray( blockAlign ) ) {
return blockAlign;
}
const validAlignments = [];
if ( true === blockAlign ) {
// `true` includes all alignments...
validAlignments.push( 'left', 'center', 'right' );
// ...including wide alignments unless explicitly `false`.
if ( getBlockSupport( blockName, 'wideAlign' ) === false ) {
deprecated( 'supports.wideAlign in Block API', {
version: '3.6',
alternative: 'supports.alignWide',
plugin: 'Gutenberg',
} );
} else if ( hasBlockSupport( blockName, 'alignWide', true ) ) {
validAlignments.push( 'wide', 'full' );
}
}
return validAlignments;
}
function PanelColor( { colors, title, colorValue, initialOpen, ...props } ) {
deprecated( 'wp.editor.PanelColor', {
version: '4.3',
alternative: 'wp.editor.PanelColorSettings',
plugin: 'Gutenberg',
} );
const colorObject = getColorObjectByColorValue( colors, colorValue );
const colorName = colorObject && colorObject.name;
return (
);
}
function getAllowedFormats( { allowedFormats, formattingControls } ) {
if ( ! allowedFormats && ! formattingControls ) {
return;
}
if ( allowedFormats ) {
return allowedFormats;
}
deprecated( 'wp.blockEditor.RichText formattingControls prop', {
alternative: 'allowedFormats',
} );
return formattingControls.map( ( name ) => `core/${ name }` );
}
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
/**
* Internal dependencies
*/
import './store';
export { default as DotTip } from './components/dot-tip';
deprecated( 'wp.nux', {
hint: 'wp.components.Guide can be used to show a user guide.',
} );
export function* hasUploadPermissions() {
deprecated( "select( 'core' ).hasUploadPermissions()", {
alternative: "select( 'core' ).canUser( 'create', 'media' )",
} );
yield* canUser( 'create', 'media' );
}
export function buildTermsTree( flatTerms ) {
deprecated( 'wp.utils.buildTermsTree', {
version: '3.5',
plugin: 'Gutenberg',
} );
const termsByParent = groupBy( flatTerms, 'parent' );
const fillWithChildren = ( terms ) => {
return terms.map( ( term ) => {
const children = termsByParent[ term.id ];
return {
...term,
children: children && children.length ?
fillWithChildren( children ) :
[],
};
} );
};
edit: ( ( { attributes, setAttributes, className } ) => {
const { width, content, columns } = attributes;
deprecated( 'The Text Columns block', {
alternative: 'the Columns block',
plugin: 'Gutenberg',
} );
return (
setAttributes( { width: nextWidth } ) }
controls={ [ 'center', 'wide', 'full' ] }
/>