mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-06-22 04:58:40 +00:00
Merge branch 'master' of github.com:naturalcrit/homebrewery
This commit is contained in:
@@ -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,15 +3,15 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
const indentLess = (view)=>{
|
const indentLess = (view)=>{
|
||||||
@@ -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,21 +51,21 @@ 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
|
||||||
? view.state.doc.sliceString(from - 2, from)
|
? view.state.doc.sliceString(from - 2, from)
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
const insert = (prev2 === ':>' || prev2 === '>>') ? '>' : ':>';
|
const insert = (prev2 === ':>' || prev2 === '>>') ? '>' : ':>';
|
||||||
|
|
||||||
view.dispatch({
|
view.dispatch({
|
||||||
changes : { from, to: from, insert },
|
changes : { from, to: from, insert },
|
||||||
selection : { anchor: from + insert.length },
|
selection : { anchor: from + insert.length },
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const makeSpace = (view)=>{
|
const makeSpace = (view)=>{
|
||||||
|
|||||||
@@ -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){
|
||||||
|
|||||||
Generated
+13
-24
@@ -25,7 +25,7 @@
|
|||||||
"@codemirror/language-data": "^6.5.2",
|
"@codemirror/language-data": "^6.5.2",
|
||||||
"@codemirror/search": "^6.6.0",
|
"@codemirror/search": "^6.6.0",
|
||||||
"@codemirror/state": "^6.6.0",
|
"@codemirror/state": "^6.6.0",
|
||||||
"@codemirror/view": "^6.42.1",
|
"@codemirror/view": "^6.43.0",
|
||||||
"@dmsnell/diff-match-patch": "^1.1.0",
|
"@dmsnell/diff-match-patch": "^1.1.0",
|
||||||
"@googleapis/drive": "^20.1.0",
|
"@googleapis/drive": "^20.1.0",
|
||||||
"@lezer/highlight": "^1.2.3",
|
"@lezer/highlight": "^1.2.3",
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
"react": "^19.2.6",
|
"react": "^19.2.6",
|
||||||
"react-dom": "^19.2.6",
|
"react-dom": "^19.2.6",
|
||||||
"react-frame-component": "^5.3.2",
|
"react-frame-component": "^5.3.2",
|
||||||
"react-router": "^7.15.0",
|
"react-router": "^7.15.1",
|
||||||
"sanitize-filename": "1.6.4",
|
"sanitize-filename": "1.6.4",
|
||||||
"superagent": "^10.2.1"
|
"superagent": "^10.2.1"
|
||||||
},
|
},
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
"jsdom": "^28.1.0",
|
"jsdom": "^28.1.0",
|
||||||
"jsdom-global": "^3.0.2",
|
"jsdom-global": "^3.0.2",
|
||||||
"postcss-less": "^6.0.0",
|
"postcss-less": "^6.0.0",
|
||||||
"stylelint": "^17.11.0",
|
"stylelint": "^17.11.1",
|
||||||
"stylelint-config-recess-order": "^7.7.0",
|
"stylelint-config-recess-order": "^7.7.0",
|
||||||
"stylelint-config-recommended": "^18.0.0",
|
"stylelint-config-recommended": "^18.0.0",
|
||||||
"supertest": "^7.1.4",
|
"supertest": "^7.1.4",
|
||||||
@@ -2545,9 +2545,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@codemirror/view": {
|
"node_modules/@codemirror/view": {
|
||||||
"version": "6.42.1",
|
"version": "6.43.0",
|
||||||
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.42.1.tgz",
|
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.0.tgz",
|
||||||
"integrity": "sha512-ToN3oFc0nsxNUYVF5P0ztLgbC4UPPjPtA9aKYhkOKQaZASpOUo6ISXyQLP66ctVwlDc+j6Jv0uK5IFALkiXztg==",
|
"integrity": "sha512-V7ZCLQO3Jus9hzh2jVCCPW3mO4IBMr43O37PqSUYautJSnnJF41YlgLw21x0fLJTYvJ+Vkm6Gp+qKGH9pltgXA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/state": "^6.6.0",
|
"@codemirror/state": "^6.6.0",
|
||||||
@@ -8927,16 +8927,6 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/is-plain-object": {
|
|
||||||
"version": "5.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
|
||||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/is-potential-custom-element-name": {
|
"node_modules/is-potential-custom-element-name": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
||||||
@@ -11794,9 +11784,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router": {
|
"node_modules/react-router": {
|
||||||
"version": "7.15.0",
|
"version": "7.15.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.15.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.15.1.tgz",
|
||||||
"integrity": "sha512-HW9vYwuM8f4yx66Izy8xfrzCM+SBJluoZcCbww9A1TySax11S5Vgw6fi3ZjMONw9J4gQwngL7PzkyIpJJpJ7RQ==",
|
"integrity": "sha512-R8rl9HhgikFYoPJymnUtPXWbnDb3oget6lQnfIoupbt61aT9aOhRkDsY2XRhZRyX1Z/8a5sL74fXmFNm3NRK5A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cookie": "^1.0.1",
|
"cookie": "^1.0.1",
|
||||||
@@ -12817,9 +12807,9 @@
|
|||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/stylelint": {
|
"node_modules/stylelint": {
|
||||||
"version": "17.11.0",
|
"version": "17.11.1",
|
||||||
"resolved": "https://registry.npmjs.org/stylelint/-/stylelint-17.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/stylelint/-/stylelint-17.11.1.tgz",
|
||||||
"integrity": "sha512-/3czzmbF9XdGWvReDF3Ex4R23Ajolo7j8RB2bFNEqk6Ht356nlpVV+G5bG2Qt8AW1ofJzXztBRDnAtd7cgowWA==",
|
"integrity": "sha512-+smN/HqVTggUx3iuAzOi9fPh8SrH+cJWlZrYVldXoJ06orWBhZ4Ue/QEp64oei6pVrAh4w3tG+Y12Vw7MbCFRQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -12854,13 +12844,12 @@
|
|||||||
"html-tags": "^5.1.0",
|
"html-tags": "^5.1.0",
|
||||||
"ignore": "^7.0.5",
|
"ignore": "^7.0.5",
|
||||||
"import-meta-resolve": "^4.2.0",
|
"import-meta-resolve": "^4.2.0",
|
||||||
"is-plain-object": "^5.0.0",
|
|
||||||
"mathml-tag-names": "^4.0.0",
|
"mathml-tag-names": "^4.0.0",
|
||||||
"meow": "^14.1.0",
|
"meow": "^14.1.0",
|
||||||
"micromatch": "^4.0.8",
|
"micromatch": "^4.0.8",
|
||||||
"normalize-path": "^3.0.0",
|
"normalize-path": "^3.0.0",
|
||||||
"picocolors": "^1.1.1",
|
"picocolors": "^1.1.1",
|
||||||
"postcss": "^8.5.13",
|
"postcss": "^8.5.14",
|
||||||
"postcss-safe-parser": "^7.0.1",
|
"postcss-safe-parser": "^7.0.1",
|
||||||
"postcss-selector-parser": "^7.1.1",
|
"postcss-selector-parser": "^7.1.1",
|
||||||
"postcss-value-parser": "^4.2.0",
|
"postcss-value-parser": "^4.2.0",
|
||||||
|
|||||||
+3
-3
@@ -101,7 +101,7 @@
|
|||||||
"@codemirror/language-data": "^6.5.2",
|
"@codemirror/language-data": "^6.5.2",
|
||||||
"@codemirror/search": "^6.6.0",
|
"@codemirror/search": "^6.6.0",
|
||||||
"@codemirror/state": "^6.6.0",
|
"@codemirror/state": "^6.6.0",
|
||||||
"@codemirror/view": "^6.42.1",
|
"@codemirror/view": "^6.43.0",
|
||||||
"@dmsnell/diff-match-patch": "^1.1.0",
|
"@dmsnell/diff-match-patch": "^1.1.0",
|
||||||
"@googleapis/drive": "^20.1.0",
|
"@googleapis/drive": "^20.1.0",
|
||||||
"@lezer/highlight": "^1.2.3",
|
"@lezer/highlight": "^1.2.3",
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
"react": "^19.2.6",
|
"react": "^19.2.6",
|
||||||
"react-dom": "^19.2.6",
|
"react-dom": "^19.2.6",
|
||||||
"react-frame-component": "^5.3.2",
|
"react-frame-component": "^5.3.2",
|
||||||
"react-router": "^7.15.0",
|
"react-router": "^7.15.1",
|
||||||
"sanitize-filename": "1.6.4",
|
"sanitize-filename": "1.6.4",
|
||||||
"superagent": "^10.2.1"
|
"superagent": "^10.2.1"
|
||||||
},
|
},
|
||||||
@@ -162,7 +162,7 @@
|
|||||||
"jsdom": "^28.1.0",
|
"jsdom": "^28.1.0",
|
||||||
"jsdom-global": "^3.0.2",
|
"jsdom-global": "^3.0.2",
|
||||||
"postcss-less": "^6.0.0",
|
"postcss-less": "^6.0.0",
|
||||||
"stylelint": "^17.11.0",
|
"stylelint": "^17.11.1",
|
||||||
"stylelint-config-recess-order": "^7.7.0",
|
"stylelint-config-recess-order": "^7.7.0",
|
||||||
"stylelint-config-recommended": "^18.0.0",
|
"stylelint-config-recommended": "^18.0.0",
|
||||||
"supertest": "^7.1.4",
|
"supertest": "^7.1.4",
|
||||||
|
|||||||
+18
-11
@@ -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;
|
||||||
@@ -397,17 +397,24 @@ const api = {
|
|||||||
return res.status(409).send(JSON.stringify({ message: `The server copy is out of sync with the saved brew. Please save your changes elsewhere, refresh, and try again.` }));
|
return res.status(409).send(JSON.stringify({ message: `The server copy is out of sync with the saved brew. Please save your changes elsewhere, refresh, and try again.` }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let result = [];
|
||||||
try {
|
try {
|
||||||
const patches = parsePatch(brewFromClient.patches);
|
const patches = parsePatch(brewFromClient.patches);
|
||||||
// Patch to a throwaway variable while parallelizing - we're more concerned with error/no error.
|
// Patch to a throwaway variable while parallelizing - we're more concerned with error/no error.
|
||||||
const patchedResult = decodeURI(applyPatches(patches, encodeURI(brewFromServer.text))[0]);
|
result = applyPatches(patches, encodeURI(brewFromServer.text));
|
||||||
if(patchedResult != brewFromClient.text)
|
const failedPatches = patches.map((patch, index)=>{if(!result[1][index]){ return patch; }});
|
||||||
|
if(failedPatches > 0){
|
||||||
|
throw (`Patch failure: ${failedPatches}/${result[1].length} did not apply`);
|
||||||
|
}
|
||||||
|
if(decodeURI(result[0]) != brewFromClient.text){
|
||||||
throw ('Patches did not apply cleanly, text mismatch detected');
|
throw ('Patches did not apply cleanly, text mismatch detected');
|
||||||
|
}
|
||||||
// brew.text = applyPatches(patches, brewFromServer.text)[0];
|
// brew.text = applyPatches(patches, brewFromServer.text)[0];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debugTextMismatch(brewFromClient.text, brewFromServer.text, `edit/${brewFromClient.editId}`);
|
debugTextMismatch(brewFromClient.text, brewFromServer.text, `edit/${brewFromClient.editId}`);
|
||||||
console.error('Failed to apply patches:', {
|
console.error('Failed to apply patches:', {
|
||||||
//patches : brewFromClient.patches,
|
// patches : brewFromClient.patches,
|
||||||
|
// result : result,
|
||||||
brewId : brewFromClient.editId || 'unknown',
|
brewId : brewFromClient.editId || 'unknown',
|
||||||
error : err
|
error : err
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const HomebrewSchema = mongoose.Schema({
|
|||||||
|
|
||||||
description : { type: String, default: '' },
|
description : { type: String, default: '' },
|
||||||
tags : { type: [String], index: true },
|
tags : { type: [String], index: true },
|
||||||
systems : { type: [String], default: undefined },
|
systems : { type: [String], default: undefined },
|
||||||
lang : { type: String, default: 'en', index: true },
|
lang : { type: String, default: 'en', index: true },
|
||||||
renderer : { type: String, default: '', index: true },
|
renderer : { type: String, default: '', index: true },
|
||||||
authors : { type: [String], index: true },
|
authors : { type: [String], index: true },
|
||||||
|
|||||||
@@ -16,17 +16,17 @@ export default {
|
|||||||
edge : (side = 'bottom')=>{
|
edge : (side = 'bottom')=>{
|
||||||
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,
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export default EditorView.theme({
|
|||||||
'.cm-strong' : { color: '#309dd2', fontWeight: 'bold' },
|
'.cm-strong' : { color: '#309dd2', fontWeight: 'bold' },
|
||||||
'.cm-em' : { fontStyle: 'italic' },
|
'.cm-em' : { fontStyle: 'italic' },
|
||||||
'.cm-keyword' : { color: '#fff' },
|
'.cm-keyword' : { color: '#fff' },
|
||||||
'.cm-atom, .cm-value, .cm-color' : { color: '#c1939a' },
|
'.cm-atom, .cm-value, .cm-color' : { color: '#c1939a' },
|
||||||
'.cm-number' : { color: '#2986cc' },
|
'.cm-number' : { color: '#2986cc' },
|
||||||
'.cm-def' : { color: '#2986cc' },
|
'.cm-def' : { color: '#2986cc' },
|
||||||
'.cm-list' : { color: '#3cbf30' },
|
'.cm-list' : { color: '#3cbf30' },
|
||||||
|
|||||||
Reference in New Issue
Block a user