Skip to content

Commit

Permalink
v2.11.0 (naturalcrit#1265)
Browse files Browse the repository at this point in the history
* Legacy renderer (naturalcrit#1184)

* Include two versions of Marked.js

* Include two versions of Marked.js

* Working two different render pipelines

Adds stylesheet "styleLegacy.less"
Adds markdownHandler "markdownLegacy.js"
The BrewRenderer will switch between these and the new pipeline dependent on the "version" prop passed in.

* Mustache-style div blocks

* Legacy snippets & columnbreak

* Codemirror styling for Div Blocks

* Lint

* Codemirror highlights for inline Divs as well

These will turn red `{{class Content}}`

Multi-line divs will turn purple

```
{{class,class2
content
}}
```

No real need for these to be different colors. Just for testing.

* More lint

* Update dependencies.

* Adding Button to switch render pipelines

* Update Marked.js

* Popup alert to refresh page when renderer changed

* Don't compress files in Development (very slow)

* Block DIV or inline Span depending on {{ placement

* \column emits a Div instead of Span

* Allow share page to use new renderer

* {{ divs no longer need empty lines. Spans work in lists.

* Typo

* Typo

* Enforce \page must be at start of line. Code cleanup.

* Inject newlines after/before {{/}} to avoid needing blank lines

* Fixes issues with tables.

* Remove console.log

* Fix spacing issue for Spans

* Move things from Brewrenderer to Markdown

Try to keep all custom text fiddling in one spot.

* Rename variables

* Update Font-Awesome to v5.15. Fix style issues on popups.

* Update {{ Divs/Spans, Fix nested hilighting

* Fixed Spans/divs with no tags or just commas

* Use blacklist for {{ to allow more characters

* Update package-lock.json

* Update all icons to Font-awesome 5

* V3 hidden behind config variable

Add "globalThis.enable_v3 = true" in the console to enable.

* lint

* Legacy renderer (naturalcrit#1229)

* Include two versions of Marked.js

* Include two versions of Marked.js

* Working two different render pipelines

Adds stylesheet "styleLegacy.less"
Adds markdownHandler "markdownLegacy.js"
The BrewRenderer will switch between these and the new pipeline dependent on the "version" prop passed in.

* Mustache-style div blocks

* Legacy snippets & columnbreak

* Codemirror styling for Div Blocks

* Lint

* Codemirror highlights for inline Divs as well

These will turn red `{{class Content}}`

Multi-line divs will turn purple

```
{{class,class2
content
}}
```

No real need for these to be different colors. Just for testing.

* More lint

* Update dependencies.

* Adding Button to switch render pipelines

* Update Marked.js

* Popup alert to refresh page when renderer changed

* Don't compress files in Development (very slow)

* Block DIV or inline Span depending on {{ placement

* \column emits a Div instead of Span

* Allow share page to use new renderer

* {{ divs no longer need empty lines. Spans work in lists.

* Typo

* Typo

* Enforce \page must be at start of line. Code cleanup.

* Inject newlines after/before {{/}} to avoid needing blank lines

* Fixes issues with tables.

* Remove console.log

* Fix spacing issue for Spans

* Move things from Brewrenderer to Markdown

Try to keep all custom text fiddling in one spot.

* Rename variables

* Update Font-Awesome to v5.15. Fix style issues on popups.

* Update {{ Divs/Spans, Fix nested hilighting

* Fixed Spans/divs with no tags or just commas

* Use blacklist for {{ to allow more characters

* Update package-lock.json

* Update all icons to Font-awesome 5

* V3 hidden behind config variable

Add "globalThis.enable_v3 = true" in the console to enable.

* lint

* Give user styles higher priority to still allow overrides

* Apply style priority to *all* user styles

* Change .legacy .v3 to .phb, .phb3

* Revert accidental color change

* Fix brew styles overwriting each other. (naturalcrit#1230)

* Fix /page not working in legacy mode. (naturalcrit#1233)

* Fix brew styles overwriting each other.

* Word wrapping, start fixing spacing on Title letter

* Fix \page in legacy brews when not at line start

* Default 'legacy' if not set. Auto-change styles.

* Fix brew styles overwriting each other.

* Word wrapping, start fixing spacing on Title letter

* Fix \page in legacy brews when not at line start

* Fix Page Padding

* Set 'legacy' as default value if not set in brew saved file.

* Apply Legacy\v3 renderer to print page (naturalcrit#1235)

* Update robots.txt (naturalcrit#1239)

* Enable caching of static assets (naturalcrit#1217)

* Enable caching of static assets

* Remove dependency on mime package

Since we only care about two file extensions at the moment,
there is no need to grab the whole package just to avoid
calling 'endsWith' twice.

* Add QR-Code as snippet under Editor (naturalcrit#539)

* Add snippet for QR-code

* Add snippet for QR-code

* Refactor to expose metadata to snippets

* Lint

Co-authored-by: Rasmus Bækgaard <[email protected]>
Co-authored-by: Trevor Buckner <[email protected]>

* Unify brew structure in all pages

* Implementing magic item snippet from Issue 671. (naturalcrit#842)

* Implementing magic item snippet from Issue 671.

* Fixes syntax errors. Function moved into existing magic module.

* Implementing magic item snippet from Issue 671.

* Fixes syntax errors. Function moved into existing magic module.

* Magic Item Snippet, <dl>, `:` for blank line

Co-authored-by: Trevor Buckner <[email protected]>

* Bump codemirror from 5.59.2 to 5.59.4 (naturalcrit#1258)

Bumps [codemirror](https://github.com/codemirror/CodeMirror) from 5.59.2 to 5.59.4.
- [Release notes](https://github.com/codemirror/CodeMirror/releases)
- [Changelog](https://github.com/codemirror/CodeMirror/blob/master/CHANGELOG.md)
- [Commits](codemirror/codemirror5@5.59.2...5.59.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump query-string from 6.13.8 to 6.14.0 (naturalcrit#1236)

Bumps [query-string](https://github.com/sindresorhus/query-string) from 6.13.8 to 6.14.0.
- [Release notes](https://github.com/sindresorhus/query-string/releases)
- [Commits](sindresorhus/query-string@v6.13.8...v6.14.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump @babel/preset-env from 7.12.11 to 7.13.5 (naturalcrit#1257)

Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.12.11 to 7.13.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.5/packages/babel-preset-env)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump lodash from 4.17.20 to 4.17.21 (naturalcrit#1252)

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.20...4.17.21)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump mongoose from 5.11.13 to 5.11.18 (naturalcrit#1256)

Bumps [mongoose](https://github.com/Automattic/mongoose) from 5.11.13 to 5.11.18.
- [Release notes](https://github.com/Automattic/mongoose/releases)
- [Changelog](https://github.com/Automattic/mongoose/blob/master/History.md)
- [Commits](Automattic/mongoose@5.11.13...5.11.18)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump googleapis from 67.0.0 to 67.1.0 (naturalcrit#1245)

Bumps [googleapis](https://github.com/googleapis/google-api-nodejs-client) from 67.0.0 to 67.1.0.
- [Release notes](https://github.com/googleapis/google-api-nodejs-client/releases)
- [Changelog](https://github.com/googleapis/google-api-nodejs-client/blob/master/CHANGELOG.md)
- [Commits](googleapis/google-api-nodejs-client@v67.0.0...v67.1.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump eslint from 7.18.0 to 7.20.0 (naturalcrit#1244)

Bumps [eslint](https://github.com/eslint/eslint) from 7.18.0 to 7.20.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.18.0...v7.20.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Update Marked.js version

* Bump @babel/preset-react from 7.12.10 to 7.12.13 (naturalcrit#1225)

Bumps [@babel/preset-react](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-react) from 7.12.10 to 7.12.13.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.12.13/packages/babel-preset-react)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump @babel/core from 7.12.10 to 7.13.1 (naturalcrit#1254)

Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.12.10 to 7.13.1.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.1/packages/babel-core)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump nconf from 0.11.1 to 0.11.2 (naturalcrit#1216)

Bumps [nconf](https://github.com/flatiron/nconf) from 0.11.1 to 0.11.2.
- [Release notes](https://github.com/flatiron/nconf/releases)
- [Changelog](https://github.com/indexzero/nconf/blob/master/CHANGELOG.md)
- [Commits](indexzero/nconf@v0.11.1...v0.11.2)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Fix title issue (naturalcrit#1251)

* Maximum title length set to 100 characters.

* Reverse unnecessary change that was incorrectly included in previous commit.

* Reduced code change to one addition on a single line.

* Revert "Reduced code change to one addition on a single line."

This reverts commit 2a355cf.

* Use newer syntax to shorten

Co-authored-by: Trevor Buckner <[email protected]>

* Updated extraKeys (bold and italic) and added new shortcut (for span tags) (naturalcrit#1191)

* Updated extraKeys (bold and italic) and added new shortcut (for span)

* Updated makeSpan shortcut to Ctrl/Cmd-M

* ESLint

* Space after {{ so text appears

Co-authored-by: Trevor Buckner <[email protected]>

Co-authored-by: G.Ambatte <[email protected]>
Co-authored-by: Alexey Sachkov <[email protected]>
Co-authored-by: Rasmus Bækgaard <[email protected]>
Co-authored-by: Rasmus Bækgaard <[email protected]>
Co-authored-by: Christian Brickhouse <[email protected]>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Rodrigo Kuerten <[email protected]>
  • Loading branch information
8 people committed Aug 18, 2021
1 parent 1885a8d commit 3d3a2ae
Show file tree
Hide file tree
Showing 6 changed files with 616 additions and 2 deletions.
78 changes: 78 additions & 0 deletions client/homebrew/editor/editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Editor = createClass({
getDefaultProps : function() {
return {
brew : {
<<<<<<< HEAD
text : '',
style : ''
},
Expand All @@ -37,6 +38,15 @@ const Editor = createClass({
onMetaChange : ()=>{},

renderer : 'legacy'
=======
text : ''
},
onChange : ()=>{},

onMetadataChange : ()=>{},
showMetaButton : true,
renderer : 'legacy'
>>>>>>> e3f9ef0 (v2.11.0 (#1265))
};
},
getInitialState : function() {
Expand Down Expand Up @@ -68,13 +78,18 @@ const Editor = createClass({
},

handleInject : function(injectText){
<<<<<<< HEAD
const text = (this.isText() ? this.props.brew.text : this.props.brew.style);

const lines = text.split('\n');
const cursorPos = this.refs.codeEditor.getCursorPosition();
lines[cursorPos.line] = splice(lines[cursorPos.line], cursorPos.ch, injectText);

this.refs.codeEditor.setCursorPosition(cursorPos.line + injectText.split('\n').length, cursorPos.ch + injectText.length);
=======
const lines = this.props.brew.text.split('\n');
lines[this.cursorPosition.line] = splice(lines[this.cursorPosition.line], this.cursorPosition.ch, injectText);
>>>>>>> e3f9ef0 (v2.11.0 (#1265))

if(this.isText()) this.props.onTextChange(lines.join('\n'));
if(this.isStyle()) this.props.onStyleChange(lines.join('\n'));
Expand All @@ -99,9 +114,13 @@ const Editor = createClass({
if(this.state.view === 'text') {
const codeMirror = this.refs.codeEditor.codeMirror;

<<<<<<< HEAD
//reset custom text styles
const customHighlights = codeMirror.getAllMarks();
for (let i=0;i<customHighlights.length;i++) customHighlights[i].clear();
=======
const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{
>>>>>>> e3f9ef0 (v2.11.0 (#1265))

const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{

Expand All @@ -117,6 +136,7 @@ const Editor = createClass({
}
}

<<<<<<< HEAD
// New Codemirror styling for V3 renderer
if(this.props.renderer == 'V3') {
if(line.startsWith('\\page')){
Expand Down Expand Up @@ -145,6 +165,27 @@ const Editor = createClass({
continue;
}
codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'inline-block' });
=======
if(line.match(/^\\column$/)){
codeMirror.addLineClass(lineNumber, 'text', 'columnSplit');
r.push(lineNumber);
}

// Highlight inline spans {{content}}
if(line.includes('{{') && line.includes('}}')){
const regex = /{{(?:="[\w,\-. ]*"|[^"'\s])*\s*|}}/g;
let match;
let blockCount = 0;
while ((match = regex.exec(line)) != null) {
if(match[0].startsWith('{')) {
blockCount += 1;
} else {
blockCount -= 1;
}
if(blockCount < 0) {
blockCount = 0;
continue;
>>>>>>> e3f9ef0 (v2.11.0 (#1265))
}
} else if(line.trimLeft().startsWith('{{') || line.trimLeft().startsWith('}}')){
// Highlight block divs {{\n Content \n}}
Expand All @@ -155,6 +196,14 @@ const Editor = createClass({
endCh = match.index+match[0].length;
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
}
} else if(line.trimLeft().startsWith('{{') || line.trimLeft().startsWith('}}')){
// Highlight block divs {{\n Content \n}}
let endCh = line.length+1;

const match = line.match(/^ *{{(?:="[\w,\-. ]*"|[^"'\s])*$|^ *}}$/);
if(match)
endCh = match.index+match[0].length;
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
}

return r;
Expand All @@ -173,6 +222,7 @@ const Editor = createClass({
this.refs.codeEditor?.updateSize();
},

<<<<<<< HEAD
renderEditor : function(){
if(this.isText()){
return <CodeEditor key='text'
Expand All @@ -193,6 +243,14 @@ const Editor = createClass({
metadata={this.props.brew}
onChange={this.props.onMetaChange} />;
}
=======
renderMetadataEditor : function(){
if(!this.state.showMetadataEditor) return;
return <MetadataEditor
metadata={this.props.brew}
onChange={this.props.onMetadataChange}
/>;
>>>>>>> e3f9ef0 (v2.11.0 (#1265))
},

render : function(){
Expand All @@ -201,13 +259,33 @@ const Editor = createClass({
<div className='editor' ref='main'>
<SnippetBar
brew={this.props.brew}
<<<<<<< HEAD
view={this.state.view}
onViewChange={this.handleViewChange}
=======
>>>>>>> e3f9ef0 (v2.11.0 (#1265))
onInject={this.handleInject}
showEditButtons={this.props.showEditButtons}
renderer={this.props.renderer} />
<<<<<<< HEAD

{this.renderEditor()}
=======
{this.renderMetadataEditor()}
<CodeEditor
ref='codeEditor'
wrap={true}
language='gfm'
value={this.props.brew.text}
onChange={this.handleTextChange}
onCursorActivity={this.handleCursorActivty} />

{/*
<div className='brewJump' onClick={this.brewJump}>
<i className='fas fa-arrow-right' />
</div>
*/}
>>>>>>> e3f9ef0 (v2.11.0 (#1265))
</div>
);
}
Expand Down
9 changes: 9 additions & 0 deletions client/homebrew/editor/snippetbar/snippetbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ const execute = function(val, brew){
const Snippetbar = createClass({
getDefaultProps : function() {
return {
<<<<<<< HEAD
brew : {},
view : 'text',
onViewChange : ()=>{},
onInject : ()=>{},
onToggle : ()=>{},
showEditButtons : true,
renderer : 'legacy'
=======
brew : {},
onInject : ()=>{},
onToggle : ()=>{},
showmeta : false,
showMetaButton : true,
renderer : ''
>>>>>>> e3f9ef0 (v2.11.0 (#1265))
};
},

Expand Down
4 changes: 2 additions & 2 deletions client/homebrew/pages/homePage/homePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const HomePage = createClass({
getDefaultProps : function() {
return {
brew : {
text : '',
text : ''
},
ver : '0.0.0'
ver : '0.0.0'
};
},
getInitialState : function() {
Expand Down
6 changes: 6 additions & 0 deletions client/homebrew/pages/newPage/newPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ const NewPage = createClass({
localStorage.setItem(BREWKEY, text);
},

handleMetadataChange : function(metadata){
this.setState({
brew : _.merge({}, this.state.brew, metadata)
});
},

handleStyleChange : function(style){
this.setState((prevState)=>({
brew : _.merge({}, prevState.brew, { style: style }),
Expand Down
Loading

0 comments on commit 3d3a2ae

Please sign in to comment.