Skip to content

Commit

Permalink
fix: crash on bullet list de-selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikrut committed Jul 6, 2021
1 parent 0075912 commit 5388513
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../../../../../../scss';
@import '../../../../../../../src/admin/scss/styles.scss';

.button-rich-text-button {
.btn {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../../../../../../scss';
@import '../../../../../../../src/admin/scss/styles.scss';

.rich-text-button {
margin: $baseline 0;
Expand Down
2 changes: 2 additions & 0 deletions src/admin/components/forms/field-types/RichText/RichText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ const RichText: React.FC<Props> = (props) => {
// do nothing
}
}

if (!valueToRender) valueToRender = defaultValue;

return (
<div
className={classes}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ const toggleElement = (editor, format) => {
const isActive = isElementActive(editor, format);
const isList = listTypes.includes(format);

Transforms.unwrapNodes(editor, {
match: (n) => listTypes.includes(n.type as string),
split: true,
});

let type = format;

if (isActive) {
Expand All @@ -24,6 +19,11 @@ const toggleElement = (editor, format) => {
Transforms.select(editor, editor.blurSelection);
}

Transforms.unwrapNodes(editor, {
match: (n) => listTypes.includes(n.type as string),
split: true,
});

Transforms.setNodes(editor, { type });

if (!isActive && isList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ const isLeafActive = (editor, format) => {
return leaves ? leaves[format] === true : false;
};


export default isLeafActive;

0 comments on commit 5388513

Please sign in to comment.