0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-23 20:53:05 +00:00

Compare commits

..

298 Commits

Author SHA1 Message Date
Víctor Losada Hernández
1a15b563b8 revert admin.jsx to module.exports for now 2026-01-22 16:18:46 +01:00
Víctor Losada Hernández
cc65b6826d linting 2026-01-22 15:55:03 +01:00
Víctor Losada Hernández
a6ac4600d3 package-lock sync to heroku 2026-01-22 15:41:21 +01:00
Víctor Losada Hernández
3fb84d03bb fix the damn tests once and for all 2026-01-22 15:32:00 +01:00
Trevor Buckner
97d777bba0 calculus's code 2026-01-21 15:03:17 -05:00
Víctor Losada Hernández
375c54d6ff jsdom to globalJsdom 2026-01-21 20:38:00 +01:00
Víctor Losada Hernández
e30ae2b88e like this? 2026-01-21 20:03:41 +01:00
Víctor Losada Hernández
8bce6bb544 nom cache clean 2026-01-21 19:45:28 +01:00
Víctor Losada Hernández
c44e32936f just in dev 2026-01-21 19:42:52 +01:00
Víctor Losada Hernández
b233030bdc lets try calc's way 2026-01-21 19:42:21 +01:00
Víctor Losada Hernández
007ae985c8 this should do it, reverted jsdom global import 2026-01-21 17:30:00 +01:00
Víctor Losada Hernández
f256316b0b Revert "fix tests?"
This reverts commit 51da573e57.
2026-01-21 17:27:46 +01:00
Víctor Losada Hernández
0868b45fa3 Revert "add jsdom"
This reverts commit be37ca4d62.
2026-01-21 17:27:41 +01:00
Víctor Losada Hernández
053fe4d701 Revert "damn npm cache"
This reverts commit 9165032c54.
2026-01-21 17:27:38 +01:00
Víctor Losada Hernández
832b18a4d4 Revert "lets try this"
This reverts commit eab526a051.
2026-01-21 17:27:00 +01:00
Víctor Losada Hernández
51da573e57 fix tests? 2026-01-21 17:21:52 +01:00
Víctor Losada Hernández
9165032c54 damn npm cache 2026-01-21 16:48:55 +01:00
Víctor Losada Hernández
be37ca4d62 add jsdom 2026-01-21 16:44:20 +01:00
Víctor Losada Hernández
21253a2f1f package-lock change? 2026-01-21 16:41:14 +01:00
Víctor Losada Hernández
eab526a051 lets try this 2026-01-21 16:39:59 +01:00
Víctor Losada Hernández
a51d3e1860 linting snippets 2026-01-21 16:18:35 +01:00
Víctor Losada Hernández
4bf485b2e2 lint client 2026-01-21 16:17:11 +01:00
Víctor Losada Hernández
3a6541269a i'll make these changes some other time 2026-01-21 16:09:36 +01:00
Víctor Losada Hernández
a8b93bd81a package-lock 2026-01-21 15:54:01 +01:00
Víctor Losada Hernández
7b00ec9fcf stable version i think 2026-01-21 15:44:33 +01:00
Víctor Losada Hernández
ca426ff68c lint 2026-01-21 09:20:55 +01:00
Víctor Losada Hernández
9e8cdacc68 fix back the vitreum thing 2026-01-20 22:39:18 +01:00
Víctor Losada Hernández
955457f22f some more fixes 2026-01-20 22:31:28 +01:00
Víctor Losada Hernández
fc8656e05b all imports 2026-01-20 22:14:34 +01:00
Víctor Losada Hernández
0d6c3c7e33 fix module.exports 2026-01-20 19:56:37 +01:00
Trevor Buckner
bfe2c11548 Merge pull request #4584 from naturalcrit/v3.20.1
v3.20.1
2026-01-11 17:50:40 -05:00
Trevor Buckner
f98c506a3f Fix version typo in changelog 2026-01-11 14:50:49 -05:00
Trevor Buckner
56f76bceae Update version number 2026-01-11 14:50:34 -05:00
Trevor Buckner
b1a1c86155 Update changelog.md 2026-01-11 14:49:07 -05:00
Trevor Buckner
727ae0693a Merge pull request #4583 from G-Ambatte/fixSaveHashMismatch
Normalize brew text before hashing for saving
2026-01-11 14:19:03 -05:00
G.Ambatte
4370597587 Normalize brew text before hashing 2026-01-11 21:02:12 +13:00
Víctor Losada Hernández
0495513059 Merge pull request #4576 from 5e-Cleric/fix-cover-footnote
fix footnote in coverpages
2026-01-03 17:50:20 +01:00
Víctor Losada Hernández
97392a9630 Merge branch 'master' of https://github.com/naturalcrit/homebrewery into fix-cover-footnote 2026-01-03 17:46:18 +01:00
Víctor Losada Hernández
494791cdd2 simple override 2026-01-03 17:43:08 +01:00
Víctor Losada Hernández
2ed5444bbc Merge pull request #4575 from 5e-Cleric/fix-vault-pagination
fix vault pagination going wild
2026-01-03 17:38:31 +01:00
Víctor Losada Hernández
044b8bf44c fix vault pagination going wild 2026-01-03 17:34:14 +01:00
Trevor Buckner
6dbc4214e5 Merge pull request #4552 from G-Ambatte/fixBackCoverAsset
Fix backCover image asset
2025-12-31 02:36:24 -05:00
G.Ambatte
aca481388e Merge branch 'master' into fixBackCoverAsset 2025-12-30 21:07:23 +13:00
Trevor Buckner
859dbea0bc Merge pull request #4569 from naturalcrit/d100_font_tweaks
D100 font tweaks
2025-12-27 20:53:22 -05:00
Trevor Buckner
12a45c39ed Update .less and .js font files to include the new d100 icons
collapses the d10 icons definitions down into one-liners (~400 lines shorter)
2025-12-27 20:44:18 -05:00
Trevor Buckner
db58c107d8 Remove unnecessary separate diceFontD100.woff2
All icons now reside in diceFont.woff2
2025-12-27 20:43:20 -05:00
Trevor Buckner
f9a4e30dea Tweak number font in D10 dice to match other dice
- Tweak the font in the d10 dice to match the other dice exactly
- Move the d10 icons over to the core diceFont.woff2 file
- Add a set of d100 icons representing an actual d100 ball die
2025-12-27 20:42:50 -05:00
G.Ambatte
d9f4f0a4ec Move image left by 1px 2025-12-01 18:59:13 +13:00
Víctor Losada Hernández
6c85484f78 Merge pull request #4352 from G-Ambatte/experimentalGoogleServiceAccountChange
Add Google service account to file permissions
2025-11-24 17:52:21 +01:00
Víctor Losada Hernández
50ebab21ce Merge branch 'master' into experimentalGoogleServiceAccountChange 2025-11-24 15:23:18 +01:00
Trevor Buckner
d79c4d9566 Merge pull request #4544 from naturalcrit/dependabot/npm_and_yarn/vitreum-929c351
Bump vitreum from `9d55fd6` to `929c351`
2025-11-21 15:21:48 -05:00
dependabot[bot]
d04434fdd8 Bump vitreum from 9d55fd6 to 929c351
Bumps [vitreum](https://github.com/calculuschild/vitreum) from `9d55fd6` to `929c351`.
- [Commits](9d55fd6fb7...929c351881)

---
updated-dependencies:
- dependency-name: vitreum
  dependency-version: 929c351881c4229550374421c7e2890a94f4dca7
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-21 19:04:00 +00:00
Trevor Buckner
755d8bb77f Merge pull request #4543 from naturalcrit/dependabot/npm_and_yarn/googleapis/drive-19.2.0
Bump @googleapis/drive from 18.0.0 to 19.2.0
2025-11-21 14:02:34 -05:00
dependabot[bot]
fd8ffe8747 Bump @googleapis/drive from 18.0.0 to 19.2.0
Bumps [@googleapis/drive](https://github.com/googleapis/google-api-nodejs-client) from 18.0.0 to 19.2.0.
- [Release notes](https://github.com/googleapis/google-api-nodejs-client/releases)
- [Changelog](https://github.com/googleapis/google-api-nodejs-client/blob/main/.release-please-manifest.json)
- [Commits](https://github.com/googleapis/google-api-nodejs-client/compare/run-v18.0.0...drive-v19.2.0)

---
updated-dependencies:
- dependency-name: "@googleapis/drive"
  dependency-version: 19.2.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-21 03:02:38 +00:00
G.Ambatte
a504a2acfe Merge branch 'master' into experimentalGoogleServiceAccountChange 2025-11-21 10:26:49 +13:00
Trevor Buckner
4fcde805ce Merge pull request #4525 from naturalcrit/dependabot/npm_and_yarn/dev-dependencies-d8b0a98ef9
Bump the dev-dependencies group across 1 directory with 2 updates
2025-11-20 11:28:08 -05:00
Trevor Buckner
8d6438feda Merge branch 'master' into dependabot/npm_and_yarn/dev-dependencies-d8b0a98ef9 2025-11-20 11:24:38 -05:00
Trevor Buckner
e85a980ee0 Merge pull request #4536 from naturalcrit/dependabot/npm_and_yarn/prod-dependencies-3bcb05f39f
Bump the prod-dependencies group across 1 directory with 7 updates
2025-11-20 11:24:22 -05:00
Trevor Buckner
106de864ff Merge branch 'master' into dependabot/npm_and_yarn/prod-dependencies-3bcb05f39f 2025-11-20 11:15:43 -05:00
Trevor Buckner
d398cabb52 Merge pull request #4538 from 5e-Cleric/fix-counter-reset
fix .resetCounter
2025-11-20 11:15:05 -05:00
Trevor Buckner
13550c0267 Merge branch 'master' into fix-counter-reset 2025-11-20 11:08:47 -05:00
Trevor Buckner
3997ebfbdf Merge pull request #4540 from naturalcrit/ReworkHTMLRenderer
Rework Marked custom HTML renderer to skip preprocess step
2025-11-19 23:57:07 -05:00
Trevor Buckner
31c034c029 Rework Marked custom HTML renderer to skip preprocess step
Marked Variables are getting cleared when the custom HTML renderer runs, because Marked.parse re-runs the whole pipeline, including the preprocessor.

Preprocess should only be run once globally during the pipeline, or the original results get overwritten (Marked Variables clears its global array of variables each time it is run)
2025-11-19 23:53:39 -05:00
Víctor Losada Hernández
f991235694 fix .resetCounter 2025-11-19 23:36:43 +01:00
dependabot[bot]
9970dd0699 Bump the prod-dependencies group across 1 directory with 7 updates
Bumps the prod-dependencies group with 7 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@babel/preset-react](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-react) | `7.27.1` | `7.28.5` |
| [core-js](https://github.com/zloirock/core-js/tree/HEAD/packages/core-js) | `3.46.0` | `3.47.0` |
| [js-yaml](https://github.com/nodeca/js-yaml) | `4.1.0` | `4.1.1` |
| [marked-emoji](https://github.com/UziTech/marked-emoji) | `2.0.1` | `2.0.2` |
| [marked-gfm-heading-id](https://github.com/markedjs/marked-gfm-heading-id) | `4.1.2` | `4.1.3` |
| [mongoose](https://github.com/Automattic/mongoose) | `8.19.2` | `8.20.0` |
| [react-router](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router) | `7.9.5` | `7.9.6` |



Updates `@babel/preset-react` from 7.27.1 to 7.28.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.28.5/packages/babel-preset-react)

Updates `core-js` from 3.46.0 to 3.47.0
- [Release notes](https://github.com/zloirock/core-js/releases)
- [Changelog](https://github.com/zloirock/core-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zloirock/core-js/commits/v3.47.0/packages/core-js)

Updates `js-yaml` from 4.1.0 to 4.1.1
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.1.0...4.1.1)

Updates `marked-emoji` from 2.0.1 to 2.0.2
- [Release notes](https://github.com/UziTech/marked-emoji/releases)
- [Changelog](https://github.com/UziTech/marked-emoji/blob/main/release.config.cjs)
- [Commits](https://github.com/UziTech/marked-emoji/compare/v2.0.1...v2.0.2)

Updates `marked-gfm-heading-id` from 4.1.2 to 4.1.3
- [Release notes](https://github.com/markedjs/marked-gfm-heading-id/releases)
- [Changelog](https://github.com/markedjs/marked-gfm-heading-id/blob/main/release.config.cjs)
- [Commits](https://github.com/markedjs/marked-gfm-heading-id/compare/v4.1.2...v4.1.3)

Updates `mongoose` from 8.19.2 to 8.20.0
- [Release notes](https://github.com/Automattic/mongoose/releases)
- [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Automattic/mongoose/compare/8.19.2...8.20.0)

Updates `react-router` from 7.9.5 to 7.9.6
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router@7.9.6/packages/react-router)

---
updated-dependencies:
- dependency-name: "@babel/preset-react"
  dependency-version: 7.28.5
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: prod-dependencies
- dependency-name: core-js
  dependency-version: 3.47.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: prod-dependencies
- dependency-name: js-yaml
  dependency-version: 4.1.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: marked-emoji
  dependency-version: 2.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: marked-gfm-heading-id
  dependency-version: 4.1.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: mongoose
  dependency-version: 8.20.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: prod-dependencies
- dependency-name: react-router
  dependency-version: 7.9.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-19 03:02:34 +00:00
dependabot[bot]
9f721ff2fc Bump the dev-dependencies group across 1 directory with 2 updates
Bumps the dev-dependencies group with 2 updates in the / directory: [eslint](https://github.com/eslint/eslint) and [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest).


Updates `eslint` from 9.39.0 to 9.39.1
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v9.39.0...v9.39.1)

Updates `eslint-plugin-jest` from 29.0.1 to 29.1.0
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v29.0.1...v29.1.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 9.39.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: dev-dependencies
- dependency-name: eslint-plugin-jest
  dependency-version: 29.1.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: dev-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-19 03:01:21 +00:00
Trevor Buckner
6a02ed410b Merge pull request #4534 from G-Ambatte/fixNewNavItem
Update New Item on NavBar
2025-11-17 23:49:42 -05:00
Trevor Buckner
429ad4d63b Linting and move checkLocalStorage inside confirmLocalStorageChange 2025-11-17 23:48:56 -05:00
Trevor Buckner
033893361d Merge branch 'master' into fixNewNavItem 2025-11-17 23:25:44 -05:00
Trevor Buckner
f1ae7e4d26 Merge pull request #4533 from naturalcrit/fix-editor-issues
Fix small bugs towards 3.20
2025-11-17 23:22:04 -05:00
Trevor Buckner
059d6d7939 Lint 2025-11-17 23:09:47 -05:00
G.Ambatte
73b7d6887b Fix typo in state property name for snippet bar height 2025-11-17 17:09:23 +13:00
Víctor Losada Hernández
f1891d9250 use state instead 2025-11-16 19:02:37 +01:00
G.Ambatte
a17ccdb2a2 Merge branch 'master' into fixNewNavItem 2025-11-16 13:19:08 +13:00
G.Ambatte
c784e2e63b Fix New item on Nav Bar 2025-11-16 13:12:40 +13:00
Víctor Losada Hernández
1d061e6d3f Merge branch 'master' of https://github.com/naturalcrit/homebrewery into fix-editor-issues 2025-11-15 23:41:10 +01:00
Víctor Losada Hernández
5e7fdb34a9 Revert "remove new brew nav item from new page"
This reverts commit b6478f3964.
2025-11-15 23:40:01 +01:00
Víctor Losada Hernández
677e8eaf6c Merge pull request #4532 from G-Ambatte/fixUnearthedArcanaTheme
Fix UnearthedArcana theme
2025-11-15 17:52:59 +01:00
Víctor Losada Hernández
b6478f3964 remove new brew nav item from new page 2025-11-15 17:25:25 +01:00
Víctor Losada Hernández
f18a73e1ff fix glitch in newPage 2025-11-15 17:25:05 +01:00
Víctor Losada Hernández
b78f5079df bring back update native func 2025-11-15 16:59:32 +01:00
Víctor Losada Hernández
7bc41f9b0d fix snippetbar hidden 2025-11-15 16:49:48 +01:00
Víctor Losada Hernández
a217779e76 fix snippetbar wrap 2025-11-15 16:05:21 +01:00
G.Ambatte
ad3d63a5b1 Merge branch 'master' into fixUnearthedArcanaTheme 2025-11-15 18:44:33 +13:00
G.Ambatte
93ef9bfd51 Set UnearthedArcana baseTheme to Blank 2025-11-15 18:33:22 +13:00
Trevor Buckner
a0cfec7668 test change 2025-11-15 04:35:23 +00:00
Trevor Buckner
972c675629 Merge pull request #4527 from MiniX16/master
Add unsaved-change warning to Home page editor
2025-11-14 23:04:19 -05:00
Trevor Buckner
fa9f180759 Modify slightly to follow the existing structure in editPage.jsx for easier merging of these pages later 2025-11-14 22:59:34 -05:00
G.Ambatte
435c6dcc6f Merge branch 'master' into experimentalGoogleServiceAccountChange 2025-11-15 16:40:47 +13:00
Trevor Buckner
5625121b82 Merge branch 'master' into master 2025-11-14 22:25:47 -05:00
Trevor Buckner
b6065dbcf5 Fix page break in changelog 2025-11-15 03:12:29 +00:00
Trevor Buckner
24065b43e9 bump version to 3.20.0 2025-11-15 03:07:56 +00:00
G.Ambatte
e063eab4e7 Make error messages more distinctive 2025-11-15 15:40:55 +13:00
G.Ambatte
1adbbc2ced Updated error message on failure to set permissions on Google Drive file 2025-11-15 15:37:01 +13:00
G.Ambatte
7547454084 Merge branch 'master' into experimentalGoogleServiceAccountChange 2025-11-15 15:33:54 +13:00
G.Ambatte
d73b695127 Merge branch 'master' into master 2025-11-15 14:34:13 +13:00
Trevor Buckner
acd37bff4f Merge pull request #4409 from G-Ambatte/fixUserPageLinks-#807
Change all links to User Page to use encodeURIComponent
2025-11-14 17:20:12 -05:00
Trevor Buckner
76a4ff11b3 Merge branch 'master' into fixUserPageLinks-#807 2025-11-14 17:19:45 -05:00
MiniX16
b66625e59d Handle unsaved warning with onbeforeunload 2025-11-13 12:16:37 +01:00
Trevor Buckner
885a59a05f Merge pull request #4526 from G-Ambatte/fixEditPageGoogleTransfer
Fix transferring brews to/from Google storage
2025-11-12 14:46:57 -05:00
Trevor Buckner
2012f373c0 Merge branch 'master' into fixEditPageGoogleTransfer 2025-11-12 14:46:41 -05:00
MiniX16
590688f123 Add unsaved-change warning to Home page editor 2025-11-12 17:59:28 +01:00
G.Ambatte
6a4ea2c6c9 Move toggleGoogleStorage's trySave call to useEffect block 2025-11-11 22:06:44 +13:00
Víctor Losada Hernández
ba2449f3d6 Merge branch 'master' into experimentalGoogleServiceAccountChange 2025-11-10 23:57:25 +01:00
Víctor Losada Hernández
6ccefc2399 Merge pull request #4510 from Gazook89/Move-Nav.JSX
Move nav.jsx from shared to client directory
2025-11-10 23:41:39 +01:00
Víctor Losada Hernández
8d2744d106 Merge branch 'master' into Move-Nav.JSX 2025-11-10 23:38:21 +01:00
Víctor Losada Hernández
fe616a534a Merge pull request #4517 from G-Ambatte/fixSaveOnNewPage
Fix CTRL+S triggering save on New Page
2025-11-10 23:38:06 +01:00
Víctor Losada Hernández
71462ef782 Merge branch 'master' into fixSaveOnNewPage 2025-11-10 23:33:43 +01:00
Víctor Losada Hernández
64589bfda6 Merge pull request #4514 from Gazook89/move-codeEditor-to-components
Move codeEditor to components directory
2025-11-10 23:26:22 +01:00
G.Ambatte
14ea286aa2 Remove Google permissions check function 2025-11-10 06:07:37 +00:00
G.Ambatte
de85c84685 Remove permissionsCheck from brew listing 2025-11-10 06:05:58 +00:00
G.Ambatte
35d93582d7 Remove unnecessary async map function 2025-11-10 06:04:10 +00:00
G.Ambatte
c2ceba2ff6 Merge branch 'master' into experimentalGoogleServiceAccountChange 2025-11-10 19:00:06 +13:00
Gazook89
f9f33955bc Merge branch 'master' into move-codeEditor-to-components 2025-11-09 23:30:53 -06:00
Gazook89
2ce13f61e1 update relative paths to absolute paths 2025-11-09 23:29:55 -06:00
Gazook89
6db4bf2274 Merge branch 'master' into Move-Nav.JSX 2025-11-09 23:24:21 -06:00
Trevor Buckner
750c237e02 Merge pull request #4513 from Gazook89/move-SVGs-to-components
Move SVG components to components folder
2025-11-09 18:39:44 -05:00
Trevor Buckner
1c8ef9ff3e Merge branch 'master' into move-SVGs-to-components 2025-11-09 18:37:20 -05:00
Trevor Buckner
5ca75ff0ef Merge pull request #4506 from dbolack-ab/dockerBuild
Add Docker Image build and Publish functions to package,json
2025-11-09 18:28:56 -05:00
Trevor Buckner
b5400b6959 Merge branch 'master' into dockerBuild 2025-11-09 18:24:07 -05:00
Trevor Buckner
e6e66ec1cc Merge branch 'master' into Move-Nav.JSX 2025-11-09 18:19:28 -05:00
Trevor Buckner
9da28f06e5 Merge pull request #4516 from Gazook89/move-markdown.js
Move markdown.js and markdownlegacy.js
2025-11-09 18:15:39 -05:00
Trevor Buckner
af348e7b2c Merge branch 'master' into move-markdown.js 2025-11-08 21:47:02 -05:00
Trevor Buckner
e02890c03e Merge pull request #4512 from Gazook89/Move-renderWarnings
Move renderWarnings from shared to client
2025-11-08 21:46:01 -05:00
G.Ambatte
20d38d03d6 Rename New Page save function to trySave for better Edit Page compatibility 2025-11-06 22:29:43 +13:00
Gazook89
c5aa774daa Move markdown.js and markdownlegacy.js
Moves the two files up a level, directly in `/shared/`.  Everything else is just updating paths for that.
2025-11-04 22:29:28 -06:00
Gazook89
29fe6430ce Move codeEditor to components directory
This simply moves the codeEditor folder to the components directory.  `codeEditor.jsx` simply builds a component which is then used elsewhere, and isn't shared between client and server, so it should be in the client directory.

Arguably it could go in `client/homebrew/editor` but I think the `/homebrew/` folder should be eliminated down the line and it's contents just re-sorted.

When working on the editor right now it's a pain to switch between `shared` and `client` hunting for the right file.
2025-11-04 13:12:56 -06:00
Gazook89
c38cc77fd0 Move SVG components to components folder
Move the SVGs out of the `shared` directory, closer to where they are actually used.  They are svg jsx files, setup as components, so i've moved them to the components directory.

Deleted `combat.svg.jsx` because we don't use it anywhere.

renamed the remaining two to be more descriptive of the image for additional clarity.
2025-11-04 12:52:12 -06:00
Gazook89
fc569e560b Move renderWarnings from shared to client
Moving this component to the component folder so it's closer to where it is actually used.  Not moving to the `homebrew` folder because ultimately i think pretty much everything in that folder should move to the components as well (`homebrew` isn't a helpful folder distinction).

Deletes a directory, moves 2 files.
2025-11-03 21:50:31 -06:00
Gazook89
081fd6f39d Move nav.jsx from shared to client directory
Moving the one file, changing a lot of imports (18 files), and deleting a directory.
2025-11-03 20:58:00 -06:00
Trevor Buckner
7c85be5db2 Merge pull request #4451 from dbolack-ab/markdown-variables
Update markdown.js to use external npm version of markdown variables
2025-11-02 22:56:23 -05:00
Trevor Buckner
e0149f4c34 Update package-lock.json from merge conflict 2025-11-02 22:52:46 -05:00
Trevor Buckner
873a009833 Merge branch 'master' into pr/4451 2025-11-02 22:51:27 -05:00
Trevor Buckner
af5720c7e2 Update to marked-variables v1.0.4 2025-11-02 22:48:25 -05:00
David Bolack
bc41b9043d Remove circleci tests 2025-10-28 14:44:54 -05:00
David Bolack
a0d288057f Add Docker Image build and Publish to workflow
Adds docker:build and docker:publish npm scripts
expects DOCKERID to contain the user/organization id for formatting the tag ( DOCKERID/hombrewery:version )

Add CircleCI test to ensure image still builds
2025-10-28 14:10:04 -05:00
Trevor Buckner
1f89acb018 Merge pull request #4485 from dbolack-ab/License_Add-Mongoose
Add Mongoose 3rd party programs to Licenses menu
2025-10-23 20:19:41 -04:00
Trevor Buckner
93a3651627 Merge branch 'master' into License_Add-Mongoose 2025-10-23 20:17:53 -04:00
Trevor Buckner
112c5c31c4 Merge pull request #4499 from dbolack-ab/License_Add-GreenRonin
Add Green Ronin licenses to license menu
2025-10-23 20:14:46 -04:00
David Bolack
3ad8d98935 Merge branch 'master' into License_Add-GreenRonin 2025-10-23 16:58:58 -05:00
Trevor Buckner
eeb9ec6b91 Merge branch 'master' into License_Add-Mongoose 2025-10-23 16:43:47 -04:00
Trevor Buckner
c7d27a2b13 Merge pull request #4502 from dbolack-ab/Licnese_Add_Icons
Add Icons Compatibility License to License Menu
2025-10-23 16:43:33 -04:00
Trevor Buckner
711815ae47 Merge branch 'master' into License_Add-Mongoose 2025-10-23 16:05:59 -04:00
Trevor Buckner
705655ba94 Merge branch 'master' into Licnese_Add_Icons 2025-10-23 16:05:50 -04:00
Trevor Buckner
1703c76f6d Merge pull request #4484 from dbolack-ab/License_Snippets_Redux
Add License Snippets for 3rd Party Publishing licenses.
2025-10-23 16:03:46 -04:00
Trevor Buckner
b632f93166 Merge branch 'master' into License_Snippets_Redux 2025-10-23 16:00:51 -04:00
David Bolack
5f89585206 Temporarily remove licesnes I cannot find communications on:
Forged in the Dark
  StarForger's Guild
  Hall of Champions
2025-10-23 10:13:46 -05:00
David Bolack
25d8cb3c10 Add Icons Licenses and Logos 2025-10-23 10:11:49 -05:00
David Bolack
b26e59fbbb Update copyright year 2025-10-23 09:19:25 -05:00
David Bolack
b3599ac26a Add default sizing to GR Logos 2025-10-22 17:35:00 -05:00
David Bolack
1db21c4658 Remove Uncommitted images
remove unneeded lodash reference
2025-10-22 17:17:13 -05:00
David Bolack
c0113d44ea Apply requested updates
Rename logofiles to a `Publisher-Name_License-Name_Logo-Identifier` format
Update file references
Remove unneeded lodash inclusions.
2025-10-22 17:13:59 -05:00
David Bolack
70051b84fd Add Green Ronin back
Rename Green Ronin Logos
2025-10-22 16:49:49 -05:00
Trevor Buckner
1a0b481756 Merge pull request #4481 from 5e-Cleric/fix-save-button-glitch
fix save button glitch
2025-10-22 14:11:25 -04:00
Trevor Buckner
0877802074 Merge branch 'master' into fix-save-button-glitch 2025-10-22 14:11:08 -04:00
David Bolack
3ca5fabb4f Small tweaks to Mongoose license presentation.
2300 AD -> 2300AD
CRS after each license
Twilight 2000 -> Twilight:2000
2025-10-21 15:49:13 -05:00
David Bolack
132a3de979 Add CR at end of snippet inserts, correct apostrophe on menu 2025-10-21 15:34:29 -05:00
David Bolack
435ef656a2 Fix snippets file. Not sure what went wrong there... 2025-10-18 10:58:47 -05:00
David Bolack
053d7bef6a Add Mongoose licenses back for initial work 2025-10-17 15:16:12 -05:00
David Bolack
807a938f01 Tweak Hero Kids, remove Mongoose file... for now. 2025-10-17 15:12:55 -05:00
David Bolack
e22bdfad0e Merge branch 'master' into License_Snippets_Redux 2025-10-17 14:54:16 -05:00
Víctor Losada Hernández
05ffd97f3a Merge pull request #4473 from naturalcrit/dependabot/npm_and_yarn/googleapis/drive-18.0.0
Bump @googleapis/drive from 13.0.1 to 18.0.0
2025-10-17 14:49:01 +02:00
Víctor Losada Hernández
b120bac424 Merge branch 'master' into dependabot/npm_and_yarn/googleapis/drive-18.0.0 2025-10-17 14:42:15 +02:00
Trevor Buckner
862d3ea6e7 Merge branch 'master' into fix-save-button-glitch 2025-10-16 23:09:32 -04:00
Trevor Buckner
a9280b65ee Merge pull request #4445 from dbolack-ab/issue_4201
Regex for parsing mustache blocks does not allow some expected characters - take 2
2025-10-16 21:35:02 -04:00
David Bolack
7e4facb478 Remove greater than and less than from evaluation.
Use calc's more concise regex

Remove errant space.
2025-10-16 10:45:00 -05:00
David Bolack
c9f1413a2d Merge branch 'master' into issue_4201 2025-10-16 10:34:26 -05:00
Víctor Losada Hernández
f7d7b6241e Merge branch 'master' of https://github.com/naturalcrit/homebrewery into fix-save-button-glitch 2025-10-16 10:02:50 +02:00
Víctor Losada Hernández
7502a260ea initial commit 2025-10-15 23:21:00 +02:00
Trevor Buckner
85252abeb5 Merge pull request #4478 from 5e-Cleric/fix-footer-text
Add uppercase style to footnotes
2025-10-15 17:14:32 -04:00
Trevor Buckner
ac583c64bc Merge branch 'master' into fix-footer-text 2025-10-15 17:12:46 -04:00
Trevor Buckner
de75100200 Merge pull request #4476 from 5e-Cleric/fix-googleId-error
handle getid uncatched error
2025-10-15 17:09:17 -04:00
Trevor Buckner
d8aabb2f57 Merge branch 'master' into fix-googleId-error 2025-10-15 17:08:23 -04:00
Trevor Buckner
a823034d6e Merge pull request #4479 from 5e-Cleric/bring-some-visibility-to-the-search-bar
Increase visibility of the search bar
2025-10-15 17:07:52 -04:00
Trevor Buckner
aa2362d822 Merge branch 'master' into bring-some-visibility-to-the-search-bar 2025-10-15 17:07:00 -04:00
Trevor Buckner
2b58bf49d0 Merge pull request #4480 from 5e-Cleric/fix-cursor-on-navigation
Fix cursor on head navigation
2025-10-15 17:06:05 -04:00
Víctor Losada Hernández
11d3cddff0 Revert "initial commit"
This reverts commit 3c3ca7981b.
2025-10-15 22:25:36 +02:00
Víctor Losada Hernández
47c84428c7 initial commit 2025-10-15 22:24:45 +02:00
Víctor Losada Hernández
3c3ca7981b initial commit 2025-10-15 22:24:07 +02:00
Víctor Losada Hernández
d728126480 initial commit 2025-10-15 22:01:13 +02:00
Víctor Losada Hernández
27861ba796 add uppercase style to footnotes 2025-10-15 21:50:01 +02:00
Víctor Losada Hernández
3f29eb227a next for throw 2025-10-15 21:22:45 +02:00
Víctor Losada Hernández
f604d0a41f handle getid uncatched error 2025-10-15 20:52:34 +02:00
dependabot[bot]
9f48755f80 Bump @googleapis/drive from 13.0.1 to 18.0.0
Bumps [@googleapis/drive](https://github.com/googleapis/google-api-nodejs-client) from 13.0.1 to 18.0.0.
- [Release notes](https://github.com/googleapis/google-api-nodejs-client/releases)
- [Changelog](https://github.com/googleapis/google-api-nodejs-client/blob/main/.release-please-manifest.json)
- [Commits](https://github.com/googleapis/google-api-nodejs-client/compare/iam-v13.0.1...run-v18.0.0)

---
updated-dependencies:
- dependency-name: "@googleapis/drive"
  dependency-version: 18.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-14 03:03:35 +00:00
Trevor Buckner
33f5d26b39 Merge pull request #4449 from dbolack-ab/d100-dicefont
Alternate Add d100/percentage support to dicefont icons
2025-10-13 20:11:30 -04:00
Trevor Buckner
3ad463cff7 Merge branch 'master' into d100-dicefont 2025-10-13 20:10:54 -04:00
Trevor Buckner
6c8265688f Restore missing empty d10 2025-10-13 20:10:31 -04:00
Trevor Buckner
d1f5c9da0d Update diceFont.less to use DiceFont100 instead of dicefont-percent 2025-10-13 20:06:13 -04:00
Trevor Buckner
43e465ceb8 Rename font to match format of existing diceFont font file. 2025-10-13 20:05:42 -04:00
Trevor Buckner
b864e9b677 Update diceFont.js to use d10 instead of dper 2025-10-13 20:05:09 -04:00
Víctor Losada Hernández
28e02f1863 Merge pull request #4466 from naturalcrit/dependabot/npm_and_yarn/prod-dependencies-f151d22b6b
Bump the prod-dependencies group across 1 directory with 10 updates
2025-10-13 23:50:02 +02:00
dependabot[bot]
333614f866 Bump the prod-dependencies group across 1 directory with 10 updates
Bumps the prod-dependencies group with 10 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) | `7.28.0` | `7.28.4` |
| [@babel/plugin-transform-runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-runtime) | `7.28.0` | `7.28.3` |
| [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) | `7.28.0` | `7.28.3` |
| [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime) | `7.27.6` | `7.28.4` |
| [core-js](https://github.com/zloirock/core-js/tree/HEAD/packages/core-js) | `3.44.0` | `3.46.0` |
| [fs-extra](https://github.com/jprichardson/node-fs-extra) | `11.3.0` | `11.3.2` |
| [marked-subsuper-text](https://github.com/naturalcrit/marked-subsuper-text) | `1.0.3` | `1.0.4` |
| [mongoose](https://github.com/Automattic/mongoose) | `8.16.3` | `8.19.1` |
| [nanoid](https://github.com/ai/nanoid) | `5.1.5` | `5.1.6` |
| [react-router](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router) | `7.6.3` | `7.9.4` |



Updates `@babel/core` from 7.28.0 to 7.28.4
- [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.28.4/packages/babel-core)

Updates `@babel/plugin-transform-runtime` from 7.28.0 to 7.28.3
- [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.28.3/packages/babel-plugin-transform-runtime)

Updates `@babel/preset-env` from 7.28.0 to 7.28.3
- [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.28.3/packages/babel-preset-env)

Updates `@babel/runtime` from 7.27.6 to 7.28.4
- [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.28.4/packages/babel-runtime)

Updates `core-js` from 3.44.0 to 3.46.0
- [Release notes](https://github.com/zloirock/core-js/releases)
- [Changelog](https://github.com/zloirock/core-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zloirock/core-js/commits/v3.46.0/packages/core-js)

Updates `fs-extra` from 11.3.0 to 11.3.2
- [Changelog](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jprichardson/node-fs-extra/compare/11.3.0...11.3.2)

Updates `marked-subsuper-text` from 1.0.3 to 1.0.4
- [Changelog](https://github.com/naturalcrit/marked-subsuper-text/blob/main/release.config.cjs)
- [Commits](https://github.com/naturalcrit/marked-subsuper-text/commits)

Updates `mongoose` from 8.16.3 to 8.19.1
- [Release notes](https://github.com/Automattic/mongoose/releases)
- [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Automattic/mongoose/compare/8.16.3...8.19.1)

Updates `nanoid` from 5.1.5 to 5.1.6
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/5.1.5...5.1.6)

Updates `react-router` from 7.6.3 to 7.9.4
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router@7.9.4/packages/react-router)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-version: 7.28.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: "@babel/plugin-transform-runtime"
  dependency-version: 7.28.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: "@babel/preset-env"
  dependency-version: 7.28.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: "@babel/runtime"
  dependency-version: 7.28.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: prod-dependencies
- dependency-name: core-js
  dependency-version: 3.46.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: prod-dependencies
- dependency-name: fs-extra
  dependency-version: 11.3.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: marked-subsuper-text
  dependency-version: 1.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: mongoose
  dependency-version: 8.19.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: prod-dependencies
- dependency-name: nanoid
  dependency-version: 5.1.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: prod-dependencies
- dependency-name: react-router
  dependency-version: 7.9.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: prod-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-13 21:45:46 +00:00
Trevor Buckner
efc8561447 Merge pull request #4450 from dbolack-ab/issue_2963
Keep the cursor in the active view page after a divider width change.
2025-10-13 13:40:47 -04:00
Trevor Buckner
9e80151eda Merge branch 'master' into issue_2963 2025-10-13 13:38:41 -04:00
Trevor Buckner
d695f8f7bc Merge pull request #4469 from 5e-Cleric/remove-config-enable-checks
Remove enable_themes and enable_v3 checks
2025-10-13 13:37:58 -04:00
Trevor Buckner
ae47442ed5 Merge branch 'master' into remove-config-enable-checks 2025-10-13 13:37:49 -04:00
Víctor Losada Hernández
34ee1853e1 Merge pull request #4459 from naturalcrit/dependabot/npm_and_yarn/dev-dependencies-8d5f5caba3
Bump the dev-dependencies group across 1 directory with 4 updates
2025-10-13 17:46:58 +02:00
David Bolack
fbf0d425e2 Don't pass isDragging to splitpane children. 2025-10-11 09:07:23 -05:00
David Bolack
8fcadd87d4 Remove comments 2025-10-09 20:24:01 -05:00
David Bolack
2de151d348 Rename font 2025-10-09 19:31:30 -05:00
David Bolack
1eff2dbedd Change dpercent to d10 2025-10-09 19:25:40 -05:00
dependabot[bot]
4ccec08f21 Bump the dev-dependencies group across 1 directory with 4 updates
Bumps the dev-dependencies group with 4 updates in the / directory: [eslint](https://github.com/eslint/eslint), [globals](https://github.com/sindresorhus/globals), [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest) and [stylelint](https://github.com/stylelint/stylelint).


Updates `eslint` from 9.35.0 to 9.37.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v9.35.0...v9.37.0)

Updates `globals` from 16.3.0 to 16.4.0
- [Release notes](https://github.com/sindresorhus/globals/releases)
- [Commits](https://github.com/sindresorhus/globals/compare/v16.3.0...v16.4.0)

Updates `jest` from 30.1.3 to 30.2.0
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v30.2.0/packages/jest)

Updates `stylelint` from 16.24.0 to 16.25.0
- [Release notes](https://github.com/stylelint/stylelint/releases)
- [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stylelint/stylelint/compare/16.24.0...16.25.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-version: 9.37.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: dev-dependencies
- dependency-name: globals
  dependency-version: 16.4.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: dev-dependencies
- dependency-name: jest
  dependency-version: 30.2.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: dev-dependencies
- dependency-name: stylelint
  dependency-version: 16.25.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: dev-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-07 03:01:39 +00:00
Trevor Buckner
3be62bd254 Merge pull request #4448 from G-Ambatte/addDBCheckMiddleware
Add DB check middleware
2025-10-06 14:20:28 -04:00
G.Ambatte
0d38b8607e Shift to router.use(dbCheck) instead of defining on every route 2025-10-06 18:51:05 +13:00
G.Ambatte
5e35ae0c8b Merge branch 'master' into addDBCheckMiddleware 2025-10-06 18:12:40 +13:00
Trevor Buckner
5f72dd2023 Merge pull request #4462 from naturalcrit/PreventInterruptedBrewJump
Move badly-placed scrollingTimeout that was doing nothing
2025-10-06 00:07:50 -04:00
Trevor Buckner
7fc03bb5a7 Merge branch 'master' into PreventInterruptedBrewJump 2025-10-06 00:07:43 -04:00
Trevor Buckner
ccf11661de Merge pull request #4461 from naturalcrit/LintEverythingOct2025
Lint everything
2025-10-06 00:07:29 -04:00
Trevor Buckner
811f274968 Move badly-placed scrollingTimeout that was doing nothing
When a user clicks brewJump or sourceJump, we disallow new jumps until the current scroll operation has finished for 150 ms. Unfortunately the timer being checked was always undefined, so you could keep clicking the jump button and get the brewRenderer or editor to keep bouncing around without finishing the jump action.

This just moves the scrollingTimeout up outside of the listener function so it isn't being reset to undefined every loop.
2025-10-06 00:06:34 -04:00
Trevor Buckner
63bebe1efd Lint everything
Catching up on a bunch of linting so random changes stop showing up on PRs when the linter is run.
2025-10-06 00:02:24 -04:00
G.Ambatte
8b2c8c0feb Merge branch 'master' into addDBCheckMiddleware 2025-10-06 16:48:37 +13:00
Trevor Buckner
22e26d635a Merge pull request #4460 from naturalcrit/cleanupLocalStorageKeysTest
Clean up localStorageMap code
2025-10-05 23:28:34 -04:00
Víctor Losada Hernández
4a5bb1efb1 initial commit 2025-10-05 22:14:13 +02:00
David Bolack
460b12e356 Proposed fix per calc.
This also works but has different currsor behavior.

Original fix left in place, commented pending decisions.
2025-10-05 11:26:43 -05:00
G.Ambatte
c17a5e72b9 Switch to Calc's simplified test spec 2025-10-05 15:40:40 +13:00
G.Ambatte
88bc9b79c9 Add new error message to nav bar error container 2025-10-05 15:31:53 +13:00
G.Ambatte
a14ea89562 Post-merge cleanup 2025-10-05 15:31:04 +13:00
G.Ambatte
bb0a840113 Fix HBErrorCode to string, not number 2025-10-05 15:30:47 +13:00
G.Ambatte
d40f8ff380 Merge branch 'master' into addDBCheckMiddleware 2025-10-05 14:58:56 +13:00
David Bolack
071f95994a Merge branch 'master' into markdown-variables 2025-10-03 19:00:43 -05:00
David Bolack
99a85ccbca Merge branch 'master' into issue_2963 2025-10-03 18:57:51 -05:00
David Bolack
5ae2f3fff7 Merge branch 'master' into d100-dicefont 2025-10-03 18:55:15 -05:00
David Bolack
8bc5f7312e Merge branch 'master' into issue_4201 2025-10-03 18:47:54 -05:00
G.Ambatte
2b138e56db Add dbCheck middleware to app.js routes that use DB 2025-10-04 12:29:06 +13:00
G.Ambatte
f141c0bebd Move dbCheck to only API calls that touch the database 2025-10-02 19:28:10 +13:00
G.Ambatte
9f3944d038 Merge branch 'master' into fixUserPageLinks-#807 2025-09-29 23:14:59 +13:00
G.Ambatte
7c050fb9a9 Merge branch 'master' into addDBCheckMiddleware 2025-09-27 22:00:30 +12:00
David Bolack
40eaf202e2 Merge branch 'master' into License_Snippets_Redux 2025-09-22 20:45:27 -05:00
David Bolack
bbfbf0d541 Merge branch 'master' into markdown-variables 2025-09-22 20:45:05 -05:00
David Bolack
da134ffdcc Merge branch 'master' into d100-dicefont 2025-09-22 20:43:48 -05:00
David Bolack
a9b7a37c1b Merge branch 'master' into issue_2963 2025-09-22 20:37:32 -05:00
David Bolack
0ab882a33c Merge branch 'master' into issue_4201 2025-09-22 20:35:42 -05:00
G.Ambatte
e1fb0a42c3 Merge branch 'master' into fixUserPageLinks-#807 2025-09-20 20:23:58 +12:00
G.Ambatte
917153e154 Merge branch 'master' into addDBCheckMiddleware 2025-09-03 19:13:45 +12:00
G.Ambatte
d6a7d0272a Update dbCheck test 2025-09-02 21:08:15 +12:00
G.Ambatte
4fca207e0e Change error result to use Error Page 2025-09-02 20:58:08 +12:00
G.Ambatte
d171077798 Merge branch 'master' into addDBCheckMiddleware 2025-09-02 20:51:12 +12:00
G.Ambatte
90de9c0af1 Change all links to User Page to use encodeURIComponent 2025-09-01 21:51:27 +12:00
David Bolack
fdd4b3c1d5 Remove braces from consideration 2025-08-30 18:07:11 -05:00
G.Ambatte
06d1652f51 Merge branch 'master' into experimentalGoogleServiceAccountChange 2025-08-26 07:32:29 +12:00
David Bolack
785af639c7 Keep the cursor as close to the same place on the screen as possible. 2025-07-30 13:04:16 -05:00
David Bolack
4aadb0b238 Keep the cursor in the active view page after a divider width change.
Solves #2963
2025-07-30 12:28:06 -05:00
G.Ambatte
005c05376c Add DB connection/disconnections events to log 2025-07-26 14:11:20 +12:00
G.Ambatte
7af22c9da7 Return a basic error message when DB connection is lost 2025-07-26 12:13:59 +12:00
G.Ambatte
8e2abb9f78 Basic Google file permission checking 2025-07-25 12:04:41 +12:00
David Bolack
4b2142b00b Merge branch 'd100-dicefont' of github.com:dbolack-ab/homebrewery into d100-dicefont 2025-07-23 20:23:42 -05:00
David Bolack
fd8cc8d1a1 Merge branch 'master' into d100-dicefont 2025-07-23 20:23:22 -05:00
David Bolack
2ac4c4ebd2 Merge branch 'master' into markdown-variables 2025-07-23 20:18:25 -05:00
David Bolack
f092f8ad53 Merge branch 'master' into License_Snippets_Redux 2025-07-23 20:12:34 -05:00
G.Ambatte
b447d81b4c Add service account to file permissions 2025-07-22 18:23:11 +12:00
David Bolack
93ed732973 Trim out non-blessed licenses from the menu for now. 2025-07-17 09:55:23 -05:00
David Bolack
7ea6557625 Add initial Mongoose material 2025-07-16 21:34:42 -05:00
David Bolack
ca53cb4700 Fix CSS manually. 2025-07-16 13:20:37 -05:00
David Bolack
54777def34 Merge branch 'master' into License_Snippets_Redux 2025-07-16 13:18:04 -05:00
David Bolack
04a174b767 Merge branch 'master' into markdown-variables 2025-07-16 10:43:55 -05:00
David Bolack
64d6392b5a Merge branch 'master' into markdown-variables 2025-07-16 10:42:01 -05:00
Trevor Buckner
1ae37e3a27 Merge branch 'master' into d100-dicefont 2025-07-15 17:00:07 -04:00
David Bolack
8268535125 Update package version in attempt to fix Circleci failures 2025-06-30 11:35:46 -05:00
David Bolack
11335f0bda Merge branch 'd100-dicefont' of github.com:dbolack-ab/homebrewery into d100-dicefont 2025-06-30 10:56:04 -05:00
David Bolack
60b1ee7db8 Merge branch 'master' into d100-dicefont 2025-06-30 10:55:23 -05:00
David Bolack
5af5a13476 Merge branch 'master' into markdown-variables 2025-06-30 10:53:27 -05:00
Víctor Losada Hernández
b915584f59 Merge branch 'master' into d100-dicefont 2025-06-25 16:45:36 +02:00
David Bolack
c1655acc10 Update module version 2025-06-17 21:04:15 -05:00
David Bolack
6848d12fb3 Revert "Touch README to trigger rebuild test"
This reverts commit 1a8b42538c.
2025-06-10 10:30:19 -05:00
David Bolack
1a8b42538c Touch README to trigger rebuild test 2025-06-10 09:43:53 -05:00
David Bolack
21192505bb Switch to npm mopdule based brew variables
`
2025-06-04 21:43:51 -05:00
David Bolack
13450cc081 WIP 2025-06-03 22:28:39 -05:00
David Bolack
0ab56788c1 Move d100 Source files 2025-05-11 18:39:25 -05:00
David Bolack
4d8ab13101 Merge branch 'master' into d100-dicefont 2025-05-11 18:33:36 -05:00
David Bolack
99d5c1b9e3 Merge branch 'd100-dicefont' of github.com:dbolack-ab/homebrewery into d100-dicefont 2025-05-11 18:33:31 -05:00
David Bolack
1a52347e9b Tweaked the Image source to use one for 2 digit numbers and one for centered numbers.
These results are much better.

Renamed the resulting face

subbed in d10s generated from teh same souce so they would match.
2025-05-11 18:31:45 -05:00
Víctor Losada Hernández
2ed17e44e4 Merge branch 'master' into d100-dicefont 2025-05-11 15:54:35 +02:00
David Bolack
a2dd8af6d7 Merge branch 'd100-dicefont' of github.com:dbolack-ab/homebrewery into d100-dicefont 2025-05-10 12:28:05 -05:00
David Bolack
f7e4e1aa2a Merge branch 'master' into d100-dicefont 2025-05-10 12:27:45 -05:00
David Bolack
f6869d9c13 Merge branch 'master' into d100-dicefont 2025-05-10 12:27:05 -05:00
David Bolack
6aa35de27e Add scripting for bus insurance. 2025-05-10 12:26:26 -05:00
Víctor Losada Hernández
5de7ea368e Merge branch 'master' into d100-dicefont 2025-05-08 13:49:48 +02:00
David Bolack
26a5cb9fab Add a percentile on single die representation to dicefont.
This is added as a new icon but inlined with the df icons for user conveniance.

used dper instead of dpercent for ease of use.
2025-04-19 22:47:33 -05:00
David Bolack
4f3b933c8d iRemove debugs 2024-10-22 19:28:04 -05:00
David Bolack
75e9b4342e WIP 2024-10-22 19:24:04 -05:00
David Bolack
f54ed3f4be Merge branch 'master' into License_Snippets_Redux 2024-10-22 19:09:02 -05:00
David Bolack
e13ecfc16d Temporarily remove Traveller's Aid Society until after recontact 20250101 2024-10-22 14:40:06 -05:00
David Bolack
1513abadd0 Remove Gallent Knights Tony Trove 2024-10-22 14:32:10 -05:00
David Bolack
1767d270ab Merge branch 'master' into License_Snippets_Redux 2024-10-13 21:37:18 -05:00
David Bolack
dd1f5929b1 Remove Old School Essentials materials 2024-09-07 23:02:37 -05:00
David Bolack
57bdc3b19e More license updates, make sure everyone can dedent. 2024-08-31 19:38:56 -05:00
David Bolack
4adcadba67 Update Blades in the Dark license sections. 2024-08-31 16:36:18 -05:00
David Bolack
f7bef214ab Update Mythmere AELF license materials. 2024-08-31 16:02:21 -05:00
David Bolack
86d3a64e1f Back in Snippets Gen exclusion change 2024-08-31 13:56:35 -05:00
David Bolack
7b2e22fa23 Merge branch 'master' into License_Snippets_Redux 2024-08-02 15:46:29 -05:00
David Bolack
08cd8ca638 More work with DTRPG licenses.
Overflows the frame. Needs reordered on the menu. Some labels need improved.
2024-07-23 21:44:56 -05:00
David Bolack
f3861cb639 Slightly reorganize licenses 2024-07-22 19:06:12 -05:00
David Bolack
822dac55bf First pass at adding a number of DriveThruRPG Partner licenses to the pile.
I skipped anything that didn't have an obvious license boilerplate in their "How To" and will revist those once these are all cleared and validated with their publishers.
2024-07-21 23:43:03 -05:00
David Bolack
4d16375b35 Merge branch 'master' into License_Snippets_Redux 2024-07-18 12:36:12 -05:00
David Bolack
5fe65c46a6 Add Forged in the Dark disclaimer and logo 2024-07-18 12:31:43 -05:00
David Bolack
29dc61a985 Add Shadowdark license 2024-07-17 17:02:53 -05:00
David Bolack
01b5a6a783 Small tweak to AELF layout
Add icons and inclusion text for Old School Essentials
2024-07-17 15:13:03 -05:00
David Bolack
1b67c69f0f Add cloned files.
Reduce CC license to just the wording and badges needed to display
Reduce the Orc license to just the Text needed to display
2024-07-17 11:30:48 -05:00
137 changed files with 8120 additions and 5828 deletions

View File

@@ -47,9 +47,7 @@ Make an changes you need to `config/docker.json` then build the image. If it doe
"naturalcrit_url" : "local.naturalcrit.com:8010",
"secret" : "secret",
"web_port" : 8000,
"enable_v3" : true,
"mongodb_uri": "mongodb://172.17.0.2/homebrewery",
"enable_themes" : true
}
```

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
import './admin.less';
import React, { useEffect, useState } from 'react';
const BrewUtils = require('./brewUtils/brewUtils.jsx');
const NotificationUtils = require('./notificationUtils/notificationUtils.jsx');
import BrewUtils from './brewUtils/brewUtils.jsx';
import NotificationUtils from './notificationUtils/notificationUtils.jsx';
import AuthorUtils from './authorUtils/authorUtils.jsx';
import LockTools from './lockTools/lockTools.jsx';

View File

@@ -84,4 +84,4 @@ const authorLookup = ()=>{
);
};
module.exports = authorLookup;
export default authorLookup;

View File

@@ -10,4 +10,4 @@ const authorUtils = ()=>{
);
};
module.exports = authorUtils;
export default authorUtils;

View File

@@ -1,9 +1,8 @@
const React = require('react');
const createClass = require('create-react-class');
import React from 'react';
import createReactClass from 'create-react-class';
import request from 'superagent';
const request = require('superagent');
const BrewCleanup = createClass({
const BrewCleanup = createReactClass({
displayName : 'BrewCleanup',
getDefaultProps(){
return {};
@@ -69,4 +68,4 @@ const BrewCleanup = createClass({
}
});
module.exports = BrewCleanup;
export default BrewCleanup;

View File

@@ -1,8 +1,8 @@
const React = require('react');
const createClass = require('create-react-class');
const request = require('superagent');
import React from 'react';
import createReactClass from 'create-react-class';
import request from 'superagent';
const BrewCompress = createClass({
const BrewCompress = createReactClass({
displayName : 'BrewCompress',
getDefaultProps(){
return {};
@@ -85,4 +85,4 @@ const BrewCompress = createClass({
}
});
module.exports = BrewCompress;
export default BrewCompress;

View File

@@ -1,12 +1,11 @@
const React = require('react');
const createClass = require('create-react-class');
const cx = require('classnames');
import React from 'react';
import createReactClass from 'create-react-class';
import request from 'superagent';
import cx from 'classnames';
const request = require('superagent');
const Moment = require('moment');
import Moment from 'moment';
const BrewLookup = createClass({
const BrewLookup = createReactClass({
getDefaultProps() {
return {};
},
@@ -110,4 +109,4 @@ const BrewLookup = createClass({
}
});
module.exports = BrewLookup;
export default BrewLookup;

View File

@@ -1,15 +1,14 @@
const React = require('react');
const createClass = require('create-react-class');
require('./brewUtils.less');
import React from 'react';
import './brewUtils.less';
const BrewCleanup = require('./brewCleanup/brewCleanup.jsx');
const BrewLookup = require('./brewLookup/brewLookup.jsx');
const BrewCompress = require ('./brewCompress/brewCompress.jsx');
const Stats = require('./stats/stats.jsx');
import BrewCleanup from './brewCleanup/brewCleanup.jsx';
import BrewLookup from './brewLookup/brewLookup.jsx';
import BrewCompress from './brewCompress/brewCompress.jsx';
import Stats from './stats/stats.jsx';
const BrewUtils = createClass({
render : function(){
return <>
const BrewUtils = ()=>{
return (
<>
<Stats />
<hr />
<BrewLookup />
@@ -17,8 +16,7 @@ const BrewUtils = createClass({
<BrewCleanup />
<hr />
<BrewCompress />
</>;
}
});
module.exports = BrewUtils;
</>
);
};
export default BrewUtils;

View File

@@ -1,9 +1,8 @@
const React = require('react');
const createClass = require('create-react-class');
import React from 'react';
import createReactClass from 'create-react-class';
import request from 'superagent';
const request = require('superagent');
const Stats = createClass({
const Stats = createReactClass({
displayName : 'Stats',
getDefaultProps(){
return {};
@@ -43,4 +42,4 @@ const Stats = createClass({
}
});
module.exports = Stats;
export default Stats;

View File

@@ -1,11 +1,11 @@
/*eslint max-lines: ["warn", {"max": 500, "skipBlankLines": true, "skipComments": true}]*/
require('./lockTools.less');
const React = require('react');
const createClass = require('create-react-class');
import './lockTools.less';
import React from 'react';
import createReactClass from 'create-react-class';
import request from '../../homebrew/utils/request-middleware.js';
const LockTools = createClass({
const LockTools = createReactClass({
displayName : 'LockTools',
getInitialState : function() {
return {
@@ -55,7 +55,7 @@ const LockTools = createClass({
}
});
const LockBrew = createClass({
const LockBrew = createReactClass({
displayName : 'LockBrew',
getInitialState : function() {
// Default values
@@ -183,7 +183,7 @@ const LockBrew = createClass({
}
});
const LockTable = createClass({
const LockTable = createReactClass({
displayName : 'LockTable',
getDefaultProps : function() {
return {
@@ -273,7 +273,7 @@ const LockTable = createClass({
}
});
const LockLookup = createClass({
const LockLookup = createReactClass({
displayName : 'LockLookup',
getDefaultProps : function() {
return {
@@ -339,4 +339,4 @@ const LockLookup = createClass({
}
});
module.exports = LockTools;
export default LockTools;

View File

@@ -1,7 +1,6 @@
require('./notificationAdd.less');
const React = require('react');
const { useState, useRef } = require('react');
const request = require('superagent');
import './notificationAdd.less';
import React, { useState, useRef } from 'react';
import request from 'superagent';
const NotificationAdd = ()=>{
const [notificationResult, setNotificationResult] = useState(null);
@@ -106,4 +105,4 @@ const NotificationAdd = ()=>{
);
};
module.exports = NotificationAdd;
export default NotificationAdd;

View File

@@ -1,9 +1,7 @@
require('./notificationLookup.less');
const React = require('react');
const { useState } = require('react');
const request = require('superagent');
const Moment = require('moment');
import './notificationLookup.less';
import React, { useState } from 'react';
import request from 'superagent';
import Moment from 'moment';
const NotificationDetail = ({ notification, onDelete })=>(
<>
@@ -102,4 +100,4 @@ const NotificationLookup = ()=>{
);
};
module.exports = NotificationLookup;
export default NotificationLookup;

View File

@@ -1,7 +1,6 @@
const React = require('react');
const NotificationLookup = require('./notificationLookup/notificationLookup.jsx');
const NotificationAdd = require('./notificationAdd/notificationAdd.jsx');
import React from 'react';
import NotificationLookup from './notificationLookup/notificationLookup.jsx';
import NotificationAdd from './notificationAdd/notificationAdd.jsx';
const NotificationUtils = ()=>{
return (
@@ -12,4 +11,4 @@ const NotificationUtils = ()=>{
);
};
module.exports = NotificationUtils;
export default NotificationUtils;

View File

@@ -1,7 +1,7 @@
import diceFont from '../../../themes/fonts/iconFonts/diceFont.js';
import elderberryInn from '../../../themes/fonts/iconFonts/elderberryInn.js';
import fontAwesome from '../../../themes/fonts/iconFonts/fontAwesome.js';
import gameIcons from '../../../themes/fonts/iconFonts/gameIcons.js';
import diceFont from 'themes/fonts/iconFonts/diceFont.js';
import elderberryInn from 'themes/fonts/iconFonts/elderberryInn.js';
import fontAwesome from 'themes/fonts/iconFonts/fontAwesome.js';
import gameIcons from 'themes/fonts/iconFonts/gameIcons.js';
const emojis = {
...diceFont,
@@ -79,6 +79,6 @@ const showAutocompleteEmoji = function(CodeMirror, editor) {
});
};
module.exports = {
export default {
showAutocompleteEmoji
};

View File

@@ -38,11 +38,11 @@ const autoCloseCurlyBraces = function(CodeMirror, cm, typingClosingBrace) {
}
};
module.exports = {
export default {
autoCloseCurlyBraces : function(CodeMirror, codeMirror) {
const map = { name: 'autoCloseCurlyBraces' };
map[`'{'`] = function(cm) { return autoCloseCurlyBraces(CodeMirror, cm); };
map[`'}'`] = function(cm) { return autoCloseCurlyBraces(CodeMirror, cm, true); };
codeMirror.addKeyMap(map);
codeMirror?.addKeyMap(map);
}
};

View File

@@ -1,51 +1,13 @@
/* eslint-disable max-lines */
require('./codeEditor.less');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const closeTag = require('./close-tag');
const autoCompleteEmoji = require('./autocompleteEmoji');
import './codeEditor.less';
import React from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import closeTag from './close-tag';
import autoCompleteEmoji from './autocompleteEmoji';
let CodeMirror;
if(typeof window !== 'undefined'){
CodeMirror = require('codemirror');
//Language Modes
require('codemirror/mode/gfm/gfm.js'); //Github flavoured markdown
require('codemirror/mode/css/css.js');
require('codemirror/mode/javascript/javascript.js');
//Addons
//Code folding
require('codemirror/addon/fold/foldcode.js');
require('codemirror/addon/fold/foldgutter.js');
//Search and replace
require('codemirror/addon/search/search.js');
require('codemirror/addon/search/searchcursor.js');
require('codemirror/addon/search/jump-to-line.js');
require('codemirror/addon/search/match-highlighter.js');
require('codemirror/addon/search/matchesonscrollbar.js');
require('codemirror/addon/dialog/dialog.js');
//Trailing space highlighting
// require('codemirror/addon/edit/trailingspace.js');
//Active line highlighting
// require('codemirror/addon/selection/active-line.js');
//Scroll past last line
require('codemirror/addon/scroll/scrollpastend.js');
//Auto-closing
//XML code folding is a requirement of the auto-closing tag feature and is not enabled
require('codemirror/addon/fold/xml-fold.js');
require('codemirror/addon/edit/closetag.js');
//Autocompletion
require('codemirror/addon/hint/show-hint.js');
const foldPagesCode = require('./fold-pages');
foldPagesCode.registerHomebreweryHelper(CodeMirror);
const foldCSSCode = require('./fold-css');
foldCSSCode.registerHomebreweryHelper(CodeMirror);
}
const CodeEditor = createClass({
const CodeEditor = createReactClass({
displayName : 'CodeEditor',
getDefaultProps : function() {
return {
@@ -66,23 +28,54 @@ const CodeEditor = createClass({
editor : React.createRef(null),
componentDidMount : function() {
async componentDidMount() {
CodeMirror = (await import('codemirror')).default;
this.CodeMirror = CodeMirror;
await import('codemirror/mode/gfm/gfm.js');
await import('codemirror/mode/css/css.js');
await import('codemirror/mode/javascript/javascript.js');
// addons
await import('codemirror/addon/fold/foldcode.js');
await import('codemirror/addon/fold/foldgutter.js');
await import('codemirror/addon/fold/xml-fold.js');
await import('codemirror/addon/search/search.js');
await import('codemirror/addon/search/searchcursor.js');
await import('codemirror/addon/search/jump-to-line.js');
await import('codemirror/addon/search/match-highlighter.js');
await import('codemirror/addon/search/matchesonscrollbar.js');
await import('codemirror/addon/dialog/dialog.js');
await import('codemirror/addon/scroll/scrollpastend.js');
await import('codemirror/addon/edit/closetag.js');
await import('codemirror/addon/hint/show-hint.js');
// import 'codemirror/addon/selection/active-line.js';
// import 'codemirror/addon/edit/trailingspace.js';
// register helpers dynamically as well
const foldPagesCode = (await import('./fold-pages')).default;
const foldCSSCode = (await import('./fold-css')).default;
foldPagesCode.registerHomebreweryHelper(CodeMirror);
foldCSSCode.registerHomebreweryHelper(CodeMirror);
this.buildEditor();
const newDoc = CodeMirror.Doc(this.props.value, this.props.language);
this.codeMirror.swapDoc(newDoc);
const newDoc = CodeMirror?.Doc(this.props.value, this.props.language);
this.codeMirror?.swapDoc(newDoc);
},
componentDidUpdate : function(prevProps) {
if(prevProps.view !== this.props.view){ //view changed; swap documents
let newDoc;
if(!this.state.docs[this.props.view]) {
newDoc = CodeMirror.Doc(this.props.value, this.props.language);
newDoc = CodeMirror?.Doc(this.props.value, this.props.language);
} else {
newDoc = this.state.docs[this.props.view];
}
const oldDoc = { [prevProps.view]: this.codeMirror.swapDoc(newDoc) };
const oldDoc = { [prevProps.view]: this.codeMirror?.swapDoc(newDoc) };
this.setState((prevState)=>({
docs : _.merge({}, prevState.docs, oldDoc)
@@ -90,17 +83,17 @@ const CodeEditor = createClass({
this.props.rerenderParent();
} else if(this.codeMirror?.getValue() != this.props.value) { //update editor contents if brew.text is changed from outside
this.codeMirror.setValue(this.props.value);
this.codeMirror?.setValue(this.props.value);
}
if(this.props.enableFolding) {
this.codeMirror.setOption('foldOptions', this.foldOptions(this.codeMirror));
this.codeMirror?.setOption('foldOptions', this.foldOptions(this.codeMirror));
} else {
this.codeMirror.setOption('foldOptions', false);
this.codeMirror?.setOption('foldOptions', false);
}
if(prevProps.editorTheme !== this.props.editorTheme){
this.codeMirror.setOption('theme', this.props.editorTheme);
this.codeMirror?.setOption('theme', this.props.editorTheme);
}
},
@@ -188,8 +181,8 @@ const CodeEditor = createClass({
closeTag.autoCloseCurlyBraces(CodeMirror, this.codeMirror);
autoCompleteEmoji.showAutocompleteEmoji(CodeMirror, this.codeMirror);
// Note: codeMirror passes a copy of itself in this callback. cm === this.codeMirror. Either one works.
this.codeMirror.on('change', (cm)=>{this.props.onChange(cm.getValue());});
// Note: codeMirror passes a copy of itself in this callback. cm === this.codeMirror?. Either one works.
this.codeMirror?.on('change', (cm)=>{this.props.onChange(cm.getValue());});
this.updateSize();
},
@@ -203,84 +196,84 @@ const CodeEditor = createClass({
},
dedent : function () {
this.codeMirror.execCommand('indentLess');
this.codeMirror?.execCommand('indentLess');
},
makeHeader : function (number) {
const selection = this.codeMirror.getSelection();
const selection = this.codeMirror?.getSelection();
const header = Array(number).fill('#').join('');
this.codeMirror.replaceSelection(`${header} ${selection}`, 'around');
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch + selection.length + number + 1 });
this.codeMirror?.replaceSelection(`${header} ${selection}`, 'around');
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line, ch: cursor.ch + selection.length + number + 1 });
},
makeBold : function() {
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '**' && selection.slice(-2) === '**';
this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `**${selection}**`, 'around');
const selection = this.codeMirror?.getSelection(), t = selection.slice(0, 2) === '**' && selection.slice(-2) === '**';
this.codeMirror?.replaceSelection(t ? selection.slice(2, -2) : `**${selection}**`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
}
},
makeItalic : function() {
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '*' && selection.slice(-1) === '*';
this.codeMirror.replaceSelection(t ? selection.slice(1, -1) : `*${selection}*`, 'around');
const selection = this.codeMirror?.getSelection(), t = selection.slice(0, 1) === '*' && selection.slice(-1) === '*';
this.codeMirror?.replaceSelection(t ? selection.slice(1, -1) : `*${selection}*`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
}
},
makeSuper : function() {
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 1) === '^' && selection.slice(-1) === '^';
this.codeMirror.replaceSelection(t ? selection.slice(1, -1) : `^${selection}^`, 'around');
const selection = this.codeMirror?.getSelection(), t = selection.slice(0, 1) === '^' && selection.slice(-1) === '^';
this.codeMirror?.replaceSelection(t ? selection.slice(1, -1) : `^${selection}^`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line, ch: cursor.ch - 1 });
}
},
makeSub : function() {
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '^^' && selection.slice(-2) === '^^';
this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `^^${selection}^^`, 'around');
const selection = this.codeMirror?.getSelection(), t = selection.slice(0, 2) === '^^' && selection.slice(-2) === '^^';
this.codeMirror?.replaceSelection(t ? selection.slice(2, -2) : `^^${selection}^^`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
}
},
makeNbsp : function() {
this.codeMirror.replaceSelection('&nbsp;', 'end');
this.codeMirror?.replaceSelection('&nbsp;', 'end');
},
makeSpace : function() {
const selection = this.codeMirror.getSelection();
const selection = this.codeMirror?.getSelection();
const t = selection.slice(0, 8) === '{{width:' && selection.slice(0 -4) === '% }}';
if(t){
const percent = parseInt(selection.slice(8, -4)) + 10;
this.codeMirror.replaceSelection(percent < 90 ? `{{width:${percent}% }}` : '{{width:100% }}', 'around');
this.codeMirror?.replaceSelection(percent < 90 ? `{{width:${percent}% }}` : '{{width:100% }}', 'around');
} else {
this.codeMirror.replaceSelection(`{{width:10% }}`, 'around');
this.codeMirror?.replaceSelection(`{{width:10% }}`, 'around');
}
},
removeSpace : function() {
const selection = this.codeMirror.getSelection();
const selection = this.codeMirror?.getSelection();
const t = selection.slice(0, 8) === '{{width:' && selection.slice(0 -4) === '% }}';
if(t){
const percent = parseInt(selection.slice(8, -4)) - 10;
this.codeMirror.replaceSelection(percent > 10 ? `{{width:${percent}% }}` : '', 'around');
this.codeMirror?.replaceSelection(percent > 10 ? `{{width:${percent}% }}` : '', 'around');
}
},
newColumn : function() {
this.codeMirror.replaceSelection('\n\\column\n\n', 'end');
this.codeMirror?.replaceSelection('\n\\column\n\n', 'end');
},
newPage : function() {
this.codeMirror.replaceSelection('\n\\page\n\n', 'end');
this.codeMirror?.replaceSelection('\n\\page\n\n', 'end');
},
injectText : function(injectText, overwrite=true) {
@@ -293,29 +286,29 @@ const CodeEditor = createClass({
},
makeUnderline : function() {
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '<u>' && selection.slice(-4) === '</u>';
this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `<u>${selection}</u>`, 'around');
const selection = this.codeMirror?.getSelection(), t = selection.slice(0, 3) === '<u>' && selection.slice(-4) === '</u>';
this.codeMirror?.replaceSelection(t ? selection.slice(3, -4) : `<u>${selection}</u>`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 4 });
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line, ch: cursor.ch - 4 });
}
},
makeSpan : function() {
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '{{' && selection.slice(-2) === '}}';
this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `{{ ${selection}}}`, 'around');
const selection = this.codeMirror?.getSelection(), t = selection.slice(0, 2) === '{{' && selection.slice(-2) === '}}';
this.codeMirror?.replaceSelection(t ? selection.slice(2, -2) : `{{ ${selection}}}`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line, ch: cursor.ch - 2 });
}
},
makeDiv : function() {
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 2) === '{{' && selection.slice(-2) === '}}';
this.codeMirror.replaceSelection(t ? selection.slice(2, -2) : `{{\n${selection}\n}}`, 'around');
const selection = this.codeMirror?.getSelection(), t = selection.slice(0, 2) === '{{' && selection.slice(-2) === '}}';
this.codeMirror?.replaceSelection(t ? selection.slice(2, -2) : `{{\n${selection}\n}}`, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line - 1, ch: cursor.ch }); // set to -2? if wanting to enter classes etc. if so, get rid of first \n when replacing selection
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line - 1, ch: cursor.ch }); // set to -2? if wanting to enter classes etc. if so, get rid of first \n when replacing selection
}
},
@@ -323,7 +316,7 @@ const CodeEditor = createClass({
let regex;
let cursorPos;
let newComment;
const selection = this.codeMirror.getSelection();
const selection = this.codeMirror?.getSelection();
if(this.props.language === 'gfm'){
regex = /^\s*(<!--\s?)(.*?)(\s?-->)\s*$/gs;
cursorPos = 4;
@@ -333,44 +326,44 @@ const CodeEditor = createClass({
cursorPos = 3;
newComment = `/* ${selection} */`;
}
this.codeMirror.replaceSelection(regex.test(selection) == true ? selection.replace(regex, '$2') : newComment, 'around');
this.codeMirror?.replaceSelection(regex.test(selection) == true ? selection.replace(regex, '$2') : newComment, 'around');
if(selection.length === 0){
const cursor = this.codeMirror.getCursor();
this.codeMirror.setCursor({ line: cursor.line, ch: cursor.ch - cursorPos });
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setCursor({ line: cursor.line, ch: cursor.ch - cursorPos });
};
},
makeLink : function() {
const isLink = /^\[(.*)\]\((.*)\)$/;
const selection = this.codeMirror.getSelection().trim();
const selection = this.codeMirror?.getSelection().trim();
let match;
if(match = isLink.exec(selection)){
const altText = match[1];
const url = match[2];
this.codeMirror.replaceSelection(`${altText} ${url}`);
const cursor = this.codeMirror.getCursor();
this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch });
this.codeMirror?.replaceSelection(`${altText} ${url}`);
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch });
} else {
this.codeMirror.replaceSelection(`[${selection || 'alt text'}](url)`);
const cursor = this.codeMirror.getCursor();
this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - 4 }, { line: cursor.line, ch: cursor.ch - 1 });
this.codeMirror?.replaceSelection(`[${selection || 'alt text'}](url)`);
const cursor = this.codeMirror?.getCursor();
this.codeMirror?.setSelection({ line: cursor.line, ch: cursor.ch - 4 }, { line: cursor.line, ch: cursor.ch - 1 });
}
},
makeList : function(listType) {
const selectionStart = this.codeMirror.getCursor('from'), selectionEnd = this.codeMirror.getCursor('to');
this.codeMirror.setSelection(
const selectionStart = this.codeMirror?.getCursor('from'), selectionEnd = this.codeMirror?.getCursor('to');
this.codeMirror?.setSelection(
{ line: selectionStart.line, ch: 0 },
{ line: selectionEnd.line, ch: this.codeMirror.getLine(selectionEnd.line).length }
{ line: selectionEnd.line, ch: this.codeMirror?.getLine(selectionEnd.line).length }
);
const newSelection = this.codeMirror.getSelection();
const newSelection = this.codeMirror?.getSelection();
const regex = /^\d+\.\s|^-\s/gm;
if(newSelection.match(regex) != null){ // if selection IS A LIST
this.codeMirror.replaceSelection(newSelection.replace(regex, ''), 'around');
this.codeMirror?.replaceSelection(newSelection.replace(regex, ''), 'around');
} else { // if selection IS NOT A LIST
listType == 'UL' ? this.codeMirror.replaceSelection(newSelection.replace(/^/gm, `- `), 'around') :
this.codeMirror.replaceSelection(newSelection.replace(/^/gm, (()=>{
listType == 'UL' ? this.codeMirror?.replaceSelection(newSelection.replace(/^/gm, `- `), 'around') :
this.codeMirror?.replaceSelection(newSelection.replace(/^/gm, (()=>{
let n = 1;
return ()=>{
return `${n++}. `;
@@ -380,39 +373,39 @@ const CodeEditor = createClass({
},
foldAllCode : function() {
this.codeMirror.execCommand('foldAll');
this.codeMirror?.execCommand('foldAll');
},
unfoldAllCode : function() {
this.codeMirror.execCommand('unfoldAll');
this.codeMirror?.execCommand('unfoldAll');
},
//=-- Externally used -==//
setCursorPosition : function(line, char){
setTimeout(()=>{
this.codeMirror.focus();
this.codeMirror.doc.setCursor(line, char);
this.codeMirror?.focus();
this.codeMirror?.doc.setCursor(line, char);
}, 10);
},
getCursorPosition : function(){
return this.codeMirror.getCursor();
return this.codeMirror?.getCursor();
},
getTopVisibleLine : function(){
const rect = this.codeMirror.getWrapperElement().getBoundingClientRect();
const topVisibleLine = this.codeMirror.lineAtHeight(rect.top, 'window');
const rect = this.codeMirror?.getWrapperElement().getBoundingClientRect();
const topVisibleLine = this.codeMirror?.lineAtHeight(rect.top, 'window');
return topVisibleLine;
},
updateSize : function(){
this.codeMirror.refresh();
this.codeMirror?.refresh();
},
redo : function(){
return this.codeMirror.redo();
return this.codeMirror?.redo();
},
undo : function(){
return this.codeMirror.undo();
return this.codeMirror?.undo();
},
historySize : function(){
return this.codeMirror.doc.historySize();
return this.codeMirror?.doc.historySize();
},
foldOptions : function(cm){
@@ -426,7 +419,7 @@ const CodeEditor = createClass({
let foldPreviewText = '';
while (currentLine <= to.line && text.length <= maxLength) {
const currentText = this.codeMirror.getLine(currentLine);
const currentText = this.codeMirror?.getLine(currentLine);
currentLine++;
if(currentText[0] == '#'){
foldPreviewText = currentText;
@@ -461,5 +454,5 @@ const CodeEditor = createClass({
}
});
module.exports = CodeEditor;
export default CodeEditor;

View File

@@ -38,6 +38,11 @@
animation-duration : 0.4s;
}
.CodeMirror-search-field {
width:25em !important;
outline:1px inset #00000055 !important;
}
//.cm-tab {
// background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAQAAACOs/baAAAARUlEQVR4nGJgIAG8JkXxUAcCtDWemcGR1lY4MvgzCEKY7jSBjgxBDAG09UEQzAe0AMwMHrSOAwEGRtpaMIwAAAAA//8DAG4ID9EKs6YqAAAAAElFTkSuQmCC) no-repeat right;
//}

View File

@@ -1,4 +1,4 @@
module.exports = {
export default {
registerHomebreweryHelper : function(CodeMirror) {
CodeMirror.registerHelper('fold', 'homebrewerycss', function(cm, start) {

View File

@@ -1,4 +1,4 @@
module.exports = {
export default {
registerHomebreweryHelper : function(CodeMirror) {
CodeMirror.registerHelper('fold', 'homebrewery', function(cm, start) {
const matcher = /^\\page.*/;

View File

@@ -1,9 +1,9 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
require('./combobox.less');
import React from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import './combobox.less';
const Combobox = createClass({
const Combobox = createReactClass({
displayName : 'Combobox',
getDefaultProps : function() {
return {
@@ -126,4 +126,4 @@ const Combobox = createClass({
}
});
module.exports = Combobox;
export default Combobox;

View File

@@ -1,11 +1,11 @@
require('./renderWarnings.less');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
import './renderWarnings.less';
import React from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import Dialog from '../../../client/components/dialog.jsx';
import Dialog from '../dialog.jsx';
const RenderWarnings = createClass({
const RenderWarnings = createReactClass({
displayName : 'RenderWarnings',
getInitialState : function() {
return {
@@ -25,7 +25,7 @@ const RenderWarnings = createClass({
if(!isChrome){
return <li key='chrome'>
<em>Built for Chrome </em> <br />
Other browsers have not been tested for compatiblilty. If you
Other browsers have not been tested for compatibility. If you
experience issues with your document not rendering or printing
properly, please try using the latest version of Chrome before
submitting a bug report.
@@ -57,4 +57,4 @@ const RenderWarnings = createClass({
}
});
module.exports = RenderWarnings;
export default RenderWarnings;

View File

@@ -1,6 +1,5 @@
require('./splitPane.less');
const React = require('react');
const { useState, useEffect } = React;
import './splitPane.less';
import React, { useEffect, useState } from 'react';
const PANE_WIDTH_KEY = 'HB_editor_splitWidth';
const LIVE_SCROLL_KEY = 'HB_editor_liveScroll';
@@ -108,4 +107,4 @@ const Pane = ({ width, children, isDragging, moveBrew, moveSource, liveScroll, s
);
};
module.exports = SplitPane;
export default SplitPane;

View File

@@ -1,7 +1,6 @@
const React = require('react');
const createClass = require('create-react-class');
import React from 'react';
module.exports = function(props){
export default function(props){
return <svg version='1.1' x='0px' y='0px' viewBox='0 0 90 112.5' enableBackground='new 0 0 90 90' >
<path d='M25.363,25.54c0,1.906,8.793,3.454,19.636,3.454c10.848,0,19.638-1.547,19.638-3.454c0-1.12-3.056-2.117-7.774-2.75 c-1.418,1.891-3.659,3.133-6.208,3.133c-2.85,0-5.315-1.547-6.67-3.833C33.617,22.185,25.363,23.692,25.363,25.54z'/><path d='M84.075,54.142c0-8.68-2.868-17.005-8.144-23.829c1.106-1.399,1.41-2.771,1.41-3.854c0-6.574-10.245-9.358-19.264-10.533 c0.209,0.706,0.359,1.439,0.359,2.215c0,0.09-0.022,0.17-0.028,0.26l0,0c-0.028,0.853-0.195,1.667-0.479,2.429 c9.106,1.282,14.508,3.754,14.508,5.63c0,2.644-10.688,6.486-27.439,6.486c-16.748,0-27.438-3.842-27.438-6.486 c0-2.542,9.904-6.183,25.559-6.459c-0.098-0.396-0.159-0.807-0.2-1.223c0.006,0,0.013,0,0.017,0 c-0.017-0.213-0.063-0.417-0.063-0.636c0-1.084,0.226-2.119,0.628-3.058c-6.788,0.129-30.846,1.299-30.846,11.376 c0,1.083,0.305,2.455,1.411,3.854c-5.276,6.823-8.145,15.149-8.145,23.829c0,11.548,5.187,20.107,14.693,25.115 c-0.902,3.146-1.391,7.056,1.111,8.181c2.626,1.178,5.364-2.139,7.111-5.005c4.73,1.261,10.13,1.923,16.161,1.923 c6.034,0,11.428-0.661,16.158-1.922c1.75,2.865,4.493,6.18,7.112,5.004c2.504-1.123,2.014-5.035,1.113-8.179 C78.889,74.249,84.075,65.689,84.075,54.142z M70.39,31.392c5.43,6.046,8.78,14,8.78,22.75c0,20.919-18.582,25.309-34.171,25.309 c-15.587,0-34.17-4.39-34.17-25.309c0-8.75,3.35-16.7,8.781-22.753c5.561,2.643,15.502,4.009,25.389,4.009 C54.886,35.397,64.829,34.031,70.39,31.392z'/><path d='M50.654,23.374c2.892,0,5.234-2.341,5.234-5.233c0-2.887-2.343-5.23-5.234-5.23c-2.887,0-5.231,2.343-5.231,5.23 C45.423,21.032,47.768,23.374,50.654,23.374z'/>
<circle cx='62.905' cy='10.089' r='3.595'/>

View File

@@ -1,6 +1,5 @@
const React = require('react');
const createClass = require('create-react-class');
import React from 'react';
module.exports = function(props){
export default function(props){
return <svg version='1.1' x='0px' y='0px' viewBox='0 0 100 100' enableBackground='new 0 0 100 100'><path d='M80.644,87.982l16.592-41.483c0.054-0.128,0.088-0.26,0.108-0.394c0.006-0.039,0.007-0.077,0.011-0.116 c0.007-0.087,0.008-0.174,0.002-0.26c-0.003-0.046-0.007-0.091-0.014-0.137c-0.014-0.089-0.036-0.176-0.063-0.262 c-0.012-0.034-0.019-0.069-0.031-0.103c-0.047-0.118-0.106-0.229-0.178-0.335c-0.004-0.006-0.006-0.012-0.01-0.018L67.999,3.358 c-0.01-0.013-0.003-0.026-0.013-0.04L68,3.315V4c0,0-0.033,0-0.037,0c-0.403-1-1.094-1.124-1.752-0.976 c0,0.004-0.004-0.012-0.007-0.012C66.201,3.016,66.194,3,66.194,3H66.19h-0.003h-0.003h-0.004h-0.003c0,0-0.004,0-0.007,0 s-0.003-0.151-0.007-0.151L20.495,15.227c-0.025,0.007-0.046-0.019-0.071-0.011c-0.087,0.028-0.172,0.041-0.253,0.083 c-0.054,0.027-0.102,0.053-0.152,0.085c-0.051,0.033-0.101,0.061-0.147,0.099c-0.044,0.036-0.084,0.073-0.124,0.113 c-0.048,0.048-0.093,0.098-0.136,0.152c-0.03,0.039-0.059,0.076-0.085,0.117c-0.046,0.07-0.084,0.145-0.12,0.223 c-0.011,0.023-0.027,0.042-0.036,0.066L2.911,57.664C2.891,57.715,3,57.768,3,57.82v0.002c0,0.186,0,0.375,0,0.562 c0,0.004,0,0.004,0,0.008c0,0,0,0,0,0.002c0,0,0,0,0,0.004v0.004v0.002c0,0.074-0.002,0.15,0.012,0.223 C3.015,58.631,3,58.631,3,58.633c0,0.004,0,0.004,0,0.008c0,0,0,0,0,0.002c0,0,0,0,0,0.004v0.004c0,0,0,0,0,0.002v0.004 c0,0.191-0.046,0.377,0.06,0.545c0-0.002-0.03,0.004-0.03,0.004c0,0.004-0.03,0.004-0.03,0.004c0,0.002,0,0.002,0,0.002 l-0.045,0.004c0.03,0.047,0.036,0.09,0.068,0.133l29.049,37.359c0.002,0.004,0,0.006,0.002,0.01c0.002,0.002,0,0.004,0.002,0.008 c0.006,0.008,0.014,0.014,0.021,0.021c0.024,0.029,0.052,0.051,0.078,0.078c0.027,0.029,0.053,0.057,0.082,0.082 c0.03,0.027,0.055,0.062,0.086,0.088c0.026,0.02,0.057,0.033,0.084,0.053c0.04,0.027,0.081,0.053,0.123,0.076 c0.005,0.004,0.01,0.008,0.016,0.01c0.087,0.051,0.176,0.09,0.269,0.123c0.042,0.014,0.082,0.031,0.125,0.043 c0.021,0.006,0.041,0.018,0.062,0.021c0.123,0.027,0.249,0.043,0.375,0.043c0.099,0,0.202-0.012,0.304-0.027l45.669-8.303 c0.057-0.01,0.108-0.021,0.163-0.037C79.547,88.992,79.562,89,79.575,89c0.004,0,0.004,0,0.004,0c0.021,0,0.039-0.027,0.06-0.035 c0.041-0.014,0.08-0.034,0.12-0.052c0.021-0.01,0.044-0.019,0.064-0.03c0.017-0.01,0.026-0.015,0.033-0.017 c0.014-0.008,0.023-0.021,0.037-0.028c0.14-0.078,0.269-0.174,0.38-0.285c0.014-0.016,0.024-0.034,0.038-0.048 c0.109-0.119,0.201-0.252,0.271-0.398c0.006-0.01,0.016-0.018,0.021-0.029c0.004-0.008,0.008-0.017,0.011-0.026 c0.002-0.004,0.003-0.006,0.005-0.01C80.627,88.021,80.635,88.002,80.644,87.982z M77.611,84.461L48.805,66.453l32.407-25.202 L77.611,84.461z M46.817,63.709L35.863,23.542l43.818,14.608L46.817,63.709z M84.668,40.542l8.926,5.952l-11.902,29.75 L84.668,40.542z M89.128,39.446L84.53,36.38l-6.129-12.257L89.128,39.446z M79.876,34.645L37.807,20.622L65.854,6.599L79.876,34.645 z M33.268,19.107l-6.485-2.162l23.781-6.487L33.268,19.107z M21.92,18.895l8.67,2.891L10.357,47.798L21.92,18.895z M32.652,24.649 l10.845,39.757L7.351,57.178L32.652,24.649z M43.472,67.857L32.969,92.363L8.462,60.855L43.472,67.857z M46.631,69.09l27.826,17.393 l-38.263,6.959L46.631,69.09z'></path></svg>;
};

View File

@@ -1,20 +1,19 @@
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
require('./brewRenderer.less');
const React = require('react');
const { useState, useRef, useMemo, useEffect } = React;
const _ = require('lodash');
import './brewRenderer.less';
import React, { useState, useRef, useMemo, useEffect } from 'react';
import _ from 'lodash';
const MarkdownLegacy = require('naturalcrit/markdownLegacy.js');
import Markdown from 'naturalcrit/markdown.js';
const ErrorBar = require('./errorBar/errorBar.jsx');
const ToolBar = require('./toolBar/toolBar.jsx');
import MarkdownLegacy from 'markdownLegacy.js';
import Markdown from 'markdown.js';
import ErrorBar from './errorBar/errorBar.jsx';
import ToolBar from './toolBar/toolBar.jsx';
//TODO: move to the brew renderer
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx');
const NotificationPopup = require('./notificationPopup/notificationPopup.jsx');
const Frame = require('react-frame-component').default;
const dedent = require('dedent-tabs').default;
const { printCurrentBrew } = require('../../../shared/helpers.js');
import RenderWarnings from 'client/components/renderWarnings/renderWarnings.jsx';
import NotificationPopup from './notificationPopup/notificationPopup.jsx';
import Frame from 'react-frame-component';
import dedent from 'dedent-tabs';
import { printCurrentBrew } from '../../../shared/helpers.js';
import HeaderNav from './headerNav/headerNav.jsx';
import { safeHTML } from './safeHTML.js';
@@ -345,4 +344,4 @@ const BrewRenderer = (props)=>{
);
};
module.exports = BrewRenderer;
export default BrewRenderer;

View File

@@ -1,5 +1,5 @@
require('./errorBar.less');
const React = require('react');
import './errorBar.less';
import React from 'react';
import Dialog from '../../../components/dialog.jsx';
@@ -50,4 +50,4 @@ const ErrorBar = (props)=>{
);
};
module.exports = ErrorBar;
export default ErrorBar;

View File

@@ -1,7 +1,7 @@
require('./headerNav.less');
import './headerNav.less';
import * as React from 'react';
import * as _ from 'lodash';
import React from 'react';
import _ from 'lodash';
const MAX_TEXT_LENGTH = 40;

View File

@@ -1,7 +1,7 @@
require('./notificationPopup.less');
import './notificationPopup.less';
import React, { useEffect, useState } from 'react';
import request from '../../utils/request-middleware.js';
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
import Dialog from '../../../components/dialog.jsx';
@@ -62,4 +62,4 @@ const NotificationPopup = ()=>{
</Dialog>;
};
module.exports = NotificationPopup;
export default NotificationPopup;

View File

@@ -1,8 +1,7 @@
/* eslint-disable max-lines */
require('./toolBar.less');
const React = require('react');
const { useState, useEffect } = React;
const _ = require('lodash');
import './toolBar.less';
import React, { useState, useEffect } from 'react';
import _ from 'lodash';
import { Anchored, AnchoredBox, AnchoredTrigger } from '../../../components/Anchored.jsx';
@@ -259,4 +258,4 @@ const ToolBar = ({ displayOptions, onDisplayOptionsChange, visiblePages, totalPa
);
};
module.exports = ToolBar;
export default ToolBar;

View File

@@ -1,14 +1,14 @@
/*eslint max-lines: ["warn", {"max": 500, "skipBlankLines": true, "skipComments": true}]*/
require('./editor.less');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const dedent = require('dedent-tabs').default;
import Markdown from '../../../shared/naturalcrit/markdown.js';
import './editor.less';
import React from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import dedent from 'dedent-tabs';
import Markdown from '../../../shared/markdown.js';
const CodeEditor = require('naturalcrit/codeEditor/codeEditor.jsx');
const SnippetBar = require('./snippetbar/snippetbar.jsx');
const MetadataEditor = require('./metadataEditor/metadataEditor.jsx');
import CodeEditor from 'client/components/codeEditor/codeEditor.jsx';
import SnippetBar from './snippetbar/snippetbar.jsx';
import MetadataEditor from './metadataEditor/metadataEditor.jsx';
const EDITOR_THEME_KEY = 'HB_editor_theme';
@@ -31,7 +31,7 @@ const DEFAULT_SNIPPET_TEXT = dedent`
`;
let isJumping = false;
const Editor = createClass({
const Editor = createReactClass({
displayName : 'Editor',
getDefaultProps : function() {
return {
@@ -58,7 +58,7 @@ const Editor = createClass({
return {
editorTheme : this.props.editorTheme,
view : 'text', //'text', 'style', 'meta', 'snippet'
snippetbarHeight : 25
snippetBarHeight : 26,
};
},
@@ -76,8 +76,8 @@ const Editor = createClass({
document.getElementById('BrewRenderer').addEventListener('keydown', this.handleControlKeys);
document.addEventListener('keydown', this.handleControlKeys);
this.codeEditor.current.codeMirror.on('cursorActivity', (cm)=>{this.updateCurrentCursorPage(cm.getCursor());});
this.codeEditor.current.codeMirror.on('scroll', _.throttle(()=>{this.updateCurrentViewPage(this.codeEditor.current.getTopVisibleLine());}, 200));
this.codeEditor.current.codeMirror?.on('cursorActivity', (cm)=>{this.updateCurrentCursorPage(cm.getCursor());});
this.codeEditor.current.codeMirror?.on('scroll', _.throttle(()=>{this.updateCurrentViewPage(this.codeEditor.current.getTopVisibleLine());}, 200));
const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY);
if(editorTheme) {
@@ -85,7 +85,15 @@ const Editor = createClass({
editorTheme : editorTheme
});
}
this.setState({ snippetbarHeight: document.querySelector('.editor > .snippetBar').offsetHeight });
const snippetBar = document.querySelector('.editor > .snippetBar');
if (!snippetBar) return;
this.resizeObserver = new ResizeObserver(entries => {
const height = document.querySelector('.editor > .snippetBar').offsetHeight;
this.setState({ snippetBarHeight: height });
});
this.resizeObserver.observe(snippetBar);
},
componentDidUpdate : function(prevProps, prevState, snapshot) {
@@ -108,6 +116,10 @@ const Editor = createClass({
}
},
componentWillUnmount() {
if (this.resizeObserver) this.resizeObserver.disconnect();
},
handleControlKeys : function(e){
if(!(e.ctrlKey && e.metaKey && e.shiftKey)) return;
const LEFTARROW_KEY = 37;
@@ -144,21 +156,21 @@ const Editor = createClass({
this.setState({
view : newView
}, ()=>{
this.codeEditor.current?.codeMirror.focus();
this.codeEditor.current?.codeMirror?.focus();
});
},
highlightCustomMarkdown : function(){
if(!this.codeEditor.current) return;
if(!this.codeEditor.current?.codeMirror) return;
if((this.state.view === 'text') ||(this.state.view === 'snippet')) {
const codeMirror = this.codeEditor.current.codeMirror;
codeMirror.operation(()=>{ // Batch CodeMirror styling
codeMirror?.operation(()=>{ // Batch CodeMirror styling
const foldLines = [];
//reset custom text styles
const customHighlights = codeMirror.getAllMarks().filter((mark)=>{
const customHighlights = codeMirror?.getAllMarks().filter((mark)=>{
// Record details of folded sections
if(mark.__isFold) {
const fold = mark.find();
@@ -179,10 +191,10 @@ const Editor = createClass({
const textOrSnip = this.state.view === 'text';
//reset custom line styles
codeMirror.removeLineClass(lineNumber, 'background', 'pageLine');
codeMirror.removeLineClass(lineNumber, 'background', 'snippetLine');
codeMirror.removeLineClass(lineNumber, 'text');
codeMirror.removeLineClass(lineNumber, 'wrap', 'sourceMoveFlash');
codeMirror?.removeLineClass(lineNumber, 'background', 'pageLine');
codeMirror?.removeLineClass(lineNumber, 'background', 'snippetLine');
codeMirror?.removeLineClass(lineNumber, 'text');
codeMirror?.removeLineClass(lineNumber, 'wrap', 'sourceMoveFlash');
// Don't process lines inside folded text
// If the current lineNumber is inside any folded marks, skip line styling
@@ -198,19 +210,19 @@ const Editor = createClass({
else if(this.state.view !== 'text') userSnippetCount += 1;
// add back the original class 'background' but also add the new class '.pageline'
codeMirror.addLineClass(lineNumber, 'background', tabHighlight);
codeMirror?.addLineClass(lineNumber, 'background', tabHighlight);
const pageCountElement = Object.assign(document.createElement('span'), {
className : 'editor-page-count',
textContent : textOrSnip ? editorPageCount : userSnippetCount
});
codeMirror.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement);
codeMirror?.setBookmark({ line: lineNumber, ch: line.length }, pageCountElement);
};
// New Codemirror styling for V3 renderer
// New CodeMirror styling for V3 renderer
if(this.props.renderer === 'V3') {
if(line.match(/^\\column(?:break)?$/)){
codeMirror.addLineClass(lineNumber, 'text', 'columnSplit');
codeMirror?.addLineClass(lineNumber, 'text', 'columnSplit');
}
// definition lists
@@ -219,14 +231,14 @@ const Editor = createClass({
const regex = /^([^\n]*?:?\s?)(::[^\n]*)(?:\n|$)/ymd; // the `d` flag, for match indices, throws an ESLint error.
let match;
while ((match = regex.exec(line)) != null){
codeMirror.markText({ line: lineNumber, ch: match.indices[0][0] }, { line: lineNumber, ch: match.indices[0][1] }, { className: 'dl-highlight' });
codeMirror.markText({ line: lineNumber, ch: match.indices[1][0] }, { line: lineNumber, ch: match.indices[1][1] }, { className: 'dt-highlight' });
codeMirror.markText({ line: lineNumber, ch: match.indices[2][0] }, { line: lineNumber, ch: match.indices[2][1] }, { className: 'dd-highlight' });
codeMirror?.markText({ line: lineNumber, ch: match.indices[0][0] }, { line: lineNumber, ch: match.indices[0][1] }, { className: 'dl-highlight' });
codeMirror?.markText({ line: lineNumber, ch: match.indices[1][0] }, { line: lineNumber, ch: match.indices[1][1] }, { className: 'dt-highlight' });
codeMirror?.markText({ line: lineNumber, ch: match.indices[2][0] }, { line: lineNumber, ch: match.indices[2][1] }, { className: 'dd-highlight' });
const ddIndex = match.indices[2][0];
const colons = /::/g;
const colonMatches = colons.exec(match[2]);
if(colonMatches !== null){
codeMirror.markText({ line: lineNumber, ch: colonMatches.index + ddIndex }, { line: lineNumber, ch: colonMatches.index + colonMatches[0].length + ddIndex }, { className: 'dl-colon-highlight' });
codeMirror?.markText({ line: lineNumber, ch: colonMatches.index + ddIndex }, { line: lineNumber, ch: colonMatches.index + colonMatches[0].length + ddIndex }, { className: 'dl-colon-highlight' });
}
}
}
@@ -243,7 +255,7 @@ const Editor = createClass({
const match = subRegex.exec(line) || superRegex.exec(line);
if(match) {
isSuper = !subRegex.lastIndex;
codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: isSuper ? 'superscript' : 'subscript' });
codeMirror?.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: isSuper ? 'superscript' : 'subscript' });
}
startIndex = line.indexOf('^', Math.max(startIndex + 1, subRegex.lastIndex, superRegex.lastIndex));
}
@@ -254,7 +266,7 @@ const Editor = createClass({
const regex = /(?:^|[^{\n])({(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\2})/gm;
let match;
while ((match = regex.exec(line)) != null) {
codeMirror.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'injection' });
codeMirror?.markText({ line: lineNumber, ch: line.indexOf(match[1]) }, { line: lineNumber, ch: line.indexOf(match[1]) + match[1].length }, { className: 'injection' });
}
}
// Highlight inline spans {{content}}
@@ -272,7 +284,7 @@ const Editor = createClass({
blockCount = 0;
continue;
}
codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'inline-block' });
codeMirror?.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'inline-block' });
}
} else if(line.trimLeft().startsWith('{{') || line.trimLeft().startsWith('}}')){
// Highlight block divs {{\n Content \n}}
@@ -281,7 +293,7 @@ const Editor = createClass({
const match = line.match(/^ *{{(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\1 *$|^ *}}$/);
if(match)
endCh = match.index+match[0].length;
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
codeMirror?.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
}
// Emojis
@@ -302,11 +314,11 @@ const Editor = createClass({
const endPos = { line: lineNumber, ch: match.index + match[0].length };
// Iterate over conflicting marks and clear them
const marks = codeMirror.findMarks(startPos, endPos);
const marks = codeMirror?.findMarks(startPos, endPos);
marks.forEach(function(marker) {
if(!marker.__isFold) marker.clear();
});
codeMirror.markText(startPos, endPos, { className: 'emoji' });
codeMirror?.markText(startPos, endPos, { className: 'emoji' });
}
startIndex = line.indexOf(':', Math.max(startIndex + 1, emojiRegex.lastIndex));
}
@@ -325,10 +337,10 @@ const Editor = createClass({
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 checkIfScrollComplete = ()=>{
let scrollingTimeout;
clearTimeout(scrollingTimeout); // Reset the timer every time a scroll event occurs
let scrollingTimeout;
const checkIfScrollComplete = ()=>{ // Prevent interrupting a scroll in progress if user clicks multiple times
clearTimeout(scrollingTimeout); // Reset the timer every time a scroll event occurs
scrollingTimeout = setTimeout(()=>{
isJumping = false;
brewRenderer.removeEventListener('scroll', checkIfScrollComplete);
@@ -366,54 +378,51 @@ const Editor = createClass({
const textString = this.props.brew.text.split(textSplit).slice(0, targetPage-1).join(textSplit);
const targetLine = textString.match('\n') ? textString.split('\n').length - 1 : -1;
let currentY = this.codeEditor.current.codeMirror.getScrollInfo().top;
let targetY = this.codeEditor.current.codeMirror.heightAtLine(targetLine, 'local', true);
let currentY = this.codeEditor.current.codeMirror?.getScrollInfo().top;
let targetY = this.codeEditor.current.codeMirror?.heightAtLine(targetLine, 'local', true);
const checkIfScrollComplete = ()=>{
let scrollingTimeout;
let scrollingTimeout;
const checkIfScrollComplete = ()=>{ // Prevent interrupting a scroll in progress if user clicks multiple times
clearTimeout(scrollingTimeout); // Reset the timer every time a scroll event occurs
scrollingTimeout = setTimeout(()=>{
isJumping = false;
this.codeEditor.current.codeMirror.off('scroll', checkIfScrollComplete);
this.codeEditor.current.codeMirror?.off('scroll', checkIfScrollComplete);
}, 150); // If 150 ms pass without a scroll event, assume scrolling is done
};
isJumping = true;
checkIfScrollComplete();
this.codeEditor.current.codeMirror.on('scroll', checkIfScrollComplete);
if (this.codeEditor.current?.codeMirror) {
this.codeEditor.current.codeMirror?.on('scroll', checkIfScrollComplete);
}
if(smooth) {
//Scroll 1/10 of the way every 10ms until 1px off.
const incrementalScroll = setInterval(()=>{
currentY += (targetY - currentY) / 10;
this.codeEditor.current.codeMirror.scrollTo(null, currentY);
this.codeEditor.current.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.codeEditor.current.codeMirror.heightAtLine(targetLine, 'local', true);
targetY = this.codeEditor.current.codeMirror?.heightAtLine(targetLine, 'local', true);
// End when close enough
if(Math.abs(targetY - currentY) < 1) {
this.codeEditor.current.codeMirror.scrollTo(null, targetY); // Scroll any remaining difference
this.codeEditor.current.codeMirror?.scrollTo(null, targetY); // Scroll any remaining difference
this.codeEditor.current.setCursorPosition({ line: targetLine + 1, ch: 0 });
this.codeEditor.current.codeMirror.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash');
this.codeEditor.current.codeMirror?.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash');
clearInterval(incrementalScroll);
}
}, 10);
} else {
this.codeEditor.current.codeMirror.scrollTo(null, targetY); // Scroll any remaining difference
this.codeEditor.current.codeMirror?.scrollTo(null, targetY); // Scroll any remaining difference
this.codeEditor.current.setCursorPosition({ line: targetLine + 1, ch: 0 });
this.codeEditor.current.codeMirror.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash');
this.codeEditor.current.codeMirror?.addLineClass(targetLine + 1, 'wrap', 'sourceMoveFlash');
}
},
//Called when there are changes to the editor's dimensions
update : function(){
this.codeEditor.current?.updateSize();
const snipHeight = document.querySelector('.editor > .snippetBar').offsetHeight;
if(snipHeight !== this.state.snippetbarHeight)
this.setState({ snippetbarHeight: snipHeight });
},
update : function(){},
updateEditorTheme : function(newTheme){
window.localStorage.setItem(EDITOR_THEME_KEY, newTheme);
@@ -438,7 +447,7 @@ const Editor = createClass({
onChange={this.props.onBrewChange('text')}
editorTheme={this.state.editorTheme}
rerenderParent={this.rerenderParent}
style={{ height: `calc(100% - ${this.state.snippetbarHeight}px)` }} />
style={{ height: `calc(100% - ${this.state.snippetBarHeight}px)` }} />
</>;
}
if(this.isStyle()){
@@ -452,7 +461,7 @@ const Editor = createClass({
enableFolding={true}
editorTheme={this.state.editorTheme}
rerenderParent={this.rerenderParent}
style={{ height: `calc(100% - ${this.state.snippetbarHeight}px)` }} />
style={{ height: `calc(100% - ${this.state.snippetBarHeight}px)` }} />
</>;
}
if(this.isMeta()){
@@ -469,7 +478,6 @@ const Editor = createClass({
userThemes={this.props.userThemes}/>
</>;
}
if(this.isSnip()){
if(!this.props.brew.snippets) { this.props.brew.snippets = DEFAULT_SNIPPET_TEXT; }
return <>
@@ -482,7 +490,7 @@ const Editor = createClass({
enableFolding={true}
editorTheme={this.state.editorTheme}
rerenderParent={this.rerenderParent}
style={{ height: `calc(100% - ${this.state.snippetbarHeight}px)` }} />
style={{ height: `calc(100% -${this.state.snippetBarHeight}px)` }} />
</>;
}
},
@@ -536,4 +544,4 @@ const Editor = createClass({
}
});
module.exports = Editor;
export default Editor;

View File

@@ -1,19 +1,19 @@
/* eslint-disable max-lines */
require('./metadataEditor.less');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
import './metadataEditor.less';
import React from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import request from '../../utils/request-middleware.js';
const Combobox = require('client/components/combobox.jsx');
const TagInput = require('../tagInput/tagInput.jsx');
import Combobox from 'client/components/combobox.jsx';
import TagInput from '../tagInput/tagInput.jsx';
const Themes = require('themes/themes.json');
const validations = require('./validations.js');
import Themes from 'themes/themes.json';
import validations from './validations.js';
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'];
const homebreweryThumbnail = require('../../thumbnail.png');
import homebreweryThumbnail from '../../thumbnail.png';
const callIfExists = (val, fn, ...args)=>{
if(val[fn]) {
@@ -21,7 +21,7 @@ const callIfExists = (val, fn, ...args)=>{
}
};
const MetadataEditor = createClass({
const MetadataEditor = createReactClass({
displayName : 'MetadataEditor',
getDefaultProps : function() {
return {
@@ -207,8 +207,6 @@ const MetadataEditor = createClass({
},
renderThemeDropdown : function(){
if(!global.enable_themes) return;
const mergedThemes = _.merge(Themes, this.props.userThemes);
const listThemes = (renderer)=>{
@@ -307,8 +305,6 @@ const MetadataEditor = createClass({
},
renderRenderOptions : function(){
if(!global.enable_v3) return;
return <div className='field systems'>
<label>Renderer</label>
<div className='value'>
@@ -415,4 +411,4 @@ const MetadataEditor = createClass({
}
});
module.exports = MetadataEditor;
export default MetadataEditor;

View File

@@ -1,4 +1,4 @@
module.exports = {
export default {
title : [
(value)=>{
return value?.length > 100 ? 'Max title length of 100 characters' : null;
@@ -18,7 +18,7 @@ module.exports = {
try {
Boolean(new URL(value));
return null;
} catch (e) {
} catch {
return 'Must be a valid URL';
}
}

View File

@@ -1,29 +1,36 @@
/*eslint max-lines: ["warn", {"max": 350, "skipBlankLines": true, "skipComments": true}]*/
require('./snippetbar.less');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
import './snippetbar.less';
import React from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import cx from 'classnames';
import { loadHistory } from '../../utils/versionHistory.js';
import { brewSnippetsToJSON } from '../../../../shared/helpers.js';
//Import all themes
const ThemeSnippets = {};
ThemeSnippets['Legacy_5ePHB'] = require('themes/Legacy/5ePHB/snippets.js');
ThemeSnippets['V3_5ePHB'] = require('themes/V3/5ePHB/snippets.js');
ThemeSnippets['V3_5eDMG'] = require('themes/V3/5eDMG/snippets.js');
ThemeSnippets['V3_Journal'] = require('themes/V3/Journal/snippets.js');
ThemeSnippets['V3_Blank'] = require('themes/V3/Blank/snippets.js');
import Legacy5ePHB from 'themes/Legacy/5ePHB/snippets.js';
import V3_5ePHB from 'themes/V3/5ePHB/snippets.js';
import V3_5eDMG from 'themes/V3/5eDMG/snippets.js';
import V3_Journal from 'themes/V3/Journal/snippets.js';
import V3_Blank from 'themes/V3/Blank/snippets.js';
const EditorThemes = require('build/homebrew/codeMirror/editorThemes.json');
const ThemeSnippets = {
Legacy_5ePHB : Legacy5ePHB,
V3_5ePHB : V3_5ePHB,
V3_5eDMG : V3_5eDMG,
V3_Journal : V3_Journal,
V3_Blank : V3_Blank,
};
import EditorThemes from 'build/homebrew/codeMirror/editorThemes.json';
const execute = function(val, props){
if(_.isFunction(val)) return val(props);
return val;
};
const Snippetbar = createClass({
const Snippetbar = createReactClass({
displayName : 'SnippetBar',
getDefaultProps : function() {
return {
@@ -281,9 +288,9 @@ const Snippetbar = createClass({
}
});
module.exports = Snippetbar;
export default Snippetbar;
const SnippetGroup = createClass({
const SnippetGroup = createReactClass({
displayName : 'SnippetGroup',
getDefaultProps : function() {
return {

View File

@@ -14,7 +14,7 @@
.snippets {
display : flex;
justify-content : flex-start;
min-width : 432.18px; //must be controlled every time an item is added, must be hardcoded for the wrapping as it is applied
min-width : 499.35px; //must be controlled every time an item is added, must be hardcoded for the wrapping as it is applied
}
.editors {
@@ -237,7 +237,7 @@
}
}
@container editor (width < 683px) {
@container editor (width < 750px) {
.snippetBar {
.editors {
flex : 1;

View File

@@ -1,7 +1,6 @@
require('./tagInput.less');
const React = require('react');
const { useState, useEffect } = React;
const _ = require('lodash');
import './tagInput.less';
import React, { useState, useEffect } from 'react';
import _ from 'lodash';
const TagInput = ({ unique = true, values = [], ...props })=>{
const [tempInputText, setTempInputText] = useState('');
@@ -102,4 +101,4 @@ const TagInput = ({ unique = true, values = [], ...props })=>{
);
};
module.exports = TagInput;
export default TagInput;

View File

@@ -1,4 +1,4 @@
/* eslint-disable camelcase */
import 'core-js/es/string/to-well-formed.js'; //Polyfill for older browsers
import './homebrew.less';
import React from 'react';
@@ -27,8 +27,6 @@ const Homebrew = (props)=>{
url = '',
version = '0.0.0',
account = null,
enable_v3 = false,
enable_themes,
config,
brew = {
title : '',
@@ -45,8 +43,6 @@ const Homebrew = (props)=>{
global.account = account;
global.version = version;
global.enable_v3 = enable_v3;
global.enable_themes = enable_themes;
global.config = config;
const backgroundObject = ()=>{

View File

@@ -1,9 +1,9 @@
const React = require('react');
const createClass = require('create-react-class');
const Nav = require('naturalcrit/nav/nav.jsx');
const request = require('superagent');
import React from 'react';
import createReactClass from 'create-react-class';
import request from 'superagent';
import Nav from 'client/homebrew/navbar/nav.jsx';
const Account = createClass({
const Account = createReactClass({
displayName : 'AccountNavItem',
getInitialState : function() {
return {
@@ -70,7 +70,7 @@ const Account = createClass({
{global.account.username}
</Nav.item>
<Nav.item
href={`/user/${encodeURI(global.account.username)}`}
href={`/user/${encodeURIComponent(global.account.username)}`}
color='yellow'
icon='fas fa-beer'
>
@@ -111,4 +111,4 @@ const Account = createClass({
}
});
module.exports = Account;
export default Account;

View File

@@ -1,10 +1,10 @@
require('./error-navitem.less');
const React = require('react');
const Nav = require('naturalcrit/nav/nav.jsx');
import './error-navitem.less';
import React from 'react';
import Nav from 'client/homebrew/navbar/nav.jsx';
const ErrorNavItem = ({error = '', clearError})=>{
const ErrorNavItem = ({ error = '', clearError })=>{
const response = error.response;
const errorCode = error.code
const errorCode = error.code;
const status = response?.status;
const HBErrorCode = response?.body?.HBErrorCode;
const message = response?.body?.message;
@@ -15,7 +15,7 @@ const ErrorNavItem = ({error = '', clearError})=>{
errMsg += `\`\`\`\n${error.stack}\n`;
errMsg += `${JSON.stringify(response?.error, null, ' ')}\n\`\`\``;
console.log(errMsg);
} catch (e){}
} catch {}
if(status === 409) {
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
@@ -112,6 +112,15 @@ const ErrorNavItem = ({error = '', clearError})=>{
</Nav.item>;
}
if(HBErrorCode === '13') {
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
Oops!
<div className='errorContainer' onClick={clearError}>
Server has lost connection to the database.
</div>
</Nav.item>;
}
if(errorCode === 'ECONNABORTED') {
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
Oops!
@@ -135,4 +144,4 @@ const ErrorNavItem = ({error = '', clearError})=>{
</Nav.item>;
};
module.exports = ErrorNavItem;
export default ErrorNavItem;

View File

@@ -1,9 +1,9 @@
const React = require('react');
const dedent = require('dedent-tabs').default;
import React from 'react';
import dedent from 'dedent-tabs';
const Nav = require('naturalcrit/nav/nav.jsx');
import Nav from 'client/homebrew/navbar/nav.jsx';
module.exports = function(props){
export default function(props){
return <Nav.dropdown>
<Nav.item color='grey' icon='fas fa-question-circle'>
need help?

View File

@@ -1,11 +1,11 @@
const React = require('react');
const createClass = require('create-react-class');
const Moment = require('moment');
import React from 'react';
import createReactClass from 'create-react-class';
import Moment from 'moment';
const Nav = require('naturalcrit/nav/nav.jsx');
import Nav from 'client/homebrew/navbar/nav.jsx';
const MetadataNav = createClass({
const MetadataNav = createReactClass({
displayName : 'MetadataNav',
getDefaultProps : function() {
return {
@@ -32,7 +32,7 @@ const MetadataNav = createClass({
return <>
{this.props.brew.authors.map((author, idx, arr)=>{
const spacer = arr.length - 1 == idx ? <></> : <span>, </span>;
return <span key={idx}><a className='userPageLink' href={`/user/${author}`}>{author}</a>{spacer}</span>;
return <span key={idx}><a className='userPageLink' href={`/user/${encodeURIComponent(author)}`}>{author}</a>{spacer}</span>;
})}
</>;
},
@@ -86,4 +86,4 @@ const MetadataNav = createClass({
});
module.exports = MetadataNav;
export default MetadataNav;

View File

@@ -1,14 +1,13 @@
require('client/homebrew/navbar/navbar.less');
const React = require('react');
const { useState, useRef, useEffect } = React;
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
import 'client/homebrew/navbar/navbar.less';
import React, { useState, useRef, useEffect } from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import cx from 'classnames';
const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx');
import NaturalCritIcon from 'client/components/svg/naturalcrit-d20.svg.jsx';
const Nav = {
base : createClass({
base : createReactClass({
displayName : 'Nav.base',
render : function(){
return <nav>
@@ -25,7 +24,7 @@ const Nav = {
</a>;
},
section : createClass({
section : createReactClass({
displayName : 'Nav.section',
render : function(){
return <div className={`navSection ${this.props.className ?? ''}`}>
@@ -34,7 +33,7 @@ const Nav = {
}
}),
item : createClass({
item : createReactClass({
displayName : 'Nav.item',
getDefaultProps : function() {
return {
@@ -117,4 +116,4 @@ const Nav = {
};
module.exports = Nav;
export default Nav;

View File

@@ -1,11 +1,11 @@
require('./navbar.less');
const React = require('react');
const createClass = require('create-react-class');
import './navbar.less';
import React from 'react';
import createReactClass from 'create-react-class';
const Nav = require('naturalcrit/nav/nav.jsx');
const PatreonNavItem = require('./patreon.navitem.jsx');
import Nav from 'client/homebrew/navbar/nav.jsx';
import PatreonNavItem from './patreon.navitem.jsx';
const Navbar = createClass({
const Navbar = createReactClass({
displayName : 'Navbar',
getInitialState : function() {
return {
@@ -49,4 +49,4 @@ const Navbar = createClass({
}
});
module.exports = Navbar;
export default Navbar;

View File

@@ -37,7 +37,10 @@
&:has(.brewTitle) {
flex-grow : 1;
min-width : 300px;
min-width : 300px;
}
>.brewTitle {
cursor:auto;
}
}
// "NaturalCrit" logo

View File

@@ -1,21 +1,18 @@
const React = require('react');
const _ = require('lodash');
const Nav = require('naturalcrit/nav/nav.jsx');
const { splitTextStyleAndMetadata } = require('../../../shared/helpers.js'); // Importing the function from helpers.js
import React from 'react';
import _ from 'lodash';
import Nav from 'client/homebrew/navbar/nav.jsx';
import { splitTextStyleAndMetadata } from '../../../shared/helpers.js';
const BREWKEY = 'homebrewery-new';
const STYLEKEY = 'homebrewery-new-style';
const METAKEY = 'homebrewery-new-meta';
const BREWKEY = 'HB_newPage_content';
const STYLEKEY = 'HB_newPage_style';
const METAKEY = 'HB_newPage_meta';
const NewBrew = ()=>{
const handleFileChange = (e)=>{
const file = e.target.files[0];
if(!file) return;
const currentNew = localStorage.getItem(BREWKEY);
if(currentNew && !confirm(
`You have some text in the new brew space, if you load a file that text will be lost, are you sure you want to load the file?`
)) return;
if(!confirmLocalStorageChange()) return;
const reader = new FileReader();
reader.onload = (e)=>{
@@ -34,15 +31,38 @@ const NewBrew = ()=>{
}
const type = file.name.split('.').pop().toLowerCase();
alert(`This file is invalid: ${!type ? "Missing file extension" :`.${type} files are not supported`}. Only .txt files exported from the Homebrewery are allowed.`);
alert(`This file is invalid: ${!type ? 'Missing file extension' :`.${type} files are not supported`}. Only .txt files exported from the Homebrewery are allowed.`);
console.log(file);
};
reader.readAsText(file);
};
const confirmLocalStorageChange = ()=>{
const currentText = localStorage.getItem(BREWKEY);
const currentStyle = localStorage.getItem(STYLEKEY);
const currentMeta = localStorage.getItem(METAKEY);
// TRUE if no data in any local storage key
// TRUE if data in any local storage key AND approval given
// FALSE if data in any local storage key AND approval declined
return (!(currentText || currentStyle || currentMeta) || confirm(
`You have made changes in the new brew space. If you continue, that information will be PERMANENTLY LOST.\nAre you sure you wish to continue?`
));
};
const clearLocalStorage = ()=>{
if(!confirmLocalStorageChange()) return;
localStorage.removeItem(BREWKEY);
localStorage.removeItem(STYLEKEY);
localStorage.removeItem(METAKEY);
window.location.href = '/new';
return;
};
return (
<Nav.dropdown>
@@ -50,27 +70,34 @@ const NewBrew = ()=>{
className='new'
color='purple'
icon='fa-solid fa-plus-square'>
new
new
</Nav.item>
<Nav.item
className='fromBlank'
className='new'
href='/new'
newTab={true}
color='purple'
icon='fa-solid fa-file'>
from blank
resume draft
</Nav.item>
<Nav.item
className='fromBlank'
newTab={true}
color='yellow'
icon='fa-solid fa-file-circle-plus'
onClick={()=>{ clearLocalStorage(); }}>
from blank
</Nav.item>
<Nav.item
className='fromFile'
color='purple'
color='green'
icon='fa-solid fa-upload'
onClick={()=>{ document.getElementById('uploadTxt').click(); }}>
<input id='uploadTxt' className='newFromLocal' type='file' onChange={handleFileChange} style={{ display: 'none' }} />
from file
from file
</Nav.item>
</Nav.dropdown>
);
};
module.exports = NewBrew;
export default NewBrew;

View File

@@ -1,7 +1,7 @@
const React = require('react');
const Nav = require('naturalcrit/nav/nav.jsx');
import React from 'react';
import Nav from 'client/homebrew/navbar/nav.jsx';
module.exports = function(props){
export default function(props){
return <Nav.item
className='patreon'
newTab={true}

View File

@@ -1,8 +1,8 @@
const React = require('react');
const Nav = require('naturalcrit/nav/nav.jsx');
const { printCurrentBrew } = require('../../../shared/helpers.js');
import React from 'react';
import Nav from 'client/homebrew/navbar/nav.jsx';
import { printCurrentBrew } from '../../../shared/helpers.js';
module.exports = function(){
export default function(){
return <Nav.item onClick={printCurrentBrew} color='purple' icon='far fa-file-pdf'>
get PDF
</Nav.item>;

View File

@@ -1,15 +1,15 @@
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const Moment = require('moment');
import React from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import Moment from 'moment';
const Nav = require('naturalcrit/nav/nav.jsx');
import Nav from 'client/homebrew/navbar/nav.jsx';
const EDIT_KEY = 'HB_nav_recentlyEdited';
const VIEW_KEY = 'HB_nav_recentlyViewed';
const RecentItems = createClass({
const RecentItems = createReactClass({
DisplayName : 'RecentItems',
getDefaultProps : function() {
return {
@@ -175,7 +175,7 @@ const RecentItems = createClass({
});
module.exports = {
export default {
edited : (props)=>{
return <RecentItems

View File

@@ -1,23 +1,23 @@
import React from 'react';
import dedent from 'dedent-tabs';
import Nav from 'naturalcrit/nav/nav.jsx';
import Nav from 'client/homebrew/navbar/nav.jsx';
const getShareId = (brew)=>(
brew.googleId && !brew.stubbed
? brew.googleId + brew.shareId
: brew.shareId
);
const getShareId = (brew)=>(
brew.googleId && !brew.stubbed
? brew.googleId + brew.shareId
: brew.shareId
);
const getRedditLink = (brew)=>{
const text = dedent`
const getRedditLink = (brew)=>{
const text = dedent`
Hey guys! I've been working on this homebrew. I'd love your feedback. Check it out.
**[Homebrewery Link](${global.config.baseUrl}/share/${getShareId(brew)})**`;
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(brew.title.toWellFormed())}&text=${encodeURIComponent(text)}`;
};
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(brew.title.toWellFormed())}&text=${encodeURIComponent(text)}`;
};
export default ({brew}) => (
export default ({ brew })=>(
<Nav.dropdown>
<Nav.item color='teal' icon='fas fa-share-alt'>
share

View File

@@ -1,8 +1,8 @@
const React = require('react');
import React from 'react';
const Nav = require('naturalcrit/nav/nav.jsx');
import Nav from 'client/homebrew/navbar/nav.jsx';
module.exports = function (props) {
export default function (props) {
return (
<Nav.item
color='purple'

View File

@@ -1,7 +1,7 @@
const React = require('react');
const moment = require('moment');
const UIPage = require('../basePages/uiPage/uiPage.jsx');
const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx');
import React from 'react';
import moment from 'moment';
import UIPage from '../basePages/uiPage/uiPage.jsx';
import NaturalCritIcon from 'client/components/svg/naturalcrit-d20.svg.jsx';
let SAVEKEY = '';
@@ -79,4 +79,4 @@ const AccountPage = (props)=>{
</UIPage>);
};
module.exports = AccountPage;
export default AccountPage;

View File

@@ -1,12 +1,11 @@
require('./brewItem.less');
const React = require('react');
const { useCallback } = React;
const moment = require('moment');
import './brewItem.less';
import React, { useCallback } from 'react';
import moment from 'moment';
import request from '../../../../utils/request-middleware.js';
const googleDriveIcon = require('../../../../googleDrive.svg');
const homebreweryIcon = require('../../../../thumbnail.svg');
const dedent = require('dedent-tabs').default;
import googleDriveIcon from '../../../../googleDrive.svg';
import homebreweryIcon from '../../../../thumbnail.svg';
import dedent from 'dedent-tabs';
const BrewItem = ({
brew = {
@@ -143,7 +142,7 @@ const BrewItem = ({
<span title="Username contained an email address; hidden to protect user's privacy">
{author}
</span>
) : (<a href={`/user/${author}`}>{author}</a>)}
) : (<a href={`/user/${encodeURIComponent(author)}`}>{author}</a>)}
{index < brew.authors.length - 1 && ', '}
</React.Fragment>
))}
@@ -176,4 +175,4 @@ const BrewItem = ({
);
};
module.exports = BrewItem;
export default BrewItem;

View File

@@ -1,11 +1,11 @@
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
require('./listPage.less');
const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const moment = require('moment');
import './listPage.less';
import React from 'react';
import createReactClass from 'create-react-class';
import _ from 'lodash';
import moment from 'moment';
const BrewItem = require('./brewItem/brewItem.jsx');
import BrewItem from './brewItem/brewItem.jsx';
const USERPAGE_SORT_DIR = 'HB_listPage_sortDir';
const USERPAGE_SORT_TYPE = 'HB_listPage_sortType';
@@ -14,7 +14,7 @@ const USERPAGE_GROUP_VISIBILITY_PREFIX = 'HB_listPage_visibility_group';
const DEFAULT_SORT_TYPE = 'alpha';
const DEFAULT_SORT_DIR = 'asc';
const ListPage = createClass({
const ListPage = createReactClass({
displayName : 'ListPage',
getDefaultProps : function() {
return {
@@ -279,4 +279,4 @@ const ListPage = createClass({
}
});
module.exports = ListPage;
export default ListPage;

View File

@@ -1,16 +1,17 @@
require('./uiPage.less');
const React = require('react');
const createClass = require('create-react-class');
import './uiPage.less';
import React from 'react';
import createReactClass from 'create-react-class';
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../../navbar/navbar.jsx');
const NewBrewItem = require('../../../navbar/newbrew.navitem.jsx');
const HelpNavItem = require('../../../navbar/help.navitem.jsx');
const RecentNavItem = require('../../../navbar/recent.navitem.jsx').both;
const Account = require('../../../navbar/account.navitem.jsx');
import Nav from 'client/homebrew/navbar/nav.jsx';
import Navbar from 'client/homebrew/navbar/navbar.jsx';
import NewBrewItem from 'client/homebrew/navbar/newbrew.navitem.jsx';
import HelpNavItem from 'client/homebrew/navbar/help.navitem.jsx';
import RecentNavItems from 'client/homebrew/navbar/recent.navitem.jsx';
const { both: RecentNavItem } = RecentNavItems;
import Account from 'client/homebrew/navbar/account.navitem.jsx';
const UIPage = createClass({
const UIPage = createReactClass({
displayName : 'UIPage',
render : function(){
@@ -35,4 +36,4 @@ const UIPage = createClass({
}
});
module.exports = UIPage;
export default UIPage;

View File

@@ -4,7 +4,7 @@ import './editPage.less';
// Common imports
import React, { useState, useEffect, useRef } from 'react';
import request from '../../utils/request-middleware.js';
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
import _ from 'lodash';
import { DEFAULT_BREW_LOAD } from '../../../../server/brewDefaults.js';
@@ -14,15 +14,16 @@ import SplitPane from 'client/components/splitPane/splitPane.jsx';
import Editor from '../../editor/editor.jsx';
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
import Nav from 'naturalcrit/nav/nav.jsx';
import Navbar from '../../navbar/navbar.jsx';
import NewBrewItem from '../../navbar/newbrew.navitem.jsx';
import AccountNavItem from '../../navbar/account.navitem.jsx';
import ErrorNavItem from '../../navbar/error-navitem.jsx';
import HelpNavItem from '../../navbar/help.navitem.jsx';
import VaultNavItem from '../../navbar/vault.navitem.jsx';
import PrintNavItem from '../../navbar/print.navitem.jsx';
import { both as RecentNavItem } from '../../navbar/recent.navitem.jsx';
import Nav from 'client/homebrew/navbar/nav.jsx';
import Navbar from 'client/homebrew/navbar/navbar.jsx';
import NewBrewItem from 'client/homebrew/navbar/newbrew.navitem.jsx';
import AccountNavItem from 'client/homebrew/navbar/account.navitem.jsx';
import ErrorNavItem from 'client/homebrew/navbar/error-navitem.jsx';
import HelpNavItem from 'client/homebrew/navbar/help.navitem.jsx';
import VaultNavItem from 'client/homebrew/navbar/vault.navitem.jsx';
import PrintNavItem from 'client/homebrew/navbar/print.navitem.jsx';
import RecentNavItems from 'client/homebrew/navbar/recent.navitem.jsx';
const { both: RecentNavItem } = RecentNavItems;
// Page specific imports
import { Meta } from 'vitreum/headtags';
@@ -30,7 +31,7 @@ import { md5 } from 'hash-wasm';
import { gzipSync, strToU8 } from 'fflate';
import { makePatches, stringifyPatches } from '@sanity/diff-match-patch';
import ShareNavItem from '../../navbar/share.navitem.jsx';
import ShareNavItem from 'client/homebrew/navbar/share.navitem.jsx';
import LockNotification from './lockNotification/lockNotification.jsx';
import { updateHistory, versionHistoryGarbageCollection } from '../../utils/versionHistory.js';
import googleDriveIcon from '../../googleDrive.svg';
@@ -119,20 +120,24 @@ const EditPage = (props)=>{
if(autoSaveEnabled) trySave(false, hasChange);
}, [currentBrew]);
useEffect(()=>{
trySave(true);
}, [saveGoogle]);
const handleSplitMove = ()=>{
editorRef.current?.update();
};
const handleBrewChange = (field) => (value, subfield) => { //'text', 'style', 'snippets', 'metadata'
if (subfield == 'renderer' || subfield == 'theme')
const handleBrewChange = (field)=>(value, subfield)=>{ //'text', 'style', 'snippets', 'metadata'
if(subfield == 'renderer' || subfield == 'theme')
fetchThemeBundle(setError, setThemeBundle, value.renderer, value.theme);
//If there are HTML errors, run the validator on every change to give quick feedback
if(HTMLErrors.length && (field == 'text' || field == 'snippets'))
setHTMLErrors(Markdown.validate(value));
if(field == 'metadata') setCurrentBrew(prev => ({ ...prev, ...value }));
else setCurrentBrew(prev => ({ ...prev, [field]: value }));
if(field == 'metadata') setCurrentBrew((prev)=>({ ...prev, ...value }));
else setCurrentBrew((prev)=>({ ...prev, [field]: value }));
if(useLocalStorage) {
if(field == 'text') localStorage.setItem(BREWKEY, value);
@@ -179,7 +184,6 @@ const EditPage = (props)=>{
const toggleGoogleStorage = ()=>{
setSaveGoogle((prev)=>!prev);
setError(null);
trySave(true);
};
const trySave = (immediate = false, hasChanges = true)=>{
@@ -213,7 +217,7 @@ const EditPage = (props)=>{
text : brew.text.normalize('NFC'),
pageCount : ((brew.renderer === 'legacy' ? brew.text.match(/\\page/g) : brew.text.match(/^\\page$/gm)) || []).length + 1,
patches : stringifyPatches(makePatches(encodeURI(lastSavedBrew.current.text.normalize('NFC')), encodeURI(brew.text.normalize('NFC')))),
hash : await md5(lastSavedBrew.current.text),
hash : await md5(lastSavedBrew.current.text.normalize('NFC')),
textBin : undefined,
version : lastSavedBrew.current.version
};
@@ -412,4 +416,4 @@ const EditPage = (props)=>{
);
};
module.exports = EditPage;
export default EditPage;

View File

@@ -40,4 +40,4 @@ function LockNotification(props) {
</Dialog>;
};
module.exports = LockNotification;
export default LockNotification;

View File

@@ -1,8 +1,8 @@
require('./errorPage.less');
const React = require('react');
const UIPage = require('../basePages/uiPage/uiPage.jsx');
import Markdown from '../../../../shared/naturalcrit/markdown.js';
const ErrorIndex = require('./errors/errorIndex.js');
import './errorPage.less';
import React from 'react';
import UIPage from '../basePages/uiPage/uiPage.jsx';
import Markdown from '../../../../shared/markdown.js';
import ErrorIndex from './errors/errorIndex.js';
const ErrorPage = ({ brew })=>{
// Retrieving the error text based on the brew's error code from ErrorIndex
@@ -22,4 +22,4 @@ const ErrorPage = ({ brew })=>{
);
};
module.exports = ErrorPage;
export default ErrorPage;

View File

@@ -1,4 +1,4 @@
const dedent = require('dedent-tabs').default;
import dedent from 'dedent-tabs';
const loginUrl = 'https://www.naturalcrit.com/login';
@@ -96,7 +96,7 @@ const errorIndex = (props)=>{
**Brew Title:** ${escape(props.brew.brewTitle) || 'Unable to show title'}
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'}
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${encodeURIComponent(author)})`;}).join(', ') || 'Unable to list authors'}
[Click here to be redirected to the brew's share page.](/share/${props.brew.shareId})`,
@@ -111,7 +111,7 @@ const errorIndex = (props)=>{
**Brew Title:** ${escape(props.brew.brewTitle) || 'Unable to show title'}
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'}
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${encodeURIComponent(author)})`;}).join(', ') || 'Unable to list authors'}
[Click here to be redirected to the brew's share page.](/share/${props.brew.shareId})`,
@@ -196,6 +196,12 @@ const errorIndex = (props)=>{
**Brew ID:** ${props.brew.brewId}`,
// Database Connection Lost
'13' : dedent`
## Database connection has been lost.
The server could not communicate with the database.`,
//account page when account is not defined
'50' : dedent`
## You are not signed in
@@ -216,7 +222,7 @@ const errorIndex = (props)=>{
**Brew Title:** ${escape(props.brew.brewTitle)}
**Brew Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'}`,
**Brew Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${encodeURIComponent(author)})`;}).join(', ') || 'Unable to list authors'}`,
// ####### Admin page error #######
'52' : dedent`
@@ -262,4 +268,4 @@ const errorIndex = (props)=>{
};
};
module.exports = errorIndex;
export default errorIndex;

View File

@@ -4,7 +4,7 @@ import './homePage.less';
// Common imports
import React, { useState, useEffect, useRef } from 'react';
import request from '../../utils/request-middleware.js';
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
import _ from 'lodash';
import { DEFAULT_BREW } from '../../../../server/brewDefaults.js';
@@ -14,15 +14,17 @@ import SplitPane from 'client/components/splitPane/splitPane.jsx';
import Editor from '../../editor/editor.jsx';
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
import Nav from 'naturalcrit/nav/nav.jsx';
import Navbar from '../../navbar/navbar.jsx';
import NewBrewItem from '../../navbar/newbrew.navitem.jsx';
import AccountNavItem from '../../navbar/account.navitem.jsx';
import ErrorNavItem from '../../navbar/error-navitem.jsx';
import HelpNavItem from '../../navbar/help.navitem.jsx';
import VaultNavItem from '../../navbar/vault.navitem.jsx';
import PrintNavItem from '../../navbar/print.navitem.jsx';
import { both as RecentNavItem } from '../../navbar/recent.navitem.jsx';
import Nav from 'client/homebrew/navbar/nav.jsx';
import Navbar from 'client/homebrew/navbar/navbar.jsx';
import NewBrewItem from 'client/homebrew/navbar/newbrew.navitem.jsx';
import AccountNavItem from 'client/homebrew/navbar/account.navitem.jsx';
import ErrorNavItem from 'client/homebrew/navbar/error-navitem.jsx';
import HelpNavItem from 'client/homebrew/navbar/help.navitem.jsx';
import VaultNavItem from 'client/homebrew/navbar/vault.navitem.jsx';
import PrintNavItem from 'client/homebrew/navbar/print.navitem.jsx';
import RecentNavItems from 'client/homebrew/navbar/recent.navitem.jsx';
const { both: RecentNavItem } = RecentNavItems;
// Page specific imports
import { Meta } from 'vitreum/headtags';
@@ -39,8 +41,8 @@ const HomePage =(props)=>{
props = {
brew : DEFAULT_BREW,
ver : '0.0.0',
...props
};
...props
};
const [currentBrew , setCurrentBrew] = useState(props.brew);
const [error , setError] = useState(undefined);
@@ -53,8 +55,9 @@ const HomePage =(props)=>{
const [isSaving , setIsSaving] = useState(false);
const [autoSaveEnabled , setAutoSaveEnable] = useState(false);
const editorRef = useRef(null);
const lastSavedBrew = useRef(_.cloneDeep(props.brew));
const editorRef = useRef(null);
const lastSavedBrew = useRef(_.cloneDeep(props.brew));
const unsavedChangesRef = useRef(unsavedChanges);
useEffect(()=>{
fetchThemeBundle(setError, setThemeBundle, currentBrew.renderer, currentBrew.theme);
@@ -70,12 +73,20 @@ const HomePage =(props)=>{
};
document.addEventListener('keydown', handleControlKeys);
return () => {
window.onbeforeunload = ()=>{
if(unsavedChangesRef.current)
return 'You have unsaved changes!';
};
return ()=>{
document.removeEventListener('keydown', handleControlKeys);
window.onbeforeunload = null;
};
}, []);
useEffect(()=>{
unsavedChangesRef.current = unsavedChanges;
}, [unsavedChanges]);
const save = ()=>{
request.post('/api')
.send(currentBrew)
@@ -100,16 +111,16 @@ const HomePage =(props)=>{
editorRef.current.update();
};
const handleBrewChange = (field) => (value, subfield) => { //'text', 'style', 'snippets', 'metadata'
if (subfield == 'renderer' || subfield == 'theme')
const handleBrewChange = (field)=>(value, subfield)=>{ //'text', 'style', 'snippets', 'metadata'
if(subfield == 'renderer' || subfield == 'theme')
fetchThemeBundle(setError, setThemeBundle, value.renderer, value.theme);
//If there are HTML errors, run the validator on every change to give quick feedback
if(HTMLErrors.length && (field == 'text' || field == 'snippets'))
setHTMLErrors(Markdown.validate(value));
if(field == 'metadata') setCurrentBrew(prev => ({ ...prev, ...value }));
else setCurrentBrew(prev => ({ ...prev, [field]: value }));
if(field == 'metadata') setCurrentBrew((prev)=>({ ...prev, ...value }));
else setCurrentBrew((prev)=>({ ...prev, [field]: value }));
if(useLocalStorage) {
if(field == 'text') localStorage.setItem(BREWKEY, value);
@@ -218,7 +229,7 @@ const HomePage =(props)=>{
Create your own <i className='fas fa-magic' />
</a>
</div>
)
);
};
module.exports = HomePage;
export default HomePage;

View File

@@ -34,13 +34,15 @@
}
.navItem.save {
.fadeInRight();
.transition(opacity);
background-color : @orange;
transition:all 0.2s;
&:hover { background-color : @green; }
&.neverSaved {
.fadeOutRight();
translate:-100%;
opacity: 0;
background-color :#333;
cursor:auto;
}
}
}

View File

@@ -4,7 +4,7 @@ import './newPage.less';
// Common imports
import React, { useState, useEffect, useRef } from 'react';
import request from '../../utils/request-middleware.js';
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
import _ from 'lodash';
import { DEFAULT_BREW } from '../../../../server/brewDefaults.js';
@@ -14,15 +14,16 @@ import SplitPane from 'client/components/splitPane/splitPane.jsx';
import Editor from '../../editor/editor.jsx';
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
import Nav from 'naturalcrit/nav/nav.jsx';
import Navbar from '../../navbar/navbar.jsx';
import NewBrewItem from '../../navbar/newbrew.navitem.jsx';
import AccountNavItem from '../../navbar/account.navitem.jsx';
import ErrorNavItem from '../../navbar/error-navitem.jsx';
import HelpNavItem from '../../navbar/help.navitem.jsx';
import VaultNavItem from '../../navbar/vault.navitem.jsx';
import PrintNavItem from '../../navbar/print.navitem.jsx';
import { both as RecentNavItem } from '../../navbar/recent.navitem.jsx';
import Nav from 'client/homebrew/navbar/nav.jsx';
import Navbar from 'client/homebrew/navbar/navbar.jsx';
import NewBrewItem from 'client/homebrew/navbar/newbrew.navitem.jsx';
import AccountNavItem from 'client/homebrew/navbar/account.navitem.jsx';
import ErrorNavItem from 'client/homebrew/navbar/error-navitem.jsx';
import HelpNavItem from 'client/homebrew/navbar/help.navitem.jsx';
import VaultNavItem from 'client/homebrew/navbar/vault.navitem.jsx';
import PrintNavItem from 'client/homebrew/navbar/print.navitem.jsx';
import RecentNavItems from 'client/homebrew/navbar/recent.navitem.jsx';
const { both: RecentNavItem } = RecentNavItems;
// Page specific imports
import { Meta } from 'vitreum/headtags';
@@ -36,9 +37,9 @@ const SAVEKEYPREFIX = 'HB_editor_defaultSave_';
const useLocalStorage = true;
const neverSaved = true;
const NewPage = (props) => {
const NewPage = (props)=>{
props = {
brew: DEFAULT_BREW,
brew : DEFAULT_BREW,
...props
};
@@ -56,8 +57,12 @@ const NewPage = (props) => {
const editorRef = useRef(null);
const lastSavedBrew = useRef(_.cloneDeep(props.brew));
// const saveTimeout = useRef(null);
// const warnUnsavedTimeout = useRef(null);
const trySaveRef = useRef(trySave); // CTRL+S listener lives outside React and needs ref to use trySave with latest copy of brew
const unsavedChangesRef = useRef(unsavedChanges); // Similarly, onBeforeUnload lives outside React and needs ref to unsavedChanges
useEffect(() => {
useEffect(()=>{
loadBrew();
fetchThemeBundle(setError, setThemeBundle, currentBrew.renderer, currentBrew.theme);
@@ -73,7 +78,7 @@ const NewPage = (props) => {
document.addEventListener('keydown', handleControlKeys);
return () => {
return ()=>{
document.removeEventListener('keydown', handleControlKeys);
};
}, []);
@@ -114,20 +119,25 @@ const NewPage = (props) => {
if(autoSaveEnabled) trySave(false, hasChange);
}, [currentBrew]);
useEffect(()=>{
trySaveRef.current = trySave;
unsavedChangesRef.current = unsavedChanges;
});
const handleSplitMove = ()=>{
editorRef.current.update();
};
const handleBrewChange = (field) => (value, subfield) => { //'text', 'style', 'snippets', 'metadata'
if (subfield == 'renderer' || subfield == 'theme')
const handleBrewChange = (field)=>(value, subfield)=>{ //'text', 'style', 'snippets', 'metadata'
if(subfield == 'renderer' || subfield == 'theme')
fetchThemeBundle(setError, setThemeBundle, value.renderer, value.theme);
//If there are HTML errors, run the validator on every change to give quick feedback
if(HTMLErrors.length && (field == 'text' || field == 'snippets'))
setHTMLErrors(Markdown.validate(value));
if(field == 'metadata') setCurrentBrew(prev => ({ ...prev, ...value }));
else setCurrentBrew(prev => ({ ...prev, [field]: value }));
if(field == 'metadata') setCurrentBrew((prev)=>({ ...prev, ...value }));
else setCurrentBrew((prev)=>({ ...prev, [field]: value }));
if(useLocalStorage) {
if(field == 'text') localStorage.setItem(BREWKEY, value);
@@ -141,10 +151,10 @@ const NewPage = (props) => {
}
};
const save = async () => {
const trySave = async ()=>{
setIsSaving(true);
let updatedBrew = { ...currentBrew };
const updatedBrew = { ...currentBrew };
splitTextStyleAndMetadata(updatedBrew);
const pageRegex = updatedBrew.renderer === 'legacy' ? /\\page/g : /^\\page$/gm;
@@ -153,13 +163,13 @@ const NewPage = (props) => {
const res = await request
.post(`/api${saveGoogle ? '?saveToGoogle=true' : ''}`)
.send(updatedBrew)
.catch((err) => {
.catch((err)=>{
setIsSaving(false);
setError(err);
});
setIsSaving(false)
if (!res) return;
setIsSaving(false);
if(!res) return;
const savedBrew = res.body;
@@ -190,7 +200,7 @@ const NewPage = (props) => {
// #3 - Unsaved changes exist, click to save, show SAVE NOW
if(unsavedChanges)
return <Nav.item className='save' onClick={save} color='blue' icon='fas fa-save'>save now</Nav.item>;
return <Nav.item className='save' onClick={trySave} color='blue' icon='fas fa-save'>save now</Nav.item>;
// #4 - No unsaved changes, autosave is ON, show AUTO-SAVED
if(autoSaveEnabled)
@@ -209,7 +219,7 @@ const NewPage = (props) => {
setIsSaving(false);
};
const renderNavbar = () => (
const renderNavbar = ()=>(
<Navbar>
<Nav.section>
<Nav.item className='brewTitle'>{currentBrew.title}</Nav.item>
@@ -230,7 +240,7 @@ const NewPage = (props) => {
);
return (
<div className='newPage sitePage'>
<div className='newPage sitePage'>
{renderNavbar()}
<div className='content'>
<SplitPane onDragFinish={handleSplitMove}>
@@ -267,4 +277,4 @@ const NewPage = (props) => {
);
};
module.exports = NewPage;
export default NewPage;

View File

@@ -1,12 +1,15 @@
.newPage {
.navItem.save {
.fadeInRight();
.transition(opacity);
background-color : @orange;
transition:all 0.2s;
&:hover { background-color : @green; }
&.neverSaved {
.fadeOutRight();
translate:-100%;
opacity: 0;
background-color :#333;
cursor:auto;
}
}
}

View File

@@ -1,18 +1,18 @@
require('./sharePage.less');
const React = require('react');
const { useState, useEffect, useCallback } = React;
const { Meta } = require('vitreum/headtags');
import './sharePage.less';
import React, { useState, useEffect, useCallback } from 'react';
import { Meta } from 'vitreum/headtags';
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const MetadataNav = require('../../navbar/metadata.navitem.jsx');
const PrintNavItem = require('../../navbar/print.navitem.jsx');
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
const Account = require('../../navbar/account.navitem.jsx');
const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
import Nav from 'client/homebrew/navbar/nav.jsx';
import Navbar from 'client/homebrew/navbar/navbar.jsx';
import MetadataNav from 'client/homebrew/navbar/metadata.navitem.jsx';
import PrintNavItem from 'client/homebrew/navbar/print.navitem.jsx';
import RecentNavItems from 'client/homebrew/navbar/recent.navitem.jsx';
const { both: RecentNavItem } = RecentNavItems;
import Account from 'client/homebrew/navbar/account.navitem.jsx';
import BrewRenderer from '../../brewRenderer/brewRenderer.jsx';
const { DEFAULT_BREW_LOAD } = require('../../../../server/brewDefaults.js');
const { printCurrentBrew, fetchThemeBundle } = require('../../../../shared/helpers.js');
import { DEFAULT_BREW_LOAD } from '../../../../server/brewDefaults.js';
import { printCurrentBrew, fetchThemeBundle } from '../../../../shared/helpers.js';
const SharePage = (props)=>{
const { brew = DEFAULT_BREW_LOAD, disableMeta = false } = props;
@@ -116,4 +116,4 @@ const SharePage = (props)=>{
);
};
module.exports = SharePage;
export default SharePage;

View File

@@ -1,17 +1,17 @@
const React = require('react');
const { useState } = React;
const _ = require('lodash');
import React, { useState } from 'react';
import _ from 'lodash';
const ListPage = require('../basePages/listPage/listPage.jsx');
import ListPage from '../basePages/listPage/listPage.jsx';
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
const Account = require('../../navbar/account.navitem.jsx');
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
const HelpNavItem = require('../../navbar/help.navitem.jsx');
const ErrorNavItem = require('../../navbar/error-navitem.jsx');
const VaultNavitem = require('../../navbar/vault.navitem.jsx');
import Nav from 'client/homebrew/navbar/nav.jsx';
import Navbar from 'client/homebrew/navbar/navbar.jsx';
import RecentNavItems from 'client/homebrew/navbar/recent.navitem.jsx';
const { both: RecentNavItem } = RecentNavItems;
import Account from 'client/homebrew/navbar/account.navitem.jsx';
import NewBrew from 'client/homebrew/navbar/newbrew.navitem.jsx';
import HelpNavItem from 'client/homebrew/navbar/help.navitem.jsx';
import ErrorNavItem from 'client/homebrew/navbar/error-navitem.jsx';
import VaultNavitem from 'client/homebrew/navbar/vault.navitem.jsx';
const UserPage = (props)=>{
props = {
@@ -61,4 +61,4 @@ const UserPage = (props)=>{
);
};
module.exports = UserPage;
export default UserPage;

View File

@@ -1,19 +1,18 @@
/*eslint max-lines: ["warn", {"max": 400, "skipBlankLines": true, "skipComments": true}]*/
/*eslint max-params:["warn", { max: 10 }], */
require('./vaultPage.less');
import './vaultPage.less';
import React, { useState, useEffect, useRef } from 'react';
const React = require('react');
const { useState, useEffect, useRef } = React;
const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx');
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
const Account = require('../../navbar/account.navitem.jsx');
const NewBrew = require('../../navbar/newbrew.navitem.jsx');
const HelpNavItem = require('../../navbar/help.navitem.jsx');
const BrewItem = require('../basePages/listPage/brewItem/brewItem.jsx');
const SplitPane = require('client/components/splitPane/splitPane.jsx');
const ErrorIndex = require('../errorPage/errors/errorIndex.js');
import Nav from 'client/homebrew/navbar/nav.jsx';
import Navbar from 'client/homebrew/navbar/navbar.jsx';
import RecentNavItems from 'client/homebrew/navbar/recent.navitem.jsx';
const { both: RecentNavItem } = RecentNavItems;
import Account from 'client/homebrew/navbar/account.navitem.jsx';
import NewBrew from 'client/homebrew/navbar/newbrew.navitem.jsx';
import HelpNavItem from 'client/homebrew/navbar/help.navitem.jsx';
import BrewItem from '../basePages/listPage/brewItem/brewItem.jsx';
import SplitPane from 'client/components/splitPane/splitPane.jsx';
import ErrorIndex from '../errorPage/errors/errorIndex.js';
import request from '../../utils/request-middleware.js';
@@ -101,7 +100,7 @@ const VaultPage = (props)=>{
const title = titleRef.current.value || '';
const author = authorRef.current.value || '';
const count = countRef.current.value || 10;
const count = countRef.current.value || 20;
const v3 = v3Ref.current.checked != false;
const legacy = legacyRef.current.checked != false;
const sortOption = sort || 'title';
@@ -288,7 +287,8 @@ const VaultPage = (props)=>{
const renderPaginationControls = ()=>{
if(!totalBrews || totalBrews < 10) return null;
const countInt = parseInt(brewCollection.length || 20);
const countInt = parseInt(countRef.current.value || 20);
const totalPages = Math.ceil(totalBrews / countInt);
let startPage, endPage;
@@ -429,4 +429,4 @@ const VaultPage = (props)=>{
);
};
module.exports = VaultPage;
export default VaultPage;

View File

@@ -4,8 +4,6 @@
"naturalcrit_url" : "local.naturalcrit.com:8010",
"secret" : "secret",
"web_port" : 8000,
"enable_v3" : true,
"enable_themes" : true,
"local_environments" : ["docker", "local"],
"publicUrl" : "https://homebrewery.naturalcrit.com",
"hb_images" : null,

View File

@@ -32,7 +32,7 @@ export default [{
"max-depth" : ["warn", { max: 4 }],
"max-params" : ["warn", { max: 5 }],
"no-restricted-syntax" : ["warn", "ClassDeclaration", "SwitchStatement"],
"no-unused-vars" : ["warn", { vars: "all", args: "none", varsIgnorePattern: "config|_|cx|createClass" }],
"no-unused-vars" : ["warn", { vars: "all", args: "none", varsIgnorePattern: "config|_|cx|createReactClass" }],
"react/jsx-uses-vars" : "warn",
/** Fixable **/

5343
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{
"name": "homebrewery",
"description": "Create authentic looking D&D homebrews using only markdown",
"version": "3.19.3",
"version": "3.20.1",
"type": "module",
"engines": {
"npm": "^10.8.x",
@@ -44,7 +44,9 @@
"phb": "node --experimental-require-module scripts/phb.js",
"prod": "set NODE_ENV=production && npm run build",
"postinstall": "npm run build",
"start": "node --experimental-require-module server.js"
"start": "node --experimental-require-module server.js",
"docker:build": "docker build -t ${DOCKERID}/homebrewery:$npm_package_version .",
"docker:publish": "docker login && docker push ${DOCKERID}/homebrewery:$npm_package_version"
},
"author": "stolksdorf",
"license": "MIT",
@@ -59,8 +61,11 @@
"server"
],
"transformIgnorePatterns": [
"node_modules/(?!nanoid/).*"
"node_modules/(?!(nanoid|@exodus/bytes|parse5)/)"
],
"transform": {
"^.+\\.js$": "babel-jest"
},
"coveragePathIgnorePatterns": [
"build/*"
],
@@ -83,19 +88,19 @@
]
},
"dependencies": {
"@babel/core": "^7.27.1",
"@babel/plugin-transform-runtime": "^7.28.0",
"@babel/preset-env": "^7.28.0",
"@babel/preset-react": "^7.27.1",
"@babel/runtime": "^7.27.6",
"@babel/core": "^7.28.4",
"@babel/plugin-transform-runtime": "^7.28.3",
"@babel/preset-env": "^7.28.3",
"@babel/preset-react": "^7.28.5",
"@babel/runtime": "^7.28.4",
"@dmsnell/diff-match-patch": "^1.1.0",
"@googleapis/drive": "^13.0.1",
"@googleapis/drive": "^19.2.0",
"@sanity/diff-match-patch": "^3.2.0",
"body-parser": "^2.2.0",
"classnames": "^2.5.1",
"codemirror": "^5.65.6",
"cookie-parser": "^1.4.7",
"core-js": "^3.44.0",
"core-js": "^3.47.0",
"cors": "^2.8.5",
"create-react-class": "^15.7.0",
"dedent-tabs": "^0.10.3",
@@ -104,31 +109,32 @@
"express-async-handler": "^1.2.0",
"express-static-gzip": "3.0.0",
"fflate": "^0.8.2",
"fs-extra": "11.3.0",
"fs-extra": "11.3.2",
"hash-wasm": "^4.12.0",
"idb-keyval": "^6.2.2",
"js-yaml": "^4.1.0",
"js-yaml": "^4.1.1",
"jwt-simple": "^0.5.6",
"less": "^3.13.1",
"lodash": "^4.17.21",
"marked": "15.0.12",
"marked-alignment-paragraphs": "^1.0.0",
"marked-definition-lists": "^1.0.1",
"marked-emoji": "^2.0.1",
"marked-emoji": "^2.0.2",
"marked-extended-tables": "^2.0.1",
"marked-gfm-heading-id": "^4.1.2",
"marked-gfm-heading-id": "^4.1.3",
"marked-nonbreaking-spaces": "^1.0.1",
"marked-smartypants-lite": "^1.0.3",
"marked-subsuper-text": "^1.0.3",
"marked-subsuper-text": "^1.0.4",
"marked-variables": "^1.0.4",
"markedLegacy": "npm:marked@^0.3.19",
"moment": "^2.30.1",
"mongoose": "^8.16.3",
"nanoid": "5.1.5",
"mongoose": "^8.20.0",
"nanoid": "5.1.6",
"nconf": "^0.13.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-frame-component": "^4.1.3",
"react-router": "^7.6.3",
"react-router": "^7.9.6",
"romans": "^3.1.0",
"sanitize-filename": "1.6.3",
"superagent": "^10.2.1",
@@ -137,16 +143,18 @@
},
"devDependencies": {
"@stylistic/stylelint-plugin": "^4.0.0",
"babel-jest": "^30.2.0",
"babel-plugin-transform-import-meta": "^2.3.3",
"eslint": "^9.35.0",
"eslint-plugin-jest": "^29.0.1",
"eslint": "^9.39.1",
"eslint-plugin-jest": "^29.1.0",
"eslint-plugin-react": "^7.37.5",
"globals": "^16.3.0",
"jest": "^30.1.3",
"globals": "^16.4.0",
"jest": "^30.2.0",
"jest-expect-message": "^1.1.3",
"jsdom": "^27.4.0",
"jsdom-global": "^3.0.2",
"postcss-less": "^6.0.0",
"stylelint": "^16.24.0",
"stylelint": "^16.25.0",
"stylelint-config-recess-order": "^7.3.0",
"stylelint-config-recommended": "^17.0.0",
"supertest": "^7.1.4"

View File

@@ -35,6 +35,7 @@ import contentNegotiation from './middleware/content-negotiation.js';
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import forceSSL from './forcessl.mw.js';
import dbCheck from './middleware/dbCheck.js';
const sanitizeBrew = (brew, accessType)=>{
@@ -274,7 +275,7 @@ app.get('/metadata/:id', asyncHandler(getBrew('share')), (req, res)=>{
app.get('/css/:id', asyncHandler(getBrew('share')), (req, res)=>{getCSS(req, res);});
//User Page
app.get('/user/:username', async (req, res, next)=>{
app.get('/user/:username', dbCheck, async (req, res, next)=>{
const ownAccount = req.account && (req.account.username == req.params.username);
req.ogMeta = { ...defaultMetaTags,
@@ -346,7 +347,7 @@ app.get('/user/:username', async (req, res, next)=>{
});
//Change author name on brews
app.put('/api/user/rename', async (req, res)=>{
app.put('/api/user/rename', dbCheck, async (req, res)=>{
const { username, newUsername } = req.body;
const ownAccount = req.account && (req.account.username == newUsername);
@@ -432,7 +433,7 @@ app.get('/new', asyncHandler(async(req, res, next)=>{
}));
//Share Page
app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, res, next)=>{
app.get('/share/:id', dbCheck, asyncHandler(getBrew('share')), asyncHandler(async (req, res, next)=>{
const { brew } = req;
req.ogMeta = { ...defaultMetaTags,
title : `${req.brew.title || 'Untitled Brew'} - ${req.brew.authors[0] || 'No author.'}`,
@@ -459,7 +460,7 @@ app.get('/share/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, r
}));
//Account Page
app.get('/account', asyncHandler(async (req, res, next)=>{
app.get('/account', dbCheck, asyncHandler(async (req, res, next)=>{
const data = {};
data.title = 'Account Information Page';
@@ -562,8 +563,6 @@ const renderPage = async (req, res)=>{
brews : req.brews,
googleBrews : req.googleBrews,
account : req.account,
enable_v3 : config.get('enable_v3'),
enable_themes : config.get('enable_themes'),
config : configuration,
ogMeta : req.ogMeta,
userThemes : req.userThemes

View File

@@ -22,6 +22,14 @@ const handleConnectionError = (error)=>{
}
};
const addListeners = (conn)=>{
conn.connection.on('disconnecting', ()=>{console.log('Mongo disconnecting...');});
conn.connection.on('disconnected', ()=>{console.log('Mongo disconnected!');});
conn.connection.on('connecting', ()=>{console.log('Mongo connecting...');});
conn.connection.on('connected', ()=>{console.log('Mongo connected!');});
return conn;
};
const disconnect = async ()=>{
return await Mongoose.disconnect();
};
@@ -31,10 +39,12 @@ const connect = async (config)=>{
retryWrites : false,
autoIndex : (config.get('local_environments').includes(config.get('node_env')))
})
.catch((error)=>handleConnectionError(error));
.then(addListeners(Mongoose))
.catch((error)=>handleConnectionError(error));
};
export default {
connect,
disconnect
};

View File

@@ -6,6 +6,7 @@ import config from './config.js';
let serviceAuth;
let clientEmail;
if(!config.get('service_account')){
const reset = '\x1b[0m'; // Reset to default style
const yellow = '\x1b[33m'; // yellow color
@@ -15,6 +16,10 @@ if(!config.get('service_account')){
JSON.parse(config.get('service_account')) :
config.get('service_account');
if(keys?.client_email) {
clientEmail = keys.client_email;
}
try {
serviceAuth = googleDrive.auth.fromJSON(keys);
serviceAuth.scopes = ['https://www.googleapis.com/auth/drive'];
@@ -227,14 +232,30 @@ const GoogleActions = {
if(!obj) return;
if(clientEmail) {
await drive.permissions.create({
resource : {
type : 'user',
emailAddress : clientEmail,
role : 'writer'
},
fileId : obj.data.id,
fields : 'id',
})
.catch((err)=>{
console.log('Error adding Service Account permissions on Google Drive file');
console.error(err);
});
}
await drive.permissions.create({
resource : { type : 'anyone',
role : 'writer' },
role : 'writer' },
fileId : obj.data.id,
fields : 'id',
})
.catch((err)=>{
console.log('Error updating permissions');
console.log('Error adding "Anyone" permissions on Google Drive file');
console.error(err);
});

View File

@@ -4,15 +4,16 @@ import { model as HomebrewModel } from './homebrew.model.js';
import express from 'express';
import zlib from 'zlib';
import GoogleActions from './googleActions.js';
import Markdown from '../shared/naturalcrit/markdown.js';
import Markdown from '../shared/markdown.js';
import yaml from 'js-yaml';
import asyncHandler from 'express-async-handler';
import { nanoid } from 'nanoid';
import {makePatches, applyPatches, stringifyPatches, parsePatch} from '@sanity/diff-match-patch';
import { makePatches, applyPatches, stringifyPatches, parsePatch } from '@sanity/diff-match-patch';
import { md5 } from 'hash-wasm';
import { splitTextStyleAndMetadata,
import { splitTextStyleAndMetadata,
brewSnippetsToJSON, debugTextMismatch } from '../shared/helpers.js';
import checkClientVersion from './middleware/check-client-version.js';
import dbCheck from './middleware/dbCheck.js';
const router = express.Router();
@@ -377,14 +378,14 @@ const api = {
// Patch to a throwaway variable while parallelizing - we're more concerned with error/no error.
const patchedResult = decodeURI(applyPatches(patches, encodeURI(brewFromServer.text))[0]);
if(patchedResult != 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];
} catch (err) {
//debugTextMismatch(brewFromClient.text, brewFromServer.text, `edit/${brewFromClient.editId}`);
console.error('Failed to apply patches:', {
//patches : brewFromClient.patches,
brewId : brewFromClient.editId || 'unknown',
error : err
brewId : brewFromClient.editId || 'unknown',
error : err
});
// While running in parallel, don't throw the error upstream.
// throw err; // rethrow to preserve the 500 behavior
@@ -480,6 +481,7 @@ const api = {
await HomebrewModel.deleteOne({ editId: id });
return next();
}
throw(err);
}
let brew = req.brew;
@@ -530,6 +532,8 @@ const api = {
}
};
router.use(dbCheck);
router.post('/api', checkClientVersion, asyncHandler(api.newBrew));
router.put('/api/:id', checkClientVersion, asyncHandler(api.getBrew('edit', false)), asyncHandler(api.updateBrew));
router.put('/api/update/:id', checkClientVersion, asyncHandler(api.getBrew('edit', false)), asyncHandler(api.updateBrew));

View File

@@ -0,0 +1,15 @@
import mongoose from 'mongoose';
import config from '../config.js';
export default (req, res, next)=>{
// Bypass DB checks during testing
if(config.get('node_env') == 'test') return next();
if(mongoose.connection.readyState == 1) return next();
throw {
HBErrorCode : '13',
name : 'Database Connection Error',
message : 'Unable to connect to database',
status : mongoose.connection.readyState
};
};

View File

@@ -0,0 +1,28 @@
import mongoose from 'mongoose';
import dbCheck from './dbCheck.js';
import config from '../config.js';
describe('dbCheck middleware', ()=>{
const next = jest.fn();
afterEach(()=>jest.clearAllMocks());
it('should skip check in test mode', ()=>{
config.get = jest.fn(()=>'test');
expect(()=>dbCheck({}, {}, next)).not.toThrow();
expect(next).toHaveBeenCalled();
});
it('should call next if readyState == 1', ()=>{
config.get = jest.fn(()=>'production');
mongoose.connection.readyState = 1;
dbCheck({}, {}, next);
expect(next).toHaveBeenCalled();
});
it('should throw if readyState != 1', ()=>{
config.get = jest.fn(()=>'production');
mongoose.connection.readyState = 99;
expect(()=>dbCheck({}, {}, next)).toThrow(/Unable to connect/);
});
});

View File

@@ -8,7 +8,7 @@ const brewSnippetsToJSON = (menuTitle, userBrewSnippets, themeBundleSnippets=nul
const mpAsSnippets = [];
// Snippets from Themes first.
if(themeBundleSnippets) {
for (let themes of themeBundleSnippets) {
for (const themes of themeBundleSnippets) {
if(typeof themes !== 'string') {
const userSnippets = [];
const snipSplit = themes.snippets.trim().split(textSplit).slice(1);
@@ -76,9 +76,9 @@ const yamlSnippetsToText = (yamlObj)=>{
if(typeof yamlObj == 'string') return yamlObj;
let snippetsText = '';
for (let snippet of yamlObj) {
for (let subSnippet of snippet.subsnippets) {
for (const snippet of yamlObj) {
for (const subSnippet of snippet.subsnippets) {
snippetsText = `${snippetsText}\\snippet ${subSnippet.name}\n${subSnippet.gen || ''}\n`;
}
}
@@ -121,7 +121,7 @@ const fetchThemeBundle = async (setError, setThemeBundle, renderer, theme)=>{
const res = await request
.get(`/api/theme/${renderer}/${theme}`)
.catch((err)=>{
setError(err)
setError(err);
});
if(!res) {
setThemeBundle({});
@@ -133,14 +133,14 @@ const fetchThemeBundle = async (setError, setThemeBundle, renderer, theme)=>{
setError(null);
};
const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {
const debugTextMismatch = (clientTextRaw, serverTextRaw, label)=>{
const clientText = clientTextRaw?.normalize('NFC') || '';
const serverText = serverTextRaw?.normalize('NFC') || '';
const clientBuffer = Buffer.from(clientText, 'utf8');
const serverBuffer = Buffer.from(serverText, 'utf8');
if (clientBuffer.equals(serverBuffer)) {
if(clientBuffer.equals(serverBuffer)) {
console.log(`${label} text matches byte-for-byte.`);
return;
}
@@ -151,7 +151,7 @@ const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {
// Byte-level diff
for (let i = 0; i < Math.min(clientBuffer.length, serverBuffer.length); i++) {
if (clientBuffer[i] !== serverBuffer[i]) {
if(clientBuffer[i] !== serverBuffer[i]) {
console.log(`Byte mismatch at offset ${i}: client=0x${clientBuffer[i].toString(16)} server=0x${serverBuffer[i].toString(16)}`);
break;
}
@@ -159,14 +159,14 @@ const debugTextMismatch = (clientTextRaw, serverTextRaw, label) => {
// Char-level diff
for (let i = 0; i < Math.min(clientText.length, serverText.length); i++) {
if (clientText[i] !== serverText[i]) {
if(clientText[i] !== serverText[i]) {
console.log(`Char mismatch at index ${i}:`);
console.log(` Client: '${clientText[i]}' (U+${clientText.charCodeAt(i).toString(16).toUpperCase()})`);
console.log(` Server: '${serverText[i]}' (U+${serverText.charCodeAt(i).toString(16).toUpperCase()})`);
break;
}
}
}
};
export {
splitTextStyleAndMetadata,

View File

@@ -1,117 +1,29 @@
/* eslint-disable max-depth */
/* eslint-disable max-lines */
import _ from 'lodash';
import { Parser as MathParser } from 'expr-eval';
import { marked as Marked } from 'marked';
import MarkedExtendedTables from 'marked-extended-tables';
import MarkedDefinitionLists from 'marked-definition-lists';
import MarkedAlignedParagraphs from 'marked-alignment-paragraphs';
import MarkedNonbreakingSpaces from 'marked-nonbreaking-spaces';
import MarkedSubSuperText from 'marked-subsuper-text';
import { markedVariables,
setMarkedVariablePage,
setMarkedVariable,
getMarkedVariable } from 'marked-variables';
import { markedSmartypantsLite as MarkedSmartypantsLite } from 'marked-smartypants-lite';
import { gfmHeadingId as MarkedGFMHeadingId, resetHeadings as MarkedGFMResetHeadingIDs } from 'marked-gfm-heading-id';
import { markedEmoji as MarkedEmojis } from 'marked-emoji';
import { romanize } from 'romans';
import writtenNumber from 'written-number';
//Icon fonts included so they can appear in emoji autosuggest dropdown
import diceFont from '../../themes/fonts/iconFonts/diceFont.js';
import elderberryInn from '../../themes/fonts/iconFonts/elderberryInn.js';
import gameIcons from '../../themes/fonts/iconFonts/gameIcons.js';
import fontAwesome from '../../themes/fonts/iconFonts/fontAwesome.js';
import diceFont from '../themes/fonts/iconFonts/diceFont.js';
import elderberryInn from '../themes/fonts/iconFonts/elderberryInn.js';
import gameIcons from '../themes/fonts/iconFonts/gameIcons.js';
import fontAwesome from '../themes/fonts/iconFonts/fontAwesome.js';
const renderer = new Marked.Renderer();
const tokenizer = new Marked.Tokenizer();
//Limit math features to simple items
const mathParser = new MathParser({
operators : {
// These default to true, but are included to be explicit
add : true,
subtract : true,
multiply : true,
divide : true,
power : true,
round : true,
floor : true,
ceil : true,
abs : true,
sin : false, cos : false, tan : false, asin : false, acos : false,
atan : false, sinh : false, cosh : false, tanh : false, asinh : false,
acosh : false, atanh : false, sqrt : false, cbrt : false, log : false,
log2 : false, ln : false, lg : false, log10 : false, expm1 : false,
log1p : false, trunc : false, join : false, sum : false, indexOf : false,
'-' : false, '+' : false, exp : false, not : false, length : false,
'!' : false, sign : false, random : false, fac : false, min : false,
max : false, hypot : false, pyt : false, pow : false, atan2 : false,
'if' : false, gamma : false, roundTo : false, map : false, fold : false,
filter : false,
remainder : false, factorial : false,
comparison : false, concatenate : false,
logical : false, assignment : false,
array : false, fndef : false
}
});
// Add sign function
mathParser.functions.sign = function (a) {
if(a >= 0) return '+';
return '-';
};
// Add signed function
mathParser.functions.signed = function (a) {
if(a >= 0) return `+${a}`;
return `${a}`;
};
// Add Roman numeral functions
mathParser.functions.toRomans = function (a) {
return romanize(a);
};
mathParser.functions.toRomansUpper = function (a) {
return romanize(a).toUpperCase();
};
mathParser.functions.toRomansLower = function (a) {
return romanize(a).toLowerCase();
};
// Add character functions
mathParser.functions.toChar = function (a) {
if(a <= 0) return a;
const genChars = function (i) {
return (i > 26 ? genChars(Math.floor((i - 1) / 26)) : '') + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[(i - 1) % 26];
};
return genChars(a);
};
mathParser.functions.toCharUpper = function (a) {
return mathParser.functions.toChar(a).toUpperCase();
};
mathParser.functions.toCharLower = function (a) {
return mathParser.functions.toChar(a).toLowerCase();
};
// Add word functions
mathParser.functions.toWords = function (a) {
return writtenNumber(a);
};
mathParser.functions.toWordsUpper = function (a) {
return mathParser.functions.toWords(a).toUpperCase();
};
mathParser.functions.toWordsLower = function (a) {
return mathParser.functions.toWords(a).toLowerCase();
};
mathParser.functions.toWordsCaps = function (a) {
const words = mathParser.functions.toWords(a).split(' ');
return words.map((word)=>{
return word.replace(/(?:^|\b|\s)(\w)/g, function(w, index) {
return index === 0 ? w.toLowerCase() : w.toUpperCase();
});
}).join(' ');
};
// Normalize variable names; trim edge spaces and shorten blocks of whitespace to 1 space
const normalizeVarNames = (label)=>{
return label.trim().replace(/\s+/g, ' ');
};
//Processes the markdown within an HTML block if it's just a class-wrapper
renderer.html = function (token) {
let html = token.text;
@@ -119,7 +31,12 @@ renderer.html = function (token) {
const openTag = html.substring(0, html.indexOf('>')+1);
html = html.substring(html.indexOf('>')+1);
html = html.substring(0, html.lastIndexOf('</div>'));
return `${openTag} ${Marked.parse(html)} </div>`;
// Repeat the markdown processing for content inside the div, minus the preprocessing and postprocessing hooks which should only run once globally
const opts = Marked.defaults;
const tokens = Marked.lexer(html, opts);
Marked.walkTokens(tokens, opts.walkTokens);
return `${openTag} ${Marked.parser(tokens, opts)} </div>`;
}
return html;
};
@@ -185,7 +102,7 @@ const mustacheSpans = {
start(src) { return src.match(/{{[^{]/)?.index; }, // Hint to Marked.js to stop and check for a match
tokenizer(src, tokens) {
const completeSpan = /^{{[^\n]*}}/; // Regex for the complete token
const inlineRegex = /{{(?=((?:[:=](?:"['\w,\-+*/()#%=?. ]*"|[\w\-+*/()#%.]*)|[^"=':{}\s]*)*))\1 *|}}/g;
const inlineRegex = /{{(?=((?:[:=](?:"['\w,\-+*/()#%=?.&:!@$^;:\[\]_= ]*"|[\w\-+*/()#%.]*)|[^"=':{}\s]*)*))\1 *|}}/g;
const match = completeSpan.exec(src);
if(match) {
//Find closing delimiter
@@ -242,7 +159,7 @@ const mustacheDivs = {
start(src) { return src.match(/\n *{{[^{]/m)?.index; }, // Hint to Marked.js to stop and check for a match
tokenizer(src, tokens) {
const completeBlock = /^ *{{[^\n}]* *\n.*\n *}}/s; // Regex for the complete token
const blockRegex = /^ *{{(?=((?:[:=](?:"['\w,\-+*/()#%=?. ]*"|[\w\-+*/()#%.]*)|[^"=':{}\s]*)*))\1 *$|^ *}}$/gm;
const blockRegex = /^ *{{(?=((?:[:=](?:"['\w,\-+*/()#%=?.&:!@$^;:\[\]_= ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1 *$|^ *}}$/gm;
const match = completeBlock.exec(src);
if(match) {
//Find closing delimiter
@@ -297,7 +214,7 @@ const mustacheInjectInline = {
level : 'inline',
start(src) { return src.match(/ *{[^{\n]/)?.index; }, // Hint to Marked.js to stop and check for a match
tokenizer(src, tokens) {
const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-+*/()#%=?. ]*"|[\w\-+*/()#%.]*)|[^"=':{}\s]*)*))\1}/g;
const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-+*/()#%=?.&:!@$^;:\[\]_= ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1}/g;
const match = inlineRegex.exec(src);
if(match) {
const lastToken = tokens[tokens.length - 1];
@@ -343,7 +260,7 @@ const mustacheInjectBlock = {
level : 'block',
start(src) { return src.match(/\n *{[^{\n]/m)?.index; }, // Hint to Marked.js to stop and check for a match
tokenizer(src, tokens) {
const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-+*/()#%=?. ]*"|[\w\-+*/()#%.]*)|[^"=':{}\s]*)*))\1}/ym;
const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-+*/()#%=?.&:!@$^;:\[\]_= ]*"|[\w\-+*/()#%.]*)|[^"=':{}\s]*)*))\1}/ym;
const match = inlineRegex.exec(src);
if(match) {
const lastToken = tokens[tokens.length - 1];
@@ -411,248 +328,6 @@ const forcedParagraphBreaks = {
}
};
//v=====--------------------< Variable Handling >-------------------=====v// 242 lines
const replaceVar = function(input, hoist=false, allowUnresolved=false) {
const regex = /([!$]?)\[((?!\s*\])(?:\\.|[^\[\]\\])+)\]/g;
const match = regex.exec(input);
const prefix = match[1];
const label = normalizeVarNames(match[2]); // Ensure the label name is normalized as it should be in the var stack.
//v=====--------------------< HANDLE MATH >-------------------=====v//
const mathRegex = /[a-z]+\(|[+\-*/^(),]/g;
const matches = label.split(mathRegex);
const mathVars = matches.filter((match)=>isNaN(match))?.map((s)=>s.trim()); // Capture any variable names
let replacedLabel = label;
if(prefix[0] == '$' && mathVars?.[0] !== label.trim()) {// If there was mathy stuff not captured, let's do math!
mathVars?.forEach((variable)=>{
const foundVar = lookupVar(variable, globalPageNumber, hoist);
if(foundVar && foundVar.resolved && foundVar.content && !isNaN(foundVar.content)) // Only subsitute math values if fully resolved, not empty strings, and numbers
replacedLabel = replacedLabel.replaceAll(new RegExp(`(?<!\\w)(${variable})(?!\\w)`, 'g'), foundVar.content);
});
try {
return mathParser.evaluate(replacedLabel);
} catch (error) {
return undefined; // Return undefined if invalid math result
}
}
//^=====--------------------< HANDLE MATH >-------------------=====^//
const foundVar = lookupVar(label, globalPageNumber, hoist);
if(!foundVar || (!foundVar.resolved && !allowUnresolved))
return undefined; // Return undefined if not found, or parially-resolved vars are not allowed
// url or <url> "title" or 'title' or (title)
const linkRegex = /^([^<\s][^\s]*|<.*?>)(?: ("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\((?:\\\(|\\\)|[^()])*\)))?$/m;
const linkMatch = linkRegex.exec(foundVar.content);
const href = linkMatch ? linkMatch[1] : null; //TODO: TRIM OFF < > IF PRESENT
const title = linkMatch ? linkMatch[2]?.slice(1, -1) : null;
if(!prefix[0] && href) // Link
return `[${label}](${href}${title ? ` "${title}"` : ''})`;
if(prefix[0] == '!' && href) // Image
return `![${label}](${href} ${title ? ` "${title}"` : ''})`;
if(prefix[0] == '$') // Variable
return foundVar.content;
};
const lookupVar = function(label, index, hoist=false) {
while (index >= 0) {
if(globalVarsList[index]?.[label] !== undefined)
return globalVarsList[index][label];
index--;
}
if(hoist) { //If normal lookup failed, attempt hoisting
index = Object.keys(globalVarsList).length; // Move index to start from last page
while (index >= 0) {
if(globalVarsList[index]?.[label] !== undefined)
return globalVarsList[index][label];
index--;
}
}
return undefined;
};
const processVariableQueue = function() {
let resolvedOne = true;
let finalLoop = false;
while (resolvedOne || finalLoop) { // Loop through queue until no more variable calls can be resolved
resolvedOne = false;
for (const item of varsQueue) {
if(item.type == 'text')
continue;
if(item.type == 'varDefBlock') {
const regex = /[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\]/g;
let match;
let resolved = true;
let tempContent = item.content;
while (match = regex.exec(item.content)) { // regex to find variable calls
const value = replaceVar(match[0], true);
if(value == undefined)
resolved = false;
else
tempContent = tempContent.replaceAll(match[0], value);
}
if(resolved == true || item.content != tempContent) {
resolvedOne = true;
item.content = tempContent;
}
globalVarsList[globalPageNumber][item.varName] = {
content : item.content,
resolved : resolved
};
if(resolved)
item.type = 'resolved';
}
if(item.type == 'varCallBlock' || item.type == 'varCallInline') {
const value = replaceVar(item.content, true, finalLoop); // final loop will just use the best value so far
if(value == undefined)
continue;
resolvedOne = true;
item.content = value;
item.type = 'text';
}
}
varsQueue = varsQueue.filter((item)=>item.type !== 'resolved'); // Remove any fully-resolved variable definitions
if(finalLoop)
break;
if(!resolvedOne)
finalLoop = true;
}
varsQueue = varsQueue.filter((item)=>item.type !== 'varDefBlock');
};
function MarkedVariables() {
return {
hooks : {
preprocess(src) {
const codeBlockSkip = /^(?: {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+|^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})(?:[^\n]*)(?:\n|$)(?:|(?:[\s\S]*?)(?:\n|$))(?: {0,3}\2[~`]* *(?=\n|$))|`[^`]*?`/;
const blockDefRegex = /^[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\]:(?!\() *((?:\n? *[^\s].*)+)(?=\n+|$)/; //Matches 3, [4]:5
const blockCallRegex = /^[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\](?=\n|$)/; //Matches 6, [7]
const inlineDefRegex = /([!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\])\(([^\n]+)\)/; //Matches 8, 9[10](11)
const inlineCallRegex = /[!$]?\[((?!\s*\])(?:\\.|[^\[\]\\])+)\](?!\()/; //Matches 12, [13]
// Combine regexes and wrap in parens like so: (regex1)|(regex2)|(regex3)|(regex4)
const combinedRegex = new RegExp([codeBlockSkip, blockDefRegex, blockCallRegex, inlineDefRegex, inlineCallRegex].map((s)=>`(${s.source})`).join('|'), 'gm');
let lastIndex = 0;
let match;
while ((match = combinedRegex.exec(src)) !== null) {
// Format any matches into tokens and store
if(match.index > lastIndex) { // Any non-variable stuff
varsQueue.push(
{ type : 'text',
varName : null,
content : src.slice(lastIndex, match.index)
});
}
if(match[1]) {
varsQueue.push(
{ type : 'text',
varName : null,
content : match[0]
});
}
if(match[3]) { // Block Definition
const label = match[4] ? normalizeVarNames(match[4]) : null;
const content = match[5] ? match[5].trim().replace(/[ \t]+/g, ' ') : null; // Normalize text content (except newlines for block-level content)
varsQueue.push(
{ type : 'varDefBlock',
varName : label,
content : content
});
}
if(match[6]) { // Block Call
const label = match[7] ? normalizeVarNames(match[7]) : null;
varsQueue.push(
{ type : 'varCallBlock',
varName : label,
content : match[0]
});
}
if(match[8]) { // Inline Definition
const label = match[10] ? normalizeVarNames(match[10]) : null;
let content = match[11] || null;
// In case of nested (), find the correct matching end )
let level = 0;
let i;
for (i = 0; i < content.length; i++) {
if(content[i] === '\\') {
i++;
} else if(content[i] === '(') {
level++;
} else if(content[i] === ')') {
level--;
if(level < 0)
break;
}
}
combinedRegex.lastIndex = combinedRegex.lastIndex - (content.length - i);
content = content.slice(0, i).trim().replace(/\s+/g, ' ');
varsQueue.push(
{ type : 'varDefBlock',
varName : label,
content : content
});
varsQueue.push(
{ type : 'varCallInline',
varName : label,
content : match[9]
});
}
if(match[12]) { // Inline Call
const label = match[13] ? normalizeVarNames(match[13]) : null;
varsQueue.push(
{ type : 'varCallInline',
varName : label,
content : match[0]
});
}
lastIndex = combinedRegex.lastIndex;
}
if(lastIndex < src.length) {
varsQueue.push(
{ type : 'text',
varName : null,
content : src.slice(lastIndex)
});
}
processVariableQueue();
const output = varsQueue.map((item)=>item.content).join('');
varsQueue = []; // Must clear varsQueue because custom HTML renderer uses Marked.parse which will preprocess again without clearing the array
return output;
}
}
};
};
//^=====--------------------< Variable Handling >-------------------=====^//
// Emoji options
// To add more icon fonts, need to do these things
// 1) Add the font file as .woff2 to themes/fonts/iconFonts folder
@@ -678,9 +353,9 @@ const tableTerminators = [
` *{{[^{\n]*\n.*?\n}}` // mustacheDiv
];
Marked.use(MarkedVariables());
Marked.use(markedVariables());
Marked.use(MarkedDefinitionLists());
Marked.use({ extensions : [forcedParagraphBreaks, mustacheSpans, mustacheDivs, mustacheInjectInline] });
Marked.use({ extensions: [forcedParagraphBreaks, mustacheSpans, mustacheDivs, mustacheInjectInline] });
Marked.use(mustacheInjectBlock);
Marked.use(MarkedAlignedParagraphs());
Marked.use(MarkedSubSuperText());
@@ -805,25 +480,17 @@ const mergeHTMLTags = (originalTags, newTags)=>{
};
};
const globalVarsList = {};
let varsQueue = [];
let globalPageNumber = 0;
const Markdown = {
marked : Marked,
render : (rawBrewText, pageNumber=0)=>{
const lastPageNumber = pageNumber > 0 ? globalVarsList[pageNumber - 1].HB_pageNumber.content : 0;
globalVarsList[pageNumber] = { //Reset global links for current page, to ensure values are parsed in order
'HB_pageNumber' : { //Add document variables for this page
content : !isNaN(Number(lastPageNumber)) ? Number(lastPageNumber) + 1 : lastPageNumber,
resolved : true
}
};
varsQueue = []; //Could move into MarkedVariables()
globalPageNumber = pageNumber;
if(pageNumber==0) {
MarkedGFMResetHeadingIDs();
}
setMarkedVariablePage(pageNumber);
const lastPageNumber = pageNumber > 0 ? getMarkedVariable('HB_pageNumber', pageNumber - 1) : 0;
setMarkedVariable('HB_pageNumber', //Add document variables for this page
!isNaN(Number(lastPageNumber)) ? Number(lastPageNumber) + 1 : lastPageNumber,
pageNumber);
if(pageNumber==0) MarkedGFMResetHeadingIDs();
rawBrewText = rawBrewText.replace(/^\\column(?:break)?$/gm, `\n<div class='columnSplit'></div>\n`);

View File

@@ -1,5 +1,5 @@
const _ = require('lodash');
const Markdown = require('markedLegacy');
import _ from 'lodash';
import Markdown from 'markedLegacy';
const renderer = new Markdown.Renderer();
//Processes the markdown within an HTML block if it's just a class-wrapper
@@ -49,7 +49,7 @@ const cleanUrl = function (sanitize, base, href) {
prot = decodeURIComponent(unescape(href))
.replace(nonWordAndColonTest, '')
.toLowerCase();
} catch (e) {
} catch {
return null;
}
if(prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
@@ -58,7 +58,7 @@ const cleanUrl = function (sanitize, base, href) {
}
try {
href = encodeURI(href).replace(/%25/g, '%');
} catch (e) {
} catch {
return null;
}
return href;
@@ -103,7 +103,7 @@ const voidTags = new Set([
]);
module.exports = {
export default {
marked : Markdown,
render : (rawBrewText)=>{
return Markdown(

View File

@@ -1,3 +0,0 @@
module.exports = function(props){
return <svg version='1.1' x='0px' y='0px' viewBox='0 0 80 100' enableBackground='new 0 0 80 80'><g><g><polygon fill='#000000' points='12.9,71.4 7.6,66.1 19.3,54.4 20.7,55.8 10.4,66.1 12.9,68.6 23.2,58.3 24.6,59.7 '/></g><g><path fill='#000000' d='M29,61.6c-1.7,0-3.4-0.7-4.6-1.9l-5.1-5.1c-2.5-2.5-2.5-6.6,0-9.2l0.7-0.7L34.3,59l-0.7,0.7 C32.4,60.9,30.8,61.6,29,61.6z M20.1,47.6c-1.1,1.7-0.9,4.1,0.6,5.6l5.1,5.1c0.8,0.8,2,1.3,3.2,1.3c0.9,0,1.7-0.2,2.4-0.7 L20.1,47.6z'/></g><g><path fill='#000000' d='M12.3,74.8c-0.8,0-1.5-0.3-2-0.8l-5.2-5.2c-0.5-0.5-0.8-1.2-0.8-2c0-0.8,0.3-1.5,0.8-2 c1.1-1.1,2.9-1.1,4,0l5.2,5.2c1.1,1.1,1.1,2.9,0,4C13.8,74.5,13.1,74.8,12.3,74.8z M7.1,65.9c-0.2,0-0.4,0.1-0.6,0.2 c-0.2,0.2-0.2,0.4-0.2,0.6s0.1,0.4,0.2,0.6l5.2,5.2c0.3,0.3,0.9,0.3,1.2,0c0.3-0.3,0.3-0.8,0-1.2l-5.2-5.2 C7.5,66,7.3,65.9,7.1,65.9z'/></g><g><polygon fill='#000000' points='31.7,58.7 30.3,57.3 70,17.6 70,9 62.4,9 23.3,49.4 21.9,48 61.6,7 72,7 72,18.4 '/></g><g><rect x='46' y='6.7' transform='matrix(0.7168 0.6973 -0.6973 0.7168 35.9716 -23.568)' fill='#000000' width='2' height='51.6'/></g><g><rect x='13' y='61' fill='#000000' width='2' height='7'/></g><g><rect x='17' y='57' fill='#000000' width='2' height='7'/></g></g><g><g><polygon fill='#000000' points='68.4,71.4 56.7,59.7 58.1,58.3 68.4,68.6 70.8,66.1 60.5,55.8 61.9,54.4 73.6,66.1 '/></g><g><path fill='#000000' d='M52.2,61.6c-1.7,0-3.4-0.7-4.6-1.9L46.9,59l14.3-14.3l0.7,0.7c2.5,2.5,2.5,6.6,0,9.2l-5.1,5.1 C55.6,60.9,53.9,61.6,52.2,61.6z M49.8,58.9c0.7,0.4,1.5,0.7,2.4,0.7c1.2,0,2.3-0.5,3.2-1.3l5.1-5.1c1.5-1.5,1.7-3.8,0.6-5.6 L49.8,58.9z'/></g><g><path fill='#000000' d='M68.9,74.8c-0.8,0-1.5-0.3-2-0.8c-1.1-1.1-1.1-2.9,0-4l5.2-5.2c1.1-1.1,2.9-1.1,4,0c0.5,0.5,0.8,1.2,0.8,2 c0,0.8-0.3,1.5-0.8,2L70.9,74C70.4,74.5,69.7,74.8,68.9,74.8z M74.2,65.9c-0.2,0-0.4,0.1-0.6,0.2l-5.2,5.2c-0.3,0.3-0.3,0.8,0,1.2 c0.3,0.3,0.9,0.3,1.2,0l5.2-5.2c0.2-0.2,0.2-0.4,0.2-0.6s-0.1-0.4-0.2-0.6C74.6,66,74.4,65.9,74.2,65.9z'/></g><g><rect x='38.6' y='52.3' transform='matrix(0.7082 0.706 -0.706 0.7082 50.8397 -16.4875)' fill='#000000' width='13.4' height='2'/></g><g><polygon fill='#000000' points='30.6,39.9 9,18.4 9,7 19.7,7 41.1,29.1 39.7,30.5 18.8,9 11,9 11,17.6 32,38.5 '/></g><g><rect x='47.8' y='43.1' transform='matrix(0.6959 0.7181 -0.7181 0.6959 48.1381 -25.5246)' fill='#000000' width='12.8' height='2'/></g><g><rect x='12' y='23.1' transform='matrix(0.6974 0.7167 -0.7167 0.6974 25.1384 -11.3825)' fill='#000000' width='28.1' height='2'/></g><g><rect x='43.8' y='46.4' transform='matrix(0.6974 0.7167 -0.7167 0.6974 48.7492 -20.5985)' fill='#000000' width='10' height='2'/></g><g><rect x='66' y='61' fill='#000000' width='2' height='7'/></g><g><rect x='62' y='57' fill='#000000' width='2' height='7'/></g></g></svg>;
};

View File

@@ -1,7 +1,5 @@
require('jsdom-global')();
import globalJsdom from 'jsdom-global';
globalJsdom();
import { safeHTML } from '../../client/homebrew/brewRenderer/safeHTML';
test('Exit if no document', function() {

View File

@@ -1,6 +1,6 @@
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
test('Processes the markdown within an HTML block if its just a class wrapper', function() {
const source = '<div>*Bold text*</div>';

View File

@@ -1,6 +1,6 @@
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
describe('Inline Definition Lists', ()=>{
test('No Term 1 Definition', function() {

View File

@@ -1,5 +1,5 @@
import Markdown from 'naturalcrit/markdown.js';
const dedent = require('dedent-tabs').default;
import Markdown from 'markdown.js';
import dedent from 'dedent-tabs';
// Marked.js adds line returns after closing tags on some default tokens.
// This removes those line returns for comparison sake.

View File

@@ -1,6 +1,6 @@
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
describe('Hard Breaks', ()=>{
test('Single Break', function() {

View File

@@ -1,7 +1,7 @@
/* eslint-disable max-lines */
const dedent = require('dedent-tabs').default;
import Markdown from 'naturalcrit/markdown.js';
import dedent from 'dedent-tabs';
import Markdown from 'markdown.js';
// Marked.js adds line returns after closing tags on some default tokens.
// This removes those line returns for comparison sake.

View File

@@ -1,6 +1,6 @@
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
describe('Non-Breaking Spaces Interactions', ()=>{
test('I am actually a single-line definition list!', function() {

View File

@@ -1,6 +1,6 @@
import Markdown from 'naturalcrit/markdown.js';
import Markdown from 'markdown.js';
describe('Justification', ()=>{
test('Left Justify', function() {

View File

@@ -1,7 +1,7 @@
/* eslint-disable max-lines */
const dedent = require('dedent-tabs').default;
import Markdown from 'naturalcrit/markdown.js';
import dedent from 'dedent-tabs';
import Markdown from 'markdown.js';
// Marked.js adds line returns after closing tags on some default tokens.
// This removes those line returns for comparison sake.

View File

@@ -1,14 +1,14 @@
/* eslint-disable max-lines */
const MagicGen = require('./snippets/magic.gen.js');
const ClassTableGen = require('./snippets/classtable.gen.js');
const MonsterBlockGen = require('./snippets/monsterblock.gen.js');
const ClassFeatureGen = require('./snippets/classfeature.gen.js');
const CoverPageGen = require('./snippets/coverpage.gen.js');
const TableOfContentsGen = require('./snippets/tableOfContents.gen.js');
const dedent = require('dedent-tabs').default;
import MagicGen from './snippets/magic.gen.js';
import ClassTableGen from './snippets/classtable.gen.js';
import MonsterBlockGen from './snippets/monsterblock.gen.js';
import ClassFeatureGen from './snippets/classfeature.gen.js';
import CoverPageGen from './snippets/coverpage.gen.js';
import TableOfContentsGen from './snippets/tableOfContents.gen.js';
import dedent from 'dedent-tabs';
module.exports = [
export default [
{
groupName : 'Text Editor',

View File

@@ -1,6 +1,6 @@
const _ = require('lodash');
import _ from 'lodash';
module.exports = function(classname){
export default function(classname){
classname = _.sample(['archivist', 'fancyman', 'linguist', 'fletcher',
'notary', 'berserker-typist', 'fishmongerer', 'manicurist', 'haberdasher', 'concierge']);

View File

@@ -1,4 +1,4 @@
const _ = require('lodash');
import _ from 'lodash';
const features = [
'Astrological Botany',
@@ -50,7 +50,7 @@ const getFeature = (level)=>{
return res.join(', ');
};
module.exports = {
export default {
full : function(){
const classname = _.sample(classnames);

View File

@@ -1,4 +1,4 @@
const _ = require('lodash');
import _ from 'lodash';
const titles = [
'The Burning Gallows',
@@ -98,7 +98,7 @@ const subtitles = [
];
module.exports = ()=>{
export default ()=>{
return `<style>
.phb#p1{ text-align:center; }
.phb#p1:after{ display:none; }

View File

@@ -1,10 +1,10 @@
const _ = require('lodash');
import _ from 'lodash';
const ClassFeatureGen = require('./classfeature.gen.js');
import ClassFeatureGen from './classfeature.gen.js';
const ClassTableGen = require('./classtable.gen.js');
import ClassTableGen from './classtable.gen.js';
module.exports = function(){
export default function(){
const classname = _.sample(['Archivist', 'Fancyman', 'Linguist', 'Fletcher',
'Notary', 'Berserker-Typist', 'Fishmongerer', 'Manicurist', 'Haberdasher', 'Concierge']);

View File

@@ -1,4 +1,4 @@
const _ = require('lodash');
import _ from 'lodash';
const spellNames = [
'Astral Rite of Acne',
@@ -48,7 +48,7 @@ const spellNames = [
'Ultimate Ritual of Mouthwash',
];
module.exports = {
export default {
spellList : function(){
const levels = ['Cantrips (0 Level)', '1st Level', '2nd Level', '3rd Level', '4th Level', '5th Level', '6th Level', '7th Level', '8th Level', '9th Level'];

View File

@@ -1,4 +1,4 @@
const _ = require('lodash');
import _ from 'lodash';
const genList = function(list, max){
return _.sampleSize(list, _.random(0, max)).join(', ') || 'None';
@@ -137,7 +137,7 @@ const genAction = function(){
};
module.exports = {
export default {
full : function(){
return `${[

View File

@@ -1,4 +1,4 @@
const _ = require('lodash');
import _ from 'lodash';
const getTOC = (pages)=>{
const add1 = (title, page)=>{
@@ -47,7 +47,7 @@ const getTOC = (pages)=>{
return res;
};
module.exports = function(props){
export default function(props){
const pages = props.brew.text.split('\\page');
const TOC = getTOC(pages);
const markdown = _.reduce(TOC, (r, g1, idx1)=>{

View File

@@ -1,4 +1,4 @@
module.exports = [
export default [
];

View File

@@ -1,17 +1,14 @@
/* eslint-disable max-lines */
import MagicGen from './snippets/magic.gen.js';
import ClassTableGen from './snippets/classtable.gen.js';
import MonsterBlockGen from './snippets/monsterblock.gen.js';
import scriptGen from './snippets/script.gen.js';
import ClassFeatureGen from './snippets/classfeature.gen.js';
import CoverPageGen from './snippets/coverpage.gen.js';
import QuoteGen from './snippets/quote.gen.js';
import dedent from 'dedent-tabs';
const MagicGen = require('./snippets/magic.gen.js');
const ClassTableGen = require('./snippets/classtable.gen.js');
const MonsterBlockGen = require('./snippets/monsterblock.gen.js');
const scriptGen = require('./snippets/script.gen.js');
const ClassFeatureGen = require('./snippets/classfeature.gen.js');
const CoverPageGen = require('./snippets/coverpage.gen.js');
const QuoteGen = require('./snippets/quote.gen.js');
const dedent = require('dedent-tabs').default;
module.exports = [
export default [
{
groupName : 'Style Editor',
icon : 'fas fa-pencil-alt',

View File

@@ -1,7 +1,7 @@
const _ = require('lodash');
const dedent = require('dedent-tabs').default;
import _ from 'lodash';
import dedent from 'dedent-tabs';
module.exports = function(classname){
export default function(classname){
classname = _.sample(['archivist', 'fancyman', 'linguist', 'fletcher',
'notary', 'berserker-typist', 'fishmongerer', 'manicurist', 'haberdasher', 'concierge']);

Some files were not shown because too many files have changed in this diff Show More