Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Oct 17, 2024
1 parent e6611a0 commit 1282c97
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 22 deletions.
15 changes: 9 additions & 6 deletions src/exports/elements/tip-tap-editor-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export class TipTapEditorBase extends BaseElement {
class: { reflect: true },
accept: { reflect: true },
serializer: { reflect: true },
deferInitialize: { type: Boolean, attribute: "defer-initialize", reflect: true },
deferInitialize: {
type: Boolean,
attribute: "defer-initialize",
reflect: true,
},

// Properties
editor: { state: true },
Expand Down Expand Up @@ -130,8 +134,7 @@ export class TipTapEditorBase extends BaseElement {
/**
* When the `defer-initialize` attribute is present, it will wait to start the TipTap editor until the attribute has been removed.
*/
deferInitialize = false

deferInitialize = false;

/**
* @internal
Expand Down Expand Up @@ -323,7 +326,7 @@ export class TipTapEditorBase extends BaseElement {
changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,
): void {
if (changedProperties.has("deferInitialize") && !this.deferInitialize) {
this.startEditor()
this.startEditor();
}

if (changedProperties.has("class")) {
Expand Down Expand Up @@ -399,11 +402,11 @@ export class TipTapEditorBase extends BaseElement {
this.classList.add("rhino-editor");

if (!this.deferInitialize) {
this.startEditor()
this.startEditor();
}
}

async startEditor () {
async startEditor() {
await this.updateComplete;

setTimeout(() => {
Expand Down
58 changes: 42 additions & 16 deletions src/exports/elements/tip-tap-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ export class TipTapEditor extends TipTapEditorBase {
/**
* @override
*/
async startEditor () {
await super.startEditor()
async startEditor() {
await super.startEditor();

if (this.editor) {
this.editor.on("focus", this.closeLinkDialog);
Expand Down Expand Up @@ -337,7 +337,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderBoldButton(prefix = "") {
const boldEnabled = this.starterKitOptions.bold !== false || Boolean(this.editor?.commands.toggleBold);
const boldEnabled =
this.starterKitOptions.bold !== false ||
Boolean(this.editor?.commands.toggleBold);

if (!boldEnabled) return html``;

Expand Down Expand Up @@ -389,7 +391,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderItalicButton(prefix = "") {
const italicEnabled = this.starterKitOptions.italic !== false || Boolean(this.editor?.commands.toggleItalic);
const italicEnabled =
this.starterKitOptions.italic !== false ||
Boolean(this.editor?.commands.toggleItalic);

if (!italicEnabled) return html``;

Expand Down Expand Up @@ -445,7 +449,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderStrikeButton(prefix = "") {
const strikeEnabled = this.starterKitOptions.rhinoStrike !== false || Boolean(this.editor?.commands.toggleStrike);
const strikeEnabled =
this.starterKitOptions.rhinoStrike !== false ||
Boolean(this.editor?.commands.toggleStrike);

if (!strikeEnabled) return html``;

Expand Down Expand Up @@ -500,7 +506,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderLinkButton(prefix = "") {
const linkEnabled = this.starterKitOptions.rhinoLink !== false || Boolean(this.editor?.commands.setLink);
const linkEnabled =
this.starterKitOptions.rhinoLink !== false ||
Boolean(this.editor?.commands.setLink);

if (!linkEnabled) return html``;

Expand Down Expand Up @@ -558,7 +566,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderHeadingButton(prefix = "") {
const headingEnabled = this.starterKitOptions.heading !== false || Boolean(this.editor?.commands.toggleHeading);
const headingEnabled =
this.starterKitOptions.heading !== false ||
Boolean(this.editor?.commands.toggleHeading);

if (!headingEnabled) return html``;

Expand Down Expand Up @@ -615,7 +625,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderBlockquoteButton(prefix = "") {
const blockQuoteEnabled = this.starterKitOptions.blockquote !== false || Boolean(this.editor?.commands.toggleBlockquote);
const blockQuoteEnabled =
this.starterKitOptions.blockquote !== false ||
Boolean(this.editor?.commands.toggleBlockquote);

if (!blockQuoteEnabled) return html``;

Expand Down Expand Up @@ -672,7 +684,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderCodeBlockButton(prefix = "") {
const codeBlockEnabled = this.starterKitOptions.codeBlock !== false || Boolean(this.editor?.commands.toggleCodeBlock);
const codeBlockEnabled =
this.starterKitOptions.codeBlock !== false ||
Boolean(this.editor?.commands.toggleCodeBlock);

if (!codeBlockEnabled) return html``;

Expand Down Expand Up @@ -728,7 +742,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderBulletListButton(prefix = "") {
const bulletListEnabled = this.starterKitOptions.bulletList !== false || Boolean(this.editor?.commands.toggleBulletList);
const bulletListEnabled =
this.starterKitOptions.bulletList !== false ||
Boolean(this.editor?.commands.toggleBulletList);

if (!bulletListEnabled) return html``;

Expand Down Expand Up @@ -791,7 +807,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderOrderedListButton(prefix = "") {
const orderedListEnabled = this.starterKitOptions.orderedList !== false || Boolean(this.editor?.commands.toggleOrderedList);
const orderedListEnabled =
this.starterKitOptions.orderedList !== false ||
Boolean(this.editor?.commands.toggleOrderedList);

if (!orderedListEnabled) return html``;

Expand Down Expand Up @@ -856,7 +874,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderAttachmentButton(prefix = "") {
const attachmentEnabled = this.starterKitOptions.rhinoAttachment !== false || Boolean(this.editor?.commands.setAttachment);
const attachmentEnabled =
this.starterKitOptions.rhinoAttachment !== false ||
Boolean(this.editor?.commands.setAttachment);

if (!attachmentEnabled) return html``;

Expand Down Expand Up @@ -917,7 +937,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderUndoButton(prefix = "") {
const undoEnabled = this.starterKitOptions.history !== false || Boolean(this.editor?.commands.undo);
const undoEnabled =
this.starterKitOptions.history !== false ||
Boolean(this.editor?.commands.undo);

if (!undoEnabled) return html``;

Expand Down Expand Up @@ -971,7 +993,8 @@ export class TipTapEditor extends TipTapEditorBase {
renderDecreaseIndentation(prefix = "") {
// Decrease / increase indentation are special cases in that they rely on built-in editor
// commands and not commands added by extensions.
const decreaseIndentationEnabled = this.starterKitOptions.decreaseIndentation !== false // || Boolean(this.editor?.commands.liftListItem);
const decreaseIndentationEnabled =
this.starterKitOptions.decreaseIndentation !== false; // || Boolean(this.editor?.commands.liftListItem);

if (!decreaseIndentationEnabled) return html``;

Expand Down Expand Up @@ -1027,7 +1050,8 @@ export class TipTapEditor extends TipTapEditorBase {
renderIncreaseIndentation(prefix = "") {
// Decrease / increase indentation are special cases in that they rely on built-in editor
// commands and not commands added by extensions.
const increaseIndentationEnabled = this.starterKitOptions.increaseIndentation !== false // || Boolean(this.editor?.commands.sinkListItem);
const increaseIndentationEnabled =
this.starterKitOptions.increaseIndentation !== false; // || Boolean(this.editor?.commands.sinkListItem);

if (!increaseIndentationEnabled) return html``;

Expand Down Expand Up @@ -1081,7 +1105,9 @@ export class TipTapEditor extends TipTapEditorBase {
}

renderRedoButton(prefix = "") {
const redoEnabled = this.starterKitOptions.history !== false || Boolean(this.editor?.commands.redo);
const redoEnabled =
this.starterKitOptions.history !== false ||
Boolean(this.editor?.commands.redo);

if (!redoEnabled) return html``;

Expand Down

0 comments on commit 1282c97

Please sign in to comment.