Skip to content

Commit 4c0a734

Browse files
authored
add file.open annotation to SequenceEditor when opening file, show toast when sanitizing characters (#1883)
* add file.open annotation to CM editor transaction when opening file, show toast when sanitizing characters * fix linting * use equal check to check for sanitize smart quotes annotation from CM * update aerie-sequence-languages library to 1.0.1
1 parent 5bbbb67 commit 4c0a734

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@lezer/lr": "^1.4.2",
5252
"@nasa-jpl/aerie-actions": "1.1.0",
5353
"@nasa-jpl/aerie-ampcs": "^1.0.5",
54-
"@nasa-jpl/aerie-sequence-languages": "1.0.0",
54+
"@nasa-jpl/aerie-sequence-languages": "1.0.1",
5555
"@nasa-jpl/seq-json-schema": "^1.3.1",
5656
"@nasa-jpl/stellar": "^2.0.0-alpha.30",
5757
"@nasa-jpl/stellar-svelte": "^2.1.10",

src/components/sequencing/SequenceEditor.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { standardKeymap } from '@codemirror/commands';
55
import { syntaxTree } from '@codemirror/language';
66
import { lintGutter, openLintPanel } from '@codemirror/lint';
7-
import { Compartment, EditorState, type Extension } from '@codemirror/state';
7+
import { Compartment, EditorState, Transaction, type Extension } from '@codemirror/state';
88
import { keymap, type ViewUpdate } from '@codemirror/view';
99
import type { SyntaxNode } from '@lezer/common';
1010
import type {
@@ -104,6 +104,7 @@
104104
if (editorSequenceView?.state.doc.toString() !== sequenceDefinition) {
105105
editorSequenceView?.dispatch({
106106
changes: { from: 0, insert: sequenceDefinition, to: editorSequenceView.state.doc.length },
107+
userEvent: 'file.open',
107108
});
108109
}
109110
}
@@ -291,6 +292,13 @@
291292
blockTheme,
292293
compartmentAdaptation.of(inputEditorExtension),
293294
compartmentReadonly.of([EditorState.readOnly.of(readOnly || previewOnly || isLoading)]),
295+
EditorView.updateListener.of(viewUpdate => {
296+
for (const tr of viewUpdate.transactions) {
297+
if (tr.annotation(Transaction.userEvent) === 'sanitize.smartQuotes') {
298+
showSuccessToast('Replaced curly quotes with ASCII quotes, save to accept changes');
299+
}
300+
}
301+
}),
294302
],
295303
parent: editorSequenceDiv,
296304
});

src/utilities/sequence-editor/adaptation-utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as cmCommands from '@codemirror/commands';
33
import * as cmLanguage from '@codemirror/language';
44
import * as cmView from '@codemirror/view';
5+
import * as cmState from '@codemirror/state';
56

67
import type { PhoenixAdaptation } from '@nasa-jpl/aerie-sequence-languages';
78
import type { User } from '../../types/app';
@@ -29,6 +30,7 @@ export async function loadSequenceAdaptation(id: number, user: User | null): Pro
2930
return {
3031
'@codemirror/commands': cmCommands,
3132
'@codemirror/language': cmLanguage,
33+
'@codemirror/state': cmState,
3234
'@codemirror/view': cmView,
3335
}[id];
3436
};

0 commit comments

Comments
 (0)