mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 21:10:38 +03:00
M: Implement projection swap on ctrl + space
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
This commit is contained in:
parent
31fb5b82ef
commit
3d45510cd6
|
@ -116,6 +116,22 @@ const RSInput = forwardRef<ReactCodeMirrorRef, RSInputProps>(
|
||||||
if (!selection.empty || !schema) {
|
if (!selection.empty || !schema) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const wordRange = text.getWord(selection.from);
|
||||||
|
if (wordRange) {
|
||||||
|
const word = text.getText(wordRange.from, wordRange.to);
|
||||||
|
if (word.length > 2 && (word.startsWith('Pr') || word.startsWith('pr'))) {
|
||||||
|
text.setSelection(wordRange.from, wordRange.from + 2);
|
||||||
|
if (word.startsWith('Pr')) {
|
||||||
|
text.replaceWith('pr');
|
||||||
|
} else {
|
||||||
|
text.replaceWith('Pr');
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const hint = text.getText(selection.from - 1, selection.from);
|
const hint = text.getText(selection.from - 1, selection.from);
|
||||||
const type = guessCstType(hint);
|
const type = guessCstType(hint);
|
||||||
if (hint === getCstTypePrefix(type)) {
|
if (hint === getCstTypePrefix(type)) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ function HelpRSEditor() {
|
||||||
<IconTree className='inline-icon' /> отображение{' '}
|
<IconTree className='inline-icon' /> отображение{' '}
|
||||||
<LinkTopic text='дерева разбора' topic={HelpTopic.UI_FORMULA_TREE} />
|
<LinkTopic text='дерева разбора' topic={HelpTopic.UI_FORMULA_TREE} />
|
||||||
</li>
|
</li>
|
||||||
<li>Ctrl + Пробел дополняет до незанятого имени</li>
|
<li>Ctrl + Пробел вставка незанятого имени / замена проекции</li>
|
||||||
|
|
||||||
<h2>Термин и Текстовое определение</h2>
|
<h2>Термин и Текстовое определение</h2>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -357,6 +357,10 @@ export class CodeMirrorWrapper {
|
||||||
return this.ref.view.state.doc.sliceString(from, to);
|
return this.ref.view.state.doc.sliceString(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getWord(position: number): SelectionRange | null {
|
||||||
|
return this.ref.view.state.wordAt(position);
|
||||||
|
}
|
||||||
|
|
||||||
getSelection(): SelectionRange {
|
getSelection(): SelectionRange {
|
||||||
return this.ref.view.state.selection.main;
|
return this.ref.view.state.selection.main;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user