How to use the @wordpress/rich-text.removeFormat function in @wordpress/rich-text

To help you get started, we’ve selected a few @wordpress/rich-text 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 DefinitelyTyped / DefinitelyTyped / types / wordpress__rich-text / wordpress__rich-text-tests.tsx View on Github external
edit(props) {
        return <span data-is-active="{props.isActive}">{props.value}</span>;
    },
});

//
// remove
//
RT.remove(VALUE);
RT.remove(VALUE, 10);
RT.remove(VALUE, 10, 20);

//
// removeFormat
//
RT.removeFormat(VALUE, 'foo');
RT.removeFormat(VALUE, 'foo', 10);

//
// replace
//
RT.replace(VALUE, 'foo', 'bar');
RT.replace(VALUE, /foo/, 'bar');
RT.replace(VALUE, 'foo', match =&gt; `${match}bar`);
RT.replace(VALUE, /foo/, match =&gt; `${match}bar`);
RT.replace(VALUE, 'foo', (match, a, b) =&gt; `${match} ${a} ${b}`);

//
// slice
//
RT.slice(VALUE);
RT.slice(VALUE, 10);
github DefinitelyTyped / DefinitelyTyped / types / wordpress__rich-text / wordpress__rich-text-tests.tsx View on Github external
return <span data-is-active="{props.isActive}">{props.value}</span>;
    },
});

//
// remove
//
RT.remove(VALUE);
RT.remove(VALUE, 10);
RT.remove(VALUE, 10, 20);

//
// removeFormat
//
RT.removeFormat(VALUE, 'foo');
RT.removeFormat(VALUE, 'foo', 10);

//
// replace
//
RT.replace(VALUE, 'foo', 'bar');
RT.replace(VALUE, /foo/, 'bar');
RT.replace(VALUE, 'foo', match =&gt; `${match}bar`);
RT.replace(VALUE, /foo/, match =&gt; `${match}bar`);
RT.replace(VALUE, 'foo', (match, a, b) =&gt; `${match} ${a} ${b}`);

//
// slice
//
RT.slice(VALUE);
RT.slice(VALUE, 10);
RT.slice(VALUE, 10, 20);
github gambitph / Stackable / src / format-types / highlight / index.js View on Github external
const createApplyFormat = ( textValue, colorType, textColor, highlightColor ) => {
	// Normal text color
	if ( colorType === '' ) {
		if ( ! textColor ) {
			return removeFormat(
				textValue,
				'ugb/highlight',
			)
		}

		return applyFormat(
			textValue,
			{
				type: 'ugb/highlight',
				attributes: {
					style: `color: ${ textColor };`,
				},
			}
		)
	}
github WordPress / gutenberg / packages / format-library / src / footnote / index.js View on Github external
const removeFootnote = ( value ) => {
	const activeObject = getActiveObject( value );

	if ( activeObject && activeObject.type === name ) {
		return remove( value );
	}

	return removeFormat( value, name );
};
github WordPress / gutenberg / packages / annotations / src / format / annotation.js View on Github external
export function removeAnnotations( record ) {
	return removeFormat( record, 'core/annotation', 0, record.text.length );
}
github ampproject / amp-wp / assets / src / stories-editor / formats / text-color / edit.js View on Github external
onChange={ ( color ) => {
									if ( color ) {
										onChange( applyFormat( value, {
											type: name,
											attributes: {
												style: `color:${ color }`,
											},
										} ) );

										return;
									}

									onChange( removeFormat( value, name ) );
								} }
							/>
github ampproject / amp-wp / assets / src / stories-editor / formats / background-color / edit.js View on Github external
onChange={ ( color ) => {
									if ( color ) {
										onChange( applyFormat( value, {
											type: name,
											attributes: {
												style: `background-color:${ color }`,
											},
										} ) );

										return;
									}

									onChange( removeFormat( value, name ) );
								} }
							/>
github WordPress / gutenberg / packages / format-library / src / link / index.native.js View on Github external
onRemoveFormat() {
			const { onChange, speak } = this.props;
			const linkSelection = this.getLinkSelection();

			onChange( removeFormat( linkSelection, name ) );
			speak( __( 'Link removed.' ), 'assertive' );
		}
github WordPress / gutenberg / packages / format-library / src / text-color / inline.js View on Github external
onChange={ ( color ) => {
						if ( color ) {
							const colorObject = getColorObjectByColorValue( colors, color );
							onChange(
								applyFormat( value, {
									type: name,
									attributes: colorObject ? {
										class: getColorClassName( 'color', colorObject.slug ),
									} : {
										style: `color:${ color }`,
									},
								} )
							);
						} else {
							onChange( removeFormat( value, name ) );
						}
					} }
				>