mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-05-07 18:48:39 +00:00
small changes
This commit is contained in:
@@ -40,6 +40,8 @@ import foldOnPages from './customFolding.js';
|
|||||||
import { customHighlightStyle, tokenizeCustomMarkdown, tokenizeCustomCSS } from './customHighlight.js';
|
import { customHighlightStyle, tokenizeCustomMarkdown, tokenizeCustomCSS } from './customHighlight.js';
|
||||||
import { legacyCustomHighlightStyle, legacyTokenizeCustomMarkdown } from './legacyCustomHighlight.js';
|
import { legacyCustomHighlightStyle, legacyTokenizeCustomMarkdown } from './legacyCustomHighlight.js';
|
||||||
|
|
||||||
|
const PAGEBREAK_REGEX_V3 = /^(?=\\page(?:break)?(?: *{[^\n{}]*})?$)/m;
|
||||||
|
|
||||||
const createHighlightPlugin = (renderer, tab)=>{
|
const createHighlightPlugin = (renderer, tab)=>{
|
||||||
//this function takes the custom tokens created in the tokenize function in customhighlight files
|
//this function takes the custom tokens created in the tokenize function in customhighlight files
|
||||||
//takes the tokens defined by that function and assigns classes to them
|
//takes the tokens defined by that function and assigns classes to them
|
||||||
@@ -96,7 +98,6 @@ const createHighlightPlugin = (renderer, tab)=>{
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const setProgrammaticCursorLine = StateEffect.define();
|
const setProgrammaticCursorLine = StateEffect.define();
|
||||||
|
|
||||||
const programmaticCursorLineField = StateField.define({
|
const programmaticCursorLineField = StateField.define({
|
||||||
@@ -155,7 +156,7 @@ const CodeEditor = forwardRef(
|
|||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
|
||||||
for (const line of text.split('\n')) {
|
for (const line of text.split('\n')) {
|
||||||
if(/^(?=\\page(?:break)?(?: *{[^\n{}]*})?$)/m.test(line)) {
|
if(PAGEBREAK_REGEX_V3.test(line)) {
|
||||||
pages.push(offset);
|
pages.push(offset);
|
||||||
}
|
}
|
||||||
offset += line.length + 1;
|
offset += line.length + 1;
|
||||||
@@ -178,7 +179,7 @@ const CodeEditor = forwardRef(
|
|||||||
const createExtensions = ({ onChange, language, editorTheme })=>{
|
const createExtensions = ({ onChange, language, editorTheme })=>{
|
||||||
const setEventListeners = EditorView.updateListener.of((update)=>{
|
const setEventListeners = EditorView.updateListener.of((update)=>{
|
||||||
if(update.docChanged) {
|
if(update.docChanged) {
|
||||||
recomputePages(update.state.doc); // CHANGED (added)
|
recomputePages(update.state.doc);
|
||||||
onChange(update.state.doc.toString());
|
onChange(update.state.doc.toString());
|
||||||
}
|
}
|
||||||
if(update.selectionSet) {
|
if(update.selectionSet) {
|
||||||
|
|||||||
Reference in New Issue
Block a user