mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-06-22 04:58:40 +00:00
@@ -86,8 +86,8 @@ export function tokenizeCustomMarkdown(text) {
|
|||||||
if(/\~/.test(lineText)) {
|
if(/\~/.test(lineText)) {
|
||||||
const strikethroughRegex = /~(?!\s)(.+?)(?<!\s)~/g;
|
const strikethroughRegex = /~(?!\s)(.+?)(?<!\s)~/g;
|
||||||
|
|
||||||
let match = strikethroughRegex.exec(lineText);
|
const match = strikethroughRegex.exec(lineText);
|
||||||
let type = customTags.strikethrough;
|
const type = customTags.strikethrough;
|
||||||
|
|
||||||
if(match) {
|
if(match) {
|
||||||
tokens.push({
|
tokens.push({
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ import { keymap } from '@codemirror/view';
|
|||||||
import { undo, redo, indentMore, deleteLine } from '@codemirror/commands';
|
import { undo, redo, indentMore, deleteLine } from '@codemirror/commands';
|
||||||
import { Prec } from '@codemirror/state';
|
import { Prec } from '@codemirror/state';
|
||||||
|
|
||||||
const insertTab = (view) => {
|
const insertTab = (view)=>{
|
||||||
const { from, to } = view.state.selection.main;
|
const { from, to } = view.state.selection.main;
|
||||||
|
|
||||||
view.dispatch({
|
view.dispatch({
|
||||||
changes: { from, to, insert: ' ' },
|
changes : { from, to, insert: ' ' },
|
||||||
selection: { anchor: from + 2 }
|
selection : { anchor: from + 2 }
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -28,20 +28,18 @@ const indentLess = (view)=>{
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const wrapSelection = (prefix, suffix) => (view) => {
|
const wrapSelection = (prefix, suffix)=>(view)=>{
|
||||||
const changes = [];
|
const changes = [];
|
||||||
|
|
||||||
for(const range of view.state.selection.ranges) {
|
for (const range of view.state.selection.ranges) {
|
||||||
const { from, to } = range;
|
const { from, to } = range;
|
||||||
const selected = view.state.doc.sliceString(from, to);
|
const selected = view.state.doc.sliceString(from, to);
|
||||||
|
|
||||||
let text;
|
let text;
|
||||||
|
|
||||||
if(from === to) { text = prefix + suffix }
|
if(from === to) { text = prefix + suffix; } else if(selected.startsWith(prefix) && selected.endsWith(suffix)) {
|
||||||
else if(selected.startsWith(prefix) && selected.endsWith(suffix)) {
|
|
||||||
text = selected.slice(prefix.length, -suffix.length);
|
text = selected.slice(prefix.length, -suffix.length);
|
||||||
}
|
} else {text = `${prefix}${selected}${suffix}`;}
|
||||||
else {text = `${prefix}${selected}${suffix}`}
|
|
||||||
|
|
||||||
changes.push({ from, to, insert: text });
|
changes.push({ from, to, insert: text });
|
||||||
}
|
}
|
||||||
@@ -53,7 +51,7 @@ const wrapSelection = (prefix, suffix) => (view) => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const makeNbsp = (view) => {
|
const makeNbsp = (view)=>{
|
||||||
const { from } = view.state.selection.main;
|
const { from } = view.state.selection.main;
|
||||||
|
|
||||||
const prev2 = from >= 2
|
const prev2 = from >= 2
|
||||||
|
|||||||
@@ -30,18 +30,17 @@ import cm5Themes from 'codemirror-5-themes';
|
|||||||
const themes = { default: defaultCM5Theme, ...cm5Themes, darkbrewery };
|
const themes = { default: defaultCM5Theme, ...cm5Themes, darkbrewery };
|
||||||
|
|
||||||
const themeNames = Object.entries(themes)
|
const themeNames = Object.entries(themes)
|
||||||
.filter(([name, value]) =>
|
.filter(([name, value])=>Array.isArray(value) &&
|
||||||
Array.isArray(value) &&
|
|
||||||
!name.endsWith('Init') &&
|
!name.endsWith('Init') &&
|
||||||
!name.endsWith('Style')
|
!name.endsWith('Style')
|
||||||
)
|
)
|
||||||
.map(([name]) => name);
|
.map(([name])=>name);
|
||||||
|
|
||||||
const EditorThemes = [
|
const EditorThemes = [
|
||||||
'default',
|
'default',
|
||||||
...themeNames
|
...themeNames
|
||||||
.filter(name => name !== 'default')
|
.filter((name)=>name !== 'default')
|
||||||
.sort((a, b) => a.localeCompare(b))
|
.sort((a, b)=>a.localeCompare(b))
|
||||||
];
|
];
|
||||||
|
|
||||||
const execute = function(val, props){
|
const execute = function(val, props){
|
||||||
|
|||||||
@@ -32,20 +32,20 @@ const isStaticTheme = (renderer, themeName)=>{
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
|
|
||||||
const migrateSystemsToTags = (brew) => {
|
const migrateSystemsToTags = (brew)=>{
|
||||||
if (!('systems' in brew)) return brew;
|
if(!('systems' in brew)) return brew;
|
||||||
|
|
||||||
if (!Array.isArray(brew.systems) || brew.systems.length === 0) {
|
if(!Array.isArray(brew.systems) || brew.systems.length === 0) {
|
||||||
brew.systems = undefined;
|
brew.systems = undefined;
|
||||||
return brew;
|
return brew;
|
||||||
}
|
}
|
||||||
const systemMap = {
|
const systemMap = {
|
||||||
'5e': 'system:D&D 5e',
|
'5e' : 'system:D&D 5e',
|
||||||
'4e': 'system:D&D 4e',
|
'4e' : 'system:D&D 4e',
|
||||||
'3.5e': 'system:D&D 3.5e',
|
'3.5e' : 'system:D&D 3.5e',
|
||||||
'Pathfinder': 'system:Pathfinder 2e'
|
'Pathfinder' : 'system:Pathfinder 2e'
|
||||||
};
|
};
|
||||||
const systemTags = brew.systems.map(s => systemMap[s]);
|
const systemTags = brew.systems.map((s)=>systemMap[s]);
|
||||||
brew.tags = _.uniq([...(brew.tags || []), ...systemTags]);
|
brew.tags = _.uniq([...(brew.tags || []), ...systemTags]);
|
||||||
|
|
||||||
brew.systems = undefined;
|
brew.systems = undefined;
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ export default {
|
|||||||
const styles = ()=>{
|
const styles = ()=>{
|
||||||
switch (side) {
|
switch (side) {
|
||||||
case 'bottom':
|
case 'bottom':
|
||||||
return `{width:100%,bottom:0%}`
|
return `{width:100%,bottom:0%}`;
|
||||||
break;
|
break;
|
||||||
case 'top':
|
case 'top':
|
||||||
return `{width:100%,top:0%}`
|
return `{width:100%,top:0%}`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return `{height:100%}`
|
return `{height:100%}`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const rotation = {
|
const rotation = {
|
||||||
'bottom' : 0,
|
'bottom' : 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user