diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..28da2ef34 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,7 @@ +contact_links: + - name: /r/Homebrewery Subreddit + url: https://www.reddit.com/r/homebrewery + about: The Homebrewery community on Reddit! + - name: Discord of Many Things + url: https://discord.gg/domt + about: "Join the conversation in the #formatting channel on DoMT!" \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..05eda75b4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,21 @@ +name: Feature Request +description: Have an idea to improve the Homebrewery? Let us know! +labels: ["feature request"] +body: + - type: markdown + attributes: + value: "We'd love to hear your idea! Please be sure to [search the current Issues](https://github.com/naturalcrit/homebrewery/issues) for any duplicate requests." + - type: textarea + id: user-request + attributes: + label: "Your idea:" + description: The best feature requests provide an explanation of the current issue and then an explanation of how it could be improved. Screenshots/images can be pasted right in as well! + validations: + required: true + - type: checkboxes + id: terms + attributes: + label: "Please confirm:" + options: + - label: I have searched the Issues tracker for any duplicate requests and found none. + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/general_issue.yml b/.github/ISSUE_TEMPLATE/general_issue.yml new file mode 100644 index 000000000..33dd5b2bc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/general_issue.yml @@ -0,0 +1,54 @@ +name: General Issue +description: Report an issue unrelated to Saving +body: + - type: markdown + attributes: + value: Please include as much information as possible. + - type: checkboxes + id: renderer + attributes: + label: Renderer + description: Which renderer does this issue occur on? If you are unsure, you can check the renderer in the Properties Editor (click the "i" in the Snippet Menu bar above the editor). + options: + - label: Legacy + - label: v3 + validations: + required: true + - type: dropdown + id: browser + attributes: + label: Browser + description: Which browser were you using when the issue occurred? + options: + - Chrome + - Firefox + - Edge + - Safari + - other + validations: + required: true + - type: dropdown + id: operating-system + attributes: + label: Operating System + description: Which OS were you using when the issue occurred? + options: + - Windows + - MacOS + - Linux + - other + validations: + required: true + - type: textarea + id: user-description + attributes: + label: "What happened?" + description: Please include any steps you took leading up to the issue and if you can reproduce it. Let us know what you expected to happen, and what did happen. + validations: + required: true + - type: textarea + id: code + attributes: + label: Code + description: Paste in any relevant code snippet below. + render: gfm \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/save_issue.yml b/.github/ISSUE_TEMPLATE/save_issue.yml new file mode 100644 index 000000000..c08f485ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/save_issue.yml @@ -0,0 +1,26 @@ +name: Saving Issue +description: Report an issue Saving +labels: ["Saving"] +body: + - type: markdown + attributes: + value: | + Woops, sorry there was an issue Saving. Please add any detail you can to this report and check back soon! + - type: textarea + id: error-code + attributes: + label: Error Code + render: shell + - type: textarea + id: user-description + attributes: + label: "Your description of what happened:" + validations: + required: true + - type: markdown + attributes: + value: | + Thanks for the report. Here are some steps that may help in the meantime: + 1. Refreshing your Google credentials in Homebrewery by signing out, and back in (they expire after one year). + 2. Waiting a few minutes and trying again - sometimes there is just a momentary blip in the server. + 3. Check the Issues in Github or the /r/homebrewery subreddit to see if others are experiencing the same issue. diff --git a/changelog.md b/changelog.md index 9fed601f8..fbf376035 100644 --- a/changelog.md +++ b/changelog.md @@ -39,6 +39,121 @@ pre { ## changelog For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). +### Friday 08/09/2022 - v3.2.2 +{{taskList + +##### Jeddai: + +* [x] Fix brews not deleting from User page when removed from Google Drive externally. + + Fixes issues: [#2325](https://github.com/naturalcrit/homebrewery/issues/2325) + +##### G-Ambatte: + +* [x] Brew Tags are now searchable on the User page + +Fixes issues [#2317](https://github.com/naturalcrit/homebrewery/issues/2317), [#2319](https://github.com/naturalcrit/homebrewery/issues/2319), [#2334](https://github.com/naturalcrit/homebrewery/issues/2334) + +* [x] Several tweaks to the User page + + Fixes issues: [#1797](https://github.com/naturalcrit/homebrewery/issues/1797), [#2315](https://github.com/naturalcrit/homebrewery/issues/2315), [#2326](https://github.com/naturalcrit/homebrewery/issues/2326), [#2328](https://github.com/naturalcrit/homebrewery/issues/2328) +}} + +### Wednesday 31/08/2022 - v3.2.1 +{{taskList + +##### Calculuschild + +* [x] Reference Links should now work inside tables + + Fixes issues: [#2307](https://github.com/naturalcrit/homebrewery/issues/2307) + +##### Jeddai: + +* [x] Fix printing from `/new` not working + + Fixes issues: [#1789](https://github.com/naturalcrit/homebrewery/issues/1789), [#1806](https://github.com/naturalcrit/homebrewery/issues/1806) + +* [x] Fix broken snippet buttons on `/new` + + Fixes issues: [#2311](https://github.com/naturalcrit/homebrewery/issues/2311) + +##### G-Ambatte: + +* [x] Several small tweaks to the User page + + Fixes issues: [#2301](https://github.com/naturalcrit/homebrewery/issues/2301), [#2303](https://github.com/naturalcrit/homebrewery/issues/2303), [#2121](https://github.com/naturalcrit/homebrewery/issues/2121) +}} + +\page + +### Saturday 27/08/2022 - v3.2.0 +{{taskList + +##### Calculuschild + +* [x] The V3 renderer is now the default for new brews. + +* [x] Small tweaks to the spacing around the `classTable` style + +##### Jeddai: + +* [x] Brew transfers between Homebrewery and Google Drive now keep the same share and edit links! Metadata is now also kept across transfers. + + Fixes issues: [#1838](https://github.com/naturalcrit/homebrewery/issues/1838) + +* [x] Brews can now be labeled with tags; these will be searchable on the My Brews page in a future update. + + Fixes issues: [#758](https://github.com/naturalcrit/homebrewery/issues/758) + +##### Jlgraves: + +* [x] Small tweaks to the `ClassFeature` snippet + + Fixes issues: [#2215](https://github.com/naturalcrit/homebrewery/issues/2215) +}} + + +### Thursday 09/06/2022 - v3.1.1 +{{taskList + +##### Calculuschild: + +* [x] Fixed class table decorations appearing on top of the table in PDF output. + + Fixes issues: [#1784](https://github.com/naturalcrit/homebrewery/issues/1784) + +* [x] Fix bottom decoration on half class tables disappearing when the table is too short. + + Fixes issues: [#2202](https://github.com/naturalcrit/homebrewery/issues/2202) +}} + +### Monday 06/06/2022 - v3.1.0 +{{taskList + +##### G-Ambatte: + +* [x] "Jump to Preview/Editor" buttons added to the divider bar. Easily sync between the editor and preview panels! + + Fixes issues: [#1756](https://github.com/naturalcrit/homebrewery/issues/1756) + +* [x] Speedups to the user page for users with large and/or many brews. + + Fixes issues: [#2147](https://github.com/naturalcrit/homebrewery/issues/2147) + +* [x] Search text on the user page is saved to the URL for easy bookmarking in your browser + + Fixes issues: [#1858](https://github.com/naturalcrit/homebrewery/issues/1858) + +* [x] Added easy login system for offline installs. + + Fixes issues: [#269](https://github.com/naturalcrit/homebrewery/issues/269) + +* [x] New **THUMBNAIL** option in the {{fa,fa-info-circle}} **Properties** menu. This image will show up in social media links. + + Fixes issues: [#820](https://github.com/naturalcrit/homebrewery/issues/820) +}} + ### Wednesday 27/03/2022 - v3.0.8 {{taskList * [x] Style updates to user page. diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index 2da7123cc..654806886 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -1,3 +1,4 @@ +/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/ require('./brewRenderer.less'); const React = require('react'); const createClass = require('create-react-class'); @@ -13,6 +14,8 @@ const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx'); const NotificationPopup = require('./notificationPopup/notificationPopup.jsx'); const Frame = require('react-frame-component').default; +const Themes = require('themes/themes.json'); + const PAGE_HEIGHT = 1056; const PPR_THRESHOLD = 50; @@ -23,6 +26,7 @@ const BrewRenderer = createClass({ text : '', style : '', renderer : 'legacy', + theme : '5ePHB', errors : [] }; }, @@ -105,7 +109,12 @@ const BrewRenderer = createClass({ renderPageInfo : function(){ return
- {this.state.viewablePageNumber + 1} / {this.state.pages.length} +
+ {this.props.renderer} +
+
+ {this.state.viewablePageNumber + 1} / {this.state.pages.length} +
; }, @@ -113,7 +122,7 @@ const BrewRenderer = createClass({ if(!this.state.usePPR) return; return
- Partial Page Renderer enabled, because your brew is so large. May effect rendering. + Partial Page Renderer is enabled, because your brew is so large. May affect rendering.
; }, @@ -177,6 +186,9 @@ const BrewRenderer = createClass({ render : function(){ //render in iFrame so broken code doesn't crash the site. //Also render dummy page while iframe is mounting. + const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy'; + const themePath = this.props.theme ?? '5ePHB'; + const baseThemePath = Themes[rendererPath][themePath].baseTheme; return ( @@ -188,7 +200,7 @@ const BrewRenderer = createClass({ : null} -
- + + {baseThemePath && + + } + {/* Apply CSS from Style tab and render pages from Markdown tab */} {this.state.isMounted && diff --git a/client/homebrew/brewRenderer/brewRenderer.less b/client/homebrew/brewRenderer/brewRenderer.less index abb80fc5f..bde91c92e 100644 --- a/client/homebrew/brewRenderer/brewRenderer.less +++ b/client/homebrew/brewRenderer/brewRenderer.less @@ -21,11 +21,17 @@ right : 17px; bottom : 0; z-index : 1000; - padding : 8px 10px; background-color : #333; font-size : 10px; font-weight : 800; color : white; + div { + display: inline-block; + padding : 8px 10px; + &:not(:last-child){ + border-right: 1px solid #666; + } + } } .ppr_msg{ position : absolute; diff --git a/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx b/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx index 92193d22c..f0a0f5f1f 100644 --- a/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx +++ b/client/homebrew/brewRenderer/notificationPopup/notificationPopup.jsx @@ -4,7 +4,7 @@ const createClass = require('create-react-class'); const _ = require('lodash'); const cx = require('classnames'); //Unused variable -const DISMISS_KEY = 'dismiss_notification09-9-21'; +const DISMISS_KEY = 'dismiss_notification08-27-22'; const NotificationPopup = createClass({ displayName : 'NotificationPopup', @@ -22,45 +22,45 @@ const NotificationPopup = createClass({ }, notifications : { psa : function(){ - return
  • - V3.0.0 Released!
    - After a long and bumpy road, we decided it was high time we finally release version 3 of the homebrewery into the wild. You can check out a - brief overview and see how to opt-in to the new features here:  - V3 Welcome Page and  - the Changelog. -

    - BE WARNED: As we continue to develop V3, expect small tweaks in the styling, fonts, and snippets; your brews may look slightly - different from day-to-day. All of your old documents will continue to work as normal; we are not touching them. If you don't want to deal - with the possibility of slight formatting changes, you may choose to stick with the Legacy renderer on any of your brews for as long as you like. -

    - With this in mind, if you still wish to try out V3, you can opt-in any of your brews to the the V3 renderer. - This will likely break much of your formatting as a lot of the Markdown code has been updated, and starting from scratch may be cleaner. - (Don't worry, you can always change the renderer back to Legacy for any brew at any time). -
  • ; - }, - refreshGoogle : function (){ - return
  • - Refresh your Google Drive Credentials!
    - Currently a lot of people are striking issues with their Google credentials expiring, which happens one year after the last sign in via - Google. This can cause errors when trying to save your brews. If this happens, simply visit the  - - logout page - - , sign out, and then sign back in "with Google" to refresh your credentials. See  - - this discussion on Github - for more details. -
  • ; - }, - faq : function(){ - return
  • - Protect your work!
    - If you opt not to use your Google Drive, keep in mind that we do not save a history of your projects. Please make frequent backups of your brews!  - - See the FAQ - to learn how to avoid losing your work! -
  • ; - }, + return ( + <> +
  • + V3.2.0 Released!
    + We are happy to announce that after nearly a year of use by our many users, + we are making the V3 render mode the default setting for all new brews. + This mode has become quite popular, and has proven to be stable and powerful. + Of course, we will always keep the option to use the Legacy renderer for any + brew, which can still be accessed from the Properties menu. +
  • + +
  • + Change to Google Drive Storage!
    + We have made a change to the process of tranferring brews between Google + Drive and the Homebrewery storage. Starting now, any time a brew is + transferred, it will keep the same links instead of generating new ones! + We hope this change will help reduce issues where people "lost" their work + by trying to visit old links. +
  • + +
  • + Don't delete your Homebrewery folder on Google Drive!
    + We have had several reports of users losing their brews, not realizing + that they had deleted the files on their Google Drive. If you have a Homebrewery folder + on your Google Drive with *.txt files inside, do not delete it! + We cannot help you recover files that you have deleted from your own + Google Drive. +
  • + +
  • + Protect your work!
    + If you opt not to use your Google Drive, keep in mind that we do not save a history of your projects. Please make frequent backups of your brews!  + + See the FAQ + to learn how to avoid losing your work! +
  • + + ); + } }, checkNotifications : function(){ const hideDismiss = localStorage.getItem(DISMISS_KEY); diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index fce116fcc..de3a53a36 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -61,8 +61,14 @@ const Editor = createClass({ window.removeEventListener('resize', this.updateEditorSize); }, - componentDidUpdate : function() { + componentDidUpdate : function(prevProps, prevState, snapshot) { this.highlightCustomMarkdown(); + if(prevProps.moveBrew !== this.props.moveBrew) { + this.brewJump(); + }; + if(prevProps.moveSource !== this.props.moveSource) { + this.sourceJump(); + }; }, updateEditorSize : function() { @@ -90,15 +96,20 @@ const Editor = createClass({ }, handleViewChange : function(newView){ + this.props.setMoveArrows(newView === 'text'); this.setState({ view : newView }, this.updateEditorSize); //TODO: not sure if updateeditorsize needed }, getCurrentPage : function(){ - const lines = this.props.brew.text.split('\n').slice(0, this.cursorPosition.line + 1); + const lines = this.props.brew.text.split('\n').slice(0, this.refs.codeEditor.getCursorPosition().line + 1); return _.reduce(lines, (r, line)=>{ - if(line.indexOf('\\page') !== -1) r++; + if( + (this.props.renderer == 'legacy' && line.indexOf('\\page') !== -1) + || + (this.props.renderer == 'V3' && line.match(/^\\page$/)) + ) r++; return r; }, 1); }, @@ -120,6 +131,7 @@ const Editor = createClass({ //reset custom line styles codeMirror.removeLineClass(lineNumber, 'background', 'pageLine'); codeMirror.removeLineClass(lineNumber, 'text'); + codeMirror.removeLineClass(lineNumber, 'wrap', 'sourceMoveFlash'); // Styling for \page breaks if((this.props.renderer == 'legacy' && line.includes('\\page')) || @@ -174,9 +186,76 @@ const Editor = createClass({ } }, - brewJump : function(){ - const currentPage = this.getCurrentPage(); - window.location.hash = `p${currentPage}`; + brewJump : function(targetPage=this.getCurrentPage()){ + if(!window) return; + // console.log(`Scroll to: p${targetPage}`); + const brewRenderer = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer')[0]; + const currentPos = brewRenderer.scrollTop; + const targetPos = window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).getBoundingClientRect().top; + const interimPos = targetPos >= 0 ? -30 : 30; + + const bounceDelay = 100; + const scrollDelay = 500; + + if(!this.throttleBrewMove) { + this.throttleBrewMove = _.throttle((currentPos, interimPos, targetPos)=>{ + brewRenderer.scrollTo({ top: currentPos + interimPos, behavior: 'smooth' }); + setTimeout(()=>{ + brewRenderer.scrollTo({ top: currentPos + targetPos, behavior: 'smooth', block: 'start' }); + }, bounceDelay); + }, scrollDelay, { leading: true, trailing: false }); + }; + this.throttleBrewMove(currentPos, interimPos, targetPos); + + // const hashPage = (page != 1) ? `p${page}` : ''; + // window.location.hash = hashPage; + }, + + sourceJump : function(targetLine=null){ + if(this.isText()) { + if(targetLine == null) { + targetLine = 0; + + const pageCollection = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('page'); + const brewRendererHeight = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0).getBoundingClientRect().height; + + let currentPage = 1; + for (const page of pageCollection) { + if(page.getBoundingClientRect().bottom > (brewRendererHeight / 2)) { + currentPage = parseInt(page.id.slice(1)) || 1; + break; + } + } + + const textSplit = this.props.renderer == 'V3' ? /^\\page$/gm : /\\page/; + const textString = this.props.brew.text.split(textSplit).slice(0, currentPage-1).join(textSplit); + const textPosition = textString.length; + const lineCount = textString.match('\n') ? textString.slice(0, textPosition).split('\n').length : 0; + + targetLine = lineCount - 1; //Scroll to `\page`, which is one line back. + + let currentY = this.refs.codeEditor.codeMirror.getScrollInfo().top; + let targetY = this.refs.codeEditor.codeMirror.heightAtLine(targetLine, 'local', true); + + //Scroll 1/10 of the way every 10ms until 1px off. + const incrementalScroll = setInterval(()=>{ + currentY += (targetY - currentY) / 10; + this.refs.codeEditor.codeMirror.scrollTo(null, currentY); + + // Update target: target height is not accurate until within +-10 lines of the visible window + if(Math.abs(targetY - currentY > 100)) + targetY = this.refs.codeEditor.codeMirror.heightAtLine(targetLine, 'local', true); + + // End when close enough + if(Math.abs(targetY - currentY) < 1) { + this.refs.codeEditor.codeMirror.scrollTo(null, targetY); // Scroll any remaining difference + this.refs.codeEditor.setCursorPosition({ line: targetLine + 1, ch: 0 }); + this.refs.codeEditor.codeMirror.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash'); + clearInterval(incrementalScroll); + } + }, 10); + } + } }, //Called when there are changes to the editor's dimensions @@ -248,6 +327,7 @@ const Editor = createClass({ onInject={this.handleInject} showEditButtons={this.props.showEditButtons} renderer={this.props.renderer} + theme={this.props.brew.theme} undo={this.undo} redo={this.redo} historySize={this.historySize()} /> diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx index d692fe262..29c193323 100644 --- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx +++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx @@ -1,9 +1,14 @@ +/* eslint-disable max-lines */ require('./metadataEditor.less'); const React = require('react'); const createClass = require('create-react-class'); const _ = require('lodash'); const cx = require('classnames'); const request = require('superagent'); +const Nav = require('naturalcrit/nav/nav.jsx'); +const StringArrayEditor = require('../stringArrayEditor/stringArrayEditor.jsx'); + +const Themes = require('themes/themes.json'); const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder']; @@ -17,11 +22,12 @@ const MetadataEditor = createClass({ editId : null, title : '', description : '', - tags : '', + tags : [], published : false, authors : [], systems : [], - renderer : 'legacy' + renderer : 'legacy', + theme : '5ePHB' }, onChange : ()=>{} }; @@ -45,9 +51,10 @@ const MetadataEditor = createClass({ }, handleFieldChange : function(name, e){ - this.props.onChange(_.merge({}, this.props.metadata, { + this.props.onChange({ + ...this.props.metadata, [name] : e.target.value - })); + }); }, handleSystem : function(system, e){ if(e.target.checked){ @@ -60,13 +67,22 @@ const MetadataEditor = createClass({ handleRenderer : function(renderer, e){ if(e.target.checked){ this.props.metadata.renderer = renderer; + if(renderer == 'legacy') + this.props.metadata.theme = '5ePHB'; } this.props.onChange(this.props.metadata); }, handlePublish : function(val){ - this.props.onChange(_.merge({}, this.props.metadata, { + this.props.onChange({ + ...this.props.metadata, published : val - })); + }); + }, + + handleTheme : function(theme){ + this.props.metadata.renderer = theme.renderer; + this.props.metadata.theme = theme.path; + this.props.onChange(this.props.metadata); }, handleDelete : function(){ @@ -135,6 +151,45 @@ const MetadataEditor = createClass({ ; }, + renderThemeDropdown : function(){ + if(!global.enable_themes) return; + + const listThemes = (renderer)=>{ + return _.map(_.values(Themes[renderer]), (theme)=>{ + return
    this.handleTheme(theme)} title={''}> + {`${theme.renderer} : ${theme.name}`} + +
    ; + }); + }; + + const currentTheme = Themes[`${_.upperFirst(this.props.metadata.renderer)}`][this.props.metadata.theme]; + let dropdown; + + if(this.props.metadata.renderer == 'legacy') { + dropdown = + +
    + {`Themes are not supported in the Legacy Renderer`} +
    +
    ; + } else { + dropdown = + +
    + {`${_.upperFirst(currentTheme.renderer)} : ${currentTheme.name}`} +
    + {/*listThemes('Legacy')*/} + {listThemes('V3')} +
    ; + } + + return
    + + {dropdown} +
    ; + }, + renderRenderOptions : function(){ if(!global.enable_v3) return; @@ -161,8 +216,8 @@ const MetadataEditor = createClass({ V3 - - Click here for a quick intro to V3! + + Click here to see the demo page for the old Legacy renderer! ; @@ -193,13 +248,11 @@ const MetadataEditor = createClass({ {this.renderThumbnail()} - {/*} -
    - -