mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 07:02:39 +00:00
Mostly working. Needs tweakages. Presentable
This commit is contained in:
@@ -158,7 +158,7 @@ const Editor = createClass({
|
|||||||
|
|
||||||
highlightCustomMarkdown : function(){
|
highlightCustomMarkdown : function(){
|
||||||
if(!this.codeEditor.current) return;
|
if(!this.codeEditor.current) return;
|
||||||
if(this.state.view === 'text') {
|
if(this.state.view === 'text') {
|
||||||
const codeMirror = this.codeEditor.current.codeMirror;
|
const codeMirror = this.codeEditor.current.codeMirror;
|
||||||
|
|
||||||
codeMirror.operation(()=>{ // Batch CodeMirror styling
|
codeMirror.operation(()=>{ // Batch CodeMirror styling
|
||||||
|
|||||||
@@ -65,7 +65,10 @@ const Snippetbar = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentDidUpdate : async function(prevProps, prevState) {
|
componentDidUpdate : async function(prevProps, prevState) {
|
||||||
if(prevProps.renderer != this.props.renderer || prevProps.theme != this.props.theme || prevProps.themeBundle != this.props.themeBundle) {
|
if(prevProps.renderer != this.props.renderer ||
|
||||||
|
prevProps.theme != this.props.theme ||
|
||||||
|
prevProps.themeBundle != this.props.themeBundle ||
|
||||||
|
prevProps.brew.snippets != this.props.brew.snippets) {
|
||||||
this.setState({
|
this.setState({
|
||||||
snippets : this.compileSnippets()
|
snippets : this.compileSnippets()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ const EditPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleSnipChange : function(snippet){
|
handleSnipChange : function(snippet){
|
||||||
console.log('Snip Change!');
|
|
||||||
//If there are errors, run the validator on every change to give quick feedback
|
//If there are errors, run the validator on every change to give quick feedback
|
||||||
let htmlErrors = this.state.htmlErrors;
|
let htmlErrors = this.state.htmlErrors;
|
||||||
if(htmlErrors.length) htmlErrors = Markdown.validate(snippet);
|
if(htmlErrors.length) htmlErrors = Markdown.validate(snippet);
|
||||||
|
|||||||
@@ -5,20 +5,22 @@ const dedent = require('dedent');
|
|||||||
|
|
||||||
// Convert the templates from a brew to a Snippets Structure.
|
// Convert the templates from a brew to a Snippets Structure.
|
||||||
const brewSnippetsToJSON = (menuTitle, userBrewSnippets, themeBundleSnippets)=>{
|
const brewSnippetsToJSON = (menuTitle, userBrewSnippets, themeBundleSnippets)=>{
|
||||||
const textSplit = /^\\page/gm;
|
const textSplit = /^\\snippet /gm;
|
||||||
const mpAsSnippets = [];
|
const mpAsSnippets = [];
|
||||||
// Snippets from Themes first.
|
// Snippets from Themes first.
|
||||||
if(themeBundleSnippets) {
|
if(themeBundleSnippets) {
|
||||||
for (let themes of themeBundleSnippets) {
|
for (let themes of themeBundleSnippets) {
|
||||||
if(typeof themes !== 'string') {
|
if(typeof themes !== 'string') {
|
||||||
const userSnippets = [];
|
const userSnippets = [];
|
||||||
const name = themes.snippets.split('\n')[0];
|
for (let snips of themes.snippets.trim().split(textSplit)) {
|
||||||
if(name.length != 0) {
|
const name = snips.trim().split('\n')[0];
|
||||||
userSnippets.push({
|
if(name.length != 0) {
|
||||||
name : name.slice('\snippets '.length),
|
userSnippets.push({
|
||||||
icon : '',
|
name : name.slice('\snippets'.length),
|
||||||
gen : themes.snippets.slice(name.length + 1),
|
icon : '',
|
||||||
});
|
gen : snips.slice(name.length + 1),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(userSnippets.length > 0) {
|
if(userSnippets.length > 0) {
|
||||||
mpAsSnippets.push({
|
mpAsSnippets.push({
|
||||||
@@ -34,11 +36,11 @@ const brewSnippetsToJSON = (menuTitle, userBrewSnippets, themeBundleSnippets)=>{
|
|||||||
// Local Snippets
|
// Local Snippets
|
||||||
if(userBrewSnippets) {
|
if(userBrewSnippets) {
|
||||||
const userSnippets = [];
|
const userSnippets = [];
|
||||||
for (let snips of userBrewSnippets.split(textSplit)) {
|
for (let snips of userBrewSnippets.trim().split(textSplit)) {
|
||||||
let name = snips.split('\n')[0];
|
let name = snips.split('\n')[0];
|
||||||
if(name.length != 0) {
|
if(name.length != 0) {
|
||||||
userSnippets.push({
|
userSnippets.push({
|
||||||
name : name.slice('\snippet '.length),
|
name : name,
|
||||||
icon : '',
|
icon : '',
|
||||||
gen : snips.slice(name.length + 1),
|
gen : snips.slice(name.length + 1),
|
||||||
});
|
});
|
||||||
@@ -72,7 +74,7 @@ const splitTextStyleAndMetadata = (brew)=>{
|
|||||||
}
|
}
|
||||||
if(brew.text.startsWith('```snippets')) {
|
if(brew.text.startsWith('```snippets')) {
|
||||||
const index = brew.text.indexOf('```\n\n');
|
const index = brew.text.indexOf('```\n\n');
|
||||||
brew.snippets = brew.text.slice(11, index - 1);
|
brew.snippets = brew.text.slice(12, index - 1);
|
||||||
brew.text = brew.text.slice(index + 5);
|
brew.text = brew.text.slice(index + 5);
|
||||||
}
|
}
|
||||||
if(brew.text.startsWith('```css')) {
|
if(brew.text.startsWith('```css')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user