mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
fix merging embedding options with default ones, closes #39
This commit is contained in:
@@ -48,6 +48,18 @@ export function getDefaultEmbeddingOptions(): EmbeddingOptions {
|
||||
return JSON.parse(JSON.stringify(defaultEmbeddingOptions));
|
||||
}
|
||||
|
||||
export function getMergedEmbeddingOptions(options: any, defaultOptions: any = defaultEmbeddingOptions): EmbeddingOptions {
|
||||
const mergedOptions = JSON.parse(JSON.stringify(defaultOptions));
|
||||
for (const key in options) {
|
||||
if (typeof options[key] === 'object' && options[key] !== null && !Array.isArray(options[key])) {
|
||||
mergedOptions[key] = getMergedEmbeddingOptions(options[key], defaultOptions[key]);
|
||||
} else {
|
||||
mergedOptions[key] = options[key];
|
||||
}
|
||||
}
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
export function getCleanedEmbeddingOptions(options: any, defaultOptions: any = defaultEmbeddingOptions): any {
|
||||
const cleanedOptions = JSON.parse(JSON.stringify(options));
|
||||
for (const key in cleanedOptions) {
|
||||
|
@@ -3,7 +3,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import Embedding from '$lib/components/embedding/Embedding.svelte';
|
||||
import {
|
||||
getDefaultEmbeddingOptions,
|
||||
getMergedEmbeddingOptions,
|
||||
type EmbeddingOptions
|
||||
} from '$lib/components/embedding/Embedding';
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
if (options === null) {
|
||||
return;
|
||||
}
|
||||
embeddingOptions = Object.assign(getDefaultEmbeddingOptions(), options);
|
||||
embeddingOptions = getMergedEmbeddingOptions(options);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user