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

Update codemirror to latest versions #2874

Merged
merged 6 commits into from
Mar 29, 2024
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
7 changes: 2 additions & 5 deletions frontend/components/CellInput/cell_movement_plugin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { EditorView, autocomplete, EditorState, keymap } from "../../imports/CodemirrorPlutoSetup.js"

// Why am I like this?
let completionState = autocomplete.autocompletion()[0]

/**
* Cell movement plugin!
*
Expand Down Expand Up @@ -148,8 +145,8 @@ export let prevent_holding_a_key_from_doing_things_across_cells = EditorView.dom

// Because of the "hacky" way this works, we need to check if autocompletion is open...
// else we'll block the ability to press ArrowDown for autocomplete....
// Adopted from https://github.com/codemirror/autocomplete/blob/a53f7ff19dc3a0412f3ce6e2751b08b610e1d762/src/view.ts#L15
let autocompletion_open = view.state.field(completionState, false)?.open ?? false

let autocompletion_open = autocomplete.completionStatus(view.state) === "active"

// If we have a cursor instead of a multicharacter selection:
if (event.key === "ArrowUp" && !autocompletion_open) {
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/CellInput/pluto_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
syntaxTree,
StateField,
StateEffect,
Transaction,
} from "../../imports/CodemirrorPlutoSetup.js"
import { get_selected_doc_from_state } from "./LiveDocsFromCursor.js"
import { cl } from "../../common/ClassTable.js"
Expand All @@ -25,7 +26,7 @@ let { autocompletion, completionKeymap, completionStatus, acceptCompletion } = a
const getActiveResult = (view, source) => view.state.field(completionState).active.find((a) => a.source == source)

// These should be imported from @codemirror/autocomplete, but they are not exported.
let completionState = autocompletion()[0]
let completionState = autocompletion()[1]
let applyCompletion = (/** @type {EditorView} */ view, option) => {
let apply = option.completion.apply || option.completion.label
let result = getActiveResult(view, option.source)
Expand All @@ -48,7 +49,7 @@ const tabCompletionState = StateField.define({
return false
},

update(value, tr) {
update(value, /** @type {Transaction} */ tr) {
// Tab was pressed
for (let effect of tr.effects) {
if (effect.is(TabCompletionEffect)) return true
Expand Down
9 changes: 0 additions & 9 deletions frontend/components/ExportBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ export const ExportBanner = ({ notebook_id, print_title, open, onClose, notebook
},
[print_title]
)
// https://github.com/codemirror/dev/issues/1354
useEventListener(
window.matchMedia("print"),
"change",
() => {
// window.dispatchEvent(new CustomEvent("beforeprint", { detail: { fake: true } }))
},
[]
)

const element_ref = useRef(/** @type {HTMLDialogElement?} */ (null))

Expand Down
1 change: 1 addition & 0 deletions frontend/components/Notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const Notebook = ({
}, render_cell_outputs_delay(notebook.cell_order.length))
}
}, [cell_outputs_delayed, notebook.cell_order.length])

let global_definition_locations = useMemo(
() =>
Object.fromEntries(
Expand Down
2 changes: 0 additions & 2 deletions frontend/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,6 @@ pluto-input .cm-editor {
border-bottom-right-radius: 4px;
border: 1px solid var(--normal-cell-color);
border-left: none;
transition: border-color 0.15s ease-in-out;

/* Make sure that scrolling an editor into view gives some breathing room */
scroll-margin-block: 20vh;
Expand Down Expand Up @@ -1523,7 +1522,6 @@ body:not(.___) pluto-cell.code_folded > pluto-trafficlight {
@media screen and (any-pointer: fine) {
body:not(.disable_ui) pluto-cell:hover > pluto-trafficlight {
background: var(--normal-cell-color);
transition: background 0.05s ease-in;
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/imports/CodemirrorPlutoSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {
linter,
setDiagnostics,
//@ts-ignore
} from "https://cdn.jsdelivr.net/gh/JuliaPluto/codemirror-pluto-setup@1234.2.0/dist/index.es.min.js"
} from "https://cdn.jsdelivr.net/gh/JuliaPluto/codemirror-pluto-setup@1234.3.0/dist/index.es.min.js"

export {
linter,
Expand Down
4 changes: 3 additions & 1 deletion test/frontend/helpers/pluto.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const waitForPlutoBusy = async (page, iWantBusiness, options) => {
// @ts-ignore
document?.body?._js_init_set?.size,
document?.body?.classList?.contains("loading"),
document.querySelector(`pluto-notebook:not(.animations_enabled)`),
document?.querySelector(`#process-status-tab-button.something_is_happening`)?.id,
document?.querySelector(`pluto-cell.running, pluto-cell.queued, pluto-cell.internal_test_queued`)?.id,
]
Expand All @@ -158,7 +159,8 @@ const waitForPlutoBusy = async (page, iWantBusiness, options) => {
(quiet_vals[1] ?? 0) === 0 &&
quiet_vals[2] === false &&
quiet_vals[3] == null &&
quiet_vals[4] == null
quiet_vals[4] == null &&
quiet_vals[5] == null

window["quiet_vals"] = quiet_vals

Expand Down
Loading