Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//
RT.create();
RT.create({ text: 'Hello World!' });
RT.create({ html: '<p>Hello World!</p><p>' });
RT.create({ element: document.createElement('div') });
RT.create({
element: document.createElement('div'),
multilineTag: 'p',
multilineWrapperTags: ['div', 'p'],
range: new Range(),
});
//
// getActiveFormat
//
RT.getActiveFormat(VALUE, 'foo');
//
// getActiveObject
//
RT.getActiveObject(VALUE);
//
// getTextContent
//
RT.getTextContent(VALUE);
//
// insert
//
RT.insert(VALUE, VALUE);
RT.insert(VALUE, VALUE, 10);</p>
getLinkSelection() {
const { value, isActive } = this.props;
const startFormat = getActiveFormat( value, 'core/link' );
// if the link isn't selected, get the link manually by looking around the cursor
// TODO: handle partly selected links
if ( startFormat && isCollapsed( value ) && isActive ) {
let startIndex = value.start;
let endIndex = value.end;
while ( find( value.formats[ startIndex ], startFormat ) ) {
startIndex--;
}
endIndex++;
while ( find( value.formats[ endIndex ], startFormat ) ) {
endIndex++;
}
const FormatEdit = ( { isActive, value, onChange } ) => {
let activeColor;
if ( isActive ) {
const activeFormat = getActiveFormat( value, name );
const style = activeFormat.attributes.style;
activeColor = style.replace( new RegExp( `^color:\\s*` ), '' );
}
return (
(
render() {
const {
name,
value,
onChange,
isActive,
addingColor,
} = this.props;
let activeColor;
const isDisableCustomColors = get( select( 'core/block-editor' ).getSettings(), [ 'disableCustomColors' ], false );
const colors = get( select( 'core/block-editor' ).getSettings(), [ 'colors' ], [] );
const activeColorFormat = getActiveFormat( value, name );
if ( activeColorFormat ) {
const styleColor = activeColorFormat.attributes.style;
if ( styleColor ) {
activeColor = styleColor.replace( new RegExp( `^color:\\s*` ), '' );
} else {
const currentClass = activeColorFormat.attributes.class;
if ( currentClass ) {
const colorSlug = currentClass.replace( /.*has-(.*?)-color.*/, '$1' );
activeColor = getColorObjectByAttributeValues( colors, colorSlug ).color;
}
}
}
return (
const FormatEdit = ( { isActive, value, onChange } ) => {
let activeColor;
if ( isActive ) {
const activeFormat = getActiveFormat( value, name );
const style = activeFormat.attributes.style;
activeColor = style.replace( new RegExp( `^background-color:\\s*` ), '' );
}
return (
(