Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
title: 'Foo',
keywords: ['foo', 'bar', 'baz'],
object: false,
attributes: {
className: 'class',
myFoo: 'data-my-foo',
},
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 => `${match}bar`);
RT.replace(VALUE, /foo/, match => `${match}bar`);
keywords: ['foo', 'bar', 'baz'],
object: false,
attributes: {
className: 'class',
myFoo: 'data-my-foo',
},
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 => `${match}bar`);
RT.replace(VALUE, /foo/, match => `${match}bar`);
RT.replace(VALUE, 'foo', (match, a, b) => `${match} ${a} ${b}`);
object: false,
attributes: {
className: 'class',
myFoo: 'data-my-foo',
},
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 => `${match}bar`);
RT.replace(VALUE, /foo/, match => `${match}bar`);
RT.replace(VALUE, 'foo', (match, a, b) => `${match} ${a} ${b}`);
// Calling the merge to update the attributes and remove the block to be merged
const updatedAttributes = blockAType.merge(
cloneA.attributes,
blocksWithTheSameType[ 0 ].attributes
);
if ( hasTextSelection ) {
const newAttributeKey = findKey( updatedAttributes, ( v ) =>
typeof v === 'string' && v.indexOf( START_OF_SELECTED_AREA ) !== -1
);
const convertedHtml = updatedAttributes[ newAttributeKey ];
const multilineTag = blockAType.attributes[ newAttributeKey ].multiline;
const convertedValue = create( { html: convertedHtml, multilineTag } );
const newOffset = convertedValue.text.indexOf( START_OF_SELECTED_AREA );
const newValue = remove( convertedValue, newOffset, newOffset + 1 );
const newHtml = toHTMLString( { value: newValue, multilineTag } );
updatedAttributes[ newAttributeKey ] = newHtml;
dispatch( selectionChange(
blockA.clientId,
newAttributeKey,
newOffset,
newOffset
) );
}
dispatch( replaceBlocks(
[ blockA.clientId, blockB.clientId ],
[
{
const removeFootnote = ( value ) => {
const activeObject = getActiveObject( value );
if ( activeObject && activeObject.type === name ) {
return remove( value );
}
return removeFormat( value, name );
};
const textBefore = text.slice( 0, start - 1 );
const indexBefore = textBefore.lastIndexOf( BACKTICK );
if ( indexBefore === -1 ) {
return record;
}
const startIndex = indexBefore;
const endIndex = start - 2;
if ( startIndex === endIndex ) {
return record;
}
record = remove( record, startIndex, startIndex + 1 );
record = remove( record, endIndex, endIndex + 1 );
record = applyFormat( record, { type: 'code' }, startIndex, endIndex );
return record;
},
];
const textBefore = text.slice( 0, start - 1 );
const indexBefore = textBefore.lastIndexOf( BACKTICK );
if ( indexBefore === -1 ) {
return record;
}
const startIndex = indexBefore;
const endIndex = start - 2;
if ( startIndex === endIndex ) {
return record;
}
record = remove( record, startIndex, startIndex + 1 );
record = remove( record, endIndex, endIndex + 1 );
record = applyFormat( record, { type: 'code' }, startIndex, endIndex );
return record;
},
];
-1,
);
const indices = value.formats.reduce(
(arr, formats = [], idx) =>
formats.some(
f =>
f.type === NAME &&
get(f, ['attributes', 'id']) ===
activeId,
)
? [...arr, idx]
: arr,
[],
);
onChange(
remove(
value,
indices[0],
indices[indices.length - 1] + 1,
),
);
parseFootnotes();
} else {
setIsOpen(true);
}
}}
/>