Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to CodeMirror 6 #2058

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Upgrade to CodeMirror 6 #2058

wants to merge 16 commits into from

Conversation

grolu
Copy link
Contributor

@grolu grolu commented Aug 30, 2024

What this PR does / why we need it:
Upgrade CodeMirror 5 to CodeMirror 6

Which issue(s) this PR fixes:
Fixes #1892

Special notes for your reviewer:

Release note:

Upgraded the code editor from CodeMirror 5 to CodeMirror 6 to enhance performance, modernize the interface, and improve extensibility

 - upgrade to CM6
 - migrated editor line highlighter composable
TODO
 - code completion
 - test migration
@gardener-robot gardener-robot added needs/review Needs review size/xl Size of pull request is huge (see gardener-robot robot/bots/size.py) needs/second-opinion Needs second review by someone else labels Aug 30, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 30, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 30, 2024
@gardener-robot gardener-robot added the needs/rebase Needs git rebase label Sep 6, 2024
@gardener-robot
Copy link

@grolu You need rebase this pull request with latest master branch. Please check.

@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Sep 6, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Sep 9, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 10, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 10, 2024
- Restructured main scss theme dependant classes
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Sep 16, 2024
Make editor always consume 100% height
Cleaned-up some comments
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 16, 2024
@grolu grolu marked this pull request as ready for review September 16, 2024 16:26
@grolu grolu changed the title [DRAFT] Enh/upgrade cm 6 Upgrade to CodeMirror 6 Sep 16, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 16, 2024
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 16, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 16, 2024
let [startLine, endLine = startLine] = values
const [startLineCurrent, endLineCurrent] = valuesCurrent

if (endLine === startLine && startLine === startLineCurrent && !endLineCurrent) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had similar code in my PR where I introduce the feature to clear the selected line if the current selected line is clicked again, however holger propsed to use ESC-key instead to clear the selection. Clearing with ESC-key currently does not work anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. The problem here is that I did not find a way to add a key listener to the gutter. It is possible to add a key listener to the editor itself and clear the highlight on escape. However, the editor needs to be focused, so you would need to click inside the editor to make this work.
So I checked how Github does the highlighting and it does not clear the selection on escape, it works exactly like I implemented it now.

frontend/src/composables/useShootEditor/helper.js Outdated Show resolved Hide resolved
frontend/src/composables/useShootEditor/helper.js Outdated Show resolved Hide resolved
frontend/src/composables/useShootEditor/index.js Outdated Show resolved Hide resolved
frontend/src/composables/useShootEditor/index.js Outdated Show resolved Hide resolved
# Conflicts:
#	.pnp.cjs
#	.yarn/cache/codemirror-npm-5.65.18-debbbac10b-806e00c708.zip
#	frontend/src/composables/useShootEditor/helper.js
#	frontend/src/composables/useShootEditor/index.js
#	yarn.lock
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 24, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 24, 2024
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 24, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 24, 2024
@grolu grolu added the area/ipcei IPCEI (Important Project of Common European Interest) label Oct 14, 2024
@grolu grolu mentioned this pull request Oct 14, 2024
48 tasks
Copy link
Member

@petersutter petersutter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor things, otherwise /lgtm

frontend/src/composables/useShootEditor/helper.js Outdated Show resolved Hide resolved
frontend/src/composables/useShootEditor/helper.js Outdated Show resolved Hide resolved
<div v-bind="slotProps.props">
<g-action-button
size="x-small"
:icon="renderWhitespaces ? 'mdi-grid' : 'mdi-grid-off'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These icons are not intuitive to me. I would use these ones. We should use Hide and Show (not Render). And I think we can delete the tab icon in assets?

Screenshot 2024-10-15 at 17 22 40
Screenshot 2024-10-15 at 17 22 19

whitespace-eye
whitespace-eye-off

          <v-tooltip location="top">
            <template #activator="slotProps">
              <div v-bind="slotProps.props">
                <v-btn
                  variant="text"
                  size="x-small"
                  flat
                  icon
                  color="black"
                  @click="renderWhitespaces = !renderWhitespaces"
                >
                  <span v-html="renderWhitespaces ? whitespaceEye : whitespaceEyeOff" style="width: 18px; height: 18px"/>
                </v-btn>
              </div>
            </template>
            <span>{{ renderWhitespaces ? 'Hide' : 'Render' }} whitespaces</span>
          </v-tooltip>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petersutter WDYT?
Also, do you think we should render line breaks at all?
Moreover, the setting is not stored anywhere currently. Should we store the state in local storage?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the suggestion sounds good to me.

Also, do you think we should render line breaks at all?

I think we should not render the line breaks, it does not give much value

Moreover, the setting is not stored anywhere currently. Should we store the state in local storage?

hm, yes probably this should be stored in local storage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

  • removed the new line symbols.
  • included the proposed icons
  • store whitespace setting in local storage

frontend/src/composables/useEditorLineHighlighter.js Outdated Show resolved Hide resolved
frontend/src/composables/useEditorWhitespace.js Outdated Show resolved Hide resolved
frontend/src/composables/useEditorWhitespace.js Outdated Show resolved Hide resolved
frontend/src/composables/useShootEditor/helper.js Outdated Show resolved Hide resolved
frontend/src/composables/useShootEditor/helper.js Outdated Show resolved Hide resolved
frontend/src/sass/main.scss Outdated Show resolved Hide resolved
frontend/src/views/GNewShootEditor.vue Outdated Show resolved Hide resolved
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 17, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 17, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 17, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 17, 2024
- removed the new line symbols.
- included the proposed icons
- store whitespace setting in local storage
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Oct 18, 2024
@@ -246,6 +255,27 @@ const showToolbar = computed(() => {
return !isReadOnly.value && !props.hideToolbar
})

const whitespaceEye = computed(() => {
return `
<svg viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
Copy link
Member

@holgerkoser holgerkoser Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import the svg images from the assets folder.

import whitespaceEye from '@/assets/whitespace-eye.svg?raw'
import whitespaceEyeOff from '@/assets/whitespace-eye-off.svg?raw'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ipcei IPCEI (Important Project of Common European Interest) needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/rebase Needs git rebase needs/review Needs review needs/second-opinion Needs second review by someone else size/xl Size of pull request is huge (see gardener-robot robot/bots/size.py)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Codemirror v6
7 participants