mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-03-29 09:58:11 +00:00
fold all and unfold all restored
This commit is contained in:
@@ -16,17 +16,17 @@ import {
|
||||
dropCursor,
|
||||
} from '@codemirror/view';
|
||||
import { EditorState, Compartment } from '@codemirror/state';
|
||||
import { foldGutter, foldKeymap, syntaxHighlighting } from '@codemirror/language';
|
||||
import { foldAll as foldAllCmd, unfoldAll as unfoldAllCmd, foldGutter, foldKeymap, syntaxHighlighting } from '@codemirror/language';
|
||||
import { defaultKeymap, history, undo, redo, undoDepth, redoDepth } from '@codemirror/commands';
|
||||
import { languages } from '@codemirror/language-data';
|
||||
import { css, cssLanguage } from '@codemirror/lang-css';
|
||||
import { markdown, markdownLanguage } from '@codemirror/lang-markdown';
|
||||
import {html} from "@codemirror/lang-html"
|
||||
import { html } from '@codemirror/lang-html';
|
||||
import { autocompleteEmoji } from './autocompleteEmoji.js';
|
||||
import { searchKeymap, search } from '@codemirror/search';
|
||||
import {closeBrackets} from "@codemirror/autocomplete"
|
||||
import { closeBrackets } from '@codemirror/autocomplete';
|
||||
|
||||
const customClose = closeBrackets({ brackets: ["()", "[]", "{{}}"] });
|
||||
const customClose = closeBrackets({ brackets: ['()', '[]', '{{}}'] });
|
||||
|
||||
import * as themesImport from '@uiw/codemirror-themes-all';
|
||||
import defaultCM5Theme from '@themes/codeMirror/default.js';
|
||||
@@ -80,11 +80,11 @@ const createHighlightPlugin = (renderer, tab)=>{
|
||||
if(tok.type === 'pageLine' && tab === 'brewText') {
|
||||
pageCount++;
|
||||
line.from === 0 && pageCount--;
|
||||
decos.push( Decoration.line({ attributes: { "data-page-number": pageCount }}).range(line.from));
|
||||
decos.push(Decoration.line({ attributes: { 'data-page-number': pageCount } }).range(line.from));
|
||||
}
|
||||
if(tok.type === 'snippetLine' && tab === 'brewSnippets') {
|
||||
snippetCount++;
|
||||
decos.push(Decoration.line({ attributes: { "data-page-number": pageCount }}).range(line.from));
|
||||
decos.push(Decoration.line({ attributes: { 'data-page-number': pageCount } }).range(line.from));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -324,6 +324,17 @@ const CodeEditor = forwardRef(
|
||||
};
|
||||
},
|
||||
|
||||
foldAll : ()=>{
|
||||
const view = viewRef.current;
|
||||
if(!view) return;
|
||||
view.dispatch(foldAllCmd(view));
|
||||
},
|
||||
unfoldAll : ()=>{
|
||||
const view = viewRef.current;
|
||||
if(!view) return;
|
||||
view.dispatch(unfoldAllCmd(view));
|
||||
},
|
||||
|
||||
focus : ()=>viewRef.current.focus(),
|
||||
}));
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const pageFoldExtension = [
|
||||
const startLine = doc.lineAt(lineStart);
|
||||
const prevLineText = startLine.number > 1 ? doc.line(startLine.number - 1).text : '';
|
||||
|
||||
if(startLine.number > 1 && !matcher.test(prevLineText)) return null;
|
||||
if(!matcher.test(prevLineText)) return null;
|
||||
|
||||
let endLine = startLine.number;
|
||||
while (endLine < doc.lines && !matcher.test(doc.line(endLine + 1).text)) {
|
||||
|
||||
@@ -330,14 +330,13 @@ const Editor = createReactClass({
|
||||
return this.codeEditor.current?.undo();
|
||||
},
|
||||
|
||||
foldCode : function(){
|
||||
return this.codeEditor.current?.foldAllCode();
|
||||
},
|
||||
|
||||
unfoldCode : function(){
|
||||
return this.codeEditor.current?.unfoldAllCode();
|
||||
},
|
||||
foldCode: function() {
|
||||
return this.codeEditor.current?.foldAll();
|
||||
},
|
||||
|
||||
unfoldCode: function() {
|
||||
return this.codeEditor.current?.unfoldAll();
|
||||
},
|
||||
render : function(){
|
||||
return (
|
||||
<div className='editor' ref={this.editor}>
|
||||
|
||||
Reference in New Issue
Block a user