Skip to content

Commit

Permalink
fix block break
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Oct 31, 2023
1 parent 08e96f0 commit 2ca25b9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { registerFormatType, create, insert } from '@wordpress/rich-text';
import { registerFormatType, create, insert, applyFormat, getActiveFormats } from '@wordpress/rich-text';
import {
Fragment,
useState,
Expand Down Expand Up @@ -51,11 +51,13 @@ registerFormatType( type, {
const { start, end } = value;

function insertCharacter( char ) {
const richTextCharacter = create( {
let richTextCharacter = create( {
text: char,
} );

richTextCharacter.formats = [ value.formats.at( start ) ];
for ( const format of getActiveFormats( value ) ) {
richTextCharacter = applyFormat( richTextCharacter, format, 0, 1 );
}

const modified = insert( value, richTextCharacter, start, end );

Expand Down

0 comments on commit 2ca25b9

Please sign in to comment.