Skip to content

Commit

Permalink
Fixed several @sonarcloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leekelleher committed Sep 30, 2024
1 parent e41c1df commit 466435f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { type UmbBlockTypeBaseModel, UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';
import { UMB_BLOCK_RTE_TYPE } from '@umbraco-cms/backoffice/block-rte';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import { html, customElement, property, state, nothing } from '@umbraco-cms/backoffice/external/lit';
import {
UmbPropertyValueChangeEvent,
type UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { customElement, html, property, state, nothing } from '@umbraco-cms/backoffice/external/lit';
import { UmbInputBlockTypeElement } from '@umbraco-cms/backoffice/block-type';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UMB_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/workspace';
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor';
import { UMB_BLOCK_RTE_TYPE } from '@umbraco-cms/backoffice/block-rte';
import { UMB_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/workspace';
import type { UmbBlockTypeBaseModel } from '@umbraco-cms/backoffice/block-type';
import type {
UmbPropertyEditorUiElement,
UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';

/**
* @element umb-property-editor-ui-block-rte-type-configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { UmbServerFilePathUniqueSerializer } from '@umbraco-cms/backoffice/server-file-system';
import { customElement, html, property } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import { UmbServerFilePathUniqueSerializer } from '@umbraco-cms/backoffice/server-file-system';
import type {
UmbPropertyEditorConfigCollection,
UmbPropertyEditorUiElement,
} from '@umbraco-cms/backoffice/property-editor';
import type { UmbStylesheetInputElement } from '@umbraco-cms/backoffice/stylesheet';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { css, customElement, html, property, state, repeat } from '@umbraco-cms/backoffice/external/lit';
import { firstValueFrom } from '@umbraco-cms/backoffice/external/rxjs';
import { tinymce } from '@umbraco-cms/backoffice/external/tinymce';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbPropertyValueChangeEvent } from '@umbraco-cms/backoffice/property-editor';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import type { PropertyValueMap } from '@umbraco-cms/backoffice/external/lit';
import { customElement, css, html, property, state, repeat } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/property-editor';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { firstValueFrom } from '@umbraco-cms/backoffice/external/rxjs';
import {
UmbPropertyValueChangeEvent,
type UmbPropertyEditorConfigCollection,
import type {
UmbPropertyEditorUiElement,
UmbPropertyEditorConfigCollection,
} from '@umbraco-cms/backoffice/property-editor';
import { tinymce } from '@umbraco-cms/backoffice/external/tinymce';

const tinyIconSet = tinymce.IconManager.get('default');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um
];

@state()
private _extensions: Array<UmbTiptapExtensionApi> = [];
private readonly _extensions: Array<UmbTiptapExtensionApi> = [];

@property({ type: String })
override set value(value: string) {
Expand Down Expand Up @@ -312,9 +312,10 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um
}
}
.resize-cursor {
cursor: ew-resize;
cursor: col-resize;
.resize-cursor {
cursor: ew-resize;
cursor: col-resize;
}
}
}
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
extends UmbLitElement
implements UmbPropertyEditorUiElement
{
#inUse: Set<string> = new Set();
readonly #inUse: Set<string> = new Set();

#currentDragItem?: {
alias: string;
Expand Down Expand Up @@ -55,27 +55,27 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
});
}

#onDragStart = (event: DragEvent, alias: string, fromPos?: [number, number, number]) => {
#onDragStart(event: DragEvent, alias: string, fromPos?: [number, number, number]) {
event.dataTransfer!.effectAllowed = 'move';
this.#currentDragItem = { alias, fromPos };
};
}

#onDragOver = (event: DragEvent) => {
#onDragOver(event: DragEvent) {
event.preventDefault();
event.dataTransfer!.dropEffect = 'move';
};
}

#onDragEnd = (event: DragEvent) => {
#onDragEnd(event: DragEvent) {
event.preventDefault();
if (event.dataTransfer?.dropEffect === 'none') {
const { fromPos } = this.#currentDragItem ?? {};
if (!fromPos) return;

this.#removeItem(fromPos);
}
};
}

#onDrop = (event: DragEvent, toPos?: [number, number, number]) => {
#onDrop(event: DragEvent, toPos?: [number, number, number]) {
event.preventDefault();
const { alias, fromPos } = this.#currentDragItem ?? {};

Expand All @@ -93,9 +93,9 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
if (alias && toPos) {
this.#insertItem(alias, toPos);
}
};
}

#moveItem = (from: [number, number, number], to: [number, number, number]) => {
#moveItem(from: [number, number, number], to: [number, number, number]) {
const [rowIndex, groupIndex, itemIndex] = from;

// Get the item to move from the 'from' position
Expand All @@ -105,17 +105,17 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
this.#value[rowIndex][groupIndex].splice(itemIndex, 1);

this.#insertItem(itemToMove, to);
};
}

#insertItem = (alias: string, toPos: [number, number, number]) => {
#insertItem(alias: string, toPos: [number, number, number]) {
const [rowIndex, groupIndex, itemIndex] = toPos;

// Insert the item into the new position
const inserted = this.#value[rowIndex][groupIndex].splice(itemIndex, 0, alias);
inserted.forEach((alias) => this.#inUse.add(alias));

this.dispatchEvent(new UmbPropertyValueChangeEvent());
};
}

#removeItem(from: [number, number, number]) {
const [rowIndex, groupIndex, itemIndex] = from;
Expand All @@ -126,12 +126,12 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
this.dispatchEvent(new UmbPropertyValueChangeEvent());
}

#addGroup = (rowIndex: number, groupIndex: number) => {
#addGroup(rowIndex: number, groupIndex: number) {
this.#value[rowIndex].splice(groupIndex, 0, []);
this.dispatchEvent(new UmbPropertyValueChangeEvent());
};
}

#removeGroup = (rowIndex: number, groupIndex: number) => {
#removeGroup(rowIndex: number, groupIndex: number) {
if (this.#value[rowIndex].length > groupIndex) {
const removed = this.#value[rowIndex].splice(groupIndex, 1);
removed.forEach((group) => group.forEach((alias) => this.#inUse.delete(alias)));
Expand All @@ -143,14 +143,14 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
}

this.dispatchEvent(new UmbPropertyValueChangeEvent());
};
}

#addRow = (rowIndex: number) => {
#addRow(rowIndex: number) {
this.#value.splice(rowIndex, 0, [[]]);
this.dispatchEvent(new UmbPropertyValueChangeEvent());
};
}

#removeRow = (rowIndex: number) => {
#removeRow(rowIndex: number) {
if (this.#value.length > rowIndex) {
const removed = this.#value.splice(rowIndex, 1);
removed.forEach((row) => row.forEach((group) => group.forEach((alias) => this.#inUse.delete(alias))));
Expand All @@ -162,7 +162,7 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
}

this.dispatchEvent(new UmbPropertyValueChangeEvent());
};
}

override render() {
return html`
Expand Down Expand Up @@ -250,7 +250,7 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
`;
}

static override styles = [
static override readonly styles = [
UmbTextStyles,
css`
:host {
Expand Down

0 comments on commit 466435f

Please sign in to comment.