Skip to content

Commit

Permalink
Merge branch 'main' into release/15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
iOvergaard committed Oct 2, 2024
2 parents 9455934 + c2482c3 commit 8182b60
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"diff": "^5.2.0",
"dompurify": "^3.1.6",
"element-internals-polyfill": "^1.3.11",
"lit": "^3.1.4",
"lit": "^3.2.0",
"marked": "^14.1.0",
"monaco-editor": "^0.50.0",
"rxjs": "^7.8.1",
Expand Down Expand Up @@ -254,7 +254,7 @@
"@web/dev-server-rollup": "^0.6.4",
"@web/test-runner": "^0.18.3",
"@web/test-runner-playwright": "^0.11.0",
"babel-loader": "^9.1.3",
"babel-loader": "^9.2.1",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement

@property({ attribute: false })
set value(value: UmbTiptapToolbarValue | undefined) {
if (!value) {
if (!this.#isValidTiptapToolbarValue(value)) {
this.#value = [[[]]];
} else {
// TODO: This can be optimized with cashing;
this.#value = value ? value.map((rows) => rows.map((groups) => [...groups])) : [[[]]];
return;
}

if (value.length > 0) {
this.#value = value.map((rows) => rows.map((groups) => [...groups]));
value.forEach((row) => row.forEach((group) => group.forEach((alias) => this.#inUse.add(alias))));
}
}
get value(): UmbTiptapToolbarValue {
// TODO: This can be optimized with cashing;
return this.#value.map((rows) => rows.map((groups) => [...groups]));
return this.#value;
}
#value: UmbTiptapToolbarValue = [[[]]];

Expand All @@ -55,6 +56,20 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
});
}

#isValidTiptapToolbarValue(value: unknown): value is UmbTiptapToolbarValue {
if (!Array.isArray(value)) return false;
for (const row of value) {
if (!Array.isArray(row)) return false;
for (const group of row) {
if (!Array.isArray(group)) return false;
for (const alias of group) {
if (typeof alias !== 'string') return false;
}
}
}
return true;
}

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

0 comments on commit 8182b60

Please sign in to comment.