swap order and default to all extensions selected
This commit is contained in:
@@ -33,15 +33,14 @@ export class UmbPropertyEditorUiTiptapExtensionsConfigurationElement
|
||||
implements UmbPropertyEditorUiElement
|
||||
{
|
||||
@property({ attribute: false })
|
||||
set value(value: string[]) {
|
||||
if (!value) value = [];
|
||||
set value(value: string[] | undefined) {
|
||||
this.#value = value;
|
||||
}
|
||||
get value(): string[] {
|
||||
get value(): string[] | undefined {
|
||||
return this.#value;
|
||||
}
|
||||
|
||||
#value: string[] = [];
|
||||
#value?: string[] = [];
|
||||
|
||||
@property({ attribute: false })
|
||||
config?: UmbPropertyEditorConfigCollection;
|
||||
@@ -64,15 +63,23 @@ export class UmbPropertyEditorUiTiptapExtensionsConfigurationElement
|
||||
group: ext.meta.group,
|
||||
};
|
||||
});
|
||||
|
||||
if (!this.value) {
|
||||
// The default value is all extensions enabled
|
||||
this.#value = this._extensionConfigs.map((ext) => ext.alias);
|
||||
this.dispatchEvent(new UmbPropertyValueChangeEvent());
|
||||
}
|
||||
|
||||
this.#setupExtensionCategories();
|
||||
});
|
||||
}
|
||||
|
||||
#setupExtensionCategories() {
|
||||
const useDefault = !this.value; // The default value is all extensions enabled
|
||||
const withSelectedProperty = this._extensionConfigs.map((extensionConfig) => {
|
||||
return {
|
||||
...extensionConfig,
|
||||
selected: this.value.includes(extensionConfig.alias),
|
||||
selected: useDefault ? true : this.value!.includes(extensionConfig.alias),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -93,6 +100,10 @@ export class UmbPropertyEditorUiTiptapExtensionsConfigurationElement
|
||||
#onExtensionClick(item: ExtensionCategoryItem) {
|
||||
item.selected = !item.selected;
|
||||
|
||||
if (!this.value) {
|
||||
this.value = [];
|
||||
}
|
||||
|
||||
if (item.selected) {
|
||||
this.#value = [...this.value, item.alias];
|
||||
} else {
|
||||
|
||||
@@ -26,8 +26,12 @@ export class UmbPropertyEditorUiTiptapToolbarConfigurationElement
|
||||
implements UmbPropertyEditorUiElement
|
||||
{
|
||||
@property({ attribute: false })
|
||||
set value(value: string[][][]) {
|
||||
// TODO: Make sure that value has at least one row and one group
|
||||
set value(value: string[][][] | undefined) {
|
||||
if (!value) {
|
||||
this.#value = [[[]]];
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: This can be optimized with cashing;
|
||||
this.#value = value.map((rows) => rows.map((groups) => [...groups]));
|
||||
}
|
||||
|
||||
@@ -13,18 +13,18 @@ export const manifests: Array<ManifestTypes> = [
|
||||
group: 'richContent',
|
||||
settings: {
|
||||
properties: [
|
||||
{
|
||||
alias: 'extensions',
|
||||
label: 'Extensions',
|
||||
description: 'Extensions to enable',
|
||||
propertyEditorUiAlias: 'Umb.PropertyEditorUi.Tiptap.ExtensionsConfiguration',
|
||||
weight: 5,
|
||||
},
|
||||
{
|
||||
alias: 'toolbar',
|
||||
label: 'Toolbar',
|
||||
description: 'Pick the toolbar items that should be available when editing',
|
||||
propertyEditorUiAlias: 'Umb.PropertyEditorUi.Tiptap.ToolbarConfiguration',
|
||||
weight: 5,
|
||||
},
|
||||
{
|
||||
alias: 'extensions',
|
||||
label: 'Extensions',
|
||||
description: 'Extensions to enable',
|
||||
propertyEditorUiAlias: 'Umb.PropertyEditorUi.Tiptap.ExtensionsConfiguration',
|
||||
weight: 10,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user