How to use the @wordpress/blocks.getPhrasingContentSchema function in @wordpress/blocks

To help you get started, we’ve selected a few @wordpress/blocks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / core-blocks / paragraph / index.js View on Github external
keywords: [ __( 'text' ) ],

	supports,

	attributes: schema,

	transforms: {
		from: [
			{
				type: 'raw',
				// Paragraph is a fallback and should be matched last.
				priority: 20,
				selector: 'p',
				schema: {
					p: {
						children: getPhrasingContentSchema(),
					},
				},
			},
		],
	},

	deprecated: [
		{
			supports,
			attributes: {
				...schema,
				width: {
					type: 'string',
				},
			},
			save( { attributes } ) {
github WordPress / gutenberg / packages / block-library / src / paragraph / transforms.js View on Github external
/**
 * WordPress dependencies
 */
import { getPhrasingContentSchema } from '@wordpress/blocks';

const transforms = {
	from: [
		{
			type: 'raw',
			// Paragraph is a fallback and should be matched last.
			priority: 20,
			selector: 'p',
			schema: {
				p: {
					children: getPhrasingContentSchema(),
				},
			},
		},
	],
};

export default transforms;
github WordPress / gutenberg / packages / block-library / src / image / index.js View on Github external
attributes: [ 'src', 'alt' ],
		classes: [ 'alignleft', 'aligncenter', 'alignright', 'alignnone', /^wp-image-\d+$/ ],
	},
};

const schema = {
	figure: {
		require: [ 'img' ],
		children: {
			...imageSchema,
			a: {
				attributes: [ 'linkClass', 'href', 'rel', 'target' ],
				children: imageSchema,
			},
			figcaption: {
				children: getPhrasingContentSchema(),
			},
		},
	},
};

export const settings = {
	title: __( 'Image' ),

	description: __( 'They’re worth 1,000 words! Insert a single image.' ),

	icon: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" d="M0,0h24v24H0V0z"></path><path d="m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z"></path><path d="m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z"></path></svg>,

	category: 'common',

	keywords: [
		'img', // "img" is not translated as it is intended to reflect the HTML <img> tag.
github front / gutenberg-js / src / js / gutenberg-overrides / @wordpress / block-library / build-module / image / index.js View on Github external
attributes: [ 'src', 'alt' ],
    classes: [ 'alignleft', 'aligncenter', 'alignright', 'alignnone', /^wp-image-\d+$/ ],
  },
};

const schema = {
  figure: {
    require: [ 'img' ],
    children: {
      ...imageSchema,
      a: {
        attributes: [ 'href', 'target' ],
        children: imageSchema,
      },
      figcaption: {
        children: getPhrasingContentSchema(),
      },
    },
  },
};

export const settings = {
  title: __('Image'),

  description: __('Insert an image to make a visual statement.'),

  icon: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" d="M0,0h24v24H0V0z"></path><path d="m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z"></path><path d="m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z"></path></svg>,

  category: 'common',

  keywords: [
    'img', // "img" is not translated as it is intended to reflect the HTML <img> tag.
github WordPress / gutenberg / core-blocks / html / index.js View on Github external
},

	transforms: {
		from: [
			{
				type: 'raw',
				isMatch: ( node ) =&gt; node.nodeName === 'FIGURE' &amp;&amp; !! node.querySelector( 'iframe' ),
				schema: {
					figure: {
						require: [ 'iframe' ],
						children: {
							iframe: {
								attributes: [ 'src', 'allowfullscreen', 'height', 'width' ],
							},
							figcaption: {
								children: getPhrasingContentSchema(),
							},
						},
					},
				},
			},
		],
	},

	edit: withState( {
		isPreview: false,
	} )( ( { attributes, setAttributes, setState, isSelected, toggleSelection, isPreview } ) =&gt; (
		<div>
			
				<div>
					</div></div>
github WordPress / gutenberg / core-blocks / table / index.js View on Github external
/**
 * Internal dependencies
 */
import './editor.scss';
import './style.scss';
import TableBlock from './table-block';

const tableContentSchema = {
	tr: {
		children: {
			th: {
				children: getPhrasingContentSchema(),
			},
			td: {
				children: getPhrasingContentSchema(),
			},
		},
	},
};

const tableSchema = {
	table: {
		children: {
			thead: {
				children: tableContentSchema,
			},
			tfoot: {
				children: tableContentSchema,
			},
			tbody: {
				children: tableContentSchema,
github WordPress / gutenberg / packages / block-library / src / html / index.js View on Github external
},

	transforms: {
		from: [
			{
				type: 'raw',
				isMatch: ( node ) =&gt; node.nodeName === 'FIGURE' &amp;&amp; !! node.querySelector( 'iframe' ),
				schema: {
					figure: {
						require: [ 'iframe' ],
						children: {
							iframe: {
								attributes: [ 'src', 'allowfullscreen', 'height', 'width' ],
							},
							figcaption: {
								children: getPhrasingContentSchema(),
							},
						},
					},
				},
			},
		],
	},

	edit: edit,

	save( { attributes } ) {
		return { attributes.content };
	},
};
github godaddy-wordpress / coblocks / src / blocks / highlight / transforms.js View on Github external
type: 'block',
			blocks: [ 'core/paragraph' ],
			transform: ( { content } ) => {
				return createBlock( metadata.name, {
					content,
				} );
			},
		},
		{
			type: 'raw',
			selector: 'p.wp-block-coblocks-highlight',
			schema: {
				p: {
					children: {
						mark: {
							children: getPhrasingContentSchema(),
						},
					},
				},
			},
		},
		{
			type: 'prefix',
			prefix: ':highlight',
			transform: function( content ) {
				return createBlock( metadata.name, {
					content,
				} );
			},
		},
	],
	to: [
github WordPress / gutenberg / block-library / html / index.js View on Github external
},

	transforms: {
		from: [
			{
				type: 'raw',
				isMatch: ( node ) =&gt; node.nodeName === 'FIGURE' &amp;&amp; !! node.querySelector( 'iframe' ),
				schema: {
					figure: {
						require: [ 'iframe' ],
						children: {
							iframe: {
								attributes: [ 'src', 'allowfullscreen', 'height', 'width' ],
							},
							figcaption: {
								children: getPhrasingContentSchema(),
							},
						},
					},
				},
			},
		],
	},

	edit: withState( {
		isPreview: false,
	} )( ( { attributes, setAttributes, setState, isSelected, toggleSelection, isPreview } ) =&gt; (
		<div>
			
				<div>
					</div></div>
github WordPress / gutenberg / packages / block-library / src / heading / transforms.js View on Github external
const transforms = {
	from: [
		{
			type: 'block',
			blocks: [ 'core/paragraph' ],
			transform: ( { content } ) => {
				return createBlock( 'core/heading', {
					content,
				} );
			},
		},
		{
			type: 'raw',
			selector: 'h1,h2,h3,h4,h5,h6',
			schema: {
				h1: { children: getPhrasingContentSchema() },
				h2: { children: getPhrasingContentSchema() },
				h3: { children: getPhrasingContentSchema() },
				h4: { children: getPhrasingContentSchema() },
				h5: { children: getPhrasingContentSchema() },
				h6: { children: getPhrasingContentSchema() },
			},
			transform( node ) {
				return createBlock( 'core/heading', {
					...getBlockAttributes(
						'core/heading',
						node.outerHTML
					),
					level: getLevelFromHeadingNodeName( node.nodeName ),
				} );
			},
		},