0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-06-22 00:38:38 +00:00

lint client

This commit is contained in:
Víctor Losada Hernández
2026-05-18 16:21:57 +02:00
parent 4a565b929b
commit 15db3c9f66
3 changed files with 30 additions and 33 deletions
@@ -86,8 +86,8 @@ export function tokenizeCustomMarkdown(text) {
if(/\~/.test(lineText)) {
const strikethroughRegex = /~(?!\s)(.+?)(?<!\s)~/g;
let match = strikethroughRegex.exec(lineText);
let type = customTags.strikethrough;
const match = strikethroughRegex.exec(lineText);
const type = customTags.strikethrough;
if(match) {
tokens.push({
+8 -10
View File
@@ -3,12 +3,12 @@ import { keymap } from '@codemirror/view';
import { undo, redo, indentMore, deleteLine } from '@codemirror/commands';
import { Prec } from '@codemirror/state';
const insertTab = (view) => {
const insertTab = (view)=>{
const { from, to } = view.state.selection.main;
view.dispatch({
changes: { from, to, insert: ' ' },
selection: { anchor: from + 2 }
changes : { from, to, insert: ' ' },
selection : { anchor: from + 2 }
});
return true;
@@ -28,20 +28,18 @@ const indentLess = (view)=>{
return true;
};
const wrapSelection = (prefix, suffix) => (view) => {
const wrapSelection = (prefix, suffix)=>(view)=>{
const changes = [];
for(const range of view.state.selection.ranges) {
for (const range of view.state.selection.ranges) {
const { from, to } = range;
const selected = view.state.doc.sliceString(from, to);
let text;
if(from === to) { text = prefix + suffix }
else if(selected.startsWith(prefix) && selected.endsWith(suffix)) {
if(from === to) { text = prefix + suffix; } else if(selected.startsWith(prefix) && selected.endsWith(suffix)) {
text = selected.slice(prefix.length, -suffix.length);
}
else {text = `${prefix}${selected}${suffix}`}
} else {text = `${prefix}${selected}${suffix}`;}
changes.push({ from, to, insert: text });
}
@@ -53,7 +51,7 @@ const wrapSelection = (prefix, suffix) => (view) => {
return true;
};
const makeNbsp = (view) => {
const makeNbsp = (view)=>{
const { from } = view.state.selection.main;
const prev2 = from >= 2
@@ -30,18 +30,17 @@ import cm5Themes from 'codemirror-5-themes';
const themes = { default: defaultCM5Theme, ...cm5Themes, darkbrewery };
const themeNames = Object.entries(themes)
.filter(([name, value]) =>
Array.isArray(value) &&
.filter(([name, value])=>Array.isArray(value) &&
!name.endsWith('Init') &&
!name.endsWith('Style')
)
.map(([name]) => name);
.map(([name])=>name);
const EditorThemes = [
'default',
...themeNames
.filter(name => name !== 'default')
.sort((a, b) => a.localeCompare(b))
.filter((name)=>name !== 'default')
.sort((a, b)=>a.localeCompare(b))
];
const execute = function(val, props){