Skip to content

Commit

Permalink
fix custom extensions not loading because of eager rebuilds (#182)
Browse files Browse the repository at this point in the history
* fix custom extensions not loading because of eager rebuilds

* add changeset

* prettier

* add changeset

* prettier
  • Loading branch information
KonnorRogers authored May 18, 2024
1 parent 195f28e commit c64173a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-wombats-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rhino-editor": patch
---

Fixed a bug in the update lifecycles of RhinoEditor causing rebuilds to happen too frequently
9 changes: 5 additions & 4 deletions src/exports/elements/tip-tap-editor-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,6 @@ export class TipTapEditorBase extends BaseElement {
this.classList.add("rhino-editor");
}

if (changedProperties.has("serializer")) {
this.updateInputElementValue();
}

super.willUpdate(changedProperties);
}

Expand All @@ -328,12 +324,17 @@ export class TipTapEditorBase extends BaseElement {

if (
changedProperties.has("extensions") ||
changedProperties.has("serializer") ||
changedProperties.has("starterKitOptions") ||
changedProperties.has("translations")
) {
this.rebuildEditor();
}

if (changedProperties.has("serializer")) {
this.updateInputElementValue();
}

super.updated(changedProperties);
}

Expand Down
6 changes: 4 additions & 2 deletions src/exports/elements/tip-tap-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export class TipTapEditor extends TipTapEditorBase {
this.addEventListener("keydown", this.handleKeyboardDialogToggle);
}

protected willUpdate(changedProperties: PropertyValues<this>): void {
protected updated(changedProperties: PropertyValues<this>): void {
const returnValue = super.updated(changedProperties);
if (changedProperties.has("translations")) {
const { rhinoAttachment, rhinoPlaceholder } = this.starterKitOptions;
let shouldRebuild = Boolean(rhinoAttachment || rhinoPlaceholder);
Expand All @@ -168,7 +169,8 @@ export class TipTapEditor extends TipTapEditorBase {
this.rebuildEditor();
}
}
return super.willUpdate(changedProperties);

return returnValue;
}

/**
Expand Down

0 comments on commit c64173a

Please sign in to comment.