mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-09-20 10:05:57 +08:00
Use default prettier config for trailing commas
This commit is contained in:
parent
cf84dde559
commit
193f2193ad
|
@ -47,7 +47,7 @@ function connect() {
|
||||||
},
|
},
|
||||||
hooks: hooks,
|
hooks: hooks,
|
||||||
dom: morphdomOptions,
|
dom: morphdomOptions,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Show progress bar on live navigation and form submits
|
// Show progress bar on live navigation and form submits
|
||||||
|
|
|
@ -55,7 +55,7 @@ export function registerGlobalEventHandlers() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(
|
alert(
|
||||||
"Sorry, your browser does not support clipboard copy.\nThis generally requires a secure origin — either HTTPS or localhost."
|
"Sorry, your browser does not support clipboard copy.\nThis generally requires a secure origin — either HTTPS or localhost.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -82,25 +82,25 @@ export function registerGlobalEventHandlers() {
|
||||||
|
|
||||||
window.addEventListener("lb:session_list:on_selection_change", () => {
|
window.addEventListener("lb:session_list:on_selection_change", () => {
|
||||||
const anySessionSelected = !!document.querySelector(
|
const anySessionSelected = !!document.querySelector(
|
||||||
"[name='session_ids[]']:checked"
|
"[name='session_ids[]']:checked",
|
||||||
);
|
);
|
||||||
const disconnect = document.querySelector(
|
const disconnect = document.querySelector(
|
||||||
"#edit-sessions [name='disconnect']"
|
"#edit-sessions [name='disconnect']",
|
||||||
);
|
);
|
||||||
const closeAll = document.querySelector(
|
const closeAll = document.querySelector(
|
||||||
"#edit-sessions [name='close_all']"
|
"#edit-sessions [name='close_all']",
|
||||||
);
|
);
|
||||||
disconnect.parentElement.classList.toggle(
|
disconnect.parentElement.classList.toggle(
|
||||||
"pointer-events-none",
|
"pointer-events-none",
|
||||||
!anySessionSelected
|
!anySessionSelected,
|
||||||
);
|
);
|
||||||
disconnect.parentElement.classList.toggle(
|
disconnect.parentElement.classList.toggle(
|
||||||
"opacity-50",
|
"opacity-50",
|
||||||
!anySessionSelected
|
!anySessionSelected,
|
||||||
);
|
);
|
||||||
closeAll.parentElement.classList.toggle(
|
closeAll.parentElement.classList.toggle(
|
||||||
"pointer-events-none",
|
"pointer-events-none",
|
||||||
!anySessionSelected
|
!anySessionSelected,
|
||||||
);
|
);
|
||||||
closeAll.parentElement.classList.toggle("opacity-50", !anySessionSelected);
|
closeAll.parentElement.classList.toggle("opacity-50", !anySessionSelected);
|
||||||
});
|
});
|
||||||
|
@ -125,7 +125,7 @@ export function registerGlobalEventHandlers() {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ capture: true }
|
{ capture: true },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ const AudioInput = {
|
||||||
return encodePcmAsWav(
|
return encodePcmAsWav(
|
||||||
audioInfo.data,
|
audioInfo.data,
|
||||||
audioInfo.numChannels,
|
audioInfo.numChannels,
|
||||||
audioInfo.samplingRate
|
audioInfo.samplingRate,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -47,7 +47,7 @@ const Cell = {
|
||||||
|
|
||||||
if (["code", "smart"].includes(this.props.type)) {
|
if (["code", "smart"].includes(this.props.type)) {
|
||||||
const amplifyButton = this.el.querySelector(
|
const amplifyButton = this.el.querySelector(
|
||||||
`[data-el-amplify-outputs-button]`
|
`[data-el-amplify-outputs-button]`,
|
||||||
);
|
);
|
||||||
amplifyButton.addEventListener("click", (event) => {
|
amplifyButton.addEventListener("click", (event) => {
|
||||||
this.el.toggleAttribute("data-js-amplified");
|
this.el.toggleAttribute("data-js-amplified");
|
||||||
|
@ -56,7 +56,7 @@ const Cell = {
|
||||||
|
|
||||||
if (this.props.type === "smart") {
|
if (this.props.type === "smart") {
|
||||||
const toggleSourceButton = this.el.querySelector(
|
const toggleSourceButton = this.el.querySelector(
|
||||||
`[data-el-toggle-source-button]`
|
`[data-el-toggle-source-button]`,
|
||||||
);
|
);
|
||||||
toggleSourceButton.addEventListener("click", (event) => {
|
toggleSourceButton.addEventListener("click", (event) => {
|
||||||
this.el.toggleAttribute("data-js-source-visible");
|
this.el.toggleAttribute("data-js-source-visible");
|
||||||
|
@ -90,12 +90,12 @@ const Cell = {
|
||||||
this.subscriptions = [
|
this.subscriptions = [
|
||||||
globalPubsub.subscribe(
|
globalPubsub.subscribe(
|
||||||
"navigation",
|
"navigation",
|
||||||
this.handleNavigationEvent.bind(this)
|
this.handleNavigationEvent.bind(this),
|
||||||
),
|
),
|
||||||
globalPubsub.subscribe("cells", this.handleCellsEvent.bind(this)),
|
globalPubsub.subscribe("cells", this.handleCellsEvent.bind(this)),
|
||||||
globalPubsub.subscribe(
|
globalPubsub.subscribe(
|
||||||
`cells:${this.props.cellId}`,
|
`cells:${this.props.cellId}`,
|
||||||
this.handleCellEvent.bind(this)
|
this.handleCellEvent.bind(this),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ const Cell = {
|
||||||
this._handleViewportResize = this.handleViewportResize.bind(this);
|
this._handleViewportResize = this.handleViewportResize.bind(this);
|
||||||
window.visualViewport.addEventListener(
|
window.visualViewport.addEventListener(
|
||||||
"resize",
|
"resize",
|
||||||
this._handleViewportResize
|
this._handleViewportResize,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ const Cell = {
|
||||||
|
|
||||||
window.visualViewport.removeEventListener(
|
window.visualViewport.removeEventListener(
|
||||||
"resize",
|
"resize",
|
||||||
this._handleViewportResize
|
this._handleViewportResize,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ const Cell = {
|
||||||
// Setup markdown rendering
|
// Setup markdown rendering
|
||||||
if (this.props.type === "markdown") {
|
if (this.props.type === "markdown") {
|
||||||
const markdownContainer = this.el.querySelector(
|
const markdownContainer = this.el.querySelector(
|
||||||
`[data-el-markdown-container]`
|
`[data-el-markdown-container]`,
|
||||||
);
|
);
|
||||||
const markdown = new Markdown(markdownContainer, source, {
|
const markdown = new Markdown(markdownContainer, source, {
|
||||||
baseUrl: this.props.sessionPath,
|
baseUrl: this.props.sessionPath,
|
||||||
|
@ -240,7 +240,7 @@ const Cell = {
|
||||||
`evaluation_finished:${this.props.cellId}`,
|
`evaluation_finished:${this.props.cellId}`,
|
||||||
({ code_markers }) => {
|
({ code_markers }) => {
|
||||||
liveEditor.setCodeMarkers(code_markers);
|
liveEditor.setCodeMarkers(code_markers);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.handleEvent(`start_evaluation:${this.props.cellId}`, () => {
|
this.handleEvent(`start_evaluation:${this.props.cellId}`, () => {
|
||||||
|
@ -251,7 +251,7 @@ const Cell = {
|
||||||
`doctest_report:${this.props.cellId}`,
|
`doctest_report:${this.props.cellId}`,
|
||||||
(doctestReport) => {
|
(doctestReport) => {
|
||||||
liveEditor.updateDoctests([doctestReport]);
|
liveEditor.updateDoctests([doctestReport]);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.handleEvent(`erase_outputs`, () => {
|
this.handleEvent(`erase_outputs`, () => {
|
||||||
|
@ -288,7 +288,7 @@ const Cell = {
|
||||||
updateInsertModeAvailability() {
|
updateInsertModeAvailability() {
|
||||||
this.el.toggleAttribute(
|
this.el.toggleAttribute(
|
||||||
"data-js-insert-mode-disabled",
|
"data-js-insert-mode-disabled",
|
||||||
!this.currentEditor()
|
!this.currentEditor(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ const CellEditor = {
|
||||||
`cell_editor_init:${this.props.cellId}:${this.props.tag}`,
|
`cell_editor_init:${this.props.cellId}:${this.props.tag}`,
|
||||||
({ source, revision, doctest_reports, code_markers }) => {
|
({ source, revision, doctest_reports, code_markers }) => {
|
||||||
const editorContainer = this.el.querySelector(
|
const editorContainer = this.el.querySelector(
|
||||||
`[data-el-editor-container]`
|
`[data-el-editor-container]`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const editorEl = document.createElement("div");
|
const editorEl = document.createElement("div");
|
||||||
|
@ -20,7 +20,7 @@ const CellEditor = {
|
||||||
this.connection = new Connection(
|
this.connection = new Connection(
|
||||||
this,
|
this,
|
||||||
this.props.cellId,
|
this.props.cellId,
|
||||||
this.props.tag
|
this.props.tag,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.liveEditor = new LiveEditor(
|
this.liveEditor = new LiveEditor(
|
||||||
|
@ -30,7 +30,7 @@ const CellEditor = {
|
||||||
revision,
|
revision,
|
||||||
this.props.language,
|
this.props.language,
|
||||||
this.props.intellisense,
|
this.props.intellisense,
|
||||||
this.props.readOnly
|
this.props.readOnly,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.liveEditor.setCodeMarkers(code_markers);
|
this.liveEditor.setCodeMarkers(code_markers);
|
||||||
|
@ -48,7 +48,7 @@ const CellEditor = {
|
||||||
"whitespace-pre",
|
"whitespace-pre",
|
||||||
"text-editor",
|
"text-editor",
|
||||||
"font-editor",
|
"font-editor",
|
||||||
"px-12"
|
"px-12",
|
||||||
);
|
);
|
||||||
sourceEl.textContent = source;
|
sourceEl.textContent = source;
|
||||||
skeletonEl.replaceChildren(sourceEl);
|
skeletonEl.replaceChildren(sourceEl);
|
||||||
|
@ -62,7 +62,7 @@ const CellEditor = {
|
||||||
new CustomEvent("lb:cell:editor_created", {
|
new CustomEvent("lb:cell:editor_created", {
|
||||||
detail: { tag: this.props.tag, liveEditor: this.liveEditor },
|
detail: { tag: this.props.tag, liveEditor: this.liveEditor },
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.visibility = waitUntilInViewport(this.el, {
|
this.visibility = waitUntilInViewport(this.el, {
|
||||||
|
@ -76,7 +76,7 @@ const CellEditor = {
|
||||||
this.liveEditor.mount();
|
this.liveEditor.mount();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ const CellEditor = {
|
||||||
new CustomEvent("lb:cell:editor_removed", {
|
new CustomEvent("lb:cell:editor_removed", {
|
||||||
detail: { tag: this.props.tag },
|
detail: { tag: this.props.tag },
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
this.liveEditor.destroy();
|
this.liveEditor.destroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ export default class LiveEditor {
|
||||||
revision,
|
revision,
|
||||||
language,
|
language,
|
||||||
intellisense,
|
intellisense,
|
||||||
readOnly
|
readOnly,
|
||||||
) {
|
) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
@ -264,7 +264,7 @@ export default class LiveEditor {
|
||||||
const node = document.createElement("i");
|
const node = document.createElement("i");
|
||||||
node.classList.add(
|
node.classList.add(
|
||||||
open ? "ri-arrow-down-s-line" : "ri-arrow-right-s-line",
|
open ? "ri-arrow-down-s-line" : "ri-arrow-right-s-line",
|
||||||
open ? "cm-gutterFoldMarker-open" : null
|
open ? "cm-gutterFoldMarker-open" : null,
|
||||||
);
|
);
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
|
@ -351,7 +351,7 @@ export default class LiveEditor {
|
||||||
|
|
||||||
if (event.key === "Escape") {
|
if (event.key === "Escape") {
|
||||||
this.container.dispatchEvent(
|
this.container.dispatchEvent(
|
||||||
new CustomEvent("lb:editor_escape", { bubbles: true })
|
new CustomEvent("lb:editor_escape", { bubbles: true }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ export default class LiveEditor {
|
||||||
|
|
||||||
const replaceLength = replacedSuffixLength(
|
const replaceLength = replacedSuffixLength(
|
||||||
lineUntilCursor.text,
|
lineUntilCursor.text,
|
||||||
response.items[0].insert_text
|
response.items[0].insert_text,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -526,7 +526,7 @@ export default class LiveEditor {
|
||||||
setInitialWidgets() {
|
setInitialWidgets() {
|
||||||
if (this.initialWidgets.doctestReportsByLine) {
|
if (this.initialWidgets.doctestReportsByLine) {
|
||||||
const doctestReports = Object.values(
|
const doctestReports = Object.values(
|
||||||
this.initialWidgets.doctestReportsByLine
|
this.initialWidgets.doctestReportsByLine,
|
||||||
);
|
);
|
||||||
this.updateDoctests(doctestReports);
|
this.updateDoctests(doctestReports);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ const collabPlugin = ViewPlugin.fromClass(
|
||||||
update(update) {
|
update(update) {
|
||||||
// Skip changes dispatched by ourselves
|
// Skip changes dispatched by ourselves
|
||||||
const isRemoteChange = update.transactions.some((tr) =>
|
const isRemoteChange = update.transactions.some((tr) =>
|
||||||
tr.annotation(remoteTransaction)
|
tr.annotation(remoteTransaction),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isRemoteChange) return;
|
if (isRemoteChange) return;
|
||||||
|
@ -69,7 +69,7 @@ const collabPlugin = ViewPlugin.fromClass(
|
||||||
destroy() {
|
destroy() {
|
||||||
this.deltaSubscription.destroy();
|
this.deltaSubscription.destroy();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export function deltaToChanges(delta) {
|
export function deltaToChanges(delta) {
|
||||||
|
@ -136,8 +136,8 @@ export function transformSelection(selection, delta) {
|
||||||
const ranges = selection.ranges.map((range) =>
|
const ranges = selection.ranges.map((range) =>
|
||||||
EditorSelection.range(
|
EditorSelection.range(
|
||||||
delta.transformPosition(range.anchor),
|
delta.transformPosition(range.anchor),
|
||||||
delta.transformPosition(range.head)
|
delta.transformPosition(range.head),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return EditorSelection.create(ranges, selection.mainIndex);
|
return EditorSelection.create(ranges, selection.mainIndex);
|
||||||
|
|
|
@ -73,7 +73,7 @@ const collabMarkersPlugin = ViewPlugin.fromClass(
|
||||||
|
|
||||||
this.decorations = RangeSet.of(
|
this.decorations = RangeSet.of(
|
||||||
Object.values(this.peers).flatMap(decorationsForPeer),
|
Object.values(this.peers).flatMap(decorationsForPeer),
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.peersSubscription = collabClient.onPeersChange((peers) => {
|
this.peersSubscription = collabClient.onPeersChange((peers) => {
|
||||||
|
@ -118,7 +118,7 @@ const collabMarkersPlugin = ViewPlugin.fromClass(
|
||||||
this.peersSubscription.destroy();
|
this.peersSubscription.destroy();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ decorations: (plugin) => plugin.decorations }
|
{ decorations: (plugin) => plugin.decorations },
|
||||||
);
|
);
|
||||||
|
|
||||||
class CursorWidget extends WidgetType {
|
class CursorWidget extends WidgetType {
|
||||||
|
|
|
@ -72,11 +72,11 @@ const doctestsField = StateField.define({
|
||||||
decorations = decorations.update({
|
decorations = decorations.update({
|
||||||
filter: (from, to, decoration) => {
|
filter: (from, to, decoration) => {
|
||||||
return !reports.some(
|
return !reports.some(
|
||||||
(report) => decoration.spec.report.line === report.line
|
(report) => decoration.spec.report.line === report.line,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
add: reports.flatMap((report) =>
|
add: reports.flatMap((report) =>
|
||||||
decorationsForDoctest(report, tr.state.doc)
|
decorationsForDoctest(report, tr.state.doc),
|
||||||
),
|
),
|
||||||
sort: true,
|
sort: true,
|
||||||
});
|
});
|
||||||
|
@ -113,7 +113,7 @@ function decorationsForDoctest(report, doc) {
|
||||||
widget: new DoctestDetailsWidget(report),
|
widget: new DoctestDetailsWidget(report),
|
||||||
block: true,
|
block: true,
|
||||||
report,
|
report,
|
||||||
}).range(detailsLine.from)
|
}).range(detailsLine.from),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ const formatterPlugin = ViewPlugin.fromClass(
|
||||||
this.query = null;
|
this.query = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
function startFormat(view) {
|
function startFormat(view) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ const hintPlugin = ViewPlugin.fromClass(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
function closeHint(view) {
|
function closeHint(view) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ const characterSetsConfig = Facet.define({}).from(
|
||||||
triggerCharacters: new Set(triggerCharacters),
|
triggerCharacters: new Set(triggerCharacters),
|
||||||
// Note: all trigger characters are also retrigger characters
|
// Note: all trigger characters are also retrigger characters
|
||||||
retriggerCharacters: new Set(triggerCharacters.concat(retriggerCharacters)),
|
retriggerCharacters: new Set(triggerCharacters.concat(retriggerCharacters)),
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const setSignatureResultEffect = StateEffect.define();
|
const setSignatureResultEffect = StateEffect.define();
|
||||||
|
@ -139,7 +139,7 @@ function shouldRequestSignature(tr, isOpen) {
|
||||||
if (!tr.docChanged && startCursorPos !== cursorPos) {
|
if (!tr.docChanged && startCursorPos !== cursorPos) {
|
||||||
const movedOver = tr.state.doc.sliceString(
|
const movedOver = tr.state.doc.sliceString(
|
||||||
Math.min(startCursorPos, cursorPos),
|
Math.min(startCursorPos, cursorPos),
|
||||||
Math.max(startCursorPos, cursorPos)
|
Math.max(startCursorPos, cursorPos),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
|
@ -255,7 +255,7 @@ class SignatureTooltip {
|
||||||
this.contentLeft.textContent = item.signature.slice(0, idx);
|
this.contentLeft.textContent = item.signature.slice(0, idx);
|
||||||
this.contentActive.textContent = activeArgument;
|
this.contentActive.textContent = activeArgument;
|
||||||
this.contentRight.textContent = item.signature.slice(
|
this.contentRight.textContent = item.signature.slice(
|
||||||
idx + activeArgument.length
|
idx + activeArgument.length,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ const signaturePlugin = ViewPlugin.fromClass(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
function startSignature(view) {
|
function startSignature(view) {
|
||||||
|
@ -378,7 +378,7 @@ export function signature(
|
||||||
closeOnBlur = true,
|
closeOnBlur = true,
|
||||||
triggerCharacters = ["(", ","],
|
triggerCharacters = ["(", ","],
|
||||||
retriggerCharacters = [")"],
|
retriggerCharacters = [")"],
|
||||||
} = {}
|
} = {},
|
||||||
) {
|
) {
|
||||||
return [
|
return [
|
||||||
signatureField,
|
signatureField,
|
||||||
|
|
|
@ -415,7 +415,7 @@ function buildEditorTheme(colors, { dark }) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ dark }
|
{ dark },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ const editorTheme = buildEditorTheme(
|
||||||
searchMatchActiveBackground: "#54789e",
|
searchMatchActiveBackground: "#54789e",
|
||||||
separator: "#464b57",
|
separator: "#464b57",
|
||||||
},
|
},
|
||||||
{ dark: true }
|
{ dark: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
export const highlightStyle = buildHighlightStyle({
|
export const highlightStyle = buildHighlightStyle({
|
||||||
|
@ -532,7 +532,7 @@ const lightEditorTheme = buildEditorTheme(
|
||||||
searchMatchActiveBackground: "#9daeec",
|
searchMatchActiveBackground: "#9daeec",
|
||||||
separator: "#c9c9ca",
|
separator: "#c9c9ca",
|
||||||
},
|
},
|
||||||
{ dark: false }
|
{ dark: false },
|
||||||
);
|
);
|
||||||
|
|
||||||
export const lightHighlightStyle = buildHighlightStyle({
|
export const lightHighlightStyle = buildHighlightStyle({
|
||||||
|
|
|
@ -229,7 +229,7 @@ export default class CollabClient {
|
||||||
this.connection.sendDelta(
|
this.connection.sendDelta(
|
||||||
this.inflightDelta,
|
this.inflightDelta,
|
||||||
this.selection,
|
this.selection,
|
||||||
this.revision
|
this.revision,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.selectionChanged = false;
|
this.selectionChanged = false;
|
||||||
|
|
|
@ -130,14 +130,14 @@ export default class Connection {
|
||||||
delta = Delta.fromCompressed(delta);
|
delta = Delta.fromCompressed(delta);
|
||||||
selection = selection && selectionFromCompressed(selection);
|
selection = selection && selectionFromCompressed(selection);
|
||||||
this._onDelta.dispatch(delta, selection, client_id);
|
this._onDelta.dispatch(delta, selection, client_id);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.hook.handleEvent(
|
this.hook.handleEvent(
|
||||||
`cell_acknowledgement:${this.cellId}:${this.tag}`,
|
`cell_acknowledgement:${this.cellId}:${this.tag}`,
|
||||||
() => {
|
() => {
|
||||||
this._onAcknowledgement.dispatch();
|
this._onAcknowledgement.dispatch();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.hook.handleEvent(
|
this.hook.handleEvent(
|
||||||
|
@ -145,7 +145,7 @@ export default class Connection {
|
||||||
({ selection, client_id }) => {
|
({ selection, client_id }) => {
|
||||||
selection = selection && selectionFromCompressed(selection);
|
selection = selection && selectionFromCompressed(selection);
|
||||||
this._onSelection.dispatch(selection, client_id);
|
this._onSelection.dispatch(selection, client_id);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,19 +192,19 @@ export default class Connection {
|
||||||
} else {
|
} else {
|
||||||
reject(
|
reject(
|
||||||
new IntellisenseError(
|
new IntellisenseError(
|
||||||
"No relevant intellisense response for the given parameters"
|
"No relevant intellisense response for the given parameters",
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
reject(
|
reject(
|
||||||
new IntellisenseError(
|
new IntellisenseError(
|
||||||
"Intellisense request could not be completed"
|
"Intellisense request could not be completed",
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ function selectionToCompressed(selection) {
|
||||||
|
|
||||||
function selectionFromCompressed(list) {
|
function selectionFromCompressed(list) {
|
||||||
const ranges = list.map(([anchor, head]) =>
|
const ranges = list.map(([anchor, head]) =>
|
||||||
EditorSelection.range(anchor, head)
|
EditorSelection.range(anchor, head),
|
||||||
);
|
);
|
||||||
|
|
||||||
return EditorSelection.create(ranges);
|
return EditorSelection.create(ranges);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { settingsStore } from "../../../lib/settings";
|
||||||
export function highlight(code, language) {
|
export function highlight(code, language) {
|
||||||
const languageDesc = LanguageDescription.matchLanguageName(
|
const languageDesc = LanguageDescription.matchLanguageName(
|
||||||
languages,
|
languages,
|
||||||
language
|
language,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!languageDesc) {
|
if (!languageDesc) {
|
||||||
|
@ -28,7 +28,7 @@ export function highlight(code, language) {
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
html += "<br />";
|
html += "<br />";
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
|
|
@ -8,16 +8,16 @@ const CustomViewSettings = {
|
||||||
const settings = settingsStore.get();
|
const settings = settingsStore.get();
|
||||||
|
|
||||||
const customSectionCheckbox = this.el.querySelector(
|
const customSectionCheckbox = this.el.querySelector(
|
||||||
`[name="show_section"][value="true"]`
|
`[name="show_section"][value="true"]`,
|
||||||
);
|
);
|
||||||
const customMarkdownCheckbox = this.el.querySelector(
|
const customMarkdownCheckbox = this.el.querySelector(
|
||||||
`[name="show_markdown"][value="true"]`
|
`[name="show_markdown"][value="true"]`,
|
||||||
);
|
);
|
||||||
const customOutputCheckbox = this.el.querySelector(
|
const customOutputCheckbox = this.el.querySelector(
|
||||||
`[name="show_output"][value="true"]`
|
`[name="show_output"][value="true"]`,
|
||||||
);
|
);
|
||||||
const customSpotlightCheckbox = this.el.querySelector(
|
const customSpotlightCheckbox = this.el.querySelector(
|
||||||
`[name="spotlight"][value="true"]`
|
`[name="spotlight"][value="true"]`,
|
||||||
);
|
);
|
||||||
|
|
||||||
customSectionCheckbox.checked = settings.custom_view_show_section;
|
customSectionCheckbox.checked = settings.custom_view_show_section;
|
||||||
|
|
|
@ -12,19 +12,19 @@ const EditorSettings = {
|
||||||
const settings = settingsStore.get();
|
const settings = settingsStore.get();
|
||||||
|
|
||||||
const editorAutoCompletionCheckbox = this.el.querySelector(
|
const editorAutoCompletionCheckbox = this.el.querySelector(
|
||||||
`[name="editor_auto_completion"][value="true"]`
|
`[name="editor_auto_completion"][value="true"]`,
|
||||||
);
|
);
|
||||||
const editorAutoSignatureCheckbox = this.el.querySelector(
|
const editorAutoSignatureCheckbox = this.el.querySelector(
|
||||||
`[name="editor_auto_signature"][value="true"]`
|
`[name="editor_auto_signature"][value="true"]`,
|
||||||
);
|
);
|
||||||
const editorFontSizeCheckbox = this.el.querySelector(
|
const editorFontSizeCheckbox = this.el.querySelector(
|
||||||
`[name="editor_font_size"][value="true"]`
|
`[name="editor_font_size"][value="true"]`,
|
||||||
);
|
);
|
||||||
const editorLightThemeCheckbox = this.el.querySelector(
|
const editorLightThemeCheckbox = this.el.querySelector(
|
||||||
`[name="editor_light_theme"][value="true"]`
|
`[name="editor_light_theme"][value="true"]`,
|
||||||
);
|
);
|
||||||
const editorMarkdownWordWrapCheckbox = this.el.querySelector(
|
const editorMarkdownWordWrapCheckbox = this.el.querySelector(
|
||||||
`[name="editor_markdown_word_wrap"][value="true"]`
|
`[name="editor_markdown_word_wrap"][value="true"]`,
|
||||||
);
|
);
|
||||||
const editorMode = this.el.querySelector(`select[name="editor_mode"]`);
|
const editorMode = this.el.querySelector(`select[name="editor_mode"]`);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ const EmojiPicker = {
|
||||||
triggerElement: button,
|
triggerElement: button,
|
||||||
referenceElement: button,
|
referenceElement: button,
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
picker.addEventListener("emoji:select", ({ emoji }) => {
|
picker.addEventListener("emoji:select", ({ emoji }) => {
|
||||||
|
|
|
@ -28,7 +28,7 @@ const Headline = {
|
||||||
|
|
||||||
this.navigationSubscription = globalPubsub.subscribe(
|
this.navigationSubscription = globalPubsub.subscribe(
|
||||||
"navigation",
|
"navigation",
|
||||||
this.handleNavigationEvent.bind(this)
|
this.handleNavigationEvent.bind(this),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ const ImageInput = {
|
||||||
this.uploadButton = this.el.querySelector(`[data-btn-upload]`);
|
this.uploadButton = this.el.querySelector(`[data-btn-upload]`);
|
||||||
this.openCameraButton = this.el.querySelector(`[data-btn-open-camera]`);
|
this.openCameraButton = this.el.querySelector(`[data-btn-open-camera]`);
|
||||||
this.captureCameraButton = this.el.querySelector(
|
this.captureCameraButton = this.el.querySelector(
|
||||||
`[data-btn-capture-camera]`
|
`[data-btn-capture-camera]`,
|
||||||
);
|
);
|
||||||
this.cancelButton = this.el.querySelector(`[data-btn-cancel]`);
|
this.cancelButton = this.el.querySelector(`[data-btn-cancel]`);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ const ImageInput = {
|
||||||
const canvas = this.toCanvas(
|
const canvas = this.toCanvas(
|
||||||
this.cameraVideoEl,
|
this.cameraVideoEl,
|
||||||
this.cameraVideoEl.videoWidth,
|
this.cameraVideoEl.videoWidth,
|
||||||
this.cameraVideoEl.videoHeight
|
this.cameraVideoEl.videoHeight,
|
||||||
);
|
);
|
||||||
this.pushImage(canvas);
|
this.pushImage(canvas);
|
||||||
this.closeCameraView();
|
this.closeCameraView();
|
||||||
|
@ -153,7 +153,7 @@ const ImageInput = {
|
||||||
this.props.imageUrl,
|
this.props.imageUrl,
|
||||||
this.props.valueHeight,
|
this.props.valueHeight,
|
||||||
this.props.valueWidth,
|
this.props.valueWidth,
|
||||||
this.props.format
|
this.props.format,
|
||||||
).then((element) => {
|
).then((element) => {
|
||||||
this.setPreview(element);
|
this.setPreview(element);
|
||||||
});
|
});
|
||||||
|
@ -331,7 +331,7 @@ const ImageInput = {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
scaledWidth,
|
scaledWidth,
|
||||||
scaledHeight
|
scaledHeight,
|
||||||
);
|
);
|
||||||
} else if (this.props.fit === "crop") {
|
} else if (this.props.fit === "crop") {
|
||||||
const widthScale = boundWidth / width;
|
const widthScale = boundWidth / width;
|
||||||
|
@ -353,7 +353,7 @@ const ImageInput = {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
boundWidth,
|
boundWidth,
|
||||||
boundHeight
|
boundHeight,
|
||||||
);
|
);
|
||||||
} else if (this.props.fit === "pad") {
|
} else if (this.props.fit === "pad") {
|
||||||
const widthScale = boundWidth / width;
|
const widthScale = boundWidth / width;
|
||||||
|
@ -378,7 +378,7 @@ const ImageInput = {
|
||||||
Math.round((boundWidth - scaledWidth) / 2),
|
Math.round((boundWidth - scaledWidth) / 2),
|
||||||
Math.round((boundHeight - scaledHeight) / 2),
|
Math.round((boundHeight - scaledHeight) / 2),
|
||||||
scaledWidth,
|
scaledWidth,
|
||||||
scaledHeight
|
scaledHeight,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
canvas.width = boundWidth;
|
canvas.width = boundWidth;
|
||||||
|
@ -393,7 +393,7 @@ const ImageInput = {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
boundWidth,
|
boundWidth,
|
||||||
boundHeight
|
boundHeight,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ const ImageOutput = {
|
||||||
pixelBuffer,
|
pixelBuffer,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
channels
|
channels,
|
||||||
);
|
);
|
||||||
|
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
|
|
|
@ -104,7 +104,7 @@ const JSView = {
|
||||||
(raw) => {
|
(raw) => {
|
||||||
const [, payload] = transportDecode(raw);
|
const [, payload] = transportDecode(raw);
|
||||||
this.handleServerInit(payload);
|
this.handleServerInit(payload);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const eventRef = this.channel.on(`event:${this.props.ref}`, (raw) => {
|
const eventRef = this.channel.on(`event:${this.props.ref}`, (raw) => {
|
||||||
|
@ -116,7 +116,7 @@ const JSView = {
|
||||||
`error:${this.props.ref}`,
|
`error:${this.props.ref}`,
|
||||||
({ message, init }) => {
|
({ message, init }) => {
|
||||||
this.handleServerError(message, init);
|
this.handleServerError(message, init);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const pongRef = this.channel.on(`pong:${this.props.ref}`, () => {
|
const pongRef = this.channel.on(`pong:${this.props.ref}`, () => {
|
||||||
|
@ -133,11 +133,11 @@ const JSView = {
|
||||||
this.subscriptions = [
|
this.subscriptions = [
|
||||||
globalPubsub.subscribe(
|
globalPubsub.subscribe(
|
||||||
`js_views:${this.props.ref}`,
|
`js_views:${this.props.ref}`,
|
||||||
this.handleJSViewEvent.bind(this)
|
this.handleJSViewEvent.bind(this),
|
||||||
),
|
),
|
||||||
globalPubsub.subscribe(
|
globalPubsub.subscribe(
|
||||||
"navigation",
|
"navigation",
|
||||||
this.handleNavigationEvent.bind(this)
|
this.handleNavigationEvent.bind(this),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ const JSView = {
|
||||||
},
|
},
|
||||||
// If the client is very busy with executing JS we may reach the
|
// If the client is very busy with executing JS we may reach the
|
||||||
// default timeout of 10s, so we increase it
|
// default timeout of 10s, so we increase it
|
||||||
30_000
|
30_000,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ const JSView = {
|
||||||
|
|
||||||
const notebookEl = document.querySelector(`[data-el-notebook]`);
|
const notebookEl = document.querySelector(`[data-el-notebook]`);
|
||||||
const notebookContentEl = notebookEl.querySelector(
|
const notebookContentEl = notebookEl.querySelector(
|
||||||
`[data-el-notebook-content]`
|
`[data-el-notebook-content]`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Most placeholder position changes are accompanied by changes to the
|
// Most placeholder position changes are accompanied by changes to the
|
||||||
|
@ -244,13 +244,13 @@ const JSView = {
|
||||||
|
|
||||||
this.iframe.addEventListener("mouseenter", (event) => {
|
this.iframe.addEventListener("mouseenter", (event) => {
|
||||||
this.iframePlaceholder.dispatchEvent(
|
this.iframePlaceholder.dispatchEvent(
|
||||||
new MouseEvent("mouseenter", { bubbles: true })
|
new MouseEvent("mouseenter", { bubbles: true }),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.iframe.addEventListener("mouseleave", (event) => {
|
this.iframe.addEventListener("mouseleave", (event) => {
|
||||||
this.iframePlaceholder.dispatchEvent(
|
this.iframePlaceholder.dispatchEvent(
|
||||||
new MouseEvent("mouseleave", { bubbles: true })
|
new MouseEvent("mouseleave", { bubbles: true }),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ const JSView = {
|
||||||
// is later synced on "element_focused" events
|
// is later synced on "element_focused" events
|
||||||
this.iframe.toggleAttribute(
|
this.iframe.toggleAttribute(
|
||||||
"data-js-focused",
|
"data-js-focused",
|
||||||
!!this.el.closest(`[data-js-focused]`)
|
!!this.el.closest(`[data-js-focused]`),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
@ -308,7 +308,7 @@ const JSView = {
|
||||||
initializeIframeSource(
|
initializeIframeSource(
|
||||||
this.iframe,
|
this.iframe,
|
||||||
this.props.iframePort,
|
this.props.iframePort,
|
||||||
this.props.iframeUrl
|
this.props.iframeUrl,
|
||||||
).then(() => {
|
).then(() => {
|
||||||
iframesEl.appendChild(this.iframe);
|
iframesEl.appendChild(this.iframe);
|
||||||
});
|
});
|
||||||
|
@ -477,7 +477,7 @@ const JSView = {
|
||||||
|
|
||||||
this.iframe.toggleAttribute(
|
this.iframe.toggleAttribute(
|
||||||
"data-js-focused",
|
"data-js-focused",
|
||||||
focusableId === event.focusableId
|
focusableId === event.focusableId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -61,7 +61,7 @@ function verifyIframeSource(iframeUrl) {
|
||||||
.then((html) => {
|
.then((html) => {
|
||||||
if (sha256Base64(html) !== IFRAME_SHA256) {
|
if (sha256Base64(html) !== IFRAME_SHA256) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`The iframe loaded from ${iframeUrl} doesn't have the expected checksum ${IFRAME_SHA256}`
|
`The iframe loaded from ${iframeUrl} doesn't have the expected checksum ${IFRAME_SHA256}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -112,39 +112,39 @@ const Session = {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.getElement("clients-list").addEventListener("click", (event) =>
|
this.getElement("clients-list").addEventListener("click", (event) =>
|
||||||
this.handleClientsListClick(event)
|
this.handleClientsListClick(event),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("sections-list-toggle").addEventListener("click", (event) =>
|
this.getElement("sections-list-toggle").addEventListener("click", (event) =>
|
||||||
this.toggleSectionsList()
|
this.toggleSectionsList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("clients-list-toggle").addEventListener("click", (event) =>
|
this.getElement("clients-list-toggle").addEventListener("click", (event) =>
|
||||||
this.toggleClientsList()
|
this.toggleClientsList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("secrets-list-toggle").addEventListener("click", (event) =>
|
this.getElement("secrets-list-toggle").addEventListener("click", (event) =>
|
||||||
this.toggleSecretsList()
|
this.toggleSecretsList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("runtime-info-toggle").addEventListener("click", (event) =>
|
this.getElement("runtime-info-toggle").addEventListener("click", (event) =>
|
||||||
this.toggleRuntimeInfo()
|
this.toggleRuntimeInfo(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("app-info-toggle").addEventListener("click", (event) =>
|
this.getElement("app-info-toggle").addEventListener("click", (event) =>
|
||||||
this.toggleAppInfo()
|
this.toggleAppInfo(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("files-list-toggle").addEventListener("click", (event) =>
|
this.getElement("files-list-toggle").addEventListener("click", (event) =>
|
||||||
this.toggleFilesList()
|
this.toggleFilesList(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("notebook").addEventListener("scroll", (event) =>
|
this.getElement("notebook").addEventListener("scroll", (event) =>
|
||||||
this.updateSectionListHighlight()
|
this.updateSectionListHighlight(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("notebook-indicators").addEventListener("click", (event) =>
|
this.getElement("notebook-indicators").addEventListener("click", (event) =>
|
||||||
this.handleCellIndicatorsClick(event)
|
this.handleCellIndicatorsClick(event),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getElement("views").addEventListener("click", (event) => {
|
this.getElement("views").addEventListener("click", (event) => {
|
||||||
|
@ -153,7 +153,7 @@ const Session = {
|
||||||
|
|
||||||
this.getElement("section-toggle-collapse-all-button").addEventListener(
|
this.getElement("section-toggle-collapse-all-button").addEventListener(
|
||||||
"click",
|
"click",
|
||||||
(event) => this.toggleCollapseAllSections()
|
(event) => this.toggleCollapseAllSections(),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.initializeDragAndDrop();
|
this.initializeDragAndDrop();
|
||||||
|
@ -163,7 +163,7 @@ const Session = {
|
||||||
() => {
|
() => {
|
||||||
this.initializeFocus();
|
this.initializeFocus();
|
||||||
},
|
},
|
||||||
{ once: true }
|
{ once: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
// Server events
|
// Server events
|
||||||
|
@ -190,7 +190,7 @@ const Session = {
|
||||||
"cell_deleted",
|
"cell_deleted",
|
||||||
({ cell_id: cellId, sibling_cell_id: siblingCellId }) => {
|
({ cell_id: cellId, sibling_cell_id: siblingCellId }) => {
|
||||||
this.handleCellDeleted(cellId, siblingCellId);
|
this.handleCellDeleted(cellId, siblingCellId);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.handleEvent("cell_restored", ({ cell_id: cellId }) => {
|
this.handleEvent("cell_restored", ({ cell_id: cellId }) => {
|
||||||
|
@ -229,7 +229,7 @@ const Session = {
|
||||||
"secret_selected",
|
"secret_selected",
|
||||||
({ select_secret_ref, secret_name }) => {
|
({ select_secret_ref, secret_name }) => {
|
||||||
this.handleSecretSelected(select_secret_ref, secret_name);
|
this.handleSecretSelected(select_secret_ref, secret_name);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.handleEvent("location_report", ({ client_id, focusable_id }) => {
|
this.handleEvent("location_report", ({ client_id, focusable_id }) => {
|
||||||
|
@ -392,7 +392,7 @@ const Session = {
|
||||||
} else if (
|
} else if (
|
||||||
keyBuffer.tryMatch(["i"]) ||
|
keyBuffer.tryMatch(["i"]) ||
|
||||||
(event.target.matches(
|
(event.target.matches(
|
||||||
`body, [data-el-cell-body], [data-el-heading], [data-focusable-id]`
|
`body, [data-el-cell-body], [data-el-heading], [data-focusable-id]`,
|
||||||
) &&
|
) &&
|
||||||
this.focusedId &&
|
this.focusedId &&
|
||||||
key === "Enter")
|
key === "Enter")
|
||||||
|
@ -493,7 +493,7 @@ const Session = {
|
||||||
editableElementClicked(event, focusableEl) {
|
editableElementClicked(event, focusableEl) {
|
||||||
if (focusableEl) {
|
if (focusableEl) {
|
||||||
const editableElement = event.target.closest(
|
const editableElement = event.target.closest(
|
||||||
`[data-el-editor-container], [data-el-heading]`
|
`[data-el-editor-container], [data-el-heading]`,
|
||||||
);
|
);
|
||||||
return editableElement && focusableEl.contains(editableElement);
|
return editableElement && focusableEl.contains(editableElement);
|
||||||
}
|
}
|
||||||
|
@ -530,12 +530,12 @@ const Session = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const evalButton = event.target.closest(
|
const evalButton = event.target.closest(
|
||||||
`[data-el-queue-cell-evaluation-button]`
|
`[data-el-queue-cell-evaluation-button]`,
|
||||||
);
|
);
|
||||||
if (evalButton) {
|
if (evalButton) {
|
||||||
const cellId = evalButton.getAttribute("data-cell-id");
|
const cellId = evalButton.getAttribute("data-cell-id");
|
||||||
const disableDependenciesCache = evalButton.hasAttribute(
|
const disableDependenciesCache = evalButton.hasAttribute(
|
||||||
"data-disable-dependencies-cache"
|
"data-disable-dependencies-cache",
|
||||||
);
|
);
|
||||||
this.queueCellEvaluation(cellId, disableDependenciesCache);
|
this.queueCellEvaluation(cellId, disableDependenciesCache);
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,7 @@ const Session = {
|
||||||
history.pushState(
|
history.pushState(
|
||||||
null,
|
null,
|
||||||
document.title,
|
document.title,
|
||||||
window.location.pathname + window.location.search
|
window.location.pathname + window.location.search,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -584,7 +584,7 @@ const Session = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const clientFollowToggle = event.target.closest(
|
const clientFollowToggle = event.target.closest(
|
||||||
`[data-el-client-follow-toggle]`
|
`[data-el-client-follow-toggle]`,
|
||||||
);
|
);
|
||||||
if (clientFollowToggle) {
|
if (clientFollowToggle) {
|
||||||
this.handleClientFollowToggleClick(clientId, clientListItem);
|
this.handleClientFollowToggleClick(clientId, clientListItem);
|
||||||
|
@ -598,7 +598,7 @@ const Session = {
|
||||||
|
|
||||||
handleClientFollowToggleClick(clientId, clientListItem) {
|
handleClientFollowToggleClick(clientId, clientListItem) {
|
||||||
const followedClientListItem = this.el.querySelector(
|
const followedClientListItem = this.el.querySelector(
|
||||||
`[data-el-clients-list-item][data-js-followed]`
|
`[data-el-clients-list-item][data-js-followed]`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (followedClientListItem) {
|
if (followedClientListItem) {
|
||||||
|
@ -666,7 +666,7 @@ const Session = {
|
||||||
*/
|
*/
|
||||||
updateSectionListHighlight() {
|
updateSectionListHighlight() {
|
||||||
const currentListItem = this.el.querySelector(
|
const currentListItem = this.el.querySelector(
|
||||||
`[data-el-sections-list-item][data-js-is-viewed]`
|
`[data-el-sections-list-item][data-js-is-viewed]`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (currentListItem) {
|
if (currentListItem) {
|
||||||
|
@ -685,7 +685,7 @@ const Session = {
|
||||||
if (viewedSection) {
|
if (viewedSection) {
|
||||||
const sectionId = viewedSection.getAttribute("data-section-id");
|
const sectionId = viewedSection.getAttribute("data-section-id");
|
||||||
const listItem = this.el.querySelector(
|
const listItem = this.el.querySelector(
|
||||||
`[data-el-sections-list-item][data-section-id="${sectionId}"]`
|
`[data-el-sections-list-item][data-section-id="${sectionId}"]`,
|
||||||
);
|
);
|
||||||
listItem.setAttribute("data-js-is-viewed", "");
|
listItem.setAttribute("data-js-is-viewed", "");
|
||||||
}
|
}
|
||||||
|
@ -778,7 +778,7 @@ const Session = {
|
||||||
|
|
||||||
this.handleEvent("finish_file_drop", (event) => {
|
this.handleEvent("finish_file_drop", (event) => {
|
||||||
const inputEl = document.querySelector(
|
const inputEl = document.querySelector(
|
||||||
`#add-file-entry-modal input[type="file"]`
|
`#add-file-entry-modal input[type="file"]`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (inputEl) {
|
if (inputEl) {
|
||||||
|
@ -966,7 +966,7 @@ const Session = {
|
||||||
if (focusableIds.length > 0) {
|
if (focusableIds.length > 0) {
|
||||||
this.insertCellBelowFocusableId(
|
this.insertCellBelowFocusableId(
|
||||||
focusableIds[focusableIds.length - 1],
|
focusableIds[focusableIds.length - 1],
|
||||||
type
|
type,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1097,7 +1097,7 @@ const Session = {
|
||||||
showOutput: settings.custom_view_show_output,
|
showOutput: settings.custom_view_show_output,
|
||||||
spotlight: settings.custom_view_spotlight,
|
spotlight: settings.custom_view_spotlight,
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.pushEvent("open_custom_view_settings");
|
this.pushEvent("open_custom_view_settings");
|
||||||
|
@ -1162,7 +1162,7 @@ const Session = {
|
||||||
|
|
||||||
toggleCollapseAllSections() {
|
toggleCollapseAllSections() {
|
||||||
const allCollapsed = this.getSections().every((section) =>
|
const allCollapsed = this.getSections().every((section) =>
|
||||||
section.hasAttribute("data-js-collapsed")
|
section.hasAttribute("data-js-collapsed"),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.getSections().forEach((section) => {
|
this.getSections().forEach((section) => {
|
||||||
|
@ -1338,7 +1338,7 @@ const Session = {
|
||||||
ensureVisibleFocusableEl(cellId) {
|
ensureVisibleFocusableEl(cellId) {
|
||||||
const focusableEl = this.getFocusableEl(cellId);
|
const focusableEl = this.getFocusableEl(cellId);
|
||||||
const allFocusableEls = Array.from(
|
const allFocusableEls = Array.from(
|
||||||
this.el.querySelectorAll(`[data-focusable-id]`)
|
this.el.querySelectorAll(`[data-focusable-id]`),
|
||||||
);
|
);
|
||||||
const idx = allFocusableEls.indexOf(focusableEl);
|
const idx = allFocusableEls.indexOf(focusableEl);
|
||||||
const visibleSibling = [
|
const visibleSibling = [
|
||||||
|
@ -1370,13 +1370,13 @@ const Session = {
|
||||||
|
|
||||||
getFocusableEls() {
|
getFocusableEls() {
|
||||||
return Array.from(this.el.querySelectorAll(`[data-focusable-id]`)).filter(
|
return Array.from(this.el.querySelectorAll(`[data-focusable-id]`)).filter(
|
||||||
(el) => !isElementHidden(el)
|
(el) => !isElementHidden(el),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFocusableIds() {
|
getFocusableIds() {
|
||||||
return this.getFocusableEls().map((el) =>
|
return this.getFocusableEls().map((el) =>
|
||||||
el.getAttribute("data-focusable-id")
|
el.getAttribute("data-focusable-id"),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1397,7 +1397,7 @@ const Session = {
|
||||||
|
|
||||||
getSectionById(sectionId) {
|
getSectionById(sectionId) {
|
||||||
return this.el.querySelector(
|
return this.el.querySelector(
|
||||||
`[data-el-section][data-section-id="${sectionId}"]`
|
`[data-el-section][data-section-id="${sectionId}"]`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ const VirtualizedLines = {
|
||||||
|
|
||||||
const height = Math.min(
|
const height = Math.min(
|
||||||
this.props.maxHeight,
|
this.props.maxHeight,
|
||||||
this.lineHeight * numberOfLines
|
this.lineHeight * numberOfLines,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -127,7 +127,7 @@ const VirtualizedLines = {
|
||||||
capLines() {
|
capLines() {
|
||||||
if (this.props.maxLines) {
|
if (this.props.maxLines) {
|
||||||
const lineEls = Array.from(
|
const lineEls = Array.from(
|
||||||
this.templateEl.querySelectorAll("[data-line]")
|
this.templateEl.querySelectorAll("[data-line]"),
|
||||||
);
|
);
|
||||||
const ignoredLineEls = lineEls.slice(0, -this.props.maxLines);
|
const ignoredLineEls = lineEls.slice(0, -this.props.maxLines);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ export function parseHookProps(element, names) {
|
||||||
|
|
||||||
if (!element.hasAttribute(attr)) {
|
if (!element.hasAttribute(attr)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Missing attribute "${attr}" on element <${element.tagName}:${element.id}>`
|
`Missing attribute "${attr}" on element <${element.tagName}:${element.id}>`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,14 @@ export function encodeAnnotatedBuffer(meta, buffer) {
|
||||||
const metaArray = encoder.encode(JSON.stringify(meta));
|
const metaArray = encoder.encode(JSON.stringify(meta));
|
||||||
|
|
||||||
const raw = new ArrayBuffer(
|
const raw = new ArrayBuffer(
|
||||||
HEADER_LENGTH + metaArray.byteLength + buffer.byteLength
|
HEADER_LENGTH + metaArray.byteLength + buffer.byteLength,
|
||||||
);
|
);
|
||||||
const view = new DataView(raw);
|
const view = new DataView(raw);
|
||||||
|
|
||||||
view.setUint32(0, metaArray.byteLength);
|
view.setUint32(0, metaArray.byteLength);
|
||||||
new Uint8Array(raw, HEADER_LENGTH, metaArray.byteLength).set(metaArray);
|
new Uint8Array(raw, HEADER_LENGTH, metaArray.byteLength).set(metaArray);
|
||||||
new Uint8Array(raw, HEADER_LENGTH + metaArray.byteLength).set(
|
new Uint8Array(raw, HEADER_LENGTH + metaArray.byteLength).set(
|
||||||
new Uint8Array(buffer)
|
new Uint8Array(buffer),
|
||||||
);
|
);
|
||||||
|
|
||||||
return raw;
|
return raw;
|
||||||
|
|
|
@ -130,7 +130,7 @@ export default class Delta {
|
||||||
transform(other, priority) {
|
transform(other, priority) {
|
||||||
if (priority !== "left" && priority !== "right") {
|
if (priority !== "left" && priority !== "right") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Invalid priority "${priority}", should be either "left" or "right"`
|
`Invalid priority "${priority}", should be either "left" or "right"`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Markdown {
|
||||||
defaultCodeLanguage = null,
|
defaultCodeLanguage = null,
|
||||||
emptyText = "",
|
emptyText = "",
|
||||||
allowedUriSchemes = [],
|
allowedUriSchemes = [],
|
||||||
} = {}
|
} = {},
|
||||||
) {
|
) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
|
|
|
@ -12,7 +12,7 @@ export function load(key) {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
console.error(
|
||||||
`Failed to load from local storage, reason: ${error.message}`
|
`Failed to load from local storage, reason: ${error.message}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ export function waitUntilVisible(element) {
|
||||||
*/
|
*/
|
||||||
export function waitUntilInViewport(
|
export function waitUntilInViewport(
|
||||||
element,
|
element,
|
||||||
{ root = null, proximity = 0 } = {}
|
{ root = null, proximity = 0 } = {},
|
||||||
) {
|
) {
|
||||||
let observer = null;
|
let observer = null;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ export function waitUntilInViewport(
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ root, rootMargin: `${proximity}px` }
|
{ root, rootMargin: `${proximity}px` },
|
||||||
);
|
);
|
||||||
observer.observe(element);
|
observer.observe(element);
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ export function findChildOrThrow(element, selector) {
|
||||||
|
|
||||||
if (!child) {
|
if (!child) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`expected a child matching ${selector}, but none was found`
|
`expected a child matching ${selector}, but none was found`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"deploy": "node build.js --deploy",
|
"deploy": "node build.js --deploy",
|
||||||
"watch": "node build.js --watch",
|
"watch": "node build.js --watch",
|
||||||
"format": "prettier --trailing-comma es5 --write '{js,test,css}/**/*.{js,json,css,md}' --no-error-on-unmatched-pattern",
|
"format": "prettier --write '{js,test,css}/**/*.{js,json,css,md}' --no-error-on-unmatched-pattern",
|
||||||
"format-check": "prettier --trailing-comma es5 --check '{js,test,css}/**/*.{js,json,css,md}' --no-error-on-unmatched-pattern",
|
"format-check": "prettier --check '{js,test,css}/**/*.{js,json,css,md}' --no-error-on-unmatched-pattern",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch"
|
"test:watch": "jest --watch"
|
||||||
},
|
},
|
||||||
|
|
|
@ -149,7 +149,7 @@ describe("with buffer delta", () => {
|
||||||
expect(connection.sendDelta).toHaveBeenCalledWith(
|
expect(connection.sendDelta).toHaveBeenCalledWith(
|
||||||
bufferDelta,
|
bufferDelta,
|
||||||
bufferSelection,
|
bufferSelection,
|
||||||
1
|
1,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ describe("with buffer delta", () => {
|
||||||
expect(connection.sendDelta).toHaveBeenCalledWith(
|
expect(connection.sendDelta).toHaveBeenCalledWith(
|
||||||
bufferDelta,
|
bufferDelta,
|
||||||
bufferSelection,
|
bufferSelection,
|
||||||
2
|
2,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -254,7 +254,7 @@ describe("peers", () => {
|
||||||
getListener(connection, "onDelta")(
|
getListener(connection, "onDelta")(
|
||||||
remoteDelta2,
|
remoteDelta2,
|
||||||
remoteSelection2,
|
remoteSelection2,
|
||||||
"client3"
|
"client3",
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(onPeersChange).toHaveBeenCalledWith({
|
expect(onPeersChange).toHaveBeenCalledWith({
|
||||||
|
|
Loading…
Reference in a new issue