mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 10:32:39 +00:00
WIP
This commit is contained in:
@@ -499,7 +499,7 @@ const Editor = createClass({
|
|||||||
historySize={this.historySize()}
|
historySize={this.historySize()}
|
||||||
currentEditorTheme={this.state.editorTheme}
|
currentEditorTheme={this.state.editorTheme}
|
||||||
updateEditorTheme={this.updateEditorTheme}
|
updateEditorTheme={this.updateEditorTheme}
|
||||||
snippetBundle={this.props.snippetBundle}
|
themeBundle={this.props.themeBundle}
|
||||||
cursorPos={this.codeEditor.current?.getCursorPosition() || {}}
|
cursorPos={this.codeEditor.current?.getCursorPosition() || {}}
|
||||||
updateBrew={this.props.updateBrew}
|
updateBrew={this.props.updateBrew}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ const Snippetbar = createClass({
|
|||||||
unfoldCode : ()=>{},
|
unfoldCode : ()=>{},
|
||||||
updateEditorTheme : ()=>{},
|
updateEditorTheme : ()=>{},
|
||||||
cursorPos : {},
|
cursorPos : {},
|
||||||
snippetBundle : [],
|
|
||||||
updateBrew : ()=>{}
|
updateBrew : ()=>{}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -102,20 +101,26 @@ const Snippetbar = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
compileSnippets : function() {
|
compileSnippets : function() {
|
||||||
|
console.log('compileSnippets');
|
||||||
let compiledSnippets = [];
|
let compiledSnippets = [];
|
||||||
|
|
||||||
let oldSnippets = _.keyBy(compiledSnippets, 'groupName');
|
let oldSnippets = _.keyBy(compiledSnippets, 'groupName');
|
||||||
|
|
||||||
for (let snippets of this.props.snippetBundle) {
|
console.log(this.props.themesBundle);
|
||||||
if(typeof(snippets) == 'string') // load staticThemes as needed; they were sent as just a file name
|
|
||||||
snippets = ThemeSnippets[snippets];
|
|
||||||
|
|
||||||
const newSnippets = _.keyBy(_.cloneDeep(snippets), 'groupName');
|
if( this.props.themesBundle) {
|
||||||
compiledSnippets = _.values(_.mergeWith(oldSnippets, newSnippets, this.mergeCustomizer));
|
for (let snippets of this.props?.themesBundle?.snippets) {
|
||||||
|
if(typeof(snippets) == 'string') // load staticThemes as needed; they were sent as just a file name
|
||||||
|
snippets = ThemeSnippets[snippets];
|
||||||
|
|
||||||
oldSnippets = _.keyBy(compiledSnippets, 'groupName');
|
const newSnippets = _.keyBy(_.cloneDeep(snippets), 'groupName');
|
||||||
|
compiledSnippets = _.values(_.mergeWith(oldSnippets, newSnippets, this.mergeCustomizer));
|
||||||
|
|
||||||
|
oldSnippets = _.keyBy(compiledSnippets, 'groupName');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const userSnippetsasJSON = brewSnippetsToJSON(this.props.brew.title, this.props.brew.snippets, this.props.snippetsBundle);
|
console.log(this.props.themesBundle);
|
||||||
|
const userSnippetsasJSON = brewSnippetsToJSON(this.props.brew.title, this.props.brew.snippets, this.props?.themesBundle?.snippets);
|
||||||
compiledSnippets.push(userSnippetsasJSON);
|
compiledSnippets.push(userSnippetsasJSON);
|
||||||
|
|
||||||
return compiledSnippets;
|
return compiledSnippets;
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ const api = {
|
|||||||
splitTextStyleAndMetadata(currentTheme);
|
splitTextStyleAndMetadata(currentTheme);
|
||||||
|
|
||||||
// If there is anything in the snippets or style members, append them to the appropriate array
|
// If there is anything in the snippets or style members, append them to the appropriate array
|
||||||
if(currentTheme?.snippets) completeSnippets.push(JSON.parse(currentTheme.snippets));
|
if(currentTheme?.snippets) completeSnippets.push({ name: currentTheme.title, snippets: currentTheme.snippets });
|
||||||
if(currentTheme?.style) completeStyles.push(`/* From Brew: ${req.protocol}://${req.get('host')}/share/${req.params.id} */\n\n${currentTheme.style}`);
|
if(currentTheme?.style) completeStyles.push(`/* From Brew: ${req.protocol}://${req.get('host')}/share/${req.params.id} */\n\n${currentTheme.style}`);
|
||||||
|
|
||||||
req.params.id = currentTheme.theme;
|
req.params.id = currentTheme.theme;
|
||||||
@@ -304,9 +304,7 @@ const api = {
|
|||||||
}
|
}
|
||||||
//=== Static Themes ===//
|
//=== Static Themes ===//
|
||||||
else {
|
else {
|
||||||
const localSnippets = `${req.params.renderer}_${req.params.id}`; // Just log the name for loading on client
|
|
||||||
const localStyle = `@import url(\"/themes/${req.params.renderer}/${req.params.id}/style.css\");`;
|
const localStyle = `@import url(\"/themes/${req.params.renderer}/${req.params.id}/style.css\");`;
|
||||||
completeSnippets.push(localSnippets);
|
|
||||||
completeStyles.push(`/* From Theme ${req.params.id} */\n\n${localStyle}`);
|
completeStyles.push(`/* From Theme ${req.params.id} */\n\n${localStyle}`);
|
||||||
|
|
||||||
req.params.id = Themes[req.params.renderer][req.params.id].baseTheme;
|
req.params.id = Themes[req.params.renderer][req.params.id].baseTheme;
|
||||||
|
|||||||
@@ -627,8 +627,6 @@ brew`);
|
|||||||
`/* From Theme 5ePHB */\n\n@import url("/themes/V3/5ePHB/style.css");`
|
`/* From Theme 5ePHB */\n\n@import url("/themes/V3/5ePHB/style.css");`
|
||||||
],
|
],
|
||||||
snippets : [
|
snippets : [
|
||||||
'V3_Blank',
|
|
||||||
'V3_5ePHB'
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,9 +8,12 @@ const brewSnippetsToJSON = (menuTitle, userBrewSnippets, themeBundleSnippets)=>{
|
|||||||
const textSplit = /^\\page/gm;
|
const textSplit = /^\\page/gm;
|
||||||
const mpAsSnippets = [];
|
const mpAsSnippets = [];
|
||||||
// Snippets from Themes first.
|
// Snippets from Themes first.
|
||||||
|
//console.log(themeBundleSnippets);
|
||||||
if(themeBundleSnippets) {
|
if(themeBundleSnippets) {
|
||||||
|
console.log('Looping!');
|
||||||
for (let themes of themeBundleSnippets) {
|
for (let themes of themeBundleSnippets) {
|
||||||
const userSnippets = [];
|
const userSnippets = [];
|
||||||
|
console.log(themes);
|
||||||
for (let snips of themes.snippets.split(textSplit)) {
|
for (let snips of themes.snippets.split(textSplit)) {
|
||||||
const name = snips.split('\n')[0];
|
const name = snips.split('\n')[0];
|
||||||
if(name.length != 0) {
|
if(name.length != 0) {
|
||||||
@@ -80,9 +83,9 @@ const splitTextStyleAndMetadata = (brew)=>{
|
|||||||
brew.style = brew.text.slice(7, index - 1);
|
brew.style = brew.text.slice(7, index - 1);
|
||||||
brew.text = brew.text.slice(index + 5);
|
brew.text = brew.text.slice(index + 5);
|
||||||
}
|
}
|
||||||
// if(!brew?.snippets) {
|
if(!brew?.snippets) {
|
||||||
brew.snippets = `\\snippet Example\nI am an example user snippet\n`;
|
brew.snippets = `\\snippet Example\nI am an example user snippet\n`;
|
||||||
// }
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const printCurrentBrew = ()=>{
|
const printCurrentBrew = ()=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user