Skip to content

Bump codemirror from 5.65.16 to 6.0.2 in /jena-fuseki2/jena-fuseki-ui #2789

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jena-fuseki2/jena-fuseki-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"@zazuko/yasr": "^4.2.34",
"axios": "^1.6.1",
"bootstrap": "^5.3.2",
"codemirror": "5.65.16",
"codemirror": "6.0.2",
"codemirror-lang-turtle": "^0.0.2",
"follow-redirects": "^1.15.4",
"mitt": "^3.0.1",
"qs": "6.14.0",
Expand Down
57 changes: 41 additions & 16 deletions jena-fuseki2/jena-fuseki-ui/src/views/dataset/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@
<script>
import Menu from '@/components/dataset/Menu.vue'
import TableListing from '@/components/dataset/TableListing.vue'
import CodeMirror from 'codemirror'
import 'codemirror/mode/turtle/turtle'
import { EditorView, keymap, lineNumbers } from '@codemirror/view'
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands'
import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language'
import { turtle } from 'codemirror-lang-turtle'
import {
faTimes,
faCheck
Expand All @@ -144,6 +146,26 @@ library.add(faTimes, faCheck)

const MAX_EDITABLE_SIZE = 10000

/**
* In CodeMirror 5, the static CodeMirror.fromTextArea was used in Jena UI to
* sync an area in the page to the CodeMirror editor. That was removed in the
* 6.x release, https://codemirror.net/docs/migration/.
*
* @param textarea
* @param extensions
* @returns {EditorView}
*/
function editorFromTextArea(textarea, extensions) {
const view = new EditorView({doc: textarea.value, extensions})
textarea.parentNode.insertBefore(view.dom, textarea)
textarea.style.display = "none"
if (textarea.form) textarea.form.addEventListener("submit", () => {
textarea.value = view.state.doc.toString()
})
return view
}


export default {
name: 'DatasetEdit',

Expand Down Expand Up @@ -182,9 +204,13 @@ export default {
content: '',
code: '',
cmOptions: {
mode: 'text/turtle',
lineNumbers: true
// readOnly: 'nocursor'
extensions: [
lineNumbers(),
history(),
turtle(),
syntaxHighlighting(defaultHighlightStyle),
keymap.of([...defaultKeymap, ...historyKeymap])
]
}
}
},
Expand Down Expand Up @@ -218,9 +244,9 @@ export default {
services (newVal) {
if (newVal && newVal['gsp-rw'] && Object.keys(newVal['gsp-rw']).length > 0) {
const element = this.$refs['graph-editor']
this.codemirrorEditor = CodeMirror.fromTextArea(element, this.cmOptions)
this.codemirrorEditor.on('change', cm => {
this.content = cm.getValue()
this.codemirrorEditor = editorFromTextArea(element, this.cmOptions.extensions)
EditorView.updateListener.of(v => {
Copy link
Member

Choose a reason for hiding this comment

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

This was tough to understand how to fix. There was nothing in the docs of CodeMirror for migrating the code, no issues or anything obvious on their GH issue.

Luckily, found an example in CodeMirror forums for that: https://discuss.codemirror.net/t/listen-to-change-event/5095

this.content = v.getValue()
})
}
}
Expand All @@ -232,10 +258,13 @@ export default {

methods: {
codeChanged (newVal) {
const scrollInfo = this.codemirrorEditor.getScrollInfo()
this.codemirrorEditor.setValue(newVal)
this.content = newVal
this.codemirrorEditor.scrollTo(scrollInfo.left, scrollInfo.top)
this.codemirrorEditor.dispatch({
changes: {
from: 0,
to: this.codemirrorEditor.state.doc.length,
insert: newVal
}
})
},
listCurrentGraphs: async function () {
this.loadingGraphs = true
Expand Down Expand Up @@ -296,7 +325,3 @@ export default {
}
}
</script>

<style lang="scss">
@import '~codemirror';
</style>
2 changes: 1 addition & 1 deletion jena-fuseki2/jena-fuseki-ui/tests/e2e/specs/datasets.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('datasets', () => {
.click({ force: true })
cy.wait('@getGraph')
cy
.get('.CodeMirror-code')
.get('.cm-content')
.should('contain.text', 'Harry Potter and the Goblet of Fire')
})
it('Visits datasets page', () => {
Expand Down
123 changes: 119 additions & 4 deletions jena-fuseki2/jena-fuseki-ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,70 @@
resolved "https://registry.yarnpkg.com/@bufbuild/protobuf/-/protobuf-2.5.2.tgz#9b6cf005c50fdda72701da82f8db44635463d730"
integrity sha512-foZ7qr0IsUBjzWIq+SuBLfdQCpJ1j8cTuNNT4owngTHoN5KsJb8L9t65fzz7SCeSWzescoOil/0ldqiL041ABg==

"@codemirror/autocomplete@^6.0.0":
version "6.18.1"
resolved "https://registry.yarnpkg.com/@codemirror/autocomplete/-/autocomplete-6.18.1.tgz#3bd8d62c9c9a14d0706ab0a8adac139eaf1a41f1"
integrity sha512-iWHdj/B1ethnHRTwZj+C1obmmuCzquH29EbcKr0qIjA9NfDeBDJ7vs+WOHsFeLeflE4o+dHfYndJloMKHUkWUA==
dependencies:
"@codemirror/language" "^6.0.0"
"@codemirror/state" "^6.0.0"
"@codemirror/view" "^6.17.0"
"@lezer/common" "^1.0.0"

"@codemirror/commands@^6.0.0":
version "6.7.1"
resolved "https://registry.yarnpkg.com/@codemirror/commands/-/commands-6.7.1.tgz#04561e95bc0779eaa49efd63e916c4efb3bbf6d6"
integrity sha512-llTrboQYw5H4THfhN4U3qCnSZ1SOJ60ohhz+SzU0ADGtwlc533DtklQP0vSFaQuCPDn3BPpOd1GbbnUtwNjsrw==
dependencies:
"@codemirror/language" "^6.0.0"
"@codemirror/state" "^6.4.0"
"@codemirror/view" "^6.27.0"
"@lezer/common" "^1.1.0"

"@codemirror/language@^6.0.0":
version "6.10.3"
resolved "https://registry.yarnpkg.com/@codemirror/language/-/language-6.10.3.tgz#eb25fc5ade19032e7bf1dcaa957804e5f1660585"
integrity sha512-kDqEU5sCP55Oabl6E7m5N+vZRoc0iWqgDVhEKifcHzPzjqCegcO4amfrYVL9PmPZpl4G0yjkpTpUO/Ui8CzO8A==
dependencies:
"@codemirror/state" "^6.0.0"
"@codemirror/view" "^6.23.0"
"@lezer/common" "^1.1.0"
"@lezer/highlight" "^1.0.0"
"@lezer/lr" "^1.0.0"
style-mod "^4.0.0"

"@codemirror/lint@^6.0.0":
version "6.8.2"
resolved "https://registry.yarnpkg.com/@codemirror/lint/-/lint-6.8.2.tgz#7864b03583e9efd18554cff1dd4504da10338ab1"
integrity sha512-PDFG5DjHxSEjOXk9TQYYVjZDqlZTFaDBfhQixHnQOEVDDNHUbEh/hstAjcQJaA6FQdZTD1hquXTK0rVBLADR1g==
dependencies:
"@codemirror/state" "^6.0.0"
"@codemirror/view" "^6.0.0"
crelt "^1.0.5"

"@codemirror/search@^6.0.0":
version "6.5.6"
resolved "https://registry.yarnpkg.com/@codemirror/search/-/search-6.5.6.tgz#8f858b9e678d675869112e475f082d1e8488db93"
integrity sha512-rpMgcsh7o0GuCDUXKPvww+muLA1pDJaFrpq/CCHtpQJYz8xopu4D1hPcKRoDD0YlF8gZaqTNIRa4VRBWyhyy7Q==
dependencies:
"@codemirror/state" "^6.0.0"
"@codemirror/view" "^6.0.0"
crelt "^1.0.5"

"@codemirror/state@^6.0.0", "@codemirror/state@^6.4.0":
version "6.4.1"
resolved "https://registry.yarnpkg.com/@codemirror/state/-/state-6.4.1.tgz#da57143695c056d9a3c38705ed34136e2b68171b"
integrity sha512-QkEyUiLhsJoZkbumGZlswmAhA7CBU02Wrz7zvH4SrcifbsqwlXShVXg65f3v/ts57W3dqyamEriMhij1Z3Zz4A==

"@codemirror/view@^6.0.0", "@codemirror/view@^6.17.0", "@codemirror/view@^6.23.0", "@codemirror/view@^6.27.0":
version "6.34.1"
resolved "https://registry.yarnpkg.com/@codemirror/view/-/view-6.34.1.tgz#b17ed29c563e4adc60086233f2d3e7197e2dc33e"
integrity sha512-t1zK/l9UiRqwUNPm+pdIT0qzJlzuVckbTEMVNFhfWkGiBQClstzg+78vedCvLSX0xJEZ6lwZbPpnljL7L6iwMQ==
dependencies:
"@codemirror/state" "^6.4.0"
style-mod "^4.1.0"
w3c-keyname "^2.2.4"

"@csstools/color-helpers@^5.0.2":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@csstools/color-helpers/-/color-helpers-5.0.2.tgz#82592c9a7c2b83c293d9161894e2a6471feb97b8"
Expand Down Expand Up @@ -1197,6 +1261,25 @@
"@json2csv/formatters" "^7.0.6"
"@streamparser/json" "^0.0.20"

"@lezer/common@^1.0.0", "@lezer/common@^1.1.0":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@lezer/common/-/common-1.2.3.tgz#138fcddab157d83da557554851017c6c1e5667fd"
integrity sha512-w7ojc8ejBqr2REPsWxJjrMFsA/ysDCFICn8zEOR9mrqzOu2amhITYuLD8ag6XZf0CFXDrhKqw7+tW8cX66NaDA==

"@lezer/highlight@^1.0.0":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@lezer/highlight/-/highlight-1.2.1.tgz#596fa8f9aeb58a608be0a563e960c373cbf23f8b"
integrity sha512-Z5duk4RN/3zuVO7Jq0pGLJ3qynpxUVsh7IbUbGj88+uV2ApSAn6kWg2au3iJb+0Zi7kKtqffIESgNcRXWZWmSA==
dependencies:
"@lezer/common" "^1.0.0"

"@lezer/lr@^1.0.0":
version "1.4.2"
resolved "https://registry.yarnpkg.com/@lezer/lr/-/lr-1.4.2.tgz#931ea3dea8e9de84e90781001dae30dea9ff1727"
integrity sha512-pu0K1jCIdnQ12aWNaAVU5bzi7Bd1w54J3ECgANPmYLtQKP0HBj2cE/5coBD66MT10xbtIuUr7tg0Shbsvk0mDA==
dependencies:
"@lezer/common" "^1.0.0"

"@nodelib/[email protected]":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -2513,10 +2596,27 @@ cliui@^8.0.1:
strip-ansi "^6.0.1"
wrap-ansi "^7.0.0"

[email protected]:
version "5.65.16"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.65.16.tgz#efc0661be6bf4988a6a1c2fe6893294638cdb334"
integrity sha512-br21LjYmSlVL0vFCPWPfhzUCT34FM/pAdK7rRIZwa0rrtrIdotvP4Oh4GUHsu2E3IrQMCfRkL/fN3ytMNxVQvg==
codemirror-lang-turtle@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/codemirror-lang-turtle/-/codemirror-lang-turtle-0.0.2.tgz#2db4e56020b8defbbfa0788a85045404b494c957"
integrity sha512-YN9JzdxfUv2DKNHLZa8L7sG5StOri8ZHbMzY/zJhrq6pYR0peJaeN+GyQZaXl6fYmmq8hurf/BOqTYPh7Uzgcw==
dependencies:
"@codemirror/language" "^6.0.0"
"@lezer/highlight" "^1.0.0"
"@lezer/lr" "^1.0.0"

[email protected]:
version "6.0.2"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-6.0.2.tgz#4d3fea1ad60b6753f97ca835f2f48c6936a8946e"
integrity sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==
dependencies:
"@codemirror/autocomplete" "^6.0.0"
"@codemirror/commands" "^6.0.0"
"@codemirror/language" "^6.0.0"
"@codemirror/lint" "^6.0.0"
"@codemirror/search" "^6.0.0"
"@codemirror/state" "^6.0.0"
"@codemirror/view" "^6.0.0"

codemirror@^5.51.0:
version "5.65.19"
Expand Down Expand Up @@ -2709,6 +2809,11 @@ cors@^2.8.5:
object-assign "^4"
vary "^1"

crelt@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/crelt/-/crelt-1.0.6.tgz#7cc898ea74e190fb6ef9dae57f8f81cf7302df72"
integrity sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==

cross-env@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
Expand Down Expand Up @@ -6644,6 +6749,11 @@ strip-literal@^3.0.0:
dependencies:
js-tokens "^9.0.1"

style-mod@^4.0.0, style-mod@^4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/style-mod/-/style-mod-4.1.2.tgz#ca238a1ad4786520f7515a8539d5a63691d7bf67"
integrity sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==

supports-color@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
Expand Down Expand Up @@ -7174,6 +7284,11 @@ vue@^3.5.16:
"@vue/server-renderer" "3.5.16"
"@vue/shared" "3.5.16"

w3c-keyname@^2.2.4:
version "2.2.8"
resolved "https://registry.yarnpkg.com/w3c-keyname/-/w3c-keyname-2.2.8.tgz#7b17c8c6883d4e8b86ac8aba79d39e880f8869c5"
integrity sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==

w3c-xmlserializer@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz#f925ba26855158594d907313cedd1476c5967f6c"
Expand Down