You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2026-01-08 00:14:28 +02:00
Compare commits
80 Commits
plugin-gen
...
smaller_se
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f55003338 | ||
|
|
96f5209686 | ||
|
|
ebaddfa4a8 | ||
|
|
2ab049305e | ||
|
|
98bfb65ead | ||
|
|
09cbe3cb7c | ||
|
|
fd322edaab | ||
|
|
09ed92bc26 | ||
|
|
fb6069de6d | ||
|
|
39056ae1aa | ||
|
|
d031a04a2c | ||
|
|
ed0f0fae01 | ||
|
|
c185f00006 | ||
|
|
3117133be2 | ||
|
|
b92c650f5d | ||
|
|
9dbf5e02eb | ||
|
|
e1016b8af4 | ||
|
|
3ba4a1de72 | ||
|
|
a683f12622 | ||
|
|
89184a3f9f | ||
|
|
24dbede6c1 | ||
|
|
70e623e741 | ||
|
|
5c77317735 | ||
|
|
9684b38f7e | ||
|
|
3dfe43204d | ||
|
|
16148b2255 | ||
|
|
df14ffdee2 | ||
|
|
f6ed5eb064 | ||
|
|
a14115bfd7 | ||
|
|
dd68d6cf2c | ||
|
|
7d3555d62c | ||
|
|
af472528a2 | ||
|
|
5c8b0ec1cb | ||
|
|
5e20e890d8 | ||
|
|
50dc656f65 | ||
|
|
b36cf46a06 | ||
|
|
1781334374 | ||
|
|
71140a638f | ||
|
|
6ba0fce237 | ||
|
|
c033a343c1 | ||
|
|
898c96a566 | ||
|
|
b83fa133b2 | ||
|
|
ec7fec8b59 | ||
|
|
b2fb4f2ea2 | ||
|
|
c74e51a58e | ||
|
|
7cba4be498 | ||
|
|
19b396f2ec | ||
|
|
4ed7c340a0 | ||
|
|
fe770917fd | ||
|
|
f2168d3bca | ||
|
|
5d4ebc6e14 | ||
|
|
3cf0841775 | ||
|
|
e5b6ecc50b | ||
|
|
f451633a51 | ||
|
|
e813d15ef2 | ||
|
|
b5b02d8d7b | ||
|
|
2660ff3af6 | ||
|
|
59cdcaf8d1 | ||
|
|
9426a2170c | ||
|
|
b47a541976 | ||
|
|
4df5ad5c7a | ||
|
|
6f0f3d586e | ||
|
|
863d894af1 | ||
|
|
a595b8f250 | ||
|
|
a6ff60aa99 | ||
|
|
aaf5d74b94 | ||
|
|
c7d0d659a0 | ||
|
|
57e46711f6 | ||
|
|
297b992944 | ||
|
|
3b05e7ec5f | ||
|
|
b98e64c881 | ||
|
|
46438a5888 | ||
|
|
d1e02fd5f0 | ||
|
|
b41a3d7f8d | ||
|
|
88b56a2abd | ||
|
|
c898214e7e | ||
|
|
852e6c141b | ||
|
|
fa868297a2 | ||
|
|
3744e08335 | ||
|
|
ea56d020e9 |
@@ -1,12 +1,19 @@
|
||||
_mydocs/
|
||||
_releases/
|
||||
.git/
|
||||
.yarn/cache/
|
||||
**/.DS_Store
|
||||
**/node_modules
|
||||
Assets/
|
||||
.git/
|
||||
_releases/
|
||||
packages/app-desktop
|
||||
packages/app-cli
|
||||
packages/app-mobile
|
||||
packages/app-clipper
|
||||
packages/generator-joplin
|
||||
packages/plugin-repo-cli
|
||||
docs/
|
||||
lerna-debug.log
|
||||
packages/app-cli/
|
||||
packages/app-clipper/
|
||||
packages/app-desktop/
|
||||
packages/app-mobile/
|
||||
packages/generator-joplin/
|
||||
packages/plugin-repo-cli/
|
||||
packages/server/db-*.sqlite
|
||||
packages/server/temp
|
||||
packages/server/dist/
|
||||
packages/server/logs/
|
||||
packages/server/temp/
|
||||
|
||||
@@ -733,6 +733,9 @@ packages/app-desktop/services/commands/stateToWhenClauseContext.js.map
|
||||
packages/app-desktop/services/commands/types.d.ts
|
||||
packages/app-desktop/services/commands/types.js
|
||||
packages/app-desktop/services/commands/types.js.map
|
||||
packages/app-desktop/services/plugins/BackOffHandler.d.ts
|
||||
packages/app-desktop/services/plugins/BackOffHandler.js
|
||||
packages/app-desktop/services/plugins/BackOffHandler.js.map
|
||||
packages/app-desktop/services/plugins/PlatformImplementation.d.ts
|
||||
packages/app-desktop/services/plugins/PlatformImplementation.js
|
||||
packages/app-desktop/services/plugins/PlatformImplementation.js.map
|
||||
|
||||
1
.github/scripts/run_ci.sh
vendored
1
.github/scripts/run_ci.sh
vendored
@@ -37,6 +37,7 @@ echo "GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME"
|
||||
echo "GITHUB_REF=$GITHUB_REF"
|
||||
echo "RUNNER_OS=$RUNNER_OS"
|
||||
echo "GIT_TAG_NAME=$GIT_TAG_NAME"
|
||||
echo "BUILD_SEQUENCIAL=$BUILD_SEQUENCIAL"
|
||||
|
||||
echo "IS_CONTINUOUS_INTEGRATION=$IS_CONTINUOUS_INTEGRATION"
|
||||
echo "IS_PULL_REQUEST=$IS_PULL_REQUEST"
|
||||
|
||||
25
.github/stale.yml
vendored
25
.github/stale.yml
vendored
@@ -1,25 +0,0 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 30
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- "good first issue"
|
||||
- "upstream"
|
||||
- "backlog"
|
||||
- "high"
|
||||
- "medium"
|
||||
- "spec"
|
||||
- "cannot reproduce"
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs.
|
||||
You may comment on the issue and I will leave it open.
|
||||
Thank you for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: >
|
||||
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
|
||||
only: issues
|
||||
23
.github/workflows/close-stale-issues.yml
vendored
Normal file
23
.github/workflows/close-stale-issues.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: 'Close stale issues'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 16 * * *'
|
||||
permissions:
|
||||
issues: write
|
||||
jobs:
|
||||
ProcessStaleIssues:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v4
|
||||
with:
|
||||
# Use this to do a dry run from a pull request
|
||||
# debug-only: true
|
||||
stale-issue-message: "Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions."
|
||||
days-before-stale: 30
|
||||
days-before-close: 7
|
||||
operations-per-run: 1000
|
||||
exempt-issue-labels: 'good first issue,upstream,backlog,high,medium,spec,cannot reproduce'
|
||||
stale-issue-label: 'stale'
|
||||
close-issue-message: 'Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, feel free to create a new issue with up-to-date information.'
|
||||
# Don't process pull requests at all
|
||||
days-before-pr-stale: -1
|
||||
4
.github/workflows/github-actions-main.yml
vendored
4
.github/workflows/github-actions-main.yml
vendored
@@ -74,6 +74,7 @@ jobs:
|
||||
CSC_LINK: ${{ secrets.APPLE_CSC_LINK }}
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
IS_CONTINUOUS_INTEGRATION: 1
|
||||
BUILD_SEQUENCIAL: 1
|
||||
run: |
|
||||
"${GITHUB_WORKSPACE}/.github/scripts/run_ci.sh"
|
||||
|
||||
@@ -84,6 +85,7 @@ jobs:
|
||||
CSC_LINK: ${{ secrets.WINDOWS_CSC_LINK }}
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
IS_CONTINUOUS_INTEGRATION: 1
|
||||
BUILD_SEQUENCIAL: 1
|
||||
run: |
|
||||
yarn install
|
||||
cd packages/app-desktop
|
||||
@@ -122,6 +124,8 @@ jobs:
|
||||
corepack enable
|
||||
|
||||
- name: Build Docker Image
|
||||
env:
|
||||
BUILD_SEQUENCIAL: 1
|
||||
run: |
|
||||
yarn install
|
||||
yarn run buildServerDocker --tag-name server-v0.0.0
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -723,6 +723,9 @@ packages/app-desktop/services/commands/stateToWhenClauseContext.js.map
|
||||
packages/app-desktop/services/commands/types.d.ts
|
||||
packages/app-desktop/services/commands/types.js
|
||||
packages/app-desktop/services/commands/types.js.map
|
||||
packages/app-desktop/services/plugins/BackOffHandler.d.ts
|
||||
packages/app-desktop/services/plugins/BackOffHandler.js
|
||||
packages/app-desktop/services/plugins/BackOffHandler.js.map
|
||||
packages/app-desktop/services/plugins/PlatformImplementation.d.ts
|
||||
packages/app-desktop/services/plugins/PlatformImplementation.js
|
||||
packages/app-desktop/services/plugins/PlatformImplementation.js.map
|
||||
|
||||
43
.yarn/patches/markdown-it-multimd-table-npm-4.1.1-47e334d4bd
Normal file
43
.yarn/patches/markdown-it-multimd-table-npm-4.1.1-47e334d4bd
Normal file
@@ -0,0 +1,43 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index 85d89900d5fe575dd0c19430209fb1703b03554e..5fa68cc9a4bd2b21a7188bd263262fd9b1604ac6 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -145,7 +145,8 @@ module.exports = function multimd_table_plugin(md, options) {
|
||||
colspan, leftToken,
|
||||
rowspan, upTokens = [],
|
||||
tableLines, tgroupLines,
|
||||
- tag, text, range, r, c, b;
|
||||
+ tag, text, range, r, c, b, t,
|
||||
+ blockState;
|
||||
|
||||
if (startLine + 2 > endLine) { return false; }
|
||||
|
||||
@@ -315,18 +316,26 @@ module.exports = function multimd_table_plugin(md, options) {
|
||||
|
||||
/* Multiline. Join the text and feed into markdown-it blockParser. */
|
||||
if (options.multiline && trToken.meta.multiline && trToken.meta.mbounds) {
|
||||
- text = [ text.trimRight() ];
|
||||
+ // Pad the text with empty lines to ensure the line number mapping is correct
|
||||
+ text = new Array(trToken.map[0]).fill('').concat([ text.trimRight() ]);
|
||||
for (b = 1; b < trToken.meta.mbounds.length; b++) {
|
||||
/* Line with N bounds has cells indexed from 0 to N-2 */
|
||||
if (c > trToken.meta.mbounds[b].length - 2) { continue; }
|
||||
range = [ trToken.meta.mbounds[b][c] + 1, trToken.meta.mbounds[b][c + 1] ];
|
||||
text.push(state.src.slice.apply(state.src, range).trimRight());
|
||||
}
|
||||
- state.md.block.parse(text.join('\n'), state.md, state.env, state.tokens);
|
||||
+ blockState = new state.md.block.State(text.join('\n'), state.md, state.env, []);
|
||||
+ blockState.level = trToken.level + 1;
|
||||
+ // Start tokenizing from the actual content (trToken.map[0])
|
||||
+ state.md.block.tokenize(blockState, trToken.map[0], blockState.lineMax);
|
||||
+ for (t = 0; t < blockState.tokens.length; t++) {
|
||||
+ state.tokens.push(blockState.tokens[t]);
|
||||
+ }
|
||||
} else {
|
||||
token = state.push('inline', '', 0);
|
||||
token.content = text.trim();
|
||||
token.map = trToken.map;
|
||||
+ token.level = trToken.level + 1;
|
||||
token.children = [];
|
||||
}
|
||||
|
||||
@@ -728,6 +728,23 @@ footer .bottom-links-row p {
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
MEDIUM VIEW
|
||||
- Make menu bar elements smaller and closer to each others
|
||||
so that everything fit.
|
||||
*****************************************************************/
|
||||
|
||||
@media (max-width: 990px) {
|
||||
#nav-section > .container {
|
||||
max-width: 960px;
|
||||
}
|
||||
|
||||
#nav-section .button-link {
|
||||
padding: 4px 12px;
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
NARROW VIEW
|
||||
- Top right menu is displayed
|
||||
@@ -740,6 +757,23 @@ footer .bottom-links-row p {
|
||||
padding-bottom: 130px;
|
||||
}
|
||||
|
||||
#menu-mobile .social-links {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#menu-mobile .social-links a {
|
||||
margin-left: 15px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
#menu-mobile .social-links .social-link-mastodon,
|
||||
#menu-mobile .social-links .social-link-reddit,
|
||||
#menu-mobile .social-links .social-link-patreon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.front-page h1 {
|
||||
font-size: 2.5em;
|
||||
}
|
||||
@@ -857,7 +891,7 @@ footer .bottom-links-row p {
|
||||
}
|
||||
|
||||
#menu-mobile .button-link {
|
||||
padding: 10px 15px;
|
||||
padding: 4px 12px;
|
||||
font-size: 16px;
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
<footer class="darkblue-bg">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-12 social-links">
|
||||
<a href="https://twitter.com/joplinapp" title="Joplin Twitter feed"><i class="fab fa-twitter"></i></a>
|
||||
<a href="https://mastodon.social/@joplinapp" title="Joplin Mastodon feed"><i class="fab fa-mastodon"></i></a>
|
||||
<a href="https://www.patreon.com/joplin" title="Joplin Patreon"><i class="fab fa-patreon"></i></a>
|
||||
<a href="https://discord.gg/VSj7AFHvpq" title="Joplin Discord chat"><i class="fab fa-discord"></i></a>
|
||||
<a href="https://www.reddit.com/r/joplinapp/" title="Joplin Subreddit"><i class="fab fa-reddit"></i></a>
|
||||
<a href="https://github.com/laurent22/joplin/" title="Joplin GitHub repository"><i class="fab fa-github"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
{{> socialFeeds}}
|
||||
|
||||
<div class="row bottom-links-row">
|
||||
<div class="col-12 col-md-6">
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-9 text-right d-none d-md-block">
|
||||
<a href="{{baseUrl}}/news/" class="fw500">What's New</a>
|
||||
<a href="https://twitter.com/joplinapp" title="Joplin Twitter feed" class="fw500"><i class="fab fa-twitter"></i></a>
|
||||
<a href="{{baseUrl}}/news/" class="fw500">News</a>
|
||||
<a href="{{baseUrl}}/help/" class="fw500">Help</a>
|
||||
<a href="{{forumUrl}}" class="fw500">Forum</a>
|
||||
{{#showJoplinCloudLinks}}
|
||||
@@ -43,7 +44,7 @@
|
||||
</div>
|
||||
|
||||
<div class="text-center menu-mobile-top">
|
||||
<a href="{{baseUrl}}/news/" class="fw500 mobile-menu-link">What's New</a>
|
||||
<a href="{{baseUrl}}/news/" class="fw500 mobile-menu-link">News</a>
|
||||
<a href="{{baseUrl}}/help/" class="fw500 mobile-menu-link">Help</a>
|
||||
<a href="{{forumUrl}}" class="fw500 mobile-menu-link">Forum</a>
|
||||
</div>
|
||||
@@ -59,6 +60,8 @@
|
||||
{{#showToc}}
|
||||
<div id="toc-mobile">{{{tocHtml}}}</div>
|
||||
{{/showToc}}
|
||||
|
||||
{{> socialFeeds}}
|
||||
|
||||
<div>
|
||||
<p class="light-blue mobile-menu-link-bottom text-center">
|
||||
|
||||
10
Assets/WebsiteAssets/templates/partials/socialFeeds.mustache
Normal file
10
Assets/WebsiteAssets/templates/partials/socialFeeds.mustache
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-12 social-links">
|
||||
<a class="social-link-twitter" href="https://twitter.com/joplinapp" title="Joplin Twitter feed"><i class="fab fa-twitter"></i></a>
|
||||
<a class="social-link-mastodon" href="https://mastodon.social/@joplinapp" title="Joplin Mastodon feed"><i class="fab fa-mastodon"></i></a>
|
||||
<a class="social-link-patreon" href="https://www.patreon.com/joplin" title="Joplin Patreon"><i class="fab fa-patreon"></i></a>
|
||||
<a class="social-link-discord" href="https://discord.gg/VSj7AFHvpq" title="Joplin Discord chat"><i class="fab fa-discord"></i></a>
|
||||
<a class="social-link-reddit" href="https://www.reddit.com/r/joplinapp/" title="Joplin Subreddit"><i class="fab fa-reddit"></i></a>
|
||||
<a class="social-link-github" href="https://github.com/laurent22/joplin/" title="Joplin GitHub repository"><i class="fab fa-github"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
5
BUILD.md
5
BUILD.md
@@ -19,7 +19,8 @@ There are also a few forks of existing packages under the "fork-*" name.
|
||||
## Required dependencies
|
||||
|
||||
- Install node 16+ - https://nodejs.org/en/
|
||||
- macOS: Install Cocoapods - `brew install cocoapods`
|
||||
- [Enable yarn](https://yarnpkg.com/getting-started/install): `corepack enable`
|
||||
- macOS: Install Cocoapods - `brew install cocoapods`. Apple Silicon [may require libvips](https://github.com/laurent22/joplin/pull/5966#issuecomment-1007158597) - `brew install vips`.
|
||||
- Windows: Install Windows Build Tools - `yarn install -g windows-build-tools --vs2015`
|
||||
- Linux: Install dependencies - `sudo apt install build-essential libnss3 libsecret-1-dev python rsync`
|
||||
|
||||
@@ -59,7 +60,7 @@ Normally the **bundler** should start automatically with the application. If it
|
||||
## Building the clipper
|
||||
|
||||
cd packages/app-clipper/popup
|
||||
yarn run watch # To watch for changes
|
||||
npm run watch # To watch for changes
|
||||
|
||||
To test the extension please refer to the relevant pages for each browser: [Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension#Trying_it_out) / [Chrome](https://developer.chrome.com/docs/extensions/mv3/getstarted/). Please note that the extension in dev mode will only connect to a dev instance of the desktop app (and vice-versa).
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ Joplin is available in multiple languages thanks to the help of its users. You c
|
||||
|
||||
If you want to start contributing to the project's code, please follow these guidelines before creating a pull request:
|
||||
|
||||
- Explain WHY you want to add this change. Explain it inside the pull request and you may link to an issue for additional information, but the PR should gives a clear overview of why you want to add this.
|
||||
- Explain WHY you want to add this change. Explain it inside the pull request and you may link to an issue for additional information, but the PR should give a clear overview of why you want to add this.
|
||||
- Bug fixes are always welcome. Start by reviewing the [list of bugs](https://github.com/laurent22/joplin/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
|
||||
- A good way to easily start contributing is to pick and work on a [good first issue](https://github.com/laurent22/joplin/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). We try to make these issues as clear as possible and provide basic info on how the code should be changed, and if something is unclear feel free to ask for more information on the issue.
|
||||
- Before adding a new feature, ask about it in the [Github Issue Tracker](https://github.com/laurent22/joplin/issues?utf8=%E2%9C%93&q=is%3Aissue) or the [Joplin Forum](https://discourse.joplinapp.org/), or check if existing discussions exist to make sure the new functionality is desired.
|
||||
- **Changes that will consist in more than 50 lines of code should be discussed the [Joplin Forum](https://discourse.joplinapp.org/)**, so that you don't spend too much time implementing something that might not be accepted.
|
||||
- All the applications share the same backend (database, synchronisation, settings, models, business logic, etc.) so if you change something in the backend in one app, makes sure it still work in the other apps. Usually it does, but keep this in mind.
|
||||
- **Changes that will consist of more than 50 lines of code should be discussed on the [Joplin Forum](https://discourse.joplinapp.org/)**, so that you don't spend too much time implementing something that might not be accepted.
|
||||
- All the applications share the same backend (database, synchronisation, settings, models, business logic, etc.) so if you change something in the backend in one app, make sure it still works in the other apps. Usually it does, but keep this in mind.
|
||||
- Pull requests that make many changes using an automated tool, like for spell fixing, styling, etc. will not be accepted. An exception would be if the changes have been discussed in the forum and someone has agreed to review **and test** the pull request.
|
||||
- Pull requests that make address multiple issues will most likely stall and eventually be closed. This is because we might be fine with one of the changes but not with others and untangling that kind of pull request is too much hassle both for maintainers and the person who submitted it. So most of the time someone gives up and the PR gets closed. So please keep the pull request focused on one issue.
|
||||
|
||||
|
||||
@@ -8,65 +8,36 @@ RUN apt-get update \
|
||||
# Enables Yarn
|
||||
RUN corepack enable
|
||||
|
||||
RUN echo "Node: $(node --version)"
|
||||
RUN echo "Npm: $(npm --version)"
|
||||
RUN echo "Yarn: $(yarn --version)"
|
||||
RUN echo "Node: $(node --version)" \
|
||||
&& echo "Npm: $(npm --version)" \
|
||||
&& echo "Yarn: $(yarn --version)"
|
||||
|
||||
ARG user=joplin
|
||||
|
||||
RUN useradd --create-home --shell /bin/bash $user
|
||||
USER $user
|
||||
|
||||
ENV NODE_ENV development
|
||||
ENV NODE_ENV production
|
||||
ENV RUNNING_IN_DOCKER 1
|
||||
EXPOSE ${APP_PORT}
|
||||
|
||||
WORKDIR /home/$user
|
||||
|
||||
RUN mkdir /home/$user/logs
|
||||
RUN mkdir /home/$user/logs \
|
||||
&& mkdir /home/$user/.yarn
|
||||
|
||||
# Install the root scripts but don't run postinstall (which would bootstrap
|
||||
# and build TypeScript files, but we don't have the TypeScript files at
|
||||
# this point)
|
||||
|
||||
COPY --chown=$user:$user package*.json ./
|
||||
COPY --chown=$user:$user .yarn ./.yarn
|
||||
COPY --chown=$user:$user .yarn/patches ./.yarn/patches
|
||||
COPY --chown=$user:$user .yarn/plugins ./.yarn/plugins
|
||||
COPY --chown=$user:$user .yarn/releases ./.yarn/releases
|
||||
COPY --chown=$user:$user package.json .
|
||||
COPY --chown=$user:$user .yarnrc.yml .
|
||||
COPY --chown=$user:$user yarn.lock .
|
||||
|
||||
RUN yarn install --inline-builds --mode=skip-build
|
||||
|
||||
# To take advantage of the Docker cache, we first copy all the package.json
|
||||
# and package-lock.json files, as they rarely change, and then bootstrap
|
||||
# all the packages.
|
||||
#
|
||||
# Note that bootstrapping the packages will run all the postinstall
|
||||
# scripts, which means that for packages that have such scripts, we need to
|
||||
# copy all the files.
|
||||
#
|
||||
# We can't run boostrap with "--ignore-scripts" because that would
|
||||
# prevent certain sub-packages, such as sqlite3, from being built
|
||||
|
||||
COPY --chown=$user:$user packages/fork-sax/package*.json ./packages/fork-sax/
|
||||
COPY --chown=$user:$user packages/fork-uslug/package*.json ./packages/fork-uslug/
|
||||
COPY --chown=$user:$user packages/htmlpack/package*.json ./packages/htmlpack/
|
||||
COPY --chown=$user:$user packages/renderer/package*.json ./packages/renderer/
|
||||
COPY --chown=$user:$user packages/tools/package*.json ./packages/tools/
|
||||
COPY --chown=$user:$user packages/lib/package*.json ./packages/lib/
|
||||
COPY --chown=$user:$user gulpfile.js .
|
||||
COPY --chown=$user:$user tsconfig.json .
|
||||
|
||||
# The following have postinstall scripts so we need to copy all the files.
|
||||
# Since they should rarely change this is not an issue
|
||||
|
||||
COPY --chown=$user:$user packages/turndown ./packages/turndown
|
||||
COPY --chown=$user:$user packages/turndown-plugin-gfm ./packages/turndown-plugin-gfm
|
||||
COPY --chown=$user:$user packages/fork-htmlparser2 ./packages/fork-htmlparser2
|
||||
COPY --chown=$user:$user packages/server/package*.json ./packages/server/
|
||||
|
||||
# Then bootstrap only, without compiling the TypeScript files
|
||||
|
||||
RUN yarn install --inline-builds --mode=skip-build
|
||||
|
||||
# Now copy the source files. Put lib and server last as they are more likely to change.
|
||||
|
||||
COPY --chown=$user:$user packages/fork-sax ./packages/fork-sax
|
||||
COPY --chown=$user:$user packages/fork-uslug ./packages/fork-uslug
|
||||
COPY --chown=$user:$user packages/htmlpack ./packages/htmlpack
|
||||
@@ -75,14 +46,23 @@ COPY --chown=$user:$user packages/tools ./packages/tools
|
||||
COPY --chown=$user:$user packages/lib ./packages/lib
|
||||
COPY --chown=$user:$user packages/server ./packages/server
|
||||
|
||||
# Finally build everything, in particular the TypeScript files.
|
||||
# For some reason there's both a .yarn/cache and .yarn/berry/cache that are
|
||||
# being generated, and both have the same content. Not clear why it does this
|
||||
# but we can delete it anyway. We can delete the cache because we use
|
||||
# `nodeLinker: node-modules`. If we ever implement Zero Install, we'll need to
|
||||
# keep the cache.
|
||||
#
|
||||
# Note that `yarn install` ignores `NODE_ENV=production` and will install dev
|
||||
# dependencies too, but this is fine because we need them to build the app.
|
||||
|
||||
RUN yarn run build
|
||||
RUN BUILD_SEQUENCIAL=1 yarn install --inline-builds \
|
||||
&& yarn cache clean \
|
||||
&& rm -rf .yarn/berry
|
||||
|
||||
ENV RUNNING_IN_DOCKER=1
|
||||
EXPOSE ${APP_PORT}
|
||||
|
||||
CMD [ "yarn", "--prefix", "packages/server", "start" ]
|
||||
# Call the command directly, without going via npm:
|
||||
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#cmd
|
||||
WORKDIR "/home/$user/packages/server"
|
||||
CMD [ "node", "dist/app.js" ]
|
||||
|
||||
# Build-time metadata
|
||||
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
|
||||
|
||||
@@ -219,6 +219,7 @@ then
|
||||
Type=Application
|
||||
Categories=Office;
|
||||
MimeType=x-scheme-handler/joplin;
|
||||
X-GNOME-SingleWindow=true
|
||||
EOF
|
||||
|
||||
# Update application icons
|
||||
|
||||
10
LICENSE
10
LICENSE
@@ -1,9 +1,9 @@
|
||||
All code in this repository is licensed under the MIT License **unless a
|
||||
directory contains a LICENSE file**, in which case that LICENSE file applies to
|
||||
the code in that sub-directory.
|
||||
directory contains a LICENSE or LICENSE.md file**, in which case that file
|
||||
applies to the code in that sub-directory.
|
||||
|
||||
For example, packages/fork-sax contains a ISC LICENSE file, thus all code under
|
||||
the packages/fork-sax directory is licensed under ISC.
|
||||
For example, packages/server contains a LICENSE.md file, thus all code under the
|
||||
packages/server directory is licensed under that license.
|
||||
|
||||
For example, packages/app-cli does NOT contain a LICENSE file, thus all code
|
||||
under that directory is licensed under the default license, which is MIT.
|
||||
@@ -20,7 +20,7 @@ icons please contact the author in order to get a permission.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2021 Laurent Cozic
|
||||
Copyright (c) 2016-2022 Laurent Cozic
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
@@ -300,10 +300,10 @@ To add a **Bucket Policy** from the AWS S3 Web Console, navigate to the **Permis
|
||||
{
|
||||
"Sid": "VisualEditor0",
|
||||
"Effect": "Allow",
|
||||
"Principal": "*",
|
||||
"Action": [
|
||||
"s3:ListBucket",
|
||||
"s3:GetBucketLocation",
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject",
|
||||
"s3:DeleteObjectVersion",
|
||||
"s3:PutObject"
|
||||
|
||||
16
gulpfile.js
16
gulpfile.js
@@ -20,6 +20,22 @@ const tasks = {
|
||||
await utils.execCommandVerbose('git', ['push']);
|
||||
},
|
||||
},
|
||||
build: {
|
||||
fn: async () => {
|
||||
// Building everything in parallel seems to be unreliable on CI as
|
||||
// certain scripts randomly fail with missing files or folder, or
|
||||
// cannot delete certain directories (eg. copyPluginAssets or
|
||||
// copyApplicationAssets). Because of this, on CI, we run the build
|
||||
// sequencially. Locally we run it in parallel, which is much
|
||||
// faster, especially when having to rebuild after adding a
|
||||
// dependency.
|
||||
if (process.env.BUILD_SEQUENCIAL === '1') {
|
||||
await utils.execCommandVerbose('yarn', ['run', 'buildSequential']);
|
||||
} else {
|
||||
await utils.execCommandVerbose('yarn', ['run', 'buildParallel']);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
utils.registerGulpTasks(gulp, tasks);
|
||||
|
||||
14
package.json
14
package.json
@@ -12,7 +12,8 @@
|
||||
"node": ">=16"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn workspaces foreach --verbose --interlaced --parallel run build && yarn run tsc",
|
||||
"buildParallel": "yarn workspaces foreach --verbose --interlaced --parallel --jobs 2 run build && yarn run tsc",
|
||||
"buildSequential": "yarn workspaces foreach --verbose --interlaced run build && yarn run tsc",
|
||||
"buildApiDoc": "yarn workspace joplin start apidoc ../../readme/api/references/rest_api.md",
|
||||
"buildCommandIndex": "gulp buildCommandIndex",
|
||||
"buildPluginDoc": "typedoc --name 'Joplin Plugin API Documentation' --mode file -theme './Assets/PluginDocTheme/' --readme './Assets/PluginDocTheme/index.md' --excludeNotExported --excludeExternals --excludePrivate --excludeProtected --out ../joplin-website/docs/api/references/plugin_api packages/lib/services/plugins/api/",
|
||||
@@ -28,9 +29,9 @@
|
||||
"linter-ci": "eslint --resolve-plugins-relative-to . --quiet --ext .js --ext .jsx --ext .ts --ext .tsx",
|
||||
"linter-precommit": "eslint --resolve-plugins-relative-to . --fix --ext .js --ext .jsx --ext .ts --ext .tsx",
|
||||
"linter": "eslint --resolve-plugins-relative-to . --fix --quiet --ext .js --ext .jsx --ext .ts --ext .tsx",
|
||||
"postinstall": "yarn run build",
|
||||
"publishAll": "git pull && yarn run build && lerna version --yes --no-private --no-git-tag-version && gulp completePublishAll",
|
||||
"releaseAndroid": "yarn run build && export PATH=\"/usr/local/opt/openjdk@11/bin:$PATH\" && node packages/tools/release-android.js",
|
||||
"postinstall": "gulp build",
|
||||
"publishAll": "git pull && yarn run buildParallel && lerna version --yes --no-private --no-git-tag-version && gulp completePublishAll",
|
||||
"releaseAndroid": "yarn run buildParallel && export PATH=\"/usr/local/opt/openjdk@11/bin:$PATH\" && node packages/tools/release-android.js",
|
||||
"releaseAndroidClean": "node packages/tools/release-android.js",
|
||||
"releaseCli": "node packages/tools/release-cli.js",
|
||||
"releaseClipper": "node packages/tools/release-clipper.js",
|
||||
@@ -77,5 +78,8 @@
|
||||
"node-gyp": "^8.4.1",
|
||||
"nodemon": "^2.0.9"
|
||||
},
|
||||
"packageManager": "yarn@3.1.1"
|
||||
"packageManager": "yarn@3.1.1",
|
||||
"resolutions": {
|
||||
"markdown-it-multimd-table@4.1.1": "patch:markdown-it-multimd-table@npm:4.1.1#.yarn/patches/markdown-it-multimd-table-npm-4.1.1-47e334d4bd"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
<title>Joplin Web Clipper</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
|
||||
2
packages/app-desktop/.gitignore
vendored
2
packages/app-desktop/.gitignore
vendored
@@ -12,5 +12,5 @@ runForSharingCommands-*
|
||||
runForTestingCommands-*
|
||||
style.min.css
|
||||
build/lib/
|
||||
vendor/
|
||||
vendor/*
|
||||
!vendor/loadEmojiLib.js
|
||||
|
||||
@@ -24,7 +24,6 @@ import ExternalEditWatcher from '@joplin/lib/services/ExternalEditWatcher';
|
||||
import appReducer, { createAppDefaultState } from './app.reducer';
|
||||
const { FoldersScreenUtils } = require('@joplin/lib/folders-screen-utils.js');
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
const fs = require('fs-extra');
|
||||
import Tag from '@joplin/lib/models/Tag';
|
||||
import { reg } from '@joplin/lib/registry';
|
||||
const packageInfo = require('./packageInfo.js');
|
||||
@@ -63,6 +62,7 @@ import ShareService from '@joplin/lib/services/share/ShareService';
|
||||
import checkForUpdates from './checkForUpdates';
|
||||
import { AppState } from './app.reducer';
|
||||
import syncDebugLog from '@joplin/lib/services/synchronizer/syncDebugLog';
|
||||
import eventManager from '@joplin/lib/eventManager';
|
||||
// import { runIntegrationTests } from '@joplin/lib/services/e2ee/ppkTestUtils';
|
||||
|
||||
const pluginClasses = [
|
||||
@@ -234,23 +234,6 @@ class Application extends BaseApplication {
|
||||
});
|
||||
}
|
||||
|
||||
async loadCustomCss(filePath: string) {
|
||||
let cssString = '';
|
||||
if (await fs.pathExists(filePath)) {
|
||||
try {
|
||||
cssString = await fs.readFile(filePath, 'utf-8');
|
||||
|
||||
} catch (error) {
|
||||
let msg = error.message ? error.message : '';
|
||||
msg = `Could not load custom css from ${filePath}\n${msg}`;
|
||||
error.message = msg;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return cssString;
|
||||
}
|
||||
|
||||
private async checkForLegacyTemplates() {
|
||||
const templatesDir = `${Setting.value('profileDir')}/templates`;
|
||||
if (await shim.fsDriver().exists(templatesDir)) {
|
||||
@@ -463,8 +446,9 @@ class Application extends BaseApplication {
|
||||
|
||||
await this.checkForLegacyTemplates();
|
||||
|
||||
// Note: Auto-update currently doesn't work in Linux: it downloads the update
|
||||
// but then doesn't install it on exit.
|
||||
// Note: Auto-update is a misnomer in the code.
|
||||
// The code below only checks, if a new version is available.
|
||||
// We only allow Windows and macOS users to automatically check for updates
|
||||
if (shim.isWindows() || shim.isMac()) {
|
||||
const runAutoUpdateCheck = () => {
|
||||
if (Setting.value('autoUpdateEnabled')) {
|
||||
@@ -523,6 +507,12 @@ class Application extends BaseApplication {
|
||||
|
||||
ResourceEditWatcher.instance().initialize(reg.logger(), (action: any) => { this.store().dispatch(action); }, (path: string) => bridge().openItem(path));
|
||||
|
||||
// Forwards the local event to the global event manager, so that it can
|
||||
// be picked up by the plugin manager.
|
||||
ResourceEditWatcher.instance().on('resourceChange', (event: any) => {
|
||||
eventManager.emit('resourceChange', event);
|
||||
});
|
||||
|
||||
RevisionService.instance().runInBackground();
|
||||
|
||||
// Make it available to the console window - useful to call revisionService.collectRevisions()
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
import ElectronAppWrapper from './ElectronAppWrapper';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import { _, setLocale } from '@joplin/lib/locale';
|
||||
import { BrowserWindow, nativeTheme, nativeImage } from 'electron';
|
||||
const { dirname, toSystemSlashes } = require('@joplin/lib/path-utils');
|
||||
const { BrowserWindow, nativeTheme } = require('electron');
|
||||
|
||||
interface LastSelectedPath {
|
||||
file: string;
|
||||
directory: string;
|
||||
}
|
||||
|
||||
interface LastSelectedPaths {
|
||||
[key: string]: LastSelectedPath;
|
||||
}
|
||||
|
||||
export class Bridge {
|
||||
|
||||
private electronWrapper_: ElectronAppWrapper;
|
||||
private lastSelectedPaths_: LastSelectedPaths;
|
||||
private lastSelectedPaths_: LastSelectedPath;
|
||||
|
||||
constructor(electronWrapper: ElectronAppWrapper) {
|
||||
this.electronWrapper_ = electronWrapper;
|
||||
@@ -164,11 +160,11 @@ export class Bridge {
|
||||
if (!options) options = {};
|
||||
let fileType = 'file';
|
||||
if (options.properties && options.properties.includes('openDirectory')) fileType = 'directory';
|
||||
if (!('defaultPath' in options) && this.lastSelectedPaths_[fileType]) options.defaultPath = this.lastSelectedPaths_[fileType];
|
||||
if (!('defaultPath' in options) && (this.lastSelectedPaths_ as any)[fileType]) options.defaultPath = (this.lastSelectedPaths_ as any)[fileType];
|
||||
if (!('createDirectory' in options)) options.createDirectory = true;
|
||||
const { filePaths } = await dialog.showOpenDialog(this.window(), options);
|
||||
if (filePaths && filePaths.length) {
|
||||
this.lastSelectedPaths_[fileType] = dirname(filePaths[0]);
|
||||
(this.lastSelectedPaths_ as any)[fileType] = dirname(filePaths[0]);
|
||||
}
|
||||
return filePaths;
|
||||
}
|
||||
@@ -282,6 +278,10 @@ export class Bridge {
|
||||
app.exit();
|
||||
}
|
||||
|
||||
public createImageFromPath(path: string) {
|
||||
return nativeImage.createFromPath(path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let bridge_: Bridge = null;
|
||||
|
||||
@@ -201,11 +201,11 @@ export default async function checkForUpdates(inBackground: boolean, parentWindo
|
||||
});
|
||||
|
||||
if (buttonIndex === 0) {
|
||||
bridge().openExternal(release.downloadUrl ? release.downloadUrl : release.pageUrl);
|
||||
void bridge().openExternal(release.downloadUrl ? release.downloadUrl : release.pageUrl);
|
||||
} else if (buttonIndex === 1) {
|
||||
await addSkippedVersion(release.version);
|
||||
} else if (buttonIndex === 2) {
|
||||
bridge().openExternal('https://joplinapp.org/changelog/');
|
||||
void bridge().openExternal('https://joplinapp.org/changelog/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ class ClipperConfigScreenComponent extends React.Component {
|
||||
}
|
||||
|
||||
chromeButton_click() {
|
||||
bridge().openExternal('https://chrome.google.com/webstore/detail/joplin-web-clipper/alofnhikmmkdbbbgpnglcpdollgjjfek');
|
||||
void bridge().openExternal('https://chrome.google.com/webstore/detail/joplin-web-clipper/alofnhikmmkdbbbgpnglcpdollgjjfek');
|
||||
}
|
||||
|
||||
firefoxButton_click() {
|
||||
bridge().openExternal('https://addons.mozilla.org/en-US/firefox/addon/joplin-web-clipper/');
|
||||
void bridge().openExternal('https://addons.mozilla.org/en-US/firefox/addon/joplin-web-clipper/');
|
||||
}
|
||||
|
||||
copyToken_click() {
|
||||
@@ -56,7 +56,7 @@ class ClipperConfigScreenComponent extends React.Component {
|
||||
|
||||
const containerStyle = Object.assign({}, theme.containerStyle, {
|
||||
overflowY: 'scroll',
|
||||
padding: theme.configScreenPadding,
|
||||
// padding: theme.configScreenPadding,
|
||||
backgroundColor: theme.backgroundColor3,
|
||||
});
|
||||
|
||||
|
||||
@@ -155,11 +155,11 @@ export default function(props: Props) {
|
||||
const onNameClick = useCallback(() => {
|
||||
const manifest = item.manifest;
|
||||
if (!manifest.homepage_url) return;
|
||||
bridge().openExternal(manifest.homepage_url);
|
||||
void bridge().openExternal(manifest.homepage_url);
|
||||
}, [item]);
|
||||
|
||||
const onRecommendedClick = useCallback(() => {
|
||||
bridge().openExternal('https://github.com/joplin/plugins/blob/master/readme/recommended.md#recommended-plugins');
|
||||
void bridge().openExternal('https://github.com/joplin/plugins/blob/master/readme/recommended.md#recommended-plugins');
|
||||
}, []);
|
||||
|
||||
// For plugins in dev mode things like enabling/disabling or
|
||||
|
||||
@@ -198,7 +198,7 @@ export default function(props: Props) {
|
||||
}, [pluginSettings, props.onChange]);
|
||||
|
||||
const onBrowsePlugins = useCallback(() => {
|
||||
bridge().openExternal('https://github.com/joplin/plugins/blob/master/README.md#plugins');
|
||||
void bridge().openExternal('https://github.com/joplin/plugins/blob/master/README.md#plugins');
|
||||
}, []);
|
||||
|
||||
const onPluginSettingsChange = useCallback((event: OnPluginSettingChangeEvent) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useCallback, useState, useRef, useEffect } from 'react';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import DialogButtonRow, { ClickEvent } from '../DialogButtonRow';
|
||||
import Dialog from '../Dialog';
|
||||
@@ -8,25 +8,32 @@ import StyledInput from '../style/StyledInput';
|
||||
import { IconSelector, ChangeEvent } from './IconSelector';
|
||||
import useAsyncEffect, { AsyncEffectEvent } from '@joplin/lib/hooks/useAsyncEffect';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
import { FolderIcon } from '@joplin/lib/services/database/types';
|
||||
import { FolderEntity, FolderIcon } from '@joplin/lib/services/database/types';
|
||||
import Button from '../Button/Button';
|
||||
import bridge from '../../services/bridge';
|
||||
|
||||
interface Props {
|
||||
themeId: number;
|
||||
dispatch: Function;
|
||||
folderId: string;
|
||||
parentId: string;
|
||||
}
|
||||
|
||||
export default function(props: Props) {
|
||||
const [folderTitle, setFolderTitle] = useState('');
|
||||
const [folderIcon, setFolderIcon] = useState<FolderIcon>();
|
||||
const titleInputRef = useRef(null);
|
||||
|
||||
const isNew = !props.folderId;
|
||||
|
||||
useAsyncEffect(async (event: AsyncEffectEvent) => {
|
||||
if (isNew) return;
|
||||
|
||||
const folder = await Folder.load(props.folderId);
|
||||
if (event.cancelled) return;
|
||||
setFolderTitle(folder.title);
|
||||
setFolderIcon(Folder.unserializeIcon(folder.icon));
|
||||
}, [props.folderId]);
|
||||
}, [props.folderId, isNew]);
|
||||
|
||||
const onClose = useCallback(() => {
|
||||
props.dispatch({
|
||||
@@ -35,6 +42,14 @@ export default function(props: Props) {
|
||||
});
|
||||
}, [props.dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
titleInputRef.current.focus();
|
||||
|
||||
setTimeout(() => {
|
||||
titleInputRef.current.select();
|
||||
}, 100);
|
||||
}, []);
|
||||
|
||||
const onButtonRowClick = useCallback(async (event: ClickEvent) => {
|
||||
if (event.buttonName === 'cancel') {
|
||||
onClose();
|
||||
@@ -42,15 +57,29 @@ export default function(props: Props) {
|
||||
}
|
||||
|
||||
if (event.buttonName === 'ok') {
|
||||
await Folder.save({
|
||||
id: props.folderId,
|
||||
const folder: FolderEntity = {
|
||||
title: folderTitle,
|
||||
icon: Folder.serializeIcon(folderIcon),
|
||||
});
|
||||
onClose();
|
||||
};
|
||||
|
||||
if (!isNew) folder.id = props.folderId;
|
||||
if (props.parentId) folder.parent_id = props.parentId;
|
||||
|
||||
try {
|
||||
const savedFolder = await Folder.save(folder, { userSideValidation: true });
|
||||
onClose();
|
||||
|
||||
props.dispatch({
|
||||
type: 'FOLDER_SELECT',
|
||||
id: savedFolder.id,
|
||||
});
|
||||
} catch (error) {
|
||||
bridge().showErrorMessageBox(error.message);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}, [onClose, folderTitle, folderIcon, props.folderId]);
|
||||
}, [onClose, folderTitle, folderIcon, props.folderId, props.parentId]);
|
||||
|
||||
const onFolderTitleChange = useCallback((event: any) => {
|
||||
setFolderTitle(event.target.value);
|
||||
@@ -70,7 +99,7 @@ export default function(props: Props) {
|
||||
<div className="form">
|
||||
<div className="form-input-group">
|
||||
<label>{_('Title')}</label>
|
||||
<StyledInput type="text" value={folderTitle} onChange={onFolderTitleChange}/>
|
||||
<StyledInput type="text" ref={titleInputRef} value={folderTitle} onChange={onFolderTitleChange}/>
|
||||
</div>
|
||||
|
||||
<div className="form-input-group">
|
||||
@@ -96,10 +125,12 @@ export default function(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
const dialogTitle = isNew ? _('Create notebook') : _('Edit notebook');
|
||||
|
||||
function renderDialogWrapper() {
|
||||
return (
|
||||
<div className="dialog-root">
|
||||
<DialogTitle title={_('Edit notebook')}/>
|
||||
<DialogTitle title={dialogTitle}/>
|
||||
{renderContent()}
|
||||
<DialogButtonRow
|
||||
themeId={props.themeId}
|
||||
|
||||
@@ -5,7 +5,7 @@ export default function styles(themeId: number) {
|
||||
return {
|
||||
container: {
|
||||
...theme.containerStyle,
|
||||
padding: theme.configScreenPadding,
|
||||
// padding: theme.configScreenPadding,
|
||||
backgroundColor: theme.backgroundColor3,
|
||||
},
|
||||
actionsContainer: {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService';
|
||||
import CommandService, { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
const bridge = require('@electron/remote').require('./bridge').default;
|
||||
import { Options } from './openFolderDialog';
|
||||
|
||||
export const declaration: CommandDeclaration = {
|
||||
name: 'newFolder',
|
||||
@@ -9,35 +8,15 @@ export const declaration: CommandDeclaration = {
|
||||
iconName: 'fa-book',
|
||||
};
|
||||
|
||||
export const runtime = (comp: any): CommandRuntime => {
|
||||
export const runtime = (): CommandRuntime => {
|
||||
return {
|
||||
execute: async (_context: CommandContext, parentId: string = null) => {
|
||||
comp.setState({
|
||||
promptOptions: {
|
||||
label: _('Notebook title:'),
|
||||
onClose: async (answer: string) => {
|
||||
if (answer) {
|
||||
let folder = null;
|
||||
try {
|
||||
const toSave: any = { title: answer };
|
||||
if (parentId) toSave.parent_id = parentId;
|
||||
folder = await Folder.save(toSave, { userSideValidation: true });
|
||||
} catch (error) {
|
||||
bridge().showErrorMessageBox(error.message);
|
||||
}
|
||||
const options: Options = {
|
||||
isNew: true,
|
||||
parentId: parentId,
|
||||
};
|
||||
|
||||
if (folder) {
|
||||
comp.props.dispatch({
|
||||
type: 'FOLDER_SELECT',
|
||||
id: folder.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
comp.setState({ promptOptions: null });
|
||||
},
|
||||
},
|
||||
});
|
||||
void CommandService.instance().execute('openFolderDialog', options);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
|
||||
export interface Options {
|
||||
isNew?: boolean;
|
||||
folderId?: string;
|
||||
parentId?: string;
|
||||
}
|
||||
|
||||
export const declaration: CommandDeclaration = {
|
||||
name: 'openFolderDialog',
|
||||
label: () => _('Edit'),
|
||||
@@ -8,13 +14,22 @@ export const declaration: CommandDeclaration = {
|
||||
|
||||
export const runtime = (): CommandRuntime => {
|
||||
return {
|
||||
execute: async (context: CommandContext, folderId: string) => {
|
||||
execute: async (context: CommandContext, options: Options = null) => {
|
||||
options = {
|
||||
isNew: false,
|
||||
...options,
|
||||
};
|
||||
|
||||
if (options.isNew && !('parentId' in options)) throw new Error('parentId mst be specified when creating a new folder');
|
||||
if (!options.isNew && !('folderId' in options)) throw new Error('folderId property is required');
|
||||
|
||||
context.dispatch({
|
||||
type: 'DIALOG_OPEN',
|
||||
name: 'editFolder',
|
||||
isOpen: true,
|
||||
props: {
|
||||
folderId,
|
||||
folderId: options.folderId,
|
||||
parentId: options.parentId,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
@@ -27,9 +27,9 @@ export const runtime = (): CommandRuntime => {
|
||||
// but doesn't on macOS, so we need to convert it to a path
|
||||
// before passing it to openPath.
|
||||
const decodedPath = fileUriToPath(urlDecode(link), shim.platformName());
|
||||
require('electron').shell.openPath(decodedPath);
|
||||
void require('electron').shell.openPath(decodedPath);
|
||||
} else {
|
||||
require('electron').shell.openExternal(link);
|
||||
void require('electron').shell.openExternal(link);
|
||||
}
|
||||
} else {
|
||||
bridge().showErrorMessageBox(_('Unsupported link or message: %s', link));
|
||||
|
||||
@@ -19,7 +19,7 @@ export const runtime = (): CommandRuntime => {
|
||||
useSpellChecker = useSpellChecker === null ? context.state.settings['spellChecker.enabled'] : useSpellChecker;
|
||||
|
||||
const menuItems = SpellCheckerService.instance().spellCheckerConfigMenuItems(selectedLanguage, useSpellChecker);
|
||||
const menu = Menu.buildFromTemplate(menuItems);
|
||||
const menu = Menu.buildFromTemplate(menuItems as any);
|
||||
menu.popup(bridge().window());
|
||||
},
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ interface Props {
|
||||
['spellChecker.language']: string;
|
||||
plugins: PluginStates;
|
||||
customCss: string;
|
||||
locale: string;
|
||||
}
|
||||
|
||||
const commandNames: string[] = menuCommandNames();
|
||||
@@ -249,7 +250,11 @@ function useMenu(props: Props) {
|
||||
const keymapService = KeymapService.instance();
|
||||
|
||||
const pluginCommandNames = props.pluginMenuItems.map((view: any) => view.commandName);
|
||||
const menuItemDic = menuUtils.commandsToMenuItems(commandNames.concat(pluginCommandNames), (commandName: string) => onMenuItemClickRef.current(commandName));
|
||||
const menuItemDic = menuUtils.commandsToMenuItems(
|
||||
commandNames.concat(pluginCommandNames),
|
||||
(commandName: string) => onMenuItemClickRef.current(commandName),
|
||||
props.locale
|
||||
);
|
||||
|
||||
const quitMenuItem = {
|
||||
label: _('Quit'),
|
||||
@@ -697,13 +702,13 @@ function useMenu(props: Props) {
|
||||
submenu: [{
|
||||
label: _('Website and documentation'),
|
||||
accelerator: keymapService.getAccelerator('help'),
|
||||
click() { bridge().openExternal('https://joplinapp.org'); },
|
||||
click() { void bridge().openExternal('https://joplinapp.org'); },
|
||||
}, {
|
||||
label: _('Joplin Forum'),
|
||||
click() { bridge().openExternal('https://discourse.joplinapp.org'); },
|
||||
click() { void bridge().openExternal('https://discourse.joplinapp.org'); },
|
||||
}, {
|
||||
label: _('Make a donation'),
|
||||
click() { bridge().openExternal('https://joplinapp.org/donate/'); },
|
||||
click() { void bridge().openExternal('https://joplinapp.org/donate/'); },
|
||||
}, {
|
||||
label: _('Check for updates...'),
|
||||
visible: shim.isMac() ? false : true,
|
||||
@@ -816,7 +821,7 @@ function useMenu(props: Props) {
|
||||
menuItemDic.textCut,
|
||||
menuItemDic.textPaste,
|
||||
menuItemDic.textSelectAll,
|
||||
],
|
||||
] as any,
|
||||
},
|
||||
]));
|
||||
} else {
|
||||
@@ -830,7 +835,7 @@ function useMenu(props: Props) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
};
|
||||
}, [props.routeName, props.pluginMenuItems, props.pluginMenus, keymapLastChangeTime, modulesLastChangeTime, props['spellChecker.language'], props['spellChecker.enabled'], props.plugins, props.customCss]);
|
||||
}, [props.routeName, props.pluginMenuItems, props.pluginMenus, keymapLastChangeTime, modulesLastChangeTime, props['spellChecker.language'], props['spellChecker.enabled'], props.plugins, props.customCss, props.locale]);
|
||||
|
||||
useMenuStates(menu, props);
|
||||
|
||||
@@ -872,6 +877,7 @@ const mapStateToProps = (state: AppState) => {
|
||||
|
||||
return {
|
||||
menuItemProps: menuUtils.commandsToMenuItemProps(commandNames.concat(pluginCommandNames(state.pluginService.plugins)), whenClauseContext),
|
||||
locale: state.settings.locale,
|
||||
routeName: state.route.routeName,
|
||||
selectedFolderId: state.selectedFolderId,
|
||||
layoutButtonSequence: state.settings.layoutButtonSequence,
|
||||
|
||||
@@ -67,7 +67,7 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
||||
|
||||
usePluginServiceRegistration(ref);
|
||||
|
||||
const { resetScroll, editor_scroll, setEditorPercentScroll, setViewerPercentScroll, editor_resize,
|
||||
const { resetScroll, editor_scroll, setEditorPercentScroll, setViewerPercentScroll, editor_resize, getLineScrollPercent,
|
||||
} = useScrollHandler(editorRef, webviewRef, props.onScroll);
|
||||
|
||||
const codeMirror_change = useCallback((newBody: string) => {
|
||||
@@ -502,10 +502,6 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
||||
padding-left: .2em;
|
||||
}
|
||||
|
||||
div.CodeMirror span.cm-strong {
|
||||
color: ${theme.colorBright};
|
||||
}
|
||||
|
||||
div.CodeMirror span.cm-hr {
|
||||
color: ${theme.dividerColor};
|
||||
}
|
||||
@@ -580,9 +576,14 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
||||
const arg0 = args && args.length >= 1 ? args[0] : null;
|
||||
|
||||
if (msg.indexOf('checkboxclick:') === 0) {
|
||||
const newBody = shared.toggleCheckbox(msg, props.content);
|
||||
const { line, from, to } = shared.toggleCheckboxRange(msg, props.content);
|
||||
if (editorRef.current) {
|
||||
editorRef.current.updateBody(newBody);
|
||||
// To cancel CodeMirror's layout drift, the scroll position
|
||||
// is recorded before updated, and then it is restored.
|
||||
// Ref. https://github.com/laurent22/joplin/issues/5890
|
||||
const percent = getLineScrollPercent();
|
||||
editorRef.current.replaceRange(line, from, to);
|
||||
setEditorPercentScroll(percent);
|
||||
}
|
||||
} else if (msg === 'percentScroll') {
|
||||
const percent = arg0;
|
||||
|
||||
@@ -64,7 +64,7 @@ export default function useEditorSearch(CodeMirror: any) {
|
||||
}
|
||||
|
||||
if (match) {
|
||||
if (scrollTo) cm.scrollIntoView(match);
|
||||
if (scrollTo) cm.setSelection(match.from, match.to);
|
||||
return cm.markText(match.from, match.to, { className: 'cm-search-marker-selected' });
|
||||
}
|
||||
|
||||
@@ -107,7 +107,9 @@ export default function useEditorSearch(CodeMirror: any) {
|
||||
const searchTerm = getSearchTerm(keyword);
|
||||
|
||||
// We only want to scroll the first keyword into view in the case of a multi keyword search
|
||||
const scrollTo = i === 0 && (previousKeywordValue !== keyword.value || previousIndex !== options.selectedIndex);
|
||||
const scrollTo = i === 0 && (previousKeywordValue !== keyword.value || previousIndex !== options.selectedIndex ||
|
||||
// If there is only one choice, scrollTo should be true. The below is a dummy of nMatches === 1.
|
||||
options.selectedIndex === 0);
|
||||
|
||||
const match = highlightSearch(this, searchTerm, options.selectedIndex, scrollTo);
|
||||
if (match) marks.push(match);
|
||||
|
||||
@@ -7,6 +7,7 @@ export default function useScrollHandler(editorRef: any, webviewRef: any, onScro
|
||||
const ignoreNextEditorScrollTime_ = useRef(Date.now());
|
||||
const ignoreNextEditorScrollEventCount_ = useRef(0);
|
||||
const delayedSetEditorPercentScrollTimeoutID_ = useRef(null);
|
||||
const lastResizeHeight_ = useRef(NaN);
|
||||
|
||||
// Ignores one next scroll event for a short time.
|
||||
const ignoreNextEditorScrollEvent = () => {
|
||||
@@ -90,8 +91,7 @@ export default function useScrollHandler(editorRef: any, webviewRef: any, onScro
|
||||
}, [scheduleOnScroll]);
|
||||
|
||||
const editor_scroll = useCallback(() => {
|
||||
if (isNextEditorScrollEventIgnored()) return;
|
||||
|
||||
const ignored = isNextEditorScrollEventIgnored();
|
||||
const cm = editorRef.current;
|
||||
if (isCodeMirrorReady(cm)) {
|
||||
const editorPercent = Math.max(0, Math.min(1, cm.getScrollPercent()));
|
||||
@@ -104,7 +104,9 @@ export default function useScrollHandler(editorRef: any, webviewRef: any, onScro
|
||||
// calculates GUI-independent line-based percent
|
||||
const percent = translateScrollPercentE2L(cm, editorPercent);
|
||||
scrollPercent_.current = percent;
|
||||
setViewerPercentScroll(percent);
|
||||
if (!ignored) {
|
||||
setViewerPercentScroll(percent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [setViewerPercentScroll]);
|
||||
@@ -117,13 +119,29 @@ export default function useScrollHandler(editorRef: any, webviewRef: any, onScro
|
||||
}, []);
|
||||
|
||||
const editor_resize = useCallback((cm) => {
|
||||
if (cm) {
|
||||
restoreEditorPercentScroll();
|
||||
if (isCodeMirrorReady(cm)) {
|
||||
// Only when resized, the scroll position is restored.
|
||||
const info = cm.getScrollInfo();
|
||||
const height = info.height - info.clientHeight;
|
||||
if (height !== lastResizeHeight_.current) {
|
||||
restoreEditorPercentScroll();
|
||||
lastResizeHeight_.current = height;
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
const getLineScrollPercent = useCallback(() => {
|
||||
const cm = editorRef.current;
|
||||
if (isCodeMirrorReady(cm)) {
|
||||
const ePercent = cm.getScrollPercent();
|
||||
return translateScrollPercentE2L(cm, ePercent);
|
||||
} else {
|
||||
return scrollPercent_.current;
|
||||
}
|
||||
}, []);
|
||||
|
||||
return {
|
||||
resetScroll, setEditorPercentScroll, setViewerPercentScroll, editor_scroll, editor_resize,
|
||||
resetScroll, setEditorPercentScroll, setViewerPercentScroll, editor_scroll, editor_resize, getLineScrollPercent,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import ResourceEditWatcher from '@joplin/lib/services/ResourceEditWatcher/index';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { copyHtmlToClipboard } from './clipboardUtils';
|
||||
|
||||
const bridge = require('@electron/remote').require('./bridge').default;
|
||||
import bridge from '../../../services/bridge';
|
||||
const Menu = bridge().Menu;
|
||||
const MenuItem = bridge().MenuItem;
|
||||
import Resource from '@joplin/lib/models/Resource';
|
||||
@@ -131,6 +130,15 @@ export function menuItems(dispatch: Function): ContextMenuItems {
|
||||
},
|
||||
isActive: (itemType: ContextMenuItemType) => itemType === ContextMenuItemType.Image || itemType === ContextMenuItemType.Resource,
|
||||
},
|
||||
copyImage: {
|
||||
label: _('Copy image'),
|
||||
onAction: async (options: ContextMenuOptions) => {
|
||||
const { resourcePath } = await resourceInfo(options);
|
||||
const image = bridge().createImageFromPath(resourcePath);
|
||||
clipboard.writeImage(image);
|
||||
},
|
||||
isActive: (itemType: ContextMenuItemType) => itemType === ContextMenuItemType.Image,
|
||||
},
|
||||
cut: {
|
||||
label: _('Cut'),
|
||||
onAction: async (options: ContextMenuOptions) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import Logger from '@joplin/lib/Logger';
|
||||
import { SearchMarkers } from './useSearchMarkers';
|
||||
const CommandService = require('@joplin/lib/services/CommandService').default;
|
||||
|
||||
const logger = Logger.create('useNoteSearchBar');
|
||||
|
||||
@@ -70,6 +71,7 @@ export default function useNoteSearchBar() {
|
||||
const onClose = useCallback(() => {
|
||||
setShowLocalSearch(false);
|
||||
setLocalSearch(defaultLocalSearch());
|
||||
void CommandService.instance().execute('focusElementNoteBody');
|
||||
}, []);
|
||||
|
||||
const setResultCount = useCallback((count: number) => {
|
||||
|
||||
@@ -56,7 +56,15 @@ function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any, s
|
||||
});
|
||||
}
|
||||
},
|
||||
enabledCondition: '!modalDialogVisible && markdownEditorPaneVisible && oneNoteSelected && noteIsMarkdown',
|
||||
|
||||
// We disable the editor commands whenever a modal dialog is visible,
|
||||
// otherwise the user might type something in a dialog and accidentally
|
||||
// change something in the editor. However, we still enable them for
|
||||
// GotoAnything so that it's possible to type eg `textBold` and bold the
|
||||
// currently selected text.
|
||||
//
|
||||
// https://github.com/laurent22/joplin/issues/5707
|
||||
enabledCondition: '(!modalDialogVisible || gotoAnythingVisible) && markdownEditorPaneVisible && oneNoteSelected && noteIsMarkdown',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ export const Root = styled.div`
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 30px;
|
||||
`;
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -294,7 +294,7 @@ class SidebarComponent extends React.Component<Props, State> {
|
||||
);
|
||||
|
||||
if (itemType === BaseModel.TYPE_FOLDER && !item.encryption_applied) {
|
||||
menu.append(new MenuItem(menuUtils.commandToStatefulMenuItem('openFolderDialog', itemId)));
|
||||
menu.append(new MenuItem(menuUtils.commandToStatefulMenuItem('openFolderDialog', { folderId: itemId })));
|
||||
|
||||
menu.append(new MenuItem({ type: 'separator' }));
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ export default function(props: Props) {
|
||||
}, [joplinCloudEmail, joplinCloudPassword, props.dispatch]);
|
||||
|
||||
const onJoplinCloudCreateAccountClick = useCallback(() => {
|
||||
bridge().openExternal('https://joplinapp.org/plans/');
|
||||
void bridge().openExternal('https://joplinapp.org/plans/');
|
||||
}, []);
|
||||
|
||||
function renderJoplinCloudLoginForm() {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
const React = require('react');
|
||||
const { connect } = require('react-redux');
|
||||
const { themeStyle } = require('@joplin/lib/theme');
|
||||
const CommandService = require('@joplin/lib/services/CommandService').default;
|
||||
|
||||
class TagItemComponent extends React.Component {
|
||||
render() {
|
||||
const theme = themeStyle(this.props.themeId);
|
||||
const style = Object.assign({}, theme.tagStyle);
|
||||
const title = this.props.title;
|
||||
const { title, id } = this.props;
|
||||
|
||||
return <span style={style}>{title}</span>;
|
||||
return <button style={style} onClick={() => CommandService.instance().execute('openTag', id)}>{title}</button>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ function TagList(props: Props) {
|
||||
for (let i = 0; i < tags.length; i++) {
|
||||
const props = {
|
||||
title: tags[i].title,
|
||||
id: tags[i].id,
|
||||
key: tags[i].id,
|
||||
};
|
||||
output.push(<TagItem {...props} />);
|
||||
|
||||
@@ -151,7 +151,7 @@ General classes
|
||||
|
||||
body, button {
|
||||
color: var(--joplin-color);
|
||||
font-size: 16px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
div, span, a {
|
||||
@@ -159,7 +159,7 @@ div, span, a {
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
font-size: 20px;
|
||||
|
||||
&.-no-top-margin {
|
||||
margin-top: 0;
|
||||
@@ -193,7 +193,7 @@ div.form,
|
||||
|
||||
p {
|
||||
&.-small {
|
||||
font-size: 13px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
"debounce": "^1.2.0",
|
||||
"electron-window-state": "^4.1.1",
|
||||
"formatcoords": "^1.1.3",
|
||||
"fs-extra": "^5.0.0",
|
||||
"fs-extra": "10.0.0",
|
||||
"highlight.js": "^10.2.1",
|
||||
"immer": "^7.0.5",
|
||||
"keytar": "^7.0.0",
|
||||
|
||||
@@ -496,10 +496,10 @@ class Dialog extends React.PureComponent<Props, State> {
|
||||
const isSelected = item.id === this.state.selectedItemId;
|
||||
const rowStyle = isSelected ? style.rowSelected : style.row;
|
||||
const titleHtml = item.fragments
|
||||
? `<span style="font-weight: bold; color: ${theme.colorBright};">${item.title}</span>`
|
||||
: surroundKeywords(this.state.keywords, item.title, `<span style="font-weight: bold; color: ${theme.colorBright};">`, '</span>', { escapeHtml: true });
|
||||
? `<span style="font-weight: bold; color: ${theme.color};">${item.title}</span>`
|
||||
: surroundKeywords(this.state.keywords, item.title, `<span style="font-weight: bold; color: ${theme.searchMarkerColor}; background-color: ${theme.searchMarkerBackgroundColor}">`, '</span>', { escapeHtml: true });
|
||||
|
||||
const fragmentsHtml = !item.fragments ? null : surroundKeywords(this.state.keywords, item.fragments, `<span style="font-weight: bold; color: ${theme.colorBright};">`, '</span>', { escapeHtml: true });
|
||||
const fragmentsHtml = !item.fragments ? null : surroundKeywords(this.state.keywords, item.fragments, `<span style="color: ${theme.searchMarkerColor}; background-color: ${theme.searchMarkerBackgroundColor}">`, '</span>', { escapeHtml: true });
|
||||
|
||||
const folderIcon = <i style={{ fontSize: theme.fontSize, marginRight: 2 }} className="fa fa-book" />;
|
||||
const pathComp = !item.path ? null : <div style={style.rowPath}>{folderIcon} {item.path}</div>;
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
|
||||
# ./runForTesting.sh 1 createUsers,createData,reset,e2ee,sync && ./runForTesting.sh 2 reset,e2ee,sync && ./runForTesting.sh 1
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# First user has E2EE, but second one doesn't:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
# ./runForTesting.sh 1 createUsers,createData,reset,e2ee,sync && ./runForTesting.sh 2 reset,sync && ./runForTesting.sh 1
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# Without E2EE:
|
||||
# ----------------------------------------------------------------------------------
|
||||
@@ -41,6 +47,11 @@ if [ "$USER_NUM" = "1a" ]; then
|
||||
USER_PROFILE_NUM=1a
|
||||
fi
|
||||
|
||||
if [ "$USER_NUM" = "1b" ]; then
|
||||
USER_NUM=1
|
||||
USER_PROFILE_NUM=1b
|
||||
fi
|
||||
|
||||
COMMANDS=($(echo $2 | tr "," "\n"))
|
||||
PROFILE_DIR=~/.config/joplindev-desktop-$USER_PROFILE_NUM
|
||||
|
||||
@@ -54,6 +65,10 @@ do
|
||||
|
||||
curl --data '{"action": "createTestUsers"}' -H 'Content-Type: application/json' http://api.joplincloud.local:22300/api/debug
|
||||
|
||||
elif [[ $CMD == "createUserDeletions" ]]; then
|
||||
|
||||
curl --data '{"action": "createUserDeletions"}' -H 'Content-Type: application/json' http://api.joplincloud.local:22300/api/debug
|
||||
|
||||
elif [[ $CMD == "createData" ]]; then
|
||||
|
||||
echo 'mkbook "shared"' >> "$CMD_FILE"
|
||||
|
||||
@@ -17,6 +17,7 @@ export default function stateToWhenClauseContext(state: AppState, options: WhenC
|
||||
markdownEditorPaneVisible: state.settings['editor.codeView'] && state.noteVisiblePanes.includes('editor'),
|
||||
markdownViewerPaneVisible: state.settings['editor.codeView'] && state.noteVisiblePanes.includes('viewer'),
|
||||
modalDialogVisible: !!Object.keys(state.visibleDialogs).length,
|
||||
gotoAnythingVisible: !!state.visibleDialogs['gotoAnything'],
|
||||
sidebarVisible: !!state.mainLayout && layoutItemProp(state.mainLayout, 'sideBar', 'visible'),
|
||||
noteListHasNotes: !!state.notes.length,
|
||||
|
||||
|
||||
64
packages/app-desktop/services/plugins/BackOffHandler.ts
Normal file
64
packages/app-desktop/services/plugins/BackOffHandler.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import Logger from '@joplin/lib/Logger';
|
||||
import time from '@joplin/lib/time';
|
||||
|
||||
const logger = Logger.create('BackOffHandler');
|
||||
|
||||
// This handler performs two checks:
|
||||
//
|
||||
// 1. If the plugin makes many API calls one after the other, a delay is going
|
||||
// to be applied before responding. The delay is set using backOffIntervals_.
|
||||
// When a plugin needs to be throttled that way a warning is displayed so
|
||||
// that the author gets an opportunity to fix it.
|
||||
//
|
||||
// 2. If the plugin makes many simultaneous calls (over 100), the handler throws
|
||||
// an exception to stop the plugin. In that case the plugin will be broken,
|
||||
// but most plugins will not get this error anyway because call are usually
|
||||
// made in sequence. It might reveal a bug though - for example if the plugin
|
||||
// makes a call every 1 second, but does not wait for the response (or assume
|
||||
// the response will come in less than one second). In that case, the back
|
||||
// off intervals combined with the incorrect code will make the plugin fail.
|
||||
|
||||
export default class BackOffHandler {
|
||||
|
||||
private backOffIntervals_ = Array(100).fill(0).concat([0, 1, 1, 2, 3, 5, 8]);
|
||||
private lastRequestTime_ = 0;
|
||||
private pluginId_: string;
|
||||
private resetBackOffInterval_ = (this.backOffIntervals_[this.backOffIntervals_.length - 1] + 1) * 1000;
|
||||
private backOffIndex_ = 0;
|
||||
private waitCount_ = 0;
|
||||
private maxWaitCount_ = 100;
|
||||
|
||||
public constructor(pluginId: string) {
|
||||
this.pluginId_ = pluginId;
|
||||
}
|
||||
|
||||
private backOffInterval() {
|
||||
const now = Date.now();
|
||||
|
||||
if (now - this.lastRequestTime_ > this.resetBackOffInterval_) {
|
||||
this.backOffIndex_ = 0;
|
||||
} else {
|
||||
this.backOffIndex_++;
|
||||
}
|
||||
|
||||
this.lastRequestTime_ = now;
|
||||
const effectiveIndex = this.backOffIndex_ >= this.backOffIntervals_.length ? this.backOffIntervals_.length - 1 : this.backOffIndex_;
|
||||
return this.backOffIntervals_[effectiveIndex];
|
||||
}
|
||||
|
||||
public async wait(path: string, args: any) {
|
||||
const interval = this.backOffInterval();
|
||||
if (!interval) return;
|
||||
|
||||
this.waitCount_++;
|
||||
|
||||
logger.warn(`Plugin ${this.pluginId_}: Applying a backoff of ${interval} seconds due to frequent plugin API calls. Consider reducing the number of calls, caching the data, or requesting more data per call. API call was: `, path, args, `[Wait count: ${this.waitCount_}]`);
|
||||
|
||||
if (this.waitCount_ > this.maxWaitCount_) throw new Error(`Plugin ${this.pluginId_}: More than ${this.maxWaitCount_} API alls are waiting - aborting. Please consider queuing the API calls in your plugins to reduce the load on the application.`);
|
||||
|
||||
await time.sleep(interval);
|
||||
|
||||
this.waitCount_--;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import Setting from '@joplin/lib/models/Setting';
|
||||
import { EventHandlers } from '@joplin/lib/services/plugins/utils/mapEventHandlersToIds';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import Logger from '@joplin/lib/Logger';
|
||||
import BackOffHandler from './BackOffHandler';
|
||||
const ipcRenderer = require('electron').ipcRenderer;
|
||||
|
||||
const logger = Logger.create('PluginRunner');
|
||||
@@ -83,8 +84,9 @@ function mapEventIdsToHandlers(pluginId: string, arg: any) {
|
||||
export default class PluginRunner extends BasePluginRunner {
|
||||
|
||||
protected eventHandlers_: EventHandlers = {};
|
||||
private backOffHandlers_: Record<string, BackOffHandler> = {};
|
||||
|
||||
constructor() {
|
||||
public constructor() {
|
||||
super();
|
||||
|
||||
this.eventHandler = this.eventHandler.bind(this);
|
||||
@@ -95,7 +97,14 @@ export default class PluginRunner extends BasePluginRunner {
|
||||
return cb(...args);
|
||||
}
|
||||
|
||||
async run(plugin: Plugin, pluginApi: Global) {
|
||||
private backOffHandler(pluginId: string): BackOffHandler {
|
||||
if (!this.backOffHandlers_[pluginId]) {
|
||||
this.backOffHandlers_[pluginId] = new BackOffHandler(pluginId);
|
||||
}
|
||||
return this.backOffHandlers_[pluginId];
|
||||
}
|
||||
|
||||
public async run(plugin: Plugin, pluginApi: Global) {
|
||||
const scriptPath = `${Setting.value('tempDir')}/plugin_${plugin.id}.js`;
|
||||
await shim.fsDriver().writeFile(scriptPath, plugin.scriptText, 'utf8');
|
||||
|
||||
@@ -111,7 +120,7 @@ export default class PluginRunner extends BasePluginRunner {
|
||||
|
||||
bridge().electronApp().registerPluginWindow(plugin.id, pluginWindow);
|
||||
|
||||
pluginWindow.loadURL(`${require('url').format({
|
||||
void pluginWindow.loadURL(`${require('url').format({
|
||||
pathname: require('path').join(__dirname, 'plugin_index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true,
|
||||
@@ -148,6 +157,13 @@ export default class PluginRunner extends BasePluginRunner {
|
||||
const debugMappedArgs = fullPath.includes('setHtml') ? '<hidden>' : mappedArgs;
|
||||
logger.debug(`Got message (3): ${fullPath}`, debugMappedArgs);
|
||||
|
||||
try {
|
||||
await this.backOffHandler(plugin.id).wait(fullPath, debugMappedArgs);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
return;
|
||||
}
|
||||
|
||||
let result: any = null;
|
||||
let error: any = null;
|
||||
try {
|
||||
|
||||
@@ -3,8 +3,62 @@ const glob = require('glob');
|
||||
const { resolve } = require('path');
|
||||
const { dirname } = require('@joplin/tools/gulp/utils');
|
||||
|
||||
const rootDir = resolve(__dirname, '../../..');
|
||||
const nodeModulesDir = resolve(__dirname, '../node_modules');
|
||||
|
||||
function stripOffRootDir(path) {
|
||||
if (path.startsWith(rootDir)) return path.substr(rootDir.length + 1);
|
||||
return path;
|
||||
}
|
||||
|
||||
const msleep = async (ms) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, ms);
|
||||
});
|
||||
};
|
||||
|
||||
// Running this script on CI is very unreliable. It fails with errors that don't
|
||||
// make much sense, such as:
|
||||
//
|
||||
// [Error: ENOENT: no such file or directory, copyfile
|
||||
// '/home/runner/work/joplin/joplin/Assets/TinyMCE/langs/ro_RO.js' ->
|
||||
// '/home/runner/work/joplin/joplin/packages/app-desktop/vendor/lib/tinymce/langs/ro_RO.js']
|
||||
//
|
||||
// (but "Assets/TinyMCE/langs/ro_RO.js" exists, since it's in the repo, and it's
|
||||
// normal that "tinymce/langs/ro_RO.js" doesn't exist since we want to create
|
||||
// it...)
|
||||
//
|
||||
// Another one, when trying to delete a directory:
|
||||
//
|
||||
// ENOTEMPTY: directory not empty
|
||||
//
|
||||
// (also makes no sense since the point of calling `remove()` is to remove a
|
||||
// directory that is not empty)
|
||||
//
|
||||
// Those errors are random - they may or may not happen on a CI run, and always
|
||||
// on different files. Since they don't make sense and are seemingly impossible
|
||||
// to fix, we instead implement a retry mechanism with exponential backoff. The
|
||||
// failures are relatively rare so 5 attempts should be enough to ensure all CI
|
||||
// runs succeed.
|
||||
//
|
||||
// It's possible the same technique should be added to copyPluginAssets too.
|
||||
|
||||
const withRetry = async (fn) => {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
try {
|
||||
await fn();
|
||||
return;
|
||||
} catch (error) {
|
||||
console.warn(`withRetry: Failed calling function - will retry (${i})`, error);
|
||||
await msleep(1000 + i * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('withRetry: Could not run function after multiple attempts');
|
||||
};
|
||||
|
||||
async function main() {
|
||||
const langSourceDir = resolve(__dirname, '../../../Assets/TinyMCE/langs');
|
||||
const buildLibDir = resolve(__dirname, '../vendor/lib');
|
||||
@@ -50,11 +104,11 @@ async function main() {
|
||||
}
|
||||
|
||||
if (action === 'delete') {
|
||||
await remove(destDir);
|
||||
await withRetry(() => remove(destDir));
|
||||
} else {
|
||||
console.info(`Copying ${sourceDir} => ${destDir}`);
|
||||
await mkdirp(destDir);
|
||||
await copy(sourceDir, destDir, { overwrite: true });
|
||||
console.info(`Copying ${stripOffRootDir(sourceDir)} => ${stripOffRootDir(destDir)}`);
|
||||
await withRetry(() => mkdirp(destDir));
|
||||
await withRetry(() => copy(sourceDir, destDir, { overwrite: true }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,10 +124,10 @@ async function main() {
|
||||
destFile = `${buildLibDir}/${file}`;
|
||||
}
|
||||
|
||||
await mkdirp(dirname(destFile));
|
||||
await withRetry(() => mkdirp(dirname(destFile)));
|
||||
|
||||
console.info(`Copying ${sourceFile} => ${destFile}`);
|
||||
await copy(sourceFile, destFile, { overwrite: true });
|
||||
console.info(`Copying ${stripOffRootDir(sourceFile)} => ${stripOffRootDir(destFile)}`);
|
||||
await withRetry(() => copy(sourceFile, destFile, { overwrite: true }));
|
||||
}
|
||||
|
||||
const supportedLocales = glob.sync(`${langSourceDir}/*.js`).map(s => {
|
||||
|
||||
@@ -1,4 +1,28 @@
|
||||
const utils = require('@joplin/tools/gulp/utils');
|
||||
const { copy, mkdirp, remove } = require('fs-extra');
|
||||
|
||||
const msleep = async (ms) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, ms);
|
||||
});
|
||||
};
|
||||
|
||||
// Same as copyApplicationAssets - probably both scripts should be merged in
|
||||
// one.
|
||||
const withRetry = async (fn) => {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
try {
|
||||
await fn();
|
||||
return;
|
||||
} catch (error) {
|
||||
console.warn(`withRetry: Failed calling function - will retry (${i})`, error);
|
||||
await msleep(1000 + i * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('withRetry: Could not run function after multiple attempts');
|
||||
};
|
||||
|
||||
async function main() {
|
||||
const rootDir = `${__dirname}/..`;
|
||||
@@ -9,9 +33,16 @@ async function main() {
|
||||
`${rootDir}/pluginAssets`,
|
||||
];
|
||||
|
||||
for (const destDir of destDirs) {
|
||||
console.info(`Copying to ${destDir}`);
|
||||
await utils.copyDir(sourceDir, destDir);
|
||||
for (const action of ['delete', 'copy']) {
|
||||
for (const destDir of destDirs) {
|
||||
if (action === 'delete') {
|
||||
await withRetry(() => remove(destDir));
|
||||
} else {
|
||||
console.info(`Copying to ${destDir}`);
|
||||
await withRetry(() => mkdirp(destDir));
|
||||
await withRetry(() => copy(sourceDir, destDir, { overwrite: true }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
packages/app-desktop/vendor/loadEmojiLib.js
vendored
Normal file
2
packages/app-desktop/vendor/loadEmojiLib.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { EmojiButton } from './lib/@joeattardi/emoji-button/dist/index.js';
|
||||
window.EmojiButton = EmojiButton;
|
||||
@@ -1,5 +1,3 @@
|
||||
export { ModelType } from '../../../BaseModel';
|
||||
|
||||
// =================================================================
|
||||
// Command API types
|
||||
// =================================================================
|
||||
@@ -204,6 +202,25 @@ export interface Disposable {
|
||||
// dispose():void;
|
||||
}
|
||||
|
||||
export enum ModelType {
|
||||
Note = 1,
|
||||
Folder = 2,
|
||||
Setting = 3,
|
||||
Resource = 4,
|
||||
Tag = 5,
|
||||
NoteTag = 6,
|
||||
Search = 7,
|
||||
Alarm = 8,
|
||||
MasterKey = 9,
|
||||
ItemChange = 10,
|
||||
NoteResource = 11,
|
||||
ResourceLocalState = 12,
|
||||
Revision = 13,
|
||||
Migration = 14,
|
||||
SmartFilter = 15,
|
||||
Command = 16,
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Menu types
|
||||
// =================================================================
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
"keywords": [
|
||||
"joplin-plugin"
|
||||
],
|
||||
"files": [
|
||||
"publish"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.14",
|
||||
"chalk": "^4.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "generator-joplin",
|
||||
"version": "2.7.2",
|
||||
"version": "2.7.3",
|
||||
"description": "Scaffolds out a new Joplin plugin",
|
||||
"homepage": "https://github.com/laurent22/joplin/tree/dev/packages/generator-joplin",
|
||||
"author": {
|
||||
@@ -34,4 +34,4 @@
|
||||
"repository": "https://github.com/laurent22/generator-joplin",
|
||||
"license": "MIT",
|
||||
"private": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
git pull
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
echo "There are changes in the repo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
CLI_DIR="$SCRIPT_DIR/../app-cli"
|
||||
LIB_DIR="$SCRIPT_DIR/../lib"
|
||||
@@ -19,11 +12,3 @@ rsync -a --delete "$LIB_DIR/plugin_types/services/plugins/api/" "$SCRIPT_DIR/gen
|
||||
cp "$LIB_DIR/services/plugins/api/types.ts" "$SCRIPT_DIR/generators/app/templates/api/"
|
||||
cp "$SCRIPT_DIR/generators/app/templates/api_index.ts" "$SCRIPT_DIR/generators/app/templates/api/index.ts"
|
||||
rm -f "$SCRIPT_DIR/generators/app/templates/api/types.d.ts"
|
||||
|
||||
yarn link
|
||||
|
||||
"$CLI_DIR/tests/support/plugins/updatePlugins.sh"
|
||||
|
||||
git add -A
|
||||
git c -m "Plugins: Updated types"
|
||||
git push
|
||||
|
||||
22
packages/generator-joplin/updateTypesAndDemos.sh
Executable file
22
packages/generator-joplin/updateTypesAndDemos.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
git pull
|
||||
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
echo "There are changes in the repo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
CLI_DIR="$SCRIPT_DIR/../app-cli"
|
||||
LIB_DIR="$SCRIPT_DIR/../lib"
|
||||
|
||||
./updateTypes.sh
|
||||
|
||||
yarn link
|
||||
|
||||
"$CLI_DIR/tests/support/plugins/updatePlugins.sh"
|
||||
|
||||
git add -A
|
||||
git c -m "Plugins: Updated types"
|
||||
git push
|
||||
@@ -98,14 +98,14 @@ class SyncTargetAmazonS3 extends BaseSyncTarget {
|
||||
// We could implement that here, but the above workaround saves some code.
|
||||
|
||||
static async checkConfig(options) {
|
||||
const fileApi = await SyncTargetAmazonS3.newFileApi_(SyncTargetAmazonS3.id(), options);
|
||||
fileApi.requestRepeatCount_ = 0;
|
||||
|
||||
const output = {
|
||||
ok: false,
|
||||
errorMessage: '',
|
||||
};
|
||||
try {
|
||||
const fileApi = await SyncTargetAmazonS3.newFileApi_(SyncTargetAmazonS3.id(), options);
|
||||
fileApi.requestRepeatCount_ = 0;
|
||||
|
||||
const headBucketReq = new Promise((resolve, reject) => {
|
||||
fileApi.driver().api().send(
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export const runtime = (): CommandRuntime => {
|
||||
return 'auth';
|
||||
}
|
||||
|
||||
reg.logger().info('Not authentified with sync target - please check your credential.');
|
||||
reg.logger().error('Not authenticated with sync target - please check your credentials.');
|
||||
return 'error';
|
||||
}
|
||||
|
||||
@@ -43,8 +43,13 @@ export const runtime = (): CommandRuntime => {
|
||||
try {
|
||||
sync = await reg.syncTarget().synchronizer();
|
||||
} catch (error) {
|
||||
reg.logger().info('Could not acquire synchroniser:');
|
||||
reg.logger().info(error);
|
||||
reg.logger().error('Could not initialise synchroniser: ');
|
||||
reg.logger().error(error);
|
||||
error.message = `Could not initialise synchroniser: ${error.message}`;
|
||||
utils.store.dispatch({
|
||||
type: 'SYNC_REPORT_UPDATE',
|
||||
report: { errors: [error] },
|
||||
});
|
||||
return 'error';
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ shared.toggleIsTodo_onPress = function(comp) {
|
||||
comp.setState(newState);
|
||||
};
|
||||
|
||||
shared.toggleCheckbox = function(ipcMessage, noteBody) {
|
||||
function toggleCheckboxLine(ipcMessage, noteBody) {
|
||||
const newBody = noteBody.split('\n');
|
||||
const p = ipcMessage.split(':');
|
||||
const lineIndex = Number(p[p.length - 1]);
|
||||
@@ -281,7 +281,18 @@ shared.toggleCheckbox = function(ipcMessage, noteBody) {
|
||||
} else {
|
||||
line = line.replace(/- \[x\] /i, '- [ ] ');
|
||||
}
|
||||
return [newBody, lineIndex, line];
|
||||
}
|
||||
|
||||
shared.toggleCheckboxRange = function(ipcMessage, noteBody) {
|
||||
const [lineIndex, line] = toggleCheckboxLine(ipcMessage, noteBody).slice(1);
|
||||
const from = { line: lineIndex, ch: 0 };
|
||||
const to = { line: lineIndex, ch: line.length };
|
||||
return { line, from, to };
|
||||
};
|
||||
|
||||
shared.toggleCheckbox = function(ipcMessage, noteBody) {
|
||||
const [newBody, lineIndex, line] = toggleCheckboxLine(ipcMessage, noteBody);
|
||||
newBody[lineIndex] = line;
|
||||
return newBody.join('\n');
|
||||
};
|
||||
|
||||
@@ -105,7 +105,7 @@ shared.synchronize_press = async function(comp) {
|
||||
return 'auth';
|
||||
}
|
||||
|
||||
reg.logger().info('Not authentified with sync target - please check your credential.');
|
||||
reg.logger().error('Not authenticated with sync target - please check your credentials.');
|
||||
return 'error';
|
||||
}
|
||||
|
||||
@@ -113,8 +113,13 @@ shared.synchronize_press = async function(comp) {
|
||||
try {
|
||||
sync = await reg.syncTarget().synchronizer();
|
||||
} catch (error) {
|
||||
reg.logger().info('Could not acquire synchroniser:');
|
||||
reg.logger().info(error);
|
||||
reg.logger().error('Could not initialise synchroniser: ');
|
||||
reg.logger().error(error);
|
||||
error.message = `Could not initialise synchroniser: ${error.message}`;
|
||||
comp.props.dispatch({
|
||||
type: 'SYNC_REPORT_UPDATE',
|
||||
report: { errors: [error] },
|
||||
});
|
||||
return 'error';
|
||||
}
|
||||
|
||||
|
||||
@@ -1190,7 +1190,7 @@ class Setting extends BaseModel {
|
||||
},
|
||||
|
||||
|
||||
autoUpdateEnabled: { value: true, type: SettingItemType.Bool, storage: SettingStorage.File, section: 'application', public: platform !== 'linux', appTypes: [AppType.Desktop], label: () => _('Automatically update the application') },
|
||||
autoUpdateEnabled: { value: true, type: SettingItemType.Bool, storage: SettingStorage.File, section: 'application', public: platform !== 'linux', appTypes: [AppType.Desktop], label: () => _('Automatically check for updates') },
|
||||
'autoUpdate.includePreReleases': { value: false, type: SettingItemType.Bool, section: 'application', storage: SettingStorage.File, public: true, appTypes: [AppType.Desktop], label: () => _('Get pre-releases when checking for updates'), description: () => _('See the pre-release page for more details: %s', 'https://joplinapp.org/prereleases') },
|
||||
'clipperServer.autoStart': { value: false, type: SettingItemType.Bool, storage: SettingStorage.File, public: false },
|
||||
'sync.interval': {
|
||||
|
||||
@@ -89,6 +89,7 @@ export default class OneDriveApi {
|
||||
scope: 'files.readwrite offline_access sites.readwrite.all',
|
||||
response_type: 'code',
|
||||
redirect_uri: redirectUri,
|
||||
prompt: 'login',
|
||||
};
|
||||
return `https://login.microsoftonline.com/common/oauth2/v2.0/authorize?${stringify(query)}`;
|
||||
}
|
||||
|
||||
@@ -163,6 +163,7 @@ describe('services_CommandService', function() {
|
||||
it('should create menu items from commands', (async () => {
|
||||
const service = newService();
|
||||
const utils = new MenuUtils(service);
|
||||
const locale = 'fr_FR';
|
||||
|
||||
registerCommand(service, createCommand('test1', {
|
||||
execute: () => {},
|
||||
@@ -178,7 +179,7 @@ describe('services_CommandService', function() {
|
||||
clickedCommands.push(commandName);
|
||||
};
|
||||
|
||||
const menuItems = utils.commandsToMenuItems(['test1', 'test2'], onClick);
|
||||
const menuItems = utils.commandsToMenuItems(['test1', 'test2'], onClick, locale);
|
||||
|
||||
menuItems.test1.click();
|
||||
menuItems.test2.click();
|
||||
@@ -186,7 +187,10 @@ describe('services_CommandService', function() {
|
||||
expect(clickedCommands.join('_')).toBe('test1_test2');
|
||||
|
||||
// Also check that the same commands always return strictly the same menu
|
||||
expect(utils.commandsToMenuItems(['test1', 'test2'], onClick)).toBe(utils.commandsToMenuItems(['test1', 'test2'], onClick));
|
||||
expect(utils.commandsToMenuItems(['test1', 'test2'], onClick, locale)).toBe(utils.commandsToMenuItems(['test1', 'test2'], onClick, locale));
|
||||
|
||||
// And check that if the locale changes, new menu items are returned
|
||||
expect(utils.commandsToMenuItems(['test1', 'test2'], onClick, locale)).not.toBe(utils.commandsToMenuItems(['test1', 'test2'], onClick, 'en_GB'));
|
||||
}));
|
||||
|
||||
it('should give menu item props from state', (async () => {
|
||||
|
||||
@@ -97,8 +97,8 @@ export default class MenuUtils {
|
||||
});
|
||||
}
|
||||
|
||||
public commandsToMenuItems(commandNames: string[], onClick: Function): MenuItems {
|
||||
const key: string = `${this.keymapService.lastSaveTime}_${commandNames.join('_')}`;
|
||||
public commandsToMenuItems(commandNames: string[], onClick: Function, locale: string): MenuItems {
|
||||
const key: string = `${this.keymapService.lastSaveTime}_${commandNames.join('_')}_${locale}`;
|
||||
if (this.menuItemCache_[key]) return this.menuItemCache_[key];
|
||||
|
||||
const output: MenuItems = {};
|
||||
@@ -107,7 +107,9 @@ export default class MenuUtils {
|
||||
output[commandName] = this.commandToMenuItem(commandName, onClick);
|
||||
}
|
||||
|
||||
this.menuItemCache_[key] = output;
|
||||
this.menuItemCache_ = {
|
||||
[key]: output,
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Command } from './types';
|
||||
*
|
||||
* * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
|
||||
* * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
|
||||
* * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
|
||||
* * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.ts)
|
||||
*
|
||||
* To view what arguments are supported, you can open any of these files
|
||||
* and look at the `execute()` command.
|
||||
|
||||
@@ -38,8 +38,13 @@ interface SyncStartEvent {
|
||||
withErrors: boolean;
|
||||
}
|
||||
|
||||
interface ResourceChangeEvent {
|
||||
id: string;
|
||||
}
|
||||
|
||||
type ItemChangeHandler = (event: ItemChangeEvent)=> void;
|
||||
type SyncStartHandler = (event: SyncStartEvent)=> void;
|
||||
type ResourceChangeHandler = (event: ResourceChangeEvent)=> void;
|
||||
|
||||
/**
|
||||
* The workspace service provides access to all the parts of Joplin that
|
||||
@@ -54,7 +59,7 @@ export default class JoplinWorkspace {
|
||||
|
||||
private store: any;
|
||||
|
||||
constructor(store: any) {
|
||||
public constructor(store: any) {
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
@@ -98,6 +103,14 @@ export default class JoplinWorkspace {
|
||||
return makeListener(eventManager, 'itemChange', wrapperHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a resource is changed. Currently this handled will not be
|
||||
* called when a resource is added or deleted.
|
||||
*/
|
||||
public async onResourceChange(handler: ResourceChangeHandler): Promise<void> {
|
||||
makeListener(eventManager, 'resourceChange', handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
|
||||
@@ -297,7 +297,7 @@ export interface MenuItem {
|
||||
/**
|
||||
* Set to "separator" to create a divider line
|
||||
*/
|
||||
type?: string;
|
||||
type?: ('normal' | 'separator' | 'submenu' | 'checkbox' | 'radio');
|
||||
|
||||
/**
|
||||
* Accelerator associated with the menu item
|
||||
|
||||
@@ -15,7 +15,6 @@ const input: Theme = {
|
||||
colorWarn: 'rgb(228,86,0)',
|
||||
colorWarnUrl: '#155BDA',
|
||||
colorFaded: '#7C8B9E', // For less important text
|
||||
colorBright: '#000000', // For important text
|
||||
dividerColor: '#dddddd',
|
||||
selectedColor: '#e5e5e5',
|
||||
urlColor: '#155BDA',
|
||||
@@ -69,7 +68,6 @@ const expected = `
|
||||
--joplin-color-warn: rgb(228,86,0);
|
||||
--joplin-color-warn-url: #155BDA;
|
||||
--joplin-color-faded: #7C8B9E;
|
||||
--joplin-color-bright: #000000;
|
||||
--joplin-divider-color: #dddddd;
|
||||
--joplin-selected-color: #e5e5e5;
|
||||
--joplin-url-color: #155BDA;
|
||||
|
||||
@@ -227,6 +227,7 @@ function addExtraStyles(style: any) {
|
||||
justifyContent: 'center',
|
||||
marginRight: 8,
|
||||
borderRadius: 100,
|
||||
borderWidth: 0,
|
||||
};
|
||||
|
||||
style.toolbarStyle = {
|
||||
|
||||
@@ -11,7 +11,6 @@ const theme: Theme = {
|
||||
colorError: '#9a2f2f',
|
||||
colorWarn: '#d66500',
|
||||
colorFaded: '#666a73', // For less important text (e.g. not selected menu in settings)
|
||||
colorBright: '#d3dae3', // For important text; (e.g. bold)
|
||||
dividerColor: '#141a21', // Borders, I wish I could remove them
|
||||
selectedColor: '#2b5278', // Selected note
|
||||
urlColor: '#356693', // Links to external sites (e.g. in settings)
|
||||
|
||||
@@ -18,7 +18,6 @@ const theme: Theme = {
|
||||
colorWarn: '#9A5B00',
|
||||
colorWarnUrl: '#ffff82',
|
||||
colorFaded: '#999999', // For less important text
|
||||
colorBright: '#ffffff', // For important text
|
||||
dividerColor: '#555555',
|
||||
selectedColor: '#616161',
|
||||
urlColor: 'rgb(166,166,255)',
|
||||
|
||||
@@ -11,7 +11,6 @@ const theme: Theme = {
|
||||
colorError: '#ff5555',
|
||||
colorWarn: '#ffb86c',
|
||||
colorFaded: '#6272a4', // For less important text;
|
||||
colorBright: '#50fa7b', // For important text;
|
||||
dividerColor: '#bd93f9',
|
||||
selectedColor: '#44475a',
|
||||
urlColor: '#8be9fd',
|
||||
|
||||
@@ -15,7 +15,6 @@ const theme: Theme = {
|
||||
colorWarn: 'rgb(228,86,0)',
|
||||
colorWarnUrl: '#155BDA',
|
||||
colorFaded: '#7C8B9E', // For less important text
|
||||
colorBright: '#000000', // For important text
|
||||
dividerColor: '#dddddd',
|
||||
selectedColor: '#e5e5e5',
|
||||
urlColor: '#155BDA',
|
||||
|
||||
@@ -57,7 +57,6 @@ const theme: Theme = {
|
||||
colorError: nord[11],
|
||||
colorWarn: nord[12],
|
||||
colorFaded: nord[4], // For less important text;
|
||||
colorBright: nord[6], // For important text;
|
||||
dividerColor: nord[10],
|
||||
selectedColor: nord[9],
|
||||
urlColor: nord[8],
|
||||
|
||||
@@ -16,7 +16,6 @@ const theme: Theme = {
|
||||
codeBackgroundColor: 'rgb(47, 48, 49)',
|
||||
codeBorderColor: 'rgb(70, 70, 70)',
|
||||
codeThemeCss: 'atom-one-dark-reasonable.css',
|
||||
colorBright: 'rgb(220,220,220)',
|
||||
};
|
||||
|
||||
export default theme;
|
||||
|
||||
@@ -11,7 +11,6 @@ const theme: Theme = {
|
||||
colorError: '#dc322f',
|
||||
colorWarn: '#cb4b16',
|
||||
colorFaded: '#657b83', // For less important text;
|
||||
colorBright: '#eee8d5', // For important text;
|
||||
dividerColor: '#586e75',
|
||||
selectedColor: '#073642',
|
||||
urlColor: '#268bd2',
|
||||
|
||||
@@ -11,7 +11,6 @@ const theme: Theme = {
|
||||
colorError: '#dc322f',
|
||||
colorWarn: '#cb4b16',
|
||||
colorFaded: '#839496', // For less important text;
|
||||
colorBright: '#073642', // For important text;
|
||||
dividerColor: '#eee8d5',
|
||||
selectedColor: '#eee8d5',
|
||||
urlColor: '#268bd2',
|
||||
|
||||
@@ -17,7 +17,6 @@ export interface Theme {
|
||||
colorWarn: string;
|
||||
colorWarnUrl: string; // For URL displayed over a warningBackgroundColor
|
||||
colorFaded: string; // For less important text
|
||||
colorBright: string; // For important text
|
||||
dividerColor: string;
|
||||
selectedColor: string;
|
||||
urlColor: string;
|
||||
|
||||
@@ -51,6 +51,8 @@ async function extractPluginFilesFromPackage(existingManifests: any, workDir: st
|
||||
|
||||
const pluginDir = resolveRelativePathWithinDir(workDir, 'node_modules', packageName, 'publish');
|
||||
|
||||
if (!(await fs.pathExists(pluginDir))) throw new Error(`Could not find publish directory at ${pluginDir}`);
|
||||
|
||||
const files = await fs.readdir(pluginDir);
|
||||
const manifestFilePath = path.resolve(pluginDir, files.find((f: any) => path.extname(f) === '.json'));
|
||||
const pluginFilePath = path.resolve(pluginDir, files.find((f: any) => path.extname(f) === '.jpl'));
|
||||
|
||||
@@ -4,7 +4,6 @@ module.exports = {
|
||||
lineHeight: '1.6em',
|
||||
backgroundColor: 'white',
|
||||
paddingBottom: 3,
|
||||
colorBright: '#000000', // For important text
|
||||
codeBorderColor: 'rgb(220, 220, 220)',
|
||||
codeBackgroundColor: 'rgb(243, 243, 243)',
|
||||
dividerColor: 'rgb(230,230,230)',
|
||||
|
||||
@@ -49,9 +49,6 @@ export default function(theme: any, options: Options = null) {
|
||||
padding-bottom: ${formatCssSize(theme.bodyPaddingBottom)};
|
||||
padding-top: ${formatCssSize(theme.bodyPaddingTop)};
|
||||
}
|
||||
strong {
|
||||
color: ${theme.colorBright};
|
||||
}
|
||||
kbd {
|
||||
border: 1px solid ${theme.codeBorderColor};
|
||||
box-shadow: inset 0 -1px 0 ${theme.codeBorderColor};
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
Copyright (c) 2017-2021 Laurent Cozic
|
||||
|
||||
Personal Use License
|
||||
|
||||
Joplin Server is available for personal use only. For example you may host the software on your own server for non-commercial activity.
|
||||
|
||||
To obtain a license for commercial purposes, please contact us.
|
||||
282
packages/server/LICENSE.md
Normal file
282
packages/server/LICENSE.md
Normal file
@@ -0,0 +1,282 @@
|
||||
**JOPLIN SERVER PERSONAL USE LICENSE**
|
||||
|
||||
v.1: 21 December 2021
|
||||
|
||||
This Joplin Server Personal Use License (the "**License**") is a legally binding
|
||||
agreement between Cozic Ltd. registered under the laws of England and Wales
|
||||
(the "**Licensor**"), the owner of the server entitled ‘Joplin Server,’ the
|
||||
related software applications, and services (collectively, the "**Software**")
|
||||
and an individual user accessing the Software (the "**Licensee**") (each
|
||||
individually a "**Party**" and collectively, the "**Parties**").
|
||||
|
||||
# 1. Acceptance of the License
|
||||
|
||||
* **1.1** By accessing or otherwise using the Software, the Licensee confirms
|
||||
that the Licensee has read the License, accepts the terms of the License, and
|
||||
agrees to become legally bound by the License.
|
||||
|
||||
* **1.2** If the Licensee is entering into the License on behalf of a legal
|
||||
entity, the Licensee represents that the Licensee has the authority and the
|
||||
necessary capacity to bind such entity and its affiliates to the terms of the
|
||||
License.
|
||||
|
||||
* **1.3** If the Licensee does not have the authority specified in section 1.2
|
||||
or if the Licensee does not agree with one or more provisions of the License,
|
||||
the Licensee is not allowed to access the Software and the Licensee must not
|
||||
accept the License.
|
||||
|
||||
* **1.4** By using the Software, the Licensee acknowledges, agrees, and warrants
|
||||
that the Licensee:
|
||||
|
||||
* i. Shall comply with the terms of the License and all applicable local,
|
||||
state, national and foreign laws, treaties, and regulations;
|
||||
|
||||
* ii. Shall provide only true, accurate, complete, and up-to-date
|
||||
information; and
|
||||
|
||||
* iii. Has the capacity to conclude legally binding contracts with the
|
||||
Licensor.
|
||||
|
||||
# 2. Grant of RIGHTS
|
||||
|
||||
* **2.1** The Licensor hereby grants the Licensee a worldwide, non-exclusive,
|
||||
royalty free, and revocable license to access and use the Software in
|
||||
accordance with the terms of this License and the applicable laws.
|
||||
|
||||
* **2.2** Subject to the terms of the License, the Licensee is entitled to
|
||||
access and use the Software for non-commercial purposes for taking personal
|
||||
and professional notes, sharing notes with other users of the Software, and
|
||||
synchronising data.
|
||||
|
||||
* **2.3** Unless authorised by the Licensor in writing, the Software may be used
|
||||
for personal non-commercial purposes only. The Licensee is allowed to grant
|
||||
access to the Software to others for non-commercial purposes, provided that
|
||||
(i) the Licensee is not a business entity, (ii) the Licensee or the third
|
||||
party to which the access is granted does not use the Software to generate
|
||||
profits of any kind, and (iii) the Software is used for non-commercial
|
||||
purposes only. The Licensee is not allowed to: (i) use the Software for
|
||||
commercial purposes and (ii) grant others the right to use the Software for a
|
||||
fee or for any commercial purposes, including, without limitation, copying,
|
||||
reproducing, publishing, transmitting, transferring, selling, renting,
|
||||
modifying, creating derivative works from, distributing, reposting,
|
||||
performing, displaying, or in any other way commercially exploiting the
|
||||
Software without prior written authorisation from the Licensor. By way of
|
||||
illustration, the Licensee is not allowed to:
|
||||
|
||||
1. Install the Software on Licensee’s infrastructure and charge others for
|
||||
the use of the Software;
|
||||
|
||||
2. Install the Software behind a proxy and charge others for the use of the
|
||||
Software;
|
||||
|
||||
3. Install the Software on a Licensee’s or third party’s server and provide
|
||||
access to the Software to third parties (a) for a fee or (b) free of
|
||||
charge, if the said third parties may use the Software for commercial
|
||||
purposes;
|
||||
|
||||
4. Grant access to the Software to others for a fee or for any commercial
|
||||
purposes;
|
||||
|
||||
5. Grant access to the Software to others for a fee or free of charge if
|
||||
the Licensee is a legal or natural person engaged in commercial
|
||||
activities; or
|
||||
|
||||
6. Use the Software or grant other the right to use the Software in a way
|
||||
that generates income or commercial profits.
|
||||
|
||||
* **2.4** This License does not govern any commercial use of the Software, as
|
||||
authorised by the Licensor.
|
||||
|
||||
* **2.5** The Software is licensed and not sold. By accepting the License, the
|
||||
Licensee obtains the right to use the Software and not the ownership of the
|
||||
Software.
|
||||
|
||||
* **2.6** The Licensor reserves any rights not expressly granted to the
|
||||
Licensee under this License.
|
||||
|
||||
* **2.7** The Licensee is allowed to make a reasonable number of copies of the
|
||||
Software, as and if necessary for the purposes set forth herein, provided that
|
||||
only complete copies of the Software are made, including without limitation
|
||||
all ‘read me’ files, copyright notices, and other legal notices and terms
|
||||
included in the Software.
|
||||
|
||||
* **2.8** The Licensee is permitted to load and run the Software on any device,
|
||||
network or cloud virtual machines under Licensee’s control (collectively, the
|
||||
"**Devices**"), if such Devices are compatible with the Software. The Licensee
|
||||
is solely responsible for assessing the compatibility of the Devices to be
|
||||
used with the Software.
|
||||
|
||||
* **2.9** It is Licensee’s sole responsibility to verify and assess the
|
||||
suitability, validity and integrity of the Software prior to using it and to
|
||||
decide whether or not the Software fits for the intended use.
|
||||
|
||||
* **2.10** The Licensor reserves the right to grant the right to use the
|
||||
Software to third parties.
|
||||
|
||||
* **2.11** The Licensee acknowledges and agrees that any use of the Software
|
||||
that is prohibited by this License may be unlawful and may result in
|
||||
Licensee’s criminal liability.
|
||||
|
||||
# 3. Covered Software and services
|
||||
|
||||
* **3.1** The License applies only to the Software as provided to the Licensee
|
||||
by the Licensor. The License also applies to updates, supplements, and support
|
||||
services related to the Software, or any other services provided in relation
|
||||
to the Software, unless other terms and conditions have been provided thereto.
|
||||
|
||||
* **3.2** Any software or services that are not provided by the Licensor are
|
||||
not covered by this License. Such Software and services are subject to the
|
||||
terms and conditions set by the respective third party and the Licensee is
|
||||
solely responsible for obtaining, agreeing to, and complying with the
|
||||
respective terms and conditions at its own cost and expense.
|
||||
|
||||
* **3.3** The Licensor reserves the right, but is not under any obligation, to
|
||||
provide paid or free-of-charge updates and technical support services with
|
||||
regard to the Software, including fixing bugs and errors, and the possibility
|
||||
to use new versions of the Software.
|
||||
|
||||
# 4. Intellectual property and ownership
|
||||
|
||||
* **4.1** All title and copyright in and to the Software (including, but not
|
||||
limited to, any source code, images, graphics, photographs, animations, video,
|
||||
audio, music, text, and applets, incorporated in the Software) are owned by
|
||||
the Licensor. The Software is protected by the English copyright laws and
|
||||
international treaties. The Licensee is not allowed to incorporate any portion
|
||||
of the Software into other programs or compile any portion of it in
|
||||
combination with other programs, or otherwise copy (except to exercise rights
|
||||
granted in this License), modify, create derivative works of, distribute,
|
||||
assign any rights to, or license the Software in whole or in part.
|
||||
|
||||
* **4.2** The Licensee is not permitted to, without obtaining prior written
|
||||
authorisation from the Licensor, to use the trade names, trademarks, service
|
||||
marks or product names of the Licensor, except as required for the use of the
|
||||
Software.
|
||||
|
||||
* **4.3** The Licensor has made all efforts possible to avoid the Software
|
||||
being subject to the rights of third parties, in particular that its use does
|
||||
not infringe patents, copyrights or other intellectual property rights of
|
||||
third parties. However, the Licensor does not guarantee that the Software is
|
||||
not subject to the rights of third parties. The Licensee agrees to notify the
|
||||
Licensor immediately and in writing if any third party asserts an infringement
|
||||
claim against the Licensee in connection with the Software.
|
||||
|
||||
* **4.4** By submitting any content through the Software (the "Licensee’s
|
||||
Content"), the Licensee grants the Licensor unrestricted, sub-licensable,
|
||||
royalty-free, perpetual, and irrevocable rights to process the Licensee’s
|
||||
Content for the purposes of providing the Licensee with the Software and
|
||||
carrying out Licensor’s legitimate business interests.
|
||||
|
||||
* **4.5** The Licensee is not permitted to remove any copyright or other
|
||||
proprietary notices and legends.
|
||||
|
||||
# 5. PRIVACY AND DATA PROTECTION
|
||||
|
||||
* **5.1** The Licensor does not have access in any manner to the Licensee’s
|
||||
Content. Therefore, the Licensee is solely responsible for creating, keeping
|
||||
and maintaining any backup copies of any Licensee’s Content or other
|
||||
information submitted to, through, or in relation to the Software.
|
||||
|
||||
The Parties agree to individually comply with the applicable data protection
|
||||
laws pertaining to the Software.
|
||||
|
||||
# 6. AVAILABILITY
|
||||
|
||||
* **6.1** The availability of the Software may be affected by factors, which
|
||||
the Licensor cannot reasonably control, such as bandwidth problems, equipment
|
||||
failure, acts and omissions of our third-party service providers, or *force
|
||||
majeure* events. The Licensor takes no responsibility for the unavailability
|
||||
of the Software caused by such factors.
|
||||
|
||||
# 7. Limitation of liability and disclaimer of warranties
|
||||
|
||||
* **7.1** To the extent permitted by the applicable law, the Licensor expressly
|
||||
disclaims all warranties, express or implied, for the Software. The Licensor
|
||||
provides the Software on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
ANY KIND, either express or implied, including, without limitation, any
|
||||
warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. The entire risk arising out of use or
|
||||
performance of the Software remains with the Licensee.
|
||||
|
||||
* **7.2** In no event shall the Licensor be liable for any damages whatsoever
|
||||
(including, without limitation, damages for loss of business profits, business
|
||||
interruption, loss of business information, or any other pecuniary loss)
|
||||
arising out of the Licensee’s Content, the use of or inability to use the
|
||||
Software, even if the Licensor has been advised of the possibility of such
|
||||
damages.
|
||||
|
||||
* **7.3** The Licensee is solely responsible for determining the
|
||||
appropriateness of the Software and assumes any risks associated with
|
||||
Licensee’s exercise of permissions under the License.
|
||||
|
||||
* **7.4** Third-party content or services are not covered by this License. The
|
||||
Licensee shall ensure Licensee’s compliance with any terms set forth by the
|
||||
respective third parties at its own risk, cost and expense. To the maximum
|
||||
extent permitted by law, the Licensor excludes any liability for any loss or
|
||||
damage resulting from the acts and omissions of such third-party service
|
||||
providers.
|
||||
|
||||
# 8. Governing Law AND DISPUTE RESOLUTION
|
||||
|
||||
* 8.1 This License and any disputes arising out of or in connection with the
|
||||
License and the Software shall be governed by and construed in accordance with
|
||||
the laws of England and Wales. Unless otherwise provided by the applicable
|
||||
law, all disputes arising out of or in connection with the License shall be
|
||||
submitted to the exclusive jurisdiction of the courts in London, the United
|
||||
Kingdom.
|
||||
|
||||
# 9. FINAL PROVISIONS
|
||||
|
||||
* **9.1** **Indemnification.** The Licensee shall indemnify the Licensor at
|
||||
Licensee’s expense if any claims are asserted by a third party against the
|
||||
Licensor by reason of Licensee’s misconduct or breach of any terms of the
|
||||
License, including failed adherence by the Licensee with any applicable laws,
|
||||
including, whether express or implied.
|
||||
|
||||
* **9.2** **Severability.** The unenforceability of any single provision of
|
||||
this License shall not affect any other provision hereof. Where such a
|
||||
provision is held to be unenforceable, the Parties shall use their best
|
||||
endeavours to negotiate and agree upon an enforceable provision, which
|
||||
achieves, to the greatest extent possible, the economic, legal and commercial
|
||||
objectives of the unenforceable provision.
|
||||
|
||||
* **9.3** **Waiver.** A failure of either Party to enforce strictly a provision
|
||||
of this License shall in no event be considered a waiver of any part of such
|
||||
provision. No waiver by either Party of any breach or default by the other
|
||||
party shall operate as a waiver of any succeeding breach or other default or
|
||||
breach by such other Party. No waiver shall have any effect unless it is
|
||||
specific, irrevocable and in writing.
|
||||
|
||||
* **9.4** **Term and termination.** The License shall commence upon Licensee’s
|
||||
access to the Software and continue until terminated by the Licensor. Upon
|
||||
termination of the License, the Licensee agrees to (i) stop all access and use
|
||||
of the Software and (ii) destroy all copies of the Software and all its
|
||||
component parts (if any) stored on the Devices. The provisions of the License
|
||||
that, by their nature, continue and survive will survive any termination of
|
||||
the License.
|
||||
|
||||
* **9.5** **Amendments.** The Licensor reserves the right, at its sole
|
||||
discretion, to change or modify this License at any time by sending a prior
|
||||
notification to the Licensee (if the contact details of the Licensee are
|
||||
available to the Licensor). Any modifications to the License shall become
|
||||
effective on the date indicated at the top of the amended License. By
|
||||
continuing to use the Software after the date on which the modifications were
|
||||
communicated, the Licensee agrees to be bound by the modified License. The
|
||||
Licensor reserves the right to change or discontinue the Software and any
|
||||
feature thereof with or without a prior notice to the Licensee.
|
||||
|
||||
* **9.6** **Entire agreement.** This License constitutes the entire
|
||||
understanding between the Parties with respect to the subject matter thereof
|
||||
and supersedes all prior agreements, negotiations and discussions between the
|
||||
Parties relating thereto.
|
||||
|
||||
* **9.7** **Transfer of rights.** The Licensee is not allowed to assign
|
||||
Licensee’s rights under the License. The Licensor is entitled to transfer its
|
||||
rights and obligations under the License entirely or partially to a third
|
||||
party by giving a prior notice to the Licensee. If the Licensee does not agree
|
||||
to the transfer, the Licensee can terminate this License by ceasing to use the
|
||||
Software.
|
||||
|
||||
* **9.8** **Contact.** For general enquiries and commercial licenses to use the
|
||||
Software, please contact the Licensor directly.
|
||||
|
||||
***
|
||||
@@ -157,10 +157,4 @@ From `packages/server`, run `npm run start-dev`
|
||||
|
||||
# License
|
||||
|
||||
Copyright (c) 2017-2021 Laurent Cozic
|
||||
|
||||
Personal Use License
|
||||
|
||||
Joplin Server is available for personal use only. For example you may host the software on your own server for non-commercial activity.
|
||||
|
||||
To obtain a license for commercial purposes, please contact us.
|
||||
See LICENSE.md in this directory
|
||||
|
||||
@@ -12,5 +12,8 @@ module.exports = {
|
||||
|
||||
slowTestThreshold: 60,
|
||||
|
||||
setupFilesAfterEnv: [`${__dirname}/jest.setup.js`],
|
||||
setupFilesAfterEnv: [
|
||||
'jest-expect-message',
|
||||
`${__dirname}/jest.setup.js`,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/server",
|
||||
"version": "2.7.0",
|
||||
"version": "2.7.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start-dev": "yarn run build && JOPLIN_IS_TESTING=1 nodemon --config nodemon.json --ext ts,js,mustache,css,tsx dist/app.js --env dev",
|
||||
@@ -47,6 +47,7 @@
|
||||
"nodemon": "^2.0.6",
|
||||
"pg": "^8.5.1",
|
||||
"pretty-bytes": "^5.6.0",
|
||||
"prettycron": "^0.10.0",
|
||||
"query-string": "^6.8.3",
|
||||
"rate-limiter-flexible": "^2.2.4",
|
||||
"raw-body": "^2.4.1",
|
||||
@@ -58,9 +59,10 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@joplin/tools": "~2.7",
|
||||
"@rmp135/sql-ts": "^1.7.0",
|
||||
"@rmp135/sql-ts": "^1.12.1",
|
||||
"@types/fs-extra": "^8.0.0",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/jest-expect-message": "^1.0.3",
|
||||
"@types/jsdom": "^16.2.6",
|
||||
"@types/koa": "2.0.49",
|
||||
"@types/markdown-it": "^12.0.0",
|
||||
@@ -70,6 +72,7 @@
|
||||
"@types/zxcvbn": "^4.4.1",
|
||||
"gulp": "^4.0.2",
|
||||
"jest": "^26.6.3",
|
||||
"jest-expect-message": "^1.0.2",
|
||||
"jsdom": "^16.4.0",
|
||||
"node-mocks-http": "^1.10.0",
|
||||
"source-map-support": "^0.5.13",
|
||||
|
||||
@@ -87,4 +87,9 @@ h4:hover a.heading-anchor,
|
||||
h5:hover a.heading-anchor,
|
||||
h6:hover a.heading-anchor {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
abbr[title] {
|
||||
text-underline-offset: 2px;
|
||||
text-decoration: underline dotted;
|
||||
}
|
||||
|
||||
116
packages/server/readme/CLA.md
Normal file
116
packages/server/readme/CLA.md
Normal file
@@ -0,0 +1,116 @@
|
||||
# Individual Contributor License Agreement
|
||||
|
||||
Thank you for your interest in Joplin Server, owned by Cozic Ltd (the
|
||||
"Company"). In order to clarify the intellectual property license granted with
|
||||
Contributions from any person or entity, the Company must have a Contributor
|
||||
License Agreement ("CLA") on file that has been signed by each Contributor,
|
||||
indicating agreement to the license terms below. This license is for your
|
||||
protection as a Contributor as well as the protection of the Company and its
|
||||
users; it does not change your rights to use your own Contributions for any
|
||||
other purpose.
|
||||
|
||||
Please complete and sign this Agreement, and then email a copy to
|
||||
cla@joplinapp.org only (do not copy any other persons or lists). Read this
|
||||
document carefully before signing and keep a copy for your records.
|
||||
|
||||
- Full name: **FULL NAME**
|
||||
|
||||
- Postal Address: **POSTAL ADDRESS**
|
||||
|
||||
- Country: **COUNTRY**
|
||||
|
||||
- E-Mail: **EMAIL**
|
||||
|
||||
- GitHub username: **GITHUB USERNAME**
|
||||
|
||||
You accept and agree to the following terms and conditions for Your present and
|
||||
future Contributions submitted to the Company. In return, the Company shall not
|
||||
use Your Contributions in a way that is contrary to the public benefit or
|
||||
inconsistent with its bylaws in effect at the time of the Contribution. Except
|
||||
for the license granted herein to the Company and recipients of software
|
||||
distributed by the Company, You reserve all right, title, and interest in and to
|
||||
Your Contributions.
|
||||
|
||||
1. Definitions.
|
||||
|
||||
* "You" (or "Your")
|
||||
|
||||
"You" (or "Your") shall mean the copyright owner or legal entity authorized
|
||||
by the copyright owner that is making this Agreement with the Company. For
|
||||
legal entities, the entity making a Contribution and all other entities
|
||||
that control, are controlled by, or are under common control with that
|
||||
entity are considered to be a single Contributor. For the purposes of this
|
||||
definition, "control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or otherwise,
|
||||
or (ii) ownership of fifty percent (50%) or more of the outstanding shares,
|
||||
or (iii) beneficial ownership of such entity.
|
||||
|
||||
* "Contribution"
|
||||
|
||||
"Contribution" shall mean any original work of authorship, including any
|
||||
modifications or additions to an existing work, that is intentionally
|
||||
submitted by You to the Company for inclusion in, or documentation of, any
|
||||
of the products owned or managed by the Company (the "Work"). For the
|
||||
purposes of this definition, "submitted" means any form of electronic,
|
||||
verbal, or written communication sent to the Company or its
|
||||
representatives, including but not limited to communication on electronic
|
||||
mailing lists, source code control systems, and issue tracking systems that
|
||||
are managed by, or on behalf of, the Company for the purpose of discussing
|
||||
and improving the Work, but excluding communication that is conspicuously
|
||||
marked or otherwise designated in writing by You as "Not a Contribution."
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this
|
||||
Agreement, You hereby grant to the Company and to recipients of software
|
||||
distributed by the Company a perpetual, worldwide, non-exclusive, no-charge,
|
||||
royalty-free, irrevocable copyright license to reproduce, prepare derivative
|
||||
works of, publicly display, publicly perform, sublicense, and distribute Your
|
||||
Contributions and such derivative works.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this
|
||||
Agreement, You hereby grant to the Company and to recipients of software
|
||||
distributed by the Company a perpetual, worldwide, non-exclusive, no-charge,
|
||||
royalty-free, irrevocable (except as stated in this section) patent license
|
||||
to make, have made, use, offer to sell, sell, import, and otherwise transfer
|
||||
the Work, where such license applies only to those patent claims licensable
|
||||
by You that are necessarily infringed by Your Contribution(s) alone or by
|
||||
combination of Your Contribution(s) with the Work to which such
|
||||
Contribution(s) was submitted. If any entity institutes patent litigation
|
||||
against You or any other entity (including a cross-claim or counterclaim in a
|
||||
lawsuit) alleging that your Contribution, or the Work to which you have
|
||||
contributed, constitutes direct or contributory patent infringement, then any
|
||||
patent licenses granted to that entity under this Agreement for that
|
||||
Contribution or Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. You represent that you are legally entitled to grant the above license. If
|
||||
your employer(s) has rights to intellectual property that you create that
|
||||
includes your Contributions, you represent that you have received permission
|
||||
to make Contributions on behalf of that employer, that your employer has
|
||||
waived such rights for your Contributions to the Company, or that your
|
||||
employer has executed a separate Corporate CLA with the Company.
|
||||
|
||||
5. You represent that each of Your Contributions is Your original creation (see
|
||||
section 7 for submissions on behalf of others). You represent that Your
|
||||
Contribution submissions include complete details of any third-party license
|
||||
or other restriction (including, but not limited to, related patents and
|
||||
trademarks) of which you are personally aware and which are associated with
|
||||
any part of Your Contributions.
|
||||
|
||||
6. You are not expected to provide support for Your Contributions, except to the
|
||||
extent You desire to provide support. You may provide support for free, for a
|
||||
fee, or not at all. Unless required by applicable law or agreed to in
|
||||
writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including,
|
||||
without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT,
|
||||
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
7. Should You wish to submit work that is not Your original creation, You may
|
||||
submit it to the Company separately from any Contribution, identifying the
|
||||
complete details of its source and of any license or other restriction
|
||||
(including, but not limited to, related patents, trademarks, and license
|
||||
agreements) of which you are personally aware, and conspicuously marking the
|
||||
work as "Submitted on behalf of a third-party: **NAME HERE**".
|
||||
|
||||
8. You agree to notify the Company of any facts or circumstances of which you
|
||||
become aware that would make these representations inaccurate in any respect.
|
||||
|
||||
Please sign: **SIGNATURE** Date: **DATE**
|
||||
Binary file not shown.
@@ -24,6 +24,7 @@ import { RouteResponseFormat, routeResponseFormat } from './utils/routeUtils';
|
||||
import { parseEnv } from './env';
|
||||
import storageConnectionCheck from './utils/storageConnectionCheck';
|
||||
import { setLocale } from '@joplin/lib/locale';
|
||||
import checkAdminHandler from './middleware/checkAdminHandler';
|
||||
|
||||
interface Argv {
|
||||
env?: Env;
|
||||
@@ -196,6 +197,7 @@ async function main() {
|
||||
|
||||
app.use(apiVersionHandler);
|
||||
app.use(ownerHandler);
|
||||
app.use(checkAdminHandler);
|
||||
app.use(notificationHandler);
|
||||
app.use(clickJackingHandler);
|
||||
app.use(routeHandler);
|
||||
|
||||
@@ -66,7 +66,7 @@ function mailerConfigFromEnv(env: EnvVariables): MailerConfig {
|
||||
enabled: env.MAILER_ENABLED,
|
||||
host: env.MAILER_HOST,
|
||||
port: env.MAILER_PORT,
|
||||
secure: env.MAILER_SECURE,
|
||||
security: env.MAILER_SECURITY,
|
||||
authUser: env.MAILER_AUTH_USER,
|
||||
authPassword: env.MAILER_AUTH_PASSWORD,
|
||||
noReplyName: env.MAILER_NOREPLY_NAME,
|
||||
|
||||
@@ -1,74 +1,72 @@
|
||||
it('should pass', async function() {
|
||||
expect(true).toBe(true);
|
||||
import { afterAllTests, beforeAllDb, beforeEachDb, db } from './utils/testing/testUtils';
|
||||
import sqlts from '@rmp135/sql-ts';
|
||||
import { DbConnection, migrateDown, migrateUp, nextMigration } from './db';
|
||||
|
||||
async function dbSchemaSnapshot(db: DbConnection): Promise<any> {
|
||||
return sqlts.toTypeScript({}, db as any);
|
||||
}
|
||||
|
||||
describe('db', function() {
|
||||
|
||||
beforeAll(async () => {
|
||||
await beforeAllDb('db', { autoMigrate: false });
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await afterAllTests();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await beforeEachDb();
|
||||
});
|
||||
|
||||
it('should allow upgrading and downgrading schema', async function() {
|
||||
// Migrations before that didn't have a down() step.
|
||||
const ignoreAllBefore = '20210819165350_user_flags';
|
||||
|
||||
// Some migrations produce no changes visible to sql-ts, in particular
|
||||
// when the migration only adds a constraint or an index. In this case
|
||||
// we skip the migration. Ideally we should test these too but for now
|
||||
// that will do.
|
||||
const doNoCheckUpgrade = [
|
||||
'20211030103016_item_owner_name_unique',
|
||||
'20211111134329_storage_index',
|
||||
];
|
||||
|
||||
let startProcessing = false;
|
||||
|
||||
while (true) {
|
||||
await migrateUp(db());
|
||||
|
||||
if (!startProcessing) {
|
||||
const next = await nextMigration(db());
|
||||
if (next === ignoreAllBefore) {
|
||||
startProcessing = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const next = await nextMigration(db());
|
||||
|
||||
if (!next) break;
|
||||
|
||||
const initialSchema = await dbSchemaSnapshot(db());
|
||||
|
||||
await migrateUp(db());
|
||||
|
||||
const afterUpgradeSchema = await dbSchemaSnapshot(db());
|
||||
|
||||
if (!doNoCheckUpgrade.includes(next)) {
|
||||
expect(initialSchema, `Schema upgrade did not produce a new schema. In migration: ${next}`).not.toEqual(afterUpgradeSchema);
|
||||
}
|
||||
|
||||
await migrateDown(db());
|
||||
|
||||
const afterRollbackSchema = await dbSchemaSnapshot(db());
|
||||
|
||||
expect(initialSchema, `Schema rollback did not produce previous schema. In migration: ${next}`).toEqual(afterRollbackSchema);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// import { afterAllTests, beforeAllDb, beforeEachDb, db } from "./utils/testing/testUtils";
|
||||
// import sqlts from '@rmp135/sql-ts';
|
||||
// import config from "./config";
|
||||
// import { connectDb, DbConnection, disconnectDb, migrateDown, migrateList, migrateUp, nextMigration } from "./services/database/types";
|
||||
|
||||
// async function dbSchemaSnapshot(db:DbConnection):Promise<any> {
|
||||
// return sqlts.toObject({
|
||||
// client: 'sqlite',
|
||||
// knex: db,
|
||||
// // 'connection': {
|
||||
// // 'filename': config().database.name,
|
||||
// // },
|
||||
// useNullAsDefault: true,
|
||||
// } as any)
|
||||
|
||||
// // return JSON.stringify(definitions);
|
||||
// }
|
||||
|
||||
// describe('db', function() {
|
||||
|
||||
// beforeAll(async () => {
|
||||
// await beforeAllDb('db', { autoMigrate: false });
|
||||
// });
|
||||
|
||||
// afterAll(async () => {
|
||||
// await afterAllTests();
|
||||
// });
|
||||
|
||||
// beforeEach(async () => {
|
||||
// await beforeEachDb();
|
||||
// });
|
||||
|
||||
// it('should allow downgrading schema', async function() {
|
||||
// const ignoreAllBefore = '20210819165350_user_flags';
|
||||
// let startProcessing = false;
|
||||
|
||||
// //console.info(await dbSchemaSnapshot());
|
||||
|
||||
// while (true) {
|
||||
// await migrateUp(db());
|
||||
|
||||
// if (!startProcessing) {
|
||||
// const next = await nextMigration(db());
|
||||
// if (next === ignoreAllBefore) {
|
||||
// startProcessing = true;
|
||||
// } else {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!(await nextMigration(db()))) break;
|
||||
|
||||
// // await disconnectDb(db());
|
||||
// // const beforeSchema = await dbSchemaSnapshot(db());
|
||||
// // console.info(beforeSchema);
|
||||
// // await connectDb(db());
|
||||
|
||||
// // await migrateUp(db());
|
||||
// // await migrateDown(db());
|
||||
|
||||
// // const afterSchema = await dbSchemaSnapshot(db());
|
||||
|
||||
// // // console.info(beforeSchema);
|
||||
// // // console.info(afterSchema);
|
||||
|
||||
// // expect(beforeSchema).toEqual(afterSchema);
|
||||
// }
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
@@ -49,6 +49,7 @@ export interface DbConfigConnection {
|
||||
|
||||
export interface QueryContext {
|
||||
uniqueConstraintErrorLoggingDisabled?: boolean;
|
||||
noSuchTableErrorLoggingDisabled?: boolean;
|
||||
}
|
||||
|
||||
export interface KnexDatabaseConfig {
|
||||
@@ -227,6 +228,10 @@ export async function connectDb(dbConfig: DatabaseConfig): Promise<DbConnection>
|
||||
if (data.queryContext.uniqueConstraintErrorLoggingDisabled && isUniqueConstraintError(response)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.queryContext.noSuchTableErrorLoggingDisabled && isNoSuchTableError(response)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const msg: string[] = [];
|
||||
@@ -392,7 +397,8 @@ export function isUniqueConstraintError(error: any): boolean {
|
||||
|
||||
export async function latestMigration(db: DbConnection): Promise<Migration | null> {
|
||||
try {
|
||||
const result = await db('knex_migrations').select('name').orderBy('id', 'desc').first();
|
||||
const context: QueryContext = { noSuchTableErrorLoggingDisabled: true };
|
||||
const result = await db('knex_migrations').queryContext(context).select('name').orderBy('id', 'desc').first();
|
||||
return { name: result.name, done: true };
|
||||
} catch (error) {
|
||||
// If the database has never been initialized, we return null, so
|
||||
|
||||
46
packages/server/src/env.test.ts
Normal file
46
packages/server/src/env.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { afterAllTests, beforeAllDb, beforeEachDb, expectThrow } from './utils/testing/testUtils';
|
||||
import { parseEnv } from './env';
|
||||
|
||||
describe('env', function() {
|
||||
|
||||
beforeAll(async () => {
|
||||
await beforeAllDb('env');
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await afterAllTests();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await beforeEachDb();
|
||||
});
|
||||
|
||||
it('should parse env values', async function() {
|
||||
const result = parseEnv({
|
||||
DB_CLIENT: 'pg',
|
||||
POSTGRES_PORT: '123',
|
||||
MAILER_ENABLED: 'true',
|
||||
SIGNUP_ENABLED: 'false',
|
||||
TERMS_ENABLED: '0',
|
||||
ACCOUNT_TYPES_ENABLED: '1',
|
||||
});
|
||||
|
||||
expect(result.DB_CLIENT).toBe('pg');
|
||||
expect(result.POSTGRES_PORT).toBe(123);
|
||||
expect(result.MAILER_ENABLED).toBe(true);
|
||||
expect(result.SIGNUP_ENABLED).toBe(false);
|
||||
expect(result.TERMS_ENABLED).toBe(false);
|
||||
expect(result.ACCOUNT_TYPES_ENABLED).toBe(true);
|
||||
});
|
||||
|
||||
it('should overrides default values', async function() {
|
||||
expect(parseEnv({}).POSTGRES_USER).toBe('joplin');
|
||||
expect(parseEnv({}, { POSTGRES_USER: 'other' }).POSTGRES_USER).toBe('other');
|
||||
});
|
||||
|
||||
it('should validate values', async function() {
|
||||
await expectThrow(async () => parseEnv({ POSTGRES_PORT: 'notanumber' }));
|
||||
await expectThrow(async () => parseEnv({ MAILER_ENABLED: 'TRUE' }));
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,7 +1,13 @@
|
||||
// The possible env variables and their defaults are listed below.
|
||||
//
|
||||
// The env variables can be of type string, integer or boolean. When the type is
|
||||
// boolean, set the variable to "0" or "1" in your env file.
|
||||
// boolean, set the variable to "true", "false", "0" or "1" in your env file.
|
||||
|
||||
export enum MailerSecurity {
|
||||
None = 'none',
|
||||
Tls = 'tls',
|
||||
Starttls = 'starttls',
|
||||
}
|
||||
|
||||
const defaultEnvValues: EnvVariables = {
|
||||
// ==================================================
|
||||
@@ -66,8 +72,8 @@ const defaultEnvValues: EnvVariables = {
|
||||
|
||||
MAILER_ENABLED: false,
|
||||
MAILER_HOST: '',
|
||||
MAILER_PORT: 587,
|
||||
MAILER_SECURE: true,
|
||||
MAILER_PORT: 465,
|
||||
MAILER_SECURITY: MailerSecurity.Tls,
|
||||
MAILER_AUTH_USER: '',
|
||||
MAILER_AUTH_PASSWORD: '',
|
||||
MAILER_NOREPLY_NAME: '',
|
||||
@@ -120,7 +126,7 @@ export interface EnvVariables {
|
||||
MAILER_ENABLED: boolean;
|
||||
MAILER_HOST: string;
|
||||
MAILER_PORT: number;
|
||||
MAILER_SECURE: boolean;
|
||||
MAILER_SECURITY: MailerSecurity;
|
||||
MAILER_AUTH_USER: string;
|
||||
MAILER_AUTH_PASSWORD: string;
|
||||
MAILER_NOREPLY_NAME: string;
|
||||
@@ -134,7 +140,13 @@ export interface EnvVariables {
|
||||
STRIPE_WEBHOOK_SECRET: string;
|
||||
}
|
||||
|
||||
export function parseEnv(rawEnv: any, defaultOverrides: any = null): EnvVariables {
|
||||
const parseBoolean = (s: string): boolean => {
|
||||
if (s === 'true' || s === '1') return true;
|
||||
if (s === 'false' || s === '0') return false;
|
||||
throw new Error(`Invalid boolean value: "${s}" (Must be one of "true", "false", "0, "1")`);
|
||||
};
|
||||
|
||||
export function parseEnv(rawEnv: Record<string, string>, defaultOverrides: any = null): EnvVariables {
|
||||
const output: EnvVariables = {
|
||||
...defaultEnvValues,
|
||||
...defaultOverrides,
|
||||
@@ -145,17 +157,21 @@ export function parseEnv(rawEnv: any, defaultOverrides: any = null): EnvVariable
|
||||
|
||||
if (rawEnvValue === undefined) continue;
|
||||
|
||||
if (typeof value === 'number') {
|
||||
const v = Number(rawEnvValue);
|
||||
if (isNaN(v)) throw new Error(`Invalid number value for env variable ${key} = ${rawEnvValue}`);
|
||||
(output as any)[key] = v;
|
||||
} else if (typeof value === 'boolean') {
|
||||
if (rawEnvValue !== '0' && rawEnvValue !== '1') throw new Error(`Invalid boolean value for env variable ${key}: ${rawEnvValue} (Should be either "0" or "1")`);
|
||||
(output as any)[key] = rawEnvValue === '1';
|
||||
} else if (typeof value === 'string') {
|
||||
(output as any)[key] = `${rawEnvValue}`;
|
||||
} else {
|
||||
throw new Error(`Invalid env default value type: ${typeof value}`);
|
||||
try {
|
||||
if (typeof value === 'number') {
|
||||
const v = Number(rawEnvValue);
|
||||
if (isNaN(v)) throw new Error(`Invalid number value "${rawEnvValue}"`);
|
||||
(output as any)[key] = v;
|
||||
} else if (typeof value === 'boolean') {
|
||||
(output as any)[key] = parseBoolean(rawEnvValue);
|
||||
} else if (typeof value === 'string') {
|
||||
(output as any)[key] = `${rawEnvValue}`;
|
||||
} else {
|
||||
throw new Error(`Invalid env default value type: ${typeof value}`);
|
||||
}
|
||||
} catch (error) {
|
||||
error.message = `Could not parse key "${key}": ${error.message}`;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user