Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 13, 2022
1 parent 215c125 commit 62cdd52
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/blocks/src/api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@ export function isUnmodifiedDefaultBlock( block ) {
const newDefaultBlock = isUnmodifiedDefaultBlock.block;
const blockType = getBlockType( defaultBlockName );

function valueOf( value ) {
return typeof value === 'object' ? value.valueOf() : value;
}

return every(
blockType?.attributes,
( value, key ) =>
newDefaultBlock.attributes[ key ] === block.attributes[ key ]
// Allow attribute value to specify primitive value to compare.
valueOf( newDefaultBlock.attributes[ key ] ) ===
valueOf( block.attributes[ key ] )
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useIndentListItemOnSpace } from './use-indent-list-item-on-space';
import { useInputAndSelection } from './use-input-and-selection';
import { useDelete } from './use-delete';

class RichTextValue extends String {
export class RichTextValue extends String {
constructor( { value } ) {
super( toHTMLString( ...arguments ) );

Expand Down
3 changes: 2 additions & 1 deletion packages/rich-text/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
OBJECT_REPLACEMENT_CHARACTER,
ZWNBSP,
} from './special-characters';
import { RichTextValue } from './component';

/**
* @typedef {Object} RichTextFormat
Expand Down Expand Up @@ -181,7 +182,7 @@ export function create( {
};
}

if ( typeof html === 'object' ) {
if ( html instanceof RichTextValue ) {
return html;
}

Expand Down

0 comments on commit 62cdd52

Please sign in to comment.