From 5da0b43860ed63d53dbbad6210957a28b4890835 Mon Sep 17 00:00:00 2001 From: Tucsky Date: Tue, 29 Oct 2024 17:28:24 +0100 Subject: [PATCH] feat: markdown editor for indicators description --- package-lock.json | 4 +- src/assets/sass/editor.scss | 30 +++ src/components/chart/buildUtils.ts | 3 +- src/components/chart/chart.d.ts | 1 + src/components/chart/chart.ts | 13 +- src/components/framework/Dialog.vue | 12 +- src/components/framework/PromptDialog.vue | 48 ++++- src/components/framework/editor/Editor.vue | 44 +--- .../framework/editor/MarkdownEditor.vue | 204 ++++++++++++++++++ src/components/framework/editor/editor.ts | 39 ++++ src/components/indicators/IndicatorDetail.vue | 70 +++--- .../indicators/IndicatorPreview.vue | 8 + src/components/library/EditResourceDialog.vue | 31 ++- src/components/library/helpers.ts | 38 ++++ src/services/dialogService.ts | 4 +- src/services/importService.ts | 14 +- src/store/panesSettings/chart.ts | 2 +- 17 files changed, 456 insertions(+), 109 deletions(-) create mode 100644 src/assets/sass/editor.scss create mode 100644 src/components/framework/editor/MarkdownEditor.vue diff --git a/package-lock.json b/package-lock.json index 7ac3cd18..2124f8ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "aggr", - "version": "3.6.2", + "version": "3.6.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "aggr", - "version": "3.6.1", + "version": "3.6.3", "dependencies": { "@mdi/font": "^5.6.55", "@vue/eslint-config-typescript": "^11.0.3", diff --git a/src/assets/sass/editor.scss b/src/assets/sass/editor.scss new file mode 100644 index 00000000..3e718dbc --- /dev/null +++ b/src/assets/sass/editor.scss @@ -0,0 +1,30 @@ +.editor { + height: 100%; + min-height: 50px; + + .monaco-editor { + #app.-light & { + --vscode-editor-background: var(--theme-background-100); + --vscode-editorStickyScroll-background: var(--theme-background-100); + --vscode-editorStickyScrollHover-background: var(--theme-background-100); + --vscode-editorGutter-background: var(--theme-background-100); + } + + .minimap-shadow-visible { + box-shadow: rgb(0 0 0 / 10%) -6px 0 6px -6px inset; + } + + .scroll-decoration { + box-shadow: rgb(0 0 0 / 10%) 0 6px 6px -6px inset; + } + + .view-overlays .current-line { + border-color: var(--theme-background-100); + } + + .minimap { + left: auto !important; + right: 0 !important; + } + } +} \ No newline at end of file diff --git a/src/components/chart/buildUtils.ts b/src/components/chart/buildUtils.ts index 5efd0d7a..1d7e1e58 100644 --- a/src/components/chart/buildUtils.ts +++ b/src/components/chart/buildUtils.ts @@ -831,7 +831,8 @@ function parseReferences( references.push({ indicatorId, serieId, - plotIndex + plotIndex, + plotType: 'unknown' }) } diff --git a/src/components/chart/chart.d.ts b/src/components/chart/chart.d.ts index 7f5a9e5a..824177b8 100644 --- a/src/components/chart/chart.d.ts +++ b/src/components/chart/chart.d.ts @@ -108,6 +108,7 @@ export interface IndicatorReference { indicatorId: string serieId?: string plotIndex: number + plotType: string } export interface Renderer { minLength: number diff --git a/src/components/chart/chart.ts b/src/components/chart/chart.ts index b0b28073..99820ba6 100644 --- a/src/components/chart/chart.ts +++ b/src/components/chart/chart.ts @@ -1400,9 +1400,11 @@ export default class Chart { this.incrementRendererBar(temporaryRenderer) for (const id in computedSeries) { - computedSeries[id].push({ - time: temporaryRenderer.localTimestamp - }) + if (this.seriesIndicatorsMap[id].plotType !== 'broken-area') { + computedSeries[id].push({ + time: temporaryRenderer.localTimestamp + }) + } } barCount++ @@ -1475,7 +1477,7 @@ export default class Chart { } } - createIndicatorSeries(indicator) { + createIndicatorSeries(indicator: LoadedIndicator) { if (!indicator.model) { return } @@ -1501,7 +1503,8 @@ export default class Chart { this.seriesIndicatorsMap[plot.id] = { indicatorId: indicator.id, - plotIndex: i + plotIndex: i, + plotType: plot.type } series.push(plot.id) diff --git a/src/components/framework/Dialog.vue b/src/components/framework/Dialog.vue index 565a31db..13b4b2ac 100644 --- a/src/components/framework/Dialog.vue +++ b/src/components/framework/Dialog.vue @@ -183,7 +183,7 @@ export default class Dialog extends Vue { handleDrag(event) { if ( - this._handleTranslateRelease || + this._handleTranslateRelease || event.button === 2 || event.target.classList.contains('-no-grab') || event.target.parentElement.classList.contains('-no-grab') @@ -338,9 +338,15 @@ export default class Dialog extends Vue { } if (savePosition) { - this.savePosition(position) + if ( + typeof position.w === 'number' && + typeof position.h === 'number' && + (position.w !== this.position?.w || position.h !== this.position?.h) + ) { + this.$emit('resize') + } - this.$emit('resize') + this.savePosition(position) } if (this._persistTimeout) { diff --git a/src/components/framework/PromptDialog.vue b/src/components/framework/PromptDialog.vue index f8dfbdd2..515c0b28 100644 --- a/src/components/framework/PromptDialog.vue +++ b/src/components/framework/PromptDialog.vue @@ -1,12 +1,31 @@