diff --git a/client/cypress/e2e/frontend/modules/highlights.cy.ts b/client/cypress/e2e/frontend/modules/highlights.cy.ts index 106553ea..4465972d 100644 --- a/client/cypress/e2e/frontend/modules/highlights.cy.ts +++ b/client/cypress/e2e/frontend/modules/highlights.cy.ts @@ -201,4 +201,28 @@ describe('Highlights', () => { markText(); }); + + it('visits a module and highlights some text, then adds a note', () => { + cy.mockGraphqlOps({ + operations: { + ...operations, + ModuleDetailsQuery: { + module: getModule(defaultContents), + }, + }, + }); + + cy.visit('/module/my-module'); + + markText(); + cy.getByDataCy('highlight-note').click(); + cy.wait('@AddHighlight'); + const note = 'Some noteworthy stuff'; + cy.getByDataCy('highlight-note-input').should('have.value', '').type(note); + cy.getByDataCy('highlight-note-save').click(); + cy.wait('@UpdateHighlight'); + + cy.getByDataCy('highlight-note-save').should('not.exist'); + cy.getByDataCy('highlight-note-text').should('have.text', note); + }); }); diff --git a/client/cypress/fixtures/mocks.ts b/client/cypress/fixtures/mocks.ts index b4952d31..32d4e82a 100644 --- a/client/cypress/fixtures/mocks.ts +++ b/client/cypress/fixtures/mocks.ts @@ -118,4 +118,7 @@ export default { id: getInstrumentId(), bookmarks: null, }), + HighlightNode: () => ({ + note: null, + }), }; diff --git a/client/src/components/highlights/HighlightSidebar.vue b/client/src/components/highlights/HighlightSidebar.vue index 368ec93c..8760a7e9 100644 --- a/client/src/components/highlights/HighlightSidebar.vue +++ b/client/src/components/highlights/HighlightSidebar.vue @@ -22,19 +22,39 @@

Meine Notiz

-
+ +
+ +

+ {{ note }} +

+ Notiz bearbeiten +
@@ -58,10 +78,22 @@ const props = defineProps(); const highlightMark = ref(null); const Cross = defineAsyncComponent(() => import('@/components/icons/CrossIcon.vue')); +const inEditMode = ref(false); onMounted(() => { note.value = props.highlight.note?.text || ''; + // enable edit mode if note does not yet exist from a previous save + inEditMode.value = note.value == ''; }); + +const enableEditMode = () => { + inEditMode.value = true; +}; + +const save = () => { + emits('update-text', note.value); + inEditMode.value = false; +}; diff --git a/client/src/styles/css/typography.css b/client/src/styles/css/typography.css index 93e46c98..da338e3a 100644 --- a/client/src/styles/css/typography.css +++ b/client/src/styles/css/typography.css @@ -42,3 +42,8 @@ font-weight: var(--regular-font-weight); line-height: var(--paragraph-line-height); } + +.inline-title { + @reuse .regular-text; + color: var(--color-silver-dark); +} diff --git a/client/src/styles/css/variables.css b/client/src/styles/css/variables.css index 1bc6fe88..74587069 100644 --- a/client/src/styles/css/variables.css +++ b/client/src/styles/css/variables.css @@ -13,6 +13,7 @@ --color-white: #ffffff; --color-silver: #d0d0d0; + --color-silver-dark: #aaaaaa; --color-charcoal-dark: #333333; --sans-serif-font-family: 'Montserrat', Arial, sans-serif;