You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-30 20:39:46 +02:00
Compare commits
115 Commits
share_fold
...
android-v2
Author | SHA1 | Date | |
---|---|---|---|
|
fd48697fb2 | ||
|
28819931a3 | ||
|
815fe8d3ba | ||
|
564adb9a57 | ||
|
987417502f | ||
|
43d36f9415 | ||
|
24776ee6ce | ||
|
9a26e8aafd | ||
|
0e45336140 | ||
|
2d4fc08f2b | ||
|
b51e16c255 | ||
|
bc8392ad52 | ||
|
dba218a681 | ||
|
e83306c1f7 | ||
|
a0f003f9d5 | ||
|
0e6b5b338c | ||
|
ddbd3601ab | ||
|
236d977c41 | ||
|
7c539976dd | ||
|
fa0b741529 | ||
|
a133bb06a3 | ||
|
e71ec2bc49 | ||
|
99e8818ba0 | ||
|
e4197a985e | ||
|
c023cee0b8 | ||
|
e42fa68114 | ||
|
582f0853bb | ||
|
07ee20a0ff | ||
|
7f78e94d6e | ||
|
3fbf5ef5d0 | ||
|
25b12a2366 | ||
|
07b4117aa1 | ||
|
8abd9b401b | ||
|
1c5a79c353 | ||
|
149e409bfa | ||
|
e4854b0bc2 | ||
|
857e25d84f | ||
|
af59295968 | ||
|
c94ec4e064 | ||
|
999baf4b3d | ||
|
bfb802cd09 | ||
|
61cd924bb1 | ||
|
3e13a95053 | ||
|
b69d752734 | ||
|
821cc346f7 | ||
|
8402c20a3f | ||
|
4c50706d54 | ||
|
0f9d6a12b0 | ||
|
13da286b55 | ||
|
da4d57c1db | ||
|
7b06090255 | ||
|
2cc4ac087b | ||
|
c4ff7857b1 | ||
|
938e639a01 | ||
|
fe3ad3e9b4 | ||
|
681d413b36 | ||
|
8b452106be | ||
|
72a8724a5b | ||
|
04112b025c | ||
|
bea9edf64b | ||
|
fd432f928d | ||
|
a8f6676fb3 | ||
|
6720fd1f0e | ||
|
f3518cddbe | ||
|
d4d400217b | ||
|
a863f92490 | ||
|
aaf4dcc50c | ||
|
cfd34da03f | ||
|
c24467c15e | ||
|
3ed6ad5948 | ||
|
de0ae7653f | ||
|
a9691f6b1c | ||
|
1a7d463f09 | ||
|
47a49fd5de | ||
|
be949390f8 | ||
|
b26a9f1b22 | ||
|
b7b0f770ee | ||
|
1ae5d4ea9b | ||
|
aa267f0dc6 | ||
|
691618b50c | ||
|
33ed7545a9 | ||
|
d8d0e705f2 | ||
|
bdc970d718 | ||
|
4636d1539c | ||
|
bc1165be46 | ||
|
f5e1e45f6f | ||
|
352ee6496e | ||
|
fdbfa78e53 | ||
|
dfe5383d4b | ||
|
eb1e9e0436 | ||
|
3d7f864982 | ||
|
1ffe30b359 | ||
|
5d5bd3abd6 | ||
|
747264bd89 | ||
|
7bd1bdb0e3 | ||
|
d5ec92e540 | ||
|
2b50e99bb1 | ||
|
a4c5164bea | ||
|
88d6c94e6b | ||
|
4f45c977e2 | ||
|
cbf7e24c47 | ||
|
7ebc98633a | ||
|
1d4e3fe3ea | ||
|
94e0ea403a | ||
|
d217478852 | ||
|
4c9cbd61a4 | ||
|
d07a540618 | ||
|
720b6f0190 | ||
|
33fff4c8f0 | ||
|
6f83ccd044 | ||
|
7d68dafaed | ||
|
4f066b06d2 | ||
|
a11bed1bb2 | ||
|
96c9e29025 | ||
|
2519b73117 |
@@ -86,6 +86,7 @@ packages/lib/countable/Countable.js
|
||||
|
||||
# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD
|
||||
packages/app-cli/app/LinkSelector.js
|
||||
packages/app-cli/app/app.js
|
||||
packages/app-cli/app/base-command.js
|
||||
packages/app-cli/app/command-apidoc.js
|
||||
packages/app-cli/app/command-attach.js
|
||||
@@ -246,7 +247,6 @@ packages/app-desktop/gui/Navigator.js
|
||||
packages/app-desktop/gui/NoteContentPropertiesDialog.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/Toolbar.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/index.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/setupVim.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/types.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useContextMenu.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useCursorUtils.test.js
|
||||
@@ -294,6 +294,7 @@ packages/app-desktop/gui/NoteEditor/utils/clipboardUtils.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/contextMenu.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/contextMenuUtils.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/index.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/markupRenderOptions.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/resourceHandling.test.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/resourceHandling.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/types.js
|
||||
@@ -414,6 +415,7 @@ packages/app-desktop/integration-tests/util/activateMainMenuItem.js
|
||||
packages/app-desktop/integration-tests/util/createStartupArgs.js
|
||||
packages/app-desktop/integration-tests/util/firstNonDevToolsWindow.js
|
||||
packages/app-desktop/integration-tests/util/setFilePickerResponse.js
|
||||
packages/app-desktop/integration-tests/util/setMessageBoxResponse.js
|
||||
packages/app-desktop/integration-tests/util/test.js
|
||||
packages/app-desktop/playwright.config.js
|
||||
packages/app-desktop/plugins/GotoAnything.js
|
||||
@@ -444,6 +446,8 @@ packages/app-desktop/services/spellChecker/SpellCheckerServiceDriverNative.js
|
||||
packages/app-desktop/tools/copy7Zip.js
|
||||
packages/app-desktop/tools/notarizeMacApp.js
|
||||
packages/app-desktop/tools/renameReleaseAssets.js
|
||||
packages/app-desktop/utils/7zip/getPathToExecutable7Zip.js
|
||||
packages/app-desktop/utils/7zip/pathToBundled7Zip.js
|
||||
packages/app-desktop/utils/checkForUpdatesUtils.test.js
|
||||
packages/app-desktop/utils/checkForUpdatesUtils.js
|
||||
packages/app-desktop/utils/checkForUpdatesUtilsTestData.js
|
||||
@@ -486,10 +490,15 @@ packages/app-mobile/components/NoteEditor/MarkdownToolbar/ToggleSpaceButton.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/Toolbar.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/ToolbarButton.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/ToolbarOverflowRows.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/buttons/useActionButtons.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/buttons/useHeaderButtons.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/buttons/useInlineFormattingButtons.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/buttons/useListButtons.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/types.js
|
||||
packages/app-mobile/components/NoteEditor/NoteEditor.test.js
|
||||
packages/app-mobile/components/NoteEditor/NoteEditor.js
|
||||
packages/app-mobile/components/NoteEditor/SearchPanel.js
|
||||
packages/app-mobile/components/NoteEditor/hooks/useKeyboardVisible.js
|
||||
packages/app-mobile/components/NoteEditor/types.js
|
||||
packages/app-mobile/components/NoteList.js
|
||||
packages/app-mobile/components/ProfileSwitcher/ProfileEditor.js
|
||||
@@ -561,6 +570,7 @@ packages/default-plugins/build.js
|
||||
packages/default-plugins/buildDefaultPlugins.js
|
||||
packages/default-plugins/commands/buildAll.js
|
||||
packages/default-plugins/commands/editPatch.js
|
||||
packages/default-plugins/utils/getCurrentCommitHash.js
|
||||
packages/default-plugins/utils/getPathToPatchFileFor.js
|
||||
packages/default-plugins/utils/readRepositoryJson.js
|
||||
packages/default-plugins/utils/waitForCliInput.js
|
||||
@@ -573,6 +583,8 @@ packages/editor/CodeMirror/configFromSettings.js
|
||||
packages/editor/CodeMirror/createEditor.test.js
|
||||
packages/editor/CodeMirror/createEditor.js
|
||||
packages/editor/CodeMirror/editorCommands/editorCommands.js
|
||||
packages/editor/CodeMirror/editorCommands/insertLineAfter.test.js
|
||||
packages/editor/CodeMirror/editorCommands/insertLineAfter.js
|
||||
packages/editor/CodeMirror/editorCommands/supportsCommand.js
|
||||
packages/editor/CodeMirror/editorCommands/swapLine.js
|
||||
packages/editor/CodeMirror/getScrollFraction.js
|
||||
@@ -597,6 +609,7 @@ packages/editor/CodeMirror/testUtil/forceFullParse.js
|
||||
packages/editor/CodeMirror/testUtil/loadLanguages.js
|
||||
packages/editor/CodeMirror/theme.js
|
||||
packages/editor/CodeMirror/util/isInSyntaxNode.js
|
||||
packages/editor/CodeMirror/util/setupVim.js
|
||||
packages/editor/SelectionFormatting.js
|
||||
packages/editor/events.js
|
||||
packages/editor/types.js
|
||||
@@ -727,16 +740,19 @@ packages/lib/models/Tag.test.js
|
||||
packages/lib/models/Tag.js
|
||||
packages/lib/models/dateTimeFormats.test.js
|
||||
packages/lib/models/settings/FileHandler.js
|
||||
packages/lib/models/settings/settingValidations.js
|
||||
packages/lib/models/utils/isItemId.js
|
||||
packages/lib/models/utils/itemCanBeEncrypted.js
|
||||
packages/lib/models/utils/paginatedFeed.js
|
||||
packages/lib/models/utils/paginationToSql.js
|
||||
packages/lib/models/utils/readOnly.js
|
||||
packages/lib/models/utils/resourceUtils.js
|
||||
packages/lib/models/utils/types.js
|
||||
packages/lib/models/utils/userData.test.js
|
||||
packages/lib/models/utils/userData.js
|
||||
packages/lib/net-utils.js
|
||||
packages/lib/ntp.js
|
||||
packages/lib/onedrive-api.test.js
|
||||
packages/lib/onedrive-api.js
|
||||
packages/lib/path-utils.js
|
||||
packages/lib/reducer.js
|
||||
@@ -960,6 +976,7 @@ packages/lib/services/synchronizer/syncInfoUtils.js
|
||||
packages/lib/services/synchronizer/synchronizer_LockHandler.test.js
|
||||
packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js
|
||||
packages/lib/services/synchronizer/tools.js
|
||||
packages/lib/services/synchronizer/utils/checkDisabledSyncItemsNotification.js
|
||||
packages/lib/services/synchronizer/utils/handleConflictAction.js
|
||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
||||
packages/lib/services/synchronizer/utils/resourceRemotePath.js
|
||||
@@ -1054,13 +1071,15 @@ packages/renderer/MdToHtml/rules/sanitize_html.js
|
||||
packages/renderer/MdToHtml/rules/source_map.js
|
||||
packages/renderer/MdToHtml/setupLinkify.js
|
||||
packages/renderer/MdToHtml/validateLinks.js
|
||||
packages/renderer/assetsToHeaders.js
|
||||
packages/renderer/defaultResourceModel.js
|
||||
packages/renderer/headerAnchor.js
|
||||
packages/renderer/highlight.js
|
||||
packages/renderer/htmlUtils.test.js
|
||||
packages/renderer/htmlUtils.js
|
||||
packages/renderer/index.js
|
||||
packages/renderer/noteStyle.js
|
||||
packages/renderer/pathUtils.js
|
||||
packages/renderer/types.js
|
||||
packages/renderer/utils.js
|
||||
packages/tools/build-release-stats.test.js
|
||||
packages/tools/build-release-stats.js
|
||||
|
20
.github/scripts/run_ci.sh
vendored
20
.github/scripts/run_ci.sh
vendored
@@ -107,7 +107,7 @@ if [ "$RUN_TESTS" == "1" ]; then
|
||||
#
|
||||
# https://stackoverflow.com/questions/38558989
|
||||
export NODE_OPTIONS="--max-old-space-size=32768"
|
||||
yarn run test-ci
|
||||
yarn test-ci
|
||||
testResult=$?
|
||||
if [ $testResult -ne 0 ]; then
|
||||
exit $testResult
|
||||
@@ -122,13 +122,13 @@ fi
|
||||
if [ "$RUN_TESTS" == "1" ]; then
|
||||
echo "Step: Running linter..."
|
||||
|
||||
yarn run linter-ci ./
|
||||
yarn linter-ci ./
|
||||
testResult=$?
|
||||
if [ $testResult -ne 0 ]; then
|
||||
exit $testResult
|
||||
fi
|
||||
|
||||
yarn run packageJsonLint
|
||||
yarn packageJsonLint
|
||||
testResult=$?
|
||||
if [ $testResult -ne 0 ]; then
|
||||
exit $testResult
|
||||
@@ -175,7 +175,7 @@ fi
|
||||
|
||||
# =============================================================================
|
||||
# Check .gitignore and .eslintignore files - they should be updated when
|
||||
# new TypeScript files are added by running `yarn run updateIgnored`.
|
||||
# new TypeScript files are added by running `yarn updateIgnored`.
|
||||
# See coding_style.md
|
||||
# =============================================================================
|
||||
|
||||
@@ -200,7 +200,7 @@ if [ "$RUN_TESTS" == "1" ]; then
|
||||
|
||||
mkdir -p ../joplin-website/docs
|
||||
ll ../joplin-website/docs/api/references/plugin_api
|
||||
SKIP_SPONSOR_PROCESSING=1 yarn run buildWebsite
|
||||
SKIP_SPONSOR_PROCESSING=1 yarn buildWebsite
|
||||
testResult=$?
|
||||
if [ $testResult -ne 0 ]; then
|
||||
exit $testResult
|
||||
@@ -253,14 +253,14 @@ if [ "$IS_DESKTOP_RELEASE" == "1" ]; then
|
||||
# "python" and seems to no longer respect the PYTHON_PATH environment variable.
|
||||
# We work around this by aliasing python.
|
||||
alias python=$(which python3)
|
||||
USE_HARD_LINKS=false yarn run dist
|
||||
USE_HARD_LINKS=false yarn dist
|
||||
else
|
||||
USE_HARD_LINKS=false yarn run dist
|
||||
USE_HARD_LINKS=false yarn dist
|
||||
fi
|
||||
elif [[ $IS_LINUX = 1 ]] && [ "$IS_SERVER_RELEASE" == "1" ]; then
|
||||
echo "Step: Building Docker Image..."
|
||||
cd "$ROOT_DIR"
|
||||
yarn run buildServerDocker --tag-name $GIT_TAG_NAME --push-images --repository $SERVER_REPOSITORY
|
||||
yarn buildServerDocker --tag-name $GIT_TAG_NAME --push-images --repository $SERVER_REPOSITORY
|
||||
else
|
||||
echo "Step: Building but *not* publishing desktop application..."
|
||||
|
||||
@@ -274,8 +274,8 @@ else
|
||||
export CSC_IDENTITY_AUTO_DISCOVERY=false
|
||||
npm pkg set 'build.mac.identity'=null --json
|
||||
|
||||
USE_HARD_LINKS=false yarn run dist --publish=never
|
||||
USE_HARD_LINKS=false yarn dist --publish=never
|
||||
else
|
||||
USE_HARD_LINKS=false yarn run dist --publish=never
|
||||
USE_HARD_LINKS=false yarn dist --publish=never
|
||||
fi
|
||||
fi
|
||||
|
4
.github/workflows/build-macos-m1.yml
vendored
4
.github/workflows/build-macos-m1.yml
vendored
@@ -67,7 +67,7 @@ jobs:
|
||||
|
||||
if [[ $GIT_TAG_NAME = v* ]]; then
|
||||
echo "Building and publishing desktop application..."
|
||||
PYTHON_PATH=$(which python) USE_HARD_LINKS=false yarn run dist --mac --arm64
|
||||
PYTHON_PATH=$(which python) USE_HARD_LINKS=false yarn dist --mac --arm64
|
||||
|
||||
yarn renameReleaseAssets --repo="$GH_REPO" --tag="$GIT_TAG_NAME" --token="$GITHUB_TOKEN"
|
||||
else
|
||||
@@ -80,5 +80,5 @@ jobs:
|
||||
export CSC_IDENTITY_AUTO_DISCOVERY=false
|
||||
npm pkg set 'build.mac.identity'=null --json
|
||||
|
||||
PYTHON_PATH=$(which python) USE_HARD_LINKS=false yarn run dist --mac --arm64 --publish=never
|
||||
PYTHON_PATH=$(which python) USE_HARD_LINKS=false yarn dist --mac --arm64 --publish=never
|
||||
fi
|
||||
|
6
.github/workflows/github-actions-main.yml
vendored
6
.github/workflows/github-actions-main.yml
vendored
@@ -141,7 +141,7 @@ jobs:
|
||||
# To ensure that the operations stop on failure, all commands
|
||||
# should be on one line with "&&" in between.
|
||||
run: |
|
||||
yarn install && cd packages/app-desktop && yarn run dist
|
||||
yarn install && cd packages/app-desktop && yarn dist
|
||||
|
||||
# Build and package the Windows app, without publishing it, just to
|
||||
# verify that the build process hasn't been broken.
|
||||
@@ -153,7 +153,7 @@ jobs:
|
||||
SERVER_REPOSITORY: joplin/server
|
||||
SERVER_TAG_PREFIX: server
|
||||
run: |
|
||||
yarn install && cd packages/app-desktop && yarn run dist --publish=never
|
||||
yarn install && cd packages/app-desktop && yarn dist --publish=never
|
||||
|
||||
ServerDockerImage:
|
||||
needs: pre_job
|
||||
@@ -197,7 +197,7 @@ jobs:
|
||||
BUILD_SEQUENCIAL: 1
|
||||
run: |
|
||||
yarn install
|
||||
yarn run buildServerDocker --tag-name server-v0.0.0 --repository joplin/server
|
||||
yarn buildServerDocker --tag-name server-v0.0.0 --repository joplin/server
|
||||
|
||||
# Basic test to ensure that the created build is valid. It should exit with
|
||||
# code 0 if it works.
|
||||
|
23
.gitignore
vendored
23
.gitignore
vendored
@@ -66,6 +66,7 @@ docs/**/*.mustache
|
||||
|
||||
# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD
|
||||
packages/app-cli/app/LinkSelector.js
|
||||
packages/app-cli/app/app.js
|
||||
packages/app-cli/app/base-command.js
|
||||
packages/app-cli/app/command-apidoc.js
|
||||
packages/app-cli/app/command-attach.js
|
||||
@@ -226,7 +227,6 @@ packages/app-desktop/gui/Navigator.js
|
||||
packages/app-desktop/gui/NoteContentPropertiesDialog.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/Toolbar.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/index.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/setupVim.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/types.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useContextMenu.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useCursorUtils.test.js
|
||||
@@ -274,6 +274,7 @@ packages/app-desktop/gui/NoteEditor/utils/clipboardUtils.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/contextMenu.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/contextMenuUtils.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/index.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/markupRenderOptions.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/resourceHandling.test.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/resourceHandling.js
|
||||
packages/app-desktop/gui/NoteEditor/utils/types.js
|
||||
@@ -394,6 +395,7 @@ packages/app-desktop/integration-tests/util/activateMainMenuItem.js
|
||||
packages/app-desktop/integration-tests/util/createStartupArgs.js
|
||||
packages/app-desktop/integration-tests/util/firstNonDevToolsWindow.js
|
||||
packages/app-desktop/integration-tests/util/setFilePickerResponse.js
|
||||
packages/app-desktop/integration-tests/util/setMessageBoxResponse.js
|
||||
packages/app-desktop/integration-tests/util/test.js
|
||||
packages/app-desktop/playwright.config.js
|
||||
packages/app-desktop/plugins/GotoAnything.js
|
||||
@@ -424,6 +426,8 @@ packages/app-desktop/services/spellChecker/SpellCheckerServiceDriverNative.js
|
||||
packages/app-desktop/tools/copy7Zip.js
|
||||
packages/app-desktop/tools/notarizeMacApp.js
|
||||
packages/app-desktop/tools/renameReleaseAssets.js
|
||||
packages/app-desktop/utils/7zip/getPathToExecutable7Zip.js
|
||||
packages/app-desktop/utils/7zip/pathToBundled7Zip.js
|
||||
packages/app-desktop/utils/checkForUpdatesUtils.test.js
|
||||
packages/app-desktop/utils/checkForUpdatesUtils.js
|
||||
packages/app-desktop/utils/checkForUpdatesUtilsTestData.js
|
||||
@@ -466,10 +470,15 @@ packages/app-mobile/components/NoteEditor/MarkdownToolbar/ToggleSpaceButton.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/Toolbar.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/ToolbarButton.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/ToolbarOverflowRows.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/buttons/useActionButtons.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/buttons/useHeaderButtons.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/buttons/useInlineFormattingButtons.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/buttons/useListButtons.js
|
||||
packages/app-mobile/components/NoteEditor/MarkdownToolbar/types.js
|
||||
packages/app-mobile/components/NoteEditor/NoteEditor.test.js
|
||||
packages/app-mobile/components/NoteEditor/NoteEditor.js
|
||||
packages/app-mobile/components/NoteEditor/SearchPanel.js
|
||||
packages/app-mobile/components/NoteEditor/hooks/useKeyboardVisible.js
|
||||
packages/app-mobile/components/NoteEditor/types.js
|
||||
packages/app-mobile/components/NoteList.js
|
||||
packages/app-mobile/components/ProfileSwitcher/ProfileEditor.js
|
||||
@@ -541,6 +550,7 @@ packages/default-plugins/build.js
|
||||
packages/default-plugins/buildDefaultPlugins.js
|
||||
packages/default-plugins/commands/buildAll.js
|
||||
packages/default-plugins/commands/editPatch.js
|
||||
packages/default-plugins/utils/getCurrentCommitHash.js
|
||||
packages/default-plugins/utils/getPathToPatchFileFor.js
|
||||
packages/default-plugins/utils/readRepositoryJson.js
|
||||
packages/default-plugins/utils/waitForCliInput.js
|
||||
@@ -553,6 +563,8 @@ packages/editor/CodeMirror/configFromSettings.js
|
||||
packages/editor/CodeMirror/createEditor.test.js
|
||||
packages/editor/CodeMirror/createEditor.js
|
||||
packages/editor/CodeMirror/editorCommands/editorCommands.js
|
||||
packages/editor/CodeMirror/editorCommands/insertLineAfter.test.js
|
||||
packages/editor/CodeMirror/editorCommands/insertLineAfter.js
|
||||
packages/editor/CodeMirror/editorCommands/supportsCommand.js
|
||||
packages/editor/CodeMirror/editorCommands/swapLine.js
|
||||
packages/editor/CodeMirror/getScrollFraction.js
|
||||
@@ -577,6 +589,7 @@ packages/editor/CodeMirror/testUtil/forceFullParse.js
|
||||
packages/editor/CodeMirror/testUtil/loadLanguages.js
|
||||
packages/editor/CodeMirror/theme.js
|
||||
packages/editor/CodeMirror/util/isInSyntaxNode.js
|
||||
packages/editor/CodeMirror/util/setupVim.js
|
||||
packages/editor/SelectionFormatting.js
|
||||
packages/editor/events.js
|
||||
packages/editor/types.js
|
||||
@@ -707,16 +720,19 @@ packages/lib/models/Tag.test.js
|
||||
packages/lib/models/Tag.js
|
||||
packages/lib/models/dateTimeFormats.test.js
|
||||
packages/lib/models/settings/FileHandler.js
|
||||
packages/lib/models/settings/settingValidations.js
|
||||
packages/lib/models/utils/isItemId.js
|
||||
packages/lib/models/utils/itemCanBeEncrypted.js
|
||||
packages/lib/models/utils/paginatedFeed.js
|
||||
packages/lib/models/utils/paginationToSql.js
|
||||
packages/lib/models/utils/readOnly.js
|
||||
packages/lib/models/utils/resourceUtils.js
|
||||
packages/lib/models/utils/types.js
|
||||
packages/lib/models/utils/userData.test.js
|
||||
packages/lib/models/utils/userData.js
|
||||
packages/lib/net-utils.js
|
||||
packages/lib/ntp.js
|
||||
packages/lib/onedrive-api.test.js
|
||||
packages/lib/onedrive-api.js
|
||||
packages/lib/path-utils.js
|
||||
packages/lib/reducer.js
|
||||
@@ -940,6 +956,7 @@ packages/lib/services/synchronizer/syncInfoUtils.js
|
||||
packages/lib/services/synchronizer/synchronizer_LockHandler.test.js
|
||||
packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js
|
||||
packages/lib/services/synchronizer/tools.js
|
||||
packages/lib/services/synchronizer/utils/checkDisabledSyncItemsNotification.js
|
||||
packages/lib/services/synchronizer/utils/handleConflictAction.js
|
||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
||||
packages/lib/services/synchronizer/utils/resourceRemotePath.js
|
||||
@@ -1034,13 +1051,15 @@ packages/renderer/MdToHtml/rules/sanitize_html.js
|
||||
packages/renderer/MdToHtml/rules/source_map.js
|
||||
packages/renderer/MdToHtml/setupLinkify.js
|
||||
packages/renderer/MdToHtml/validateLinks.js
|
||||
packages/renderer/assetsToHeaders.js
|
||||
packages/renderer/defaultResourceModel.js
|
||||
packages/renderer/headerAnchor.js
|
||||
packages/renderer/highlight.js
|
||||
packages/renderer/htmlUtils.test.js
|
||||
packages/renderer/htmlUtils.js
|
||||
packages/renderer/index.js
|
||||
packages/renderer/noteStyle.js
|
||||
packages/renderer/pathUtils.js
|
||||
packages/renderer/types.js
|
||||
packages/renderer/utils.js
|
||||
packages/tools/build-release-stats.test.js
|
||||
packages/tools/build-release-stats.js
|
||||
|
@@ -0,0 +1,62 @@
|
||||
diff --git a/android/src/newarch/java/com/reactnativecommunity/slider/ReactSliderManager.java b/android/src/newarch/java/com/reactnativecommunity/slider/ReactSliderManager.java
|
||||
index a5bb95eec3337b93a2338a2869a2bda176c91cae..87817688eb280c2f702c26dc35558c6a0a4db1ea 100644
|
||||
--- a/android/src/newarch/java/com/reactnativecommunity/slider/ReactSliderManager.java
|
||||
+++ b/android/src/newarch/java/com/reactnativecommunity/slider/ReactSliderManager.java
|
||||
@@ -42,12 +42,20 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> implement
|
||||
public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
|
||||
ReactSlider slider = (ReactSlider)seekbar;
|
||||
|
||||
- if(progress < slider.getLowerLimit()) {
|
||||
- progress = slider.getLowerLimit();
|
||||
- seekbar.setProgress(progress);
|
||||
- } else if (progress > slider.getUpperLimit()) {
|
||||
- progress = slider.getUpperLimit();
|
||||
- seekbar.setProgress(progress);
|
||||
+ // During initialization, lowerLimit can be greater than upperLimit.
|
||||
+ //
|
||||
+ // If a change event is received during this, we need a check to prevent
|
||||
+ // infinite recursion.
|
||||
+ //
|
||||
+ // Issue: https://github.com/callstack/react-native-slider/issues/571
|
||||
+ if (slider.getLowerLimit() <= slider.getUpperLimit()) {
|
||||
+ if(progress < slider.getLowerLimit()) {
|
||||
+ progress = slider.getLowerLimit();
|
||||
+ seekbar.setProgress(progress);
|
||||
+ } else if (progress > slider.getUpperLimit()) {
|
||||
+ progress = slider.getUpperLimit();
|
||||
+ seekbar.setProgress(progress);
|
||||
+ }
|
||||
}
|
||||
|
||||
ReactContext reactContext = (ReactContext) seekbar.getContext();
|
||||
diff --git a/android/src/oldarch/java/com/reactnativecommunity/slider/ReactSliderManager.java b/android/src/oldarch/java/com/reactnativecommunity/slider/ReactSliderManager.java
|
||||
index 3ff5930f85a3cd92c2549925f41058abb188a57e..ab3681fdfe0b736c97020e1434e450c8183e6f18 100644
|
||||
--- a/android/src/oldarch/java/com/reactnativecommunity/slider/ReactSliderManager.java
|
||||
+++ b/android/src/oldarch/java/com/reactnativecommunity/slider/ReactSliderManager.java
|
||||
@@ -30,12 +30,20 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
|
||||
public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
|
||||
ReactSlider slider = (ReactSlider)seekbar;
|
||||
|
||||
- if(progress < slider.getLowerLimit()) {
|
||||
- progress = slider.getLowerLimit();
|
||||
- seekbar.setProgress(progress);
|
||||
- } else if(progress > slider.getUpperLimit()) {
|
||||
- progress = slider.getUpperLimit();
|
||||
- seekbar.setProgress(progress);
|
||||
+ // During initialization, lowerLimit can be greater than upperLimit.
|
||||
+ //
|
||||
+ // If a change event is received during this, we need a check to prevent
|
||||
+ // infinite recursion.
|
||||
+ //
|
||||
+ // Issue: https://github.com/callstack/react-native-slider/issues/571
|
||||
+ if (slider.getLowerLimit() <= slider.getUpperLimit()) {
|
||||
+ if(progress < slider.getLowerLimit()) {
|
||||
+ progress = slider.getLowerLimit();
|
||||
+ seekbar.setProgress(progress);
|
||||
+ } else if (progress > slider.getUpperLimit()) {
|
||||
+ progress = slider.getUpperLimit();
|
||||
+ seekbar.setProgress(progress);
|
||||
+ }
|
||||
}
|
||||
|
||||
ReactContext reactContext = (ReactContext) seekbar.getContext();
|
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
BIN
Assets/WebsiteAssets/images/news/20240127-promo-tile.png
Normal file
BIN
Assets/WebsiteAssets/images/news/20240127-promo-tile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 282 KiB |
BIN
Assets/WebsiteAssets/images/sponsors/Celebian.png
Normal file
BIN
Assets/WebsiteAssets/images/sponsors/Celebian.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
@@ -1,4 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Joplin]]></title><description><![CDATA[Joplin, the open source note-taking application]]></description><link>https://joplinapp.org</link><generator>RSS for Node</generator><lastBuildDate>Sat, 23 Dec 2023 00:00:00 GMT</lastBuildDate><atom:link href="https://joplinapp.org/rss.xml" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 Dec 2023 00:00:00 GMT</pubDate><item><title><![CDATA[Faster synchronisation in upcoming Joplin version!]]></title><description><![CDATA[<p>The next version of Joplin Cloud (and Joplin Server) will include a change that will make synchronisation, in particular when synchronising a new device for the first time, significantly faster. This is achieved by bundling more data with the calls that retrieve notes and other data, thus reducing the number of unnecessary requests.</p>
|
||||
<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Joplin]]></title><description><![CDATA[Joplin, the open source note-taking application]]></description><link>https://joplinapp.org</link><generator>RSS for Node</generator><lastBuildDate>Sat, 27 Jan 2024 00:00:00 GMT</lastBuildDate><atom:link href="https://joplinapp.org/rss.xml" rel="self" type="application/rss+xml"/><pubDate>Sat, 27 Jan 2024 00:00:00 GMT</pubDate><item><title><![CDATA[Support for new plugin metadata]]></title><description><![CDATA[<p>The plugin manifest now supports new properties to better describe and present your plugins on Joplin Plugins website. Those are the <code>icons</code>, <code>categories</code>, <code>screenshots</code> and <code>promo_tile</code> properties.</p>
|
||||
<h2>Icon<a name="icon" href="#icon" class="heading-anchor">🔗</a></h2>
|
||||
<p>This is the icon that will be used in various plugin pages, including in your main plugin page. It will be shown on the main result page too. If not provided, a default icon will be displayed instead.</p>
|
||||
<h2>Category<a name="category" href="#category" class="heading-anchor">🔗</a></h2>
|
||||
<p>You can supply one or more category for your plugin - it will be used to filter the plugins on the website.</p>
|
||||
<h2>Screenshots<a name="screenshots" href="#screenshots" class="heading-anchor">🔗</a></h2>
|
||||
<p>Again you can provide one or more screenshots to present your plugin on the website.</p>
|
||||
<p><img src="https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/news/20240127-icon-category-screenshot.png" alt=""></p>
|
||||
<p><em>An example of plugin with icon, category and screenshot</em></p>
|
||||
<h2>Promo tile<a name="promo-tile" href="#promo-tile" class="heading-anchor">🔗</a></h2>
|
||||
<p>The promo tile is an optional image that is used to display your plugin on the main website page. If no promo tile is supplied, the icon will be used instead.</p>
|
||||
<p><img src="https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/news/20240127-promo-tile.png" alt=""></p>
|
||||
<p><em>An example of promo tile</em></p>
|
||||
<h2>More information<a name="more-information" href="#more-information" class="heading-anchor">🔗</a></h2>
|
||||
<p>For more information on how to set this plugin metadata, please check the <a href="https://joplinapp.org/help/api/references/plugin_manifest">Plugin Manifest documentation</a></p>
|
||||
]]></description><link>https://joplinapp.org/news/20240127-new-plugin-metadata</link><guid isPermaLink="false">20240127-new-plugin-metadata</guid><pubDate>Sat, 27 Jan 2024 00:00:00 GMT</pubDate><twitter-text></twitter-text></item><item><title><![CDATA[Faster synchronisation in upcoming Joplin version!]]></title><description><![CDATA[<p>The next version of Joplin Cloud (and Joplin Server) will include a change that will make synchronisation, in particular when synchronising a new device for the first time, significantly faster. This is achieved by bundling more data with the calls that retrieve notes and other data, thus reducing the number of unnecessary requests.</p>
|
||||
<p>This change will be applied soon to Joplin Cloud (and Server), and the Joplin mobile, desktop and CLI applications will be able to use it from version 2.14.</p>
|
||||
<p>In my tests with about 26,000 items, synchronisation was more than twice as fast on Joplin Cloud (22.5 minutes vs 9.5 minutes):</p>
|
||||
<h2>Before<a name="before" href="#before" class="heading-anchor">🔗</a></h2>
|
||||
@@ -349,19 +364,4 @@ sys 0m38.013s</p>
|
||||
<p>In the coming month (<strong>March 7 - April 3</strong>), contributors will start getting involved in the forum and start discussing project ideas with the mentors and community. It's also a good time to start looking at Joplin's source code, perhaps work on fixing bugs or implement small features to get familiar with the source code, and to show us your skills.</p>
|
||||
<p>One difference with previous years is that anyone, not just students, are allowed to participate.</p>
|
||||
<p>Additionally, last year Google only allowed smaller projects, while this year they allow again small and large projects, so we've indicated this in the idea list - the small ones are <strong>175 hours</strong>, and the large ones <strong>350 hours</strong>.</p>
|
||||
]]></description><link>https://joplinapp.org/news/20220308-gsoc2022-start</link><guid isPermaLink="false">20220308-gsoc2022-start</guid><pubDate>Tue, 08 Mar 2022 00:00:00 GMT</pubDate><twitter-text></twitter-text></item><item><title><![CDATA[Joplin 2.7 is available!]]></title><description><![CDATA[<p>This new release is largely focused on bug fixing and optimising various parts of the apps. There's about 26 improvements and 25 bugs and security fixes included - as always many of these apply to both the mobile and desktop app (see the <a href="https://joplinapp.org/help/about/changelog/desktop">desktop changelog</a> and <a href="https://joplinapp.org/help/about/changelog/android/">mobile changelog</a>).</p>
|
||||
<p>Many thanks to all the contributors who helped create this release!</p>
|
||||
<p>Below are some of the more noticeable changes:</p>
|
||||
<h2>Notebook custom icons<a name="notebook-custom-icons" href="#notebook-custom-icons" class="heading-anchor">🔗</a></h2>
|
||||
<p>Since version 2.6 it was possible to assign an emoji icon to a notebook, and with this new version it's now possible to assign any custom icon. The icon may be a PNG or JPG file of any size. The app will then import the file and resize it to the correct size. To use a custom icon, follow these steps:</p>
|
||||
<p>Right-click on a notebook, and select "Edit":</p>
|
||||
<p><img src="https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/news/20220224-edit-notebook.png" alt=""></p>
|
||||
<p>In the "Edit notebook" dialog, click "Select file..." and browse to your icon image:</p>
|
||||
<p><img src="https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/news/20220224-edit-dialog.png" alt=""></p>
|
||||
<p>Click "OK" and the icon will now appear next to the notebook:</p>
|
||||
<p><img src="https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/news/20220224-notebook-icon.png" alt=""></p>
|
||||
<p>The icon can be changed only from the desktop application at the moment, but it will sync and be displayed correctly on the mobile app too.</p>
|
||||
<h2>Plugin API improvements<a name="plugin-api-improvements" href="#plugin-api-improvements" class="heading-anchor">🔗</a></h2>
|
||||
<p>This version also includes a number of improvements to the plugin API, in particular it is now easier to customise the editor context menu from a plugin and dynamically add items to it depending on the context. For example, with the Rich Markdown plugin it will be possible to right-click on an image and open it, or copy it to the clipboard.</p>
|
||||
<p>A few additional functions have also been added to make plugin development simpler - in particular a command to open any item, whether it's a notebook, note, tag or attachement; and functions to work with attachements, in particular to reveal an attachement in the system file explorer, and to track changes to an attachement.</p>
|
||||
]]></description><link>https://joplinapp.org/news/20220224-release-2-7</link><guid isPermaLink="false">20220224-release-2-7</guid><pubDate>Thu, 24 Feb 2022 00:00:00 GMT</pubDate><twitter-text></twitter-text></item></channel></rss>
|
||||
]]></description><link>https://joplinapp.org/news/20220308-gsoc2022-start</link><guid isPermaLink="false">20220308-gsoc2022-start</guid><pubDate>Tue, 08 Mar 2022 00:00:00 GMT</pubDate><twitter-text></twitter-text></item></channel></rss>
|
@@ -5,62 +5,64 @@ set -e
|
||||
trap 'handleError' ERR
|
||||
|
||||
handleError() {
|
||||
echo ""
|
||||
echo "If you encountered an error, please consider fixing"
|
||||
echo "the script for your environment and creating a pull"
|
||||
echo "request instead of asking for support on GitHub or"
|
||||
echo "the forum. The error message above should tell you"
|
||||
echo "where and why the error happened."
|
||||
echo ""
|
||||
echo "If you encountered an error, please consider fixing"
|
||||
echo "the script for your environment and creating a pull"
|
||||
echo "request instead of asking for support on GitHub or"
|
||||
echo "the forum. The error message above should tell you"
|
||||
echo "where and why the error happened."
|
||||
}
|
||||
|
||||
#-----------------------------------------------------
|
||||
# Variables
|
||||
#-----------------------------------------------------
|
||||
COLOR_RED=`tput setaf 1`
|
||||
COLOR_GREEN=`tput setaf 2`
|
||||
COLOR_YELLOW=`tput setaf 3`
|
||||
COLOR_BLUE=`tput setaf 4`
|
||||
COLOR_RESET=`tput sgr0`
|
||||
# Only set colors, if tput available and TERM is recognized
|
||||
if [[ `command -v tput` && `tput setaf 1 2>/dev/null` ]]; then
|
||||
COLOR_RED=`tput setaf 1`
|
||||
COLOR_GREEN=`tput setaf 2`
|
||||
COLOR_YELLOW=`tput setaf 3`
|
||||
COLOR_BLUE=`tput setaf 4`
|
||||
COLOR_RESET=`tput sgr0`
|
||||
fi
|
||||
SILENT=false
|
||||
ALLOW_ROOT=false
|
||||
SHOW_CHANGELOG=false
|
||||
INCLUDE_PRE_RELEASE=false
|
||||
|
||||
print() {
|
||||
if [[ "${SILENT}" == false ]] ; then
|
||||
echo -e "$@"
|
||||
fi
|
||||
if [[ "${SILENT}" == false ]]; then
|
||||
echo -e "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
showLogo() {
|
||||
print "${COLOR_BLUE}"
|
||||
print " _ _ _ "
|
||||
print " | | ___ _ __ | (_)_ __ "
|
||||
print " _ | |/ _ \| '_ \| | | '_ \ "
|
||||
print "| |_| | (_) | |_) | | | | | |"
|
||||
print " \___/ \___/| .__/|_|_|_| |_|"
|
||||
print " |_|"
|
||||
print ""
|
||||
print "Linux Installer and Updater"
|
||||
print "${COLOR_RESET}"
|
||||
print "${COLOR_BLUE}"
|
||||
print " _ _ _ "
|
||||
print " | | ___ _ __ | (_)_ __ "
|
||||
print " _ | |/ _ \| '_ \| | | '_ \ "
|
||||
print "| |_| | (_) | |_) | | | | | |"
|
||||
print " \___/ \___/| .__/|_|_|_| |_|"
|
||||
print " |_|"
|
||||
print ""
|
||||
print "Linux Installer and Updater"
|
||||
print "${COLOR_RESET}"
|
||||
}
|
||||
|
||||
showHelp() {
|
||||
showLogo
|
||||
print "Available Arguments:"
|
||||
print "\t" "--help" "\t" "Show this help information" "\n"
|
||||
print "\t" "--allow-root" "\t" "Allow the install to be run as root"
|
||||
print "\t" "--changelog" "\t" "Show the changelog after installation"
|
||||
print "\t" "--force" "\t" "Always download the latest version"
|
||||
print "\t" "--silent" "\t" "Don't print any output"
|
||||
print "\t" "--prerelease" "\t" "Check for new Versions including Pre-Releases"
|
||||
|
||||
if [[ ! -z $1 ]]; then
|
||||
print "\n" "${COLOR_RED}ERROR: " "$*" "${COLOR_RESET}" "\n"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
showLogo
|
||||
print "Available Arguments:"
|
||||
print "\t" "--help" "\t" "Show this help information" "\n"
|
||||
print "\t" "--allow-root" "\t" "Allow the install to be run as root"
|
||||
print "\t" "--changelog" "\t" "Show the changelog after installation"
|
||||
print "\t" "--force" "\t" "Always download the latest version"
|
||||
print "\t" "--silent" "\t" "Don't print any output"
|
||||
print "\t" "--prerelease" "\t" "Check for new Versions including Pre-Releases"
|
||||
|
||||
if [[ ! -z $1 ]]; then
|
||||
print "\n" "${COLOR_RED}ERROR: " "$*" "${COLOR_RESET}" "\n"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
#-----------------------------------------------------
|
||||
@@ -71,9 +73,9 @@ optspec=":h-:"
|
||||
while getopts "${optspec}" OPT; do
|
||||
[ "${OPT}" = " " ] && continue
|
||||
if [ "${OPT}" = "-" ]; then # long option: reformulate OPT and OPTARG
|
||||
OPT="${OPTARG%%=*}" # extract long option name
|
||||
OPTARG="${OPTARG#$OPT}" # extract long option argument (may be empty)
|
||||
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
|
||||
OPT="${OPTARG%%=*}" # extract long option name
|
||||
OPTARG="${OPTARG#$OPT}" # extract long option argument (may be empty)
|
||||
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
|
||||
fi
|
||||
case "${OPT}" in
|
||||
h | help ) showHelp ;;
|
||||
@@ -90,8 +92,8 @@ shift $((OPTIND-1)) # remove parsed options and args from $@ list
|
||||
|
||||
## Check and warn if running as root.
|
||||
if [[ $EUID = 0 ]] && [[ "${ALLOW_ROOT}" != true ]]; then
|
||||
showHelp "It is not recommended (nor necessary) to run this script as root. To do so anyway, please use '--allow-root'"
|
||||
exit 1
|
||||
showHelp "It is not recommended (nor necessary) to run this script as root. To do so anyway, please use '--allow-root'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#-----------------------------------------------------
|
||||
@@ -104,12 +106,12 @@ print "Checking architecture..."
|
||||
## uname actually gives more information than needed, but it contains all architectures (hardware and software)
|
||||
ARCHITECTURE=$(uname -m -p -i || echo "NO CHECK")
|
||||
|
||||
if [[ $ARCHITECTURE = "NO CHECK" ]] ; then
|
||||
if [[ $ARCHITECTURE = "NO CHECK" ]]; then
|
||||
print "${COLOR_YELLOW}WARNING: Can't get system architecture, skipping check${COLOR_RESET}"
|
||||
elif [[ $ARCHITECTURE =~ .*aarch.*|.*arm.* ]] ; then
|
||||
elif [[ $ARCHITECTURE =~ .*aarch.*|.*arm.* ]]; then
|
||||
showHelp "Arm systems are not officially supported by Joplin, please search the forum (https://discourse.joplinapp.org/) for more information"
|
||||
exit 1
|
||||
elif [[ $ARCHITECTURE =~ .*i386.*|.*i686.* ]] ; then
|
||||
elif [[ $ARCHITECTURE =~ .*i386.*|.*i686.* ]]; then
|
||||
showHelp "32-bit systems are not supported by Joplin, please search the forum (https://discourse.joplinapp.org/) for more information"
|
||||
exit 1
|
||||
fi
|
||||
@@ -122,7 +124,7 @@ if [[ $(command -v ldconfig) ]]; then
|
||||
else
|
||||
LIBFUSE=$(find /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib -name "libfuse.so.2" 2>/dev/null | grep "libfuse.so.2" || echo '')
|
||||
fi
|
||||
if [[ $LIBFUSE == "" ]] ; then
|
||||
if [[ $LIBFUSE == "" ]]; then
|
||||
print "${COLOR_RED}Error: Can't get libfuse2 on system, please install libfuse2${COLOR_RESET}"
|
||||
print "See https://joplinapp.org/help/faq/#desktop-application-will-not-launch-on-linux and https://github.com/AppImage/AppImageKit/wiki/FUSE for more information"
|
||||
exit 1
|
||||
@@ -141,17 +143,17 @@ fi
|
||||
|
||||
# Check if it's in the latest version
|
||||
if [[ -e ~/.joplin/VERSION ]] && [[ $(< ~/.joplin/VERSION) == "${RELEASE_VERSION}" ]]; then
|
||||
print "${COLOR_GREEN}You already have the latest version${COLOR_RESET} ${RELEASE_VERSION} ${COLOR_GREEN}installed.${COLOR_RESET}"
|
||||
([[ "$FORCE" == true ]] && print "Forcing installation...") || exit 0
|
||||
print "${COLOR_GREEN}You already have the latest version${COLOR_RESET} ${RELEASE_VERSION} ${COLOR_GREEN}installed.${COLOR_RESET}"
|
||||
([[ "$FORCE" == true ]] && print "Forcing installation...") || exit 0
|
||||
else
|
||||
[[ -e ~/.joplin/VERSION ]] && CURRENT_VERSION=$(< ~/.joplin/VERSION)
|
||||
print "The latest version is ${RELEASE_VERSION}, but you have ${CURRENT_VERSION:-no version} installed."
|
||||
[[ -e ~/.joplin/VERSION ]] && CURRENT_VERSION=$(< ~/.joplin/VERSION)
|
||||
print "The latest version is ${RELEASE_VERSION}, but you have ${CURRENT_VERSION:-no version} installed."
|
||||
fi
|
||||
|
||||
# Check if it's an update or a new install
|
||||
DOWNLOAD_TYPE="New"
|
||||
if [[ -f ~/.joplin/Joplin.AppImage ]]; then
|
||||
DOWNLOAD_TYPE="Update"
|
||||
DOWNLOAD_TYPE="Update"
|
||||
fi
|
||||
|
||||
#-----------------------------------------------------
|
||||
@@ -183,8 +185,7 @@ mv "${TEMP_DIR}/joplin.png" ~/.local/share/icons/hicolor/512x512/apps/joplin.png
|
||||
print "${COLOR_GREEN}OK${COLOR_RESET}"
|
||||
|
||||
# Detect desktop environment
|
||||
if [ "$XDG_CURRENT_DESKTOP" = "" ]
|
||||
then
|
||||
if [ "$XDG_CURRENT_DESKTOP" = "" ]; then
|
||||
DESKTOP=$(echo "${XDG_DATA_DIRS}" | sed 's/.*\(xfce\|kde\|gnome\).*/\1/')
|
||||
else
|
||||
DESKTOP=$XDG_CURRENT_DESKTOP
|
||||
@@ -210,8 +211,7 @@ if command -v lsb_release &> /dev/null; then
|
||||
# uses these to sandbox processes. Unfortunately, it doesn't look like we can get around this
|
||||
# without writing the AppImage to a non-user-writable location (without invalidating other security
|
||||
# controls). See https://discourse.joplinapp.org/t/possible-future-requirement-for-no-sandbox-flag-for-ubuntu-23-10/.
|
||||
if [[ $DISTVER = "Ubuntu23.10" || $DISTVER =~ Debian1. || ( "$DISTVER" = "Linuxmint4" && "$DISTCODENAME" = "debbie" ) || ( "$DISTVER" = "CentOS" && "$DISTMAJOR" =~ 6|7 ) ]]
|
||||
then
|
||||
if [[ $DISTVER = "Ubuntu23.10" || $DISTVER =~ Debian1. || ( "$DISTVER" = "Linuxmint4" && "$DISTCODENAME" = "debbie" ) || ( "$DISTVER" = "CentOS" && "$DISTMAJOR" =~ 6|7 ) ]]; then
|
||||
SANDBOXPARAM="--no-sandbox"
|
||||
print "${COLOR_YELLOW}WARNING${COLOR_RESET} Electron sandboxing disabled."
|
||||
print " See https://discourse.joplinapp.org/t/32160/5 for details."
|
||||
@@ -222,41 +222,40 @@ fi
|
||||
# `.local/share/desktop` had a desktop file created.
|
||||
# However some environments don't return a desktop BUT still support these desktop files
|
||||
# the command check was added to support all Desktops that have support for the
|
||||
# freedesktop standard
|
||||
# freedesktop standard
|
||||
# The old checks are left in place for historical reasons, but
|
||||
# NO MORE DESKTOP ENVIRONMENTS SHOULD BE ADDED
|
||||
# If a new environment needs to be supported, then the command check section should be re-thought
|
||||
if [[ $DESKTOP =~ .*gnome.*|.*kde.*|.*xfce.*|.*mate.*|.*lxqt.*|.*unity.*|.*x-cinnamon.*|.*deepin.*|.*pantheon.*|.*lxde.*|.*i3.*|.*sway.* ]] || [[ `command -v update-desktop-database` ]]
|
||||
then
|
||||
DATA_HOME=${XDG_DATA_HOME:-~/.local/share}
|
||||
DESKTOP_FILE_LOCATION="$DATA_HOME/applications"
|
||||
# Only delete the desktop file if it will be replaced
|
||||
rm -f "$DESKTOP_FILE_LOCATION/appimagekit-joplin.desktop"
|
||||
if [[ $DESKTOP =~ .*gnome.*|.*kde.*|.*xfce.*|.*mate.*|.*lxqt.*|.*unity.*|.*x-cinnamon.*|.*deepin.*|.*pantheon.*|.*lxde.*|.*i3.*|.*sway.* ]] || [[ `command -v update-desktop-database` ]]; then
|
||||
DATA_HOME=${XDG_DATA_HOME:-~/.local/share}
|
||||
DESKTOP_FILE_LOCATION="$DATA_HOME/applications"
|
||||
# Only delete the desktop file if it will be replaced
|
||||
rm -f "$DESKTOP_FILE_LOCATION/appimagekit-joplin.desktop"
|
||||
|
||||
# On some systems this directory doesn't exist by default
|
||||
mkdir -p "$DESKTOP_FILE_LOCATION"
|
||||
|
||||
# Tabs specifically, and not spaces, are needed for indentation with Bash heredocs
|
||||
cat >> "$DESKTOP_FILE_LOCATION/appimagekit-joplin.desktop" <<-EOF
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Joplin
|
||||
Comment=Joplin for Desktop
|
||||
Exec=${HOME}/.joplin/Joplin.AppImage ${SANDBOXPARAM} %u
|
||||
Icon=joplin
|
||||
StartupWMClass=Joplin
|
||||
Type=Application
|
||||
Categories=Office;
|
||||
MimeType=x-scheme-handler/joplin;
|
||||
X-GNOME-SingleWindow=true // should be removed eventually as it was upstream to be an XDG specification
|
||||
SingleMainWindow=true
|
||||
EOF
|
||||
|
||||
# Update application icons
|
||||
[[ `command -v update-desktop-database` ]] && update-desktop-database "$DESKTOP_FILE_LOCATION" && update-desktop-database "$DATA_HOME/icons"
|
||||
print "${COLOR_GREEN}OK${COLOR_RESET}"
|
||||
# On some systems this directory doesn't exist by default
|
||||
mkdir -p "$DESKTOP_FILE_LOCATION"
|
||||
|
||||
# No spaces or tabs should be used for indentation with Bash heredocs
|
||||
cat >> "$DESKTOP_FILE_LOCATION/appimagekit-joplin.desktop" <<-EOF
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Joplin
|
||||
Comment=Joplin for Desktop
|
||||
Exec=${HOME}/.joplin/Joplin.AppImage ${SANDBOXPARAM} %u
|
||||
Icon=joplin
|
||||
StartupWMClass=Joplin
|
||||
Type=Application
|
||||
Categories=Office;
|
||||
MimeType=x-scheme-handler/joplin;
|
||||
X-GNOME-SingleWindow=true // should be removed eventually as it was upstream to be an XDG specification
|
||||
SingleMainWindow=true
|
||||
EOF
|
||||
|
||||
# Update application icons
|
||||
[[ `command -v update-desktop-database` ]] && update-desktop-database "$DESKTOP_FILE_LOCATION" && update-desktop-database "$DATA_HOME/icons"
|
||||
print "${COLOR_GREEN}OK${COLOR_RESET}"
|
||||
else
|
||||
print "${COLOR_RED}NOT DONE, unknown desktop '${DESKTOP}'${COLOR_RESET}"
|
||||
print "${COLOR_RED}NOT DONE, unknown desktop '${DESKTOP}'${COLOR_RESET}"
|
||||
fi
|
||||
|
||||
#-----------------------------------------------------
|
||||
@@ -271,8 +270,8 @@ echo "$RELEASE_VERSION" > ~/.joplin/VERSION
|
||||
|
||||
#-----------------------------------------------------
|
||||
if [[ "$SHOW_CHANGELOG" == true ]]; then
|
||||
NOTES=$(wget -qO - https://api.github.com/repos/laurent22/joplin/releases/latest | grep -Po '"body": "\K.*(?=")')
|
||||
print "${COLOR_BLUE}Changelog:${COLOR_RESET}\n${NOTES}"
|
||||
NOTES=$(wget -qO - https://api.github.com/repos/laurent22/joplin/releases/latest | grep -Po '"body": "\K.*(?=")')
|
||||
print "${COLOR_BLUE}Changelog:${COLOR_RESET}\n${NOTES}"
|
||||
fi
|
||||
|
||||
#-----------------------------------------------------
|
||||
|
@@ -31,7 +31,7 @@ Please see the [donation page](https://github.com/laurent22/joplin/blob/dev/read
|
||||
# Sponsors
|
||||
|
||||
<!-- SPONSORS-ORG -->
|
||||
<a href="https://seirei.ne.jp"><img title="Serei Network" width="256" src="https://joplinapp.org/images/sponsors/SeireiNetwork.png"/></a> <a href="https://www.hosting.de/nextcloud/?mtm_campaign=managed-nextcloud&mtm_kwd=joplinapp&mtm_source=joplinapp-webseite&mtm_medium=banner"><img title="Hosting.de" width="256" src="https://joplinapp.org/images/sponsors/HostingDe.png"/></a> <a href="https://residence-greece.com/"><img title="Greece Golden Visa" width="256" src="https://joplinapp.org/images/sponsors/ResidenceGreece.jpg"/></a> <a href="https://grundstueckspreise.info/"><img title="SP Software GmbH" width="256" src="https://joplinapp.org/images/sponsors/Grundstueckspreise.png"/></a> <a href="https://tranio.com/spain/"><img title="Property for sale in Spain" width="256" src="https://joplinapp.org/images/sponsors/TranioOverseasProperty.jpg"/></a> <a href="https://citricsheep.com"><img title="Citric Sheep" width="256" src="https://joplinapp.org/images/sponsors/CitricSheep.png"/></a> <a href="https://sorted.travel/?utm_source=joplinapp "><img title="Sorted Travel" width="256" src="https://joplinapp.org/images/sponsors/SortedTravel.png"/></a>
|
||||
<a href="https://seirei.ne.jp"><img title="Serei Network" width="256" src="https://joplinapp.org/images/sponsors/SeireiNetwork.png"/></a> <a href="https://www.hosting.de/nextcloud/?mtm_campaign=managed-nextcloud&mtm_kwd=joplinapp&mtm_source=joplinapp-webseite&mtm_medium=banner"><img title="Hosting.de" width="256" src="https://joplinapp.org/images/sponsors/HostingDe.png"/></a> <a href="https://grundstueckspreise.info/"><img title="SP Software GmbH" width="256" src="https://joplinapp.org/images/sponsors/Grundstueckspreise.png"/></a> <a href="https://citricsheep.com"><img title="Citric Sheep" width="256" src="https://joplinapp.org/images/sponsors/CitricSheep.png"/></a> <a href="https://sorted.travel/?utm_source=joplinapp "><img title="Sorted Travel" width="256" src="https://joplinapp.org/images/sponsors/SortedTravel.png"/></a> <a href="https://celebian.com "><img title="Celebian" width="256" src="https://joplinapp.org/images/sponsors/Celebian.png"/></a>
|
||||
<!-- SPONSORS-ORG -->
|
||||
|
||||
* * *
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# For development this compose file starts the database only. The app can then
|
||||
# be started using `yarn run start-dev`, which is useful for development, because
|
||||
# be started using `yarn start-dev`, which is useful for development, because
|
||||
# it means the app Docker file doesn't have to be rebuilt on each change.
|
||||
|
||||
version: '3'
|
||||
|
@@ -11,9 +11,9 @@ module.exports = {
|
||||
//
|
||||
// '**/*.ts?(x)': () => 'npm run tsc',
|
||||
'*.{js,jsx,ts,tsx}': [
|
||||
'yarn run checkIgnoredFiles',
|
||||
// 'yarn run checkLibPaths',
|
||||
'yarn run packageJsonLint',
|
||||
'yarn run linter-precommit',
|
||||
'yarn checkIgnoredFiles',
|
||||
// 'yarn checkLibPaths',
|
||||
'yarn packageJsonLint',
|
||||
'yarn linter-precommit',
|
||||
],
|
||||
};
|
||||
|
15
package.json
15
package.json
@@ -14,13 +14,13 @@
|
||||
"scripts": {
|
||||
"buildApiDoc": "yarn workspace joplin start apidoc ../../readme/api/references/rest_api.md",
|
||||
"buildScriptIndexes": "node packages/tools/gulp/tasks/buildScriptIndexesRun.js",
|
||||
"buildParallel": "yarn workspaces foreach --verbose --interlaced --parallel --jobs 2 --topological run build && yarn run tsc",
|
||||
"buildPluginDoc": "cd packages/generate-plugin-doc && yarn run buildPluginDoc_",
|
||||
"buildSequential": "yarn workspaces foreach --verbose --interlaced --topological run build && yarn run tsc",
|
||||
"buildParallel": "yarn workspaces foreach --verbose --interlaced --parallel --jobs 2 --topological run build && yarn tsc",
|
||||
"buildPluginDoc": "cd packages/generate-plugin-doc && yarn buildPluginDoc_",
|
||||
"buildSequential": "yarn workspaces foreach --verbose --interlaced --topological run build && yarn tsc",
|
||||
"buildServerDocker": "node packages/tools/buildServerDocker.js",
|
||||
"buildSettingJsonSchema": "yarn workspace joplin start settingschema ../../../joplin-website/docs/schema/settings.json",
|
||||
"buildTranslations": "node packages/tools/build-translation.js",
|
||||
"buildWebsite": "node ./packages/tools/website/processDocs.js --env prod && node ./packages/tools/website/build.js && yarn run buildPluginDoc && yarn run buildSettingJsonSchema",
|
||||
"buildWebsite": "node ./packages/tools/website/processDocs.js --env prod && node ./packages/tools/website/build.js && yarn buildPluginDoc && yarn buildSettingJsonSchema",
|
||||
"buildWebsiteTranslations": "node packages/tools/website/buildTranslations.js",
|
||||
"checkIgnoredFiles": "node ./packages/tools/checkIgnoredFiles.js",
|
||||
"checkLibPaths": "node ./packages/tools/checkLibPaths.js",
|
||||
@@ -40,7 +40,7 @@
|
||||
"packageJsonLint": "node ./packages/tools/packageJsonLint.js",
|
||||
"postinstall": "gulp build",
|
||||
"postPreReleasesToForum": "node ./packages/tools/postPreReleasesToForum",
|
||||
"publishAll": "git pull && yarn run buildParallel && lerna version --yes --no-private --no-git-tag-version && gulp completePublishAll",
|
||||
"publishAll": "git pull && yarn buildParallel && lerna version --yes --no-private --no-git-tag-version && gulp completePublishAll",
|
||||
"releaseAndroid": "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",
|
||||
@@ -87,7 +87,7 @@
|
||||
"gulp": "4.0.2",
|
||||
"husky": "3.1.0",
|
||||
"lerna": "3.22.1",
|
||||
"lint-staged": "14.0.1",
|
||||
"lint-staged": "15.2.0",
|
||||
"madge": "6.1.0",
|
||||
"npm-package-json-lint": "7.1.0",
|
||||
"typescript": "5.2.2"
|
||||
@@ -107,6 +107,7 @@
|
||||
"app-builder-lib@24.4.0": "patch:app-builder-lib@npm%3A24.4.0#./.yarn/patches/app-builder-lib-npm-24.4.0-05322ff057.patch",
|
||||
"react-native@0.71.10": "patch:react-native@npm%3A0.71.10#./.yarn/patches/react-native-animation-fix/react-native-npm-0.71.10-f9c32562d8.patch",
|
||||
"nanoid": "patch:nanoid@npm%3A3.3.7#./.yarn/patches/nanoid-npm-3.3.7-98824ba130.patch",
|
||||
"pdfjs-dist": "patch:pdfjs-dist@npm%3A3.11.174#./.yarn/patches/pdfjs-dist-npm-3.11.174-67f2fee6d6.patch"
|
||||
"pdfjs-dist": "patch:pdfjs-dist@npm%3A3.11.174#./.yarn/patches/pdfjs-dist-npm-3.11.174-67f2fee6d6.patch",
|
||||
"@react-native-community/slider@4.4.4": "patch:@react-native-community/slider@npm%3A4.4.4#./.yarn/patches/@react-native-community-slider-npm-4.4.4-d78e472f48.patch"
|
||||
}
|
||||
}
|
||||
|
@@ -1,469 +1,461 @@
|
||||
const BaseApplication = require('@joplin/lib/BaseApplication').default;
|
||||
const { refreshFolders } = require('@joplin/lib/folders-screen-utils.js');
|
||||
const ResourceService = require('@joplin/lib/services/ResourceService').default;
|
||||
const BaseModel = require('@joplin/lib/BaseModel').default;
|
||||
const Folder = require('@joplin/lib/models/Folder').default;
|
||||
const BaseItem = require('@joplin/lib/models/BaseItem').default;
|
||||
const Note = require('@joplin/lib/models/Note').default;
|
||||
const Tag = require('@joplin/lib/models/Tag').default;
|
||||
const Setting = require('@joplin/lib/models/Setting').default;
|
||||
const { reg } = require('@joplin/lib/registry.js');
|
||||
const { fileExtension } = require('@joplin/lib/path-utils');
|
||||
const { splitCommandString } = require('@joplin/utils');
|
||||
const { splitCommandBatch } = require('@joplin/lib/string-utils');
|
||||
const { _ } = require('@joplin/lib/locale');
|
||||
const fs = require('fs-extra');
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const BaseApplication_1 = require("@joplin/lib/BaseApplication");
|
||||
const folders_screen_utils_js_1 = require("@joplin/lib/folders-screen-utils.js");
|
||||
const ResourceService_1 = require("@joplin/lib/services/ResourceService");
|
||||
const BaseModel_1 = require("@joplin/lib/BaseModel");
|
||||
const Folder_1 = require("@joplin/lib/models/Folder");
|
||||
const BaseItem_1 = require("@joplin/lib/models/BaseItem");
|
||||
const Note_1 = require("@joplin/lib/models/Note");
|
||||
const Tag_1 = require("@joplin/lib/models/Tag");
|
||||
const Setting_1 = require("@joplin/lib/models/Setting");
|
||||
const registry_js_1 = require("@joplin/lib/registry.js");
|
||||
const path_utils_1 = require("@joplin/lib/path-utils");
|
||||
const utils_1 = require("@joplin/utils");
|
||||
const locale_1 = require("@joplin/lib/locale");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const RevisionService_1 = require("@joplin/lib/services/RevisionService");
|
||||
const shim_1 = require("@joplin/lib/shim");
|
||||
const setupCommand_1 = require("./setupCommand");
|
||||
const { cliUtils } = require('./cli-utils.js');
|
||||
const Cache = require('@joplin/lib/Cache');
|
||||
const RevisionService = require('@joplin/lib/services/RevisionService').default;
|
||||
const shim = require('@joplin/lib/shim').default;
|
||||
const setupCommand = require('./setupCommand').default;
|
||||
|
||||
class Application extends BaseApplication {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.showPromptString_ = true;
|
||||
this.commands_ = {};
|
||||
this.commandMetadata_ = null;
|
||||
this.activeCommand_ = null;
|
||||
this.allCommandsLoaded_ = false;
|
||||
this.showStackTraces_ = false;
|
||||
this.gui_ = null;
|
||||
this.cache_ = new Cache();
|
||||
}
|
||||
|
||||
gui() {
|
||||
return this.gui_;
|
||||
}
|
||||
|
||||
commandStdoutMaxWidth() {
|
||||
return this.gui().stdoutMaxWidth();
|
||||
}
|
||||
|
||||
async guessTypeAndLoadItem(pattern, options = null) {
|
||||
let type = BaseModel.TYPE_NOTE;
|
||||
if (pattern.indexOf('/') === 0) {
|
||||
type = BaseModel.TYPE_FOLDER;
|
||||
pattern = pattern.substr(1);
|
||||
}
|
||||
return this.loadItem(type, pattern, options);
|
||||
}
|
||||
|
||||
async loadItem(type, pattern, options = null) {
|
||||
const output = await this.loadItems(type, pattern, options);
|
||||
|
||||
if (output.length > 1) {
|
||||
// output.sort((a, b) => { return a.user_updated_time < b.user_updated_time ? +1 : -1; });
|
||||
|
||||
// let answers = { 0: _('[Cancel]') };
|
||||
// for (let i = 0; i < output.length; i++) {
|
||||
// answers[i + 1] = output[i].title;
|
||||
// }
|
||||
|
||||
// Not really useful with new UI?
|
||||
throw new Error(_('More than one item match "%s". Please narrow down your query.', pattern));
|
||||
|
||||
// let msg = _('More than one item match "%s". Please select one:', pattern);
|
||||
// const response = await cliUtils.promptMcq(msg, answers);
|
||||
// if (!response) return null;
|
||||
|
||||
// return output[response - 1];
|
||||
} else {
|
||||
return output.length ? output[0] : null;
|
||||
}
|
||||
}
|
||||
|
||||
async loadItems(type, pattern, options = null) {
|
||||
if (type === 'folderOrNote') {
|
||||
const folders = await this.loadItems(BaseModel.TYPE_FOLDER, pattern, options);
|
||||
if (folders.length) return folders;
|
||||
return await this.loadItems(BaseModel.TYPE_NOTE, pattern, options);
|
||||
}
|
||||
|
||||
pattern = pattern ? pattern.toString() : '';
|
||||
|
||||
if (type === BaseModel.TYPE_FOLDER && (pattern === Folder.conflictFolderTitle() || pattern === Folder.conflictFolderId())) return [Folder.conflictFolder()];
|
||||
|
||||
if (!options) options = {};
|
||||
|
||||
const parent = options.parent ? options.parent : app().currentFolder();
|
||||
const ItemClass = BaseItem.itemClass(type);
|
||||
|
||||
if (type === BaseModel.TYPE_NOTE && pattern.indexOf('*') >= 0) {
|
||||
// Handle it as pattern
|
||||
if (!parent) throw new Error(_('No notebook selected.'));
|
||||
return await Note.previews(parent.id, { titlePattern: pattern });
|
||||
} else {
|
||||
// Single item
|
||||
let item = null;
|
||||
if (type === BaseModel.TYPE_NOTE) {
|
||||
if (!parent) throw new Error(_('No notebook has been specified.'));
|
||||
item = await ItemClass.loadFolderNoteByField(parent.id, 'title', pattern);
|
||||
} else {
|
||||
item = await ItemClass.loadByTitle(pattern);
|
||||
}
|
||||
if (item) return [item];
|
||||
|
||||
item = await ItemClass.load(pattern); // Load by id
|
||||
if (item) return [item];
|
||||
|
||||
if (pattern.length >= 2) {
|
||||
return await ItemClass.loadByPartialId(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
setupCommand(cmd) {
|
||||
return setupCommand(cmd, t => this.stdout(t), () => this.store(), () => this.gui());
|
||||
}
|
||||
|
||||
stdout(text) {
|
||||
return this.gui().stdout(text);
|
||||
}
|
||||
|
||||
async exit(code = 0) {
|
||||
const doExit = async () => {
|
||||
this.gui().exit();
|
||||
await super.exit(code);
|
||||
};
|
||||
|
||||
// Give it a few seconds to cancel otherwise exit anyway
|
||||
shim.setTimeout(async () => {
|
||||
await doExit();
|
||||
}, 5000);
|
||||
|
||||
if (await reg.syncTarget().syncStarted()) {
|
||||
this.stdout(_('Cancelling background synchronisation... Please wait.'));
|
||||
const sync = await reg.syncTarget().synchronizer();
|
||||
await sync.cancel();
|
||||
}
|
||||
|
||||
await doExit();
|
||||
}
|
||||
|
||||
commands(uiType = null) {
|
||||
if (!this.allCommandsLoaded_) {
|
||||
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied
|
||||
fs.readdirSync(__dirname).forEach(path => {
|
||||
if (path.indexOf('command-') !== 0) return;
|
||||
if (path.endsWith('.test.js')) return;
|
||||
const ext = fileExtension(path);
|
||||
if (ext !== 'js') return;
|
||||
|
||||
const CommandClass = require(`./${path}`);
|
||||
let cmd = new CommandClass();
|
||||
if (!cmd.enabled()) return;
|
||||
cmd = this.setupCommand(cmd);
|
||||
this.commands_[cmd.name()] = cmd;
|
||||
});
|
||||
|
||||
this.allCommandsLoaded_ = true;
|
||||
}
|
||||
|
||||
if (uiType !== null) {
|
||||
const temp = [];
|
||||
for (const n in this.commands_) {
|
||||
if (!this.commands_.hasOwnProperty(n)) continue;
|
||||
const c = this.commands_[n];
|
||||
if (!c.supportsUi(uiType)) continue;
|
||||
temp[n] = c;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
return this.commands_;
|
||||
}
|
||||
|
||||
async commandNames() {
|
||||
const metadata = await this.commandMetadata();
|
||||
const output = [];
|
||||
for (const n in metadata) {
|
||||
if (!metadata.hasOwnProperty(n)) continue;
|
||||
output.push(n);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
async commandMetadata() {
|
||||
if (this.commandMetadata_) return this.commandMetadata_;
|
||||
|
||||
let output = await this.cache_.getItem('metadata');
|
||||
if (output) {
|
||||
this.commandMetadata_ = output;
|
||||
return { ...this.commandMetadata_ };
|
||||
}
|
||||
|
||||
const commands = this.commands();
|
||||
|
||||
output = {};
|
||||
for (const n in commands) {
|
||||
if (!commands.hasOwnProperty(n)) continue;
|
||||
const cmd = commands[n];
|
||||
output[n] = cmd.metadata();
|
||||
}
|
||||
|
||||
await this.cache_.setItem('metadata', output, 1000 * 60 * 60 * 24);
|
||||
|
||||
this.commandMetadata_ = output;
|
||||
return { ...this.commandMetadata_ };
|
||||
}
|
||||
|
||||
hasGui() {
|
||||
return this.gui() && !this.gui().isDummy();
|
||||
}
|
||||
|
||||
findCommandByName(name) {
|
||||
if (this.commands_[name]) return this.commands_[name];
|
||||
|
||||
let CommandClass = null;
|
||||
try {
|
||||
CommandClass = require(`${__dirname}/command-${name}.js`);
|
||||
} catch (error) {
|
||||
if (error.message && error.message.indexOf('Cannot find module') >= 0) {
|
||||
const e = new Error(_('No such command: %s', name));
|
||||
e.type = 'notFound';
|
||||
throw e;
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
let cmd = new CommandClass();
|
||||
cmd = this.setupCommand(cmd);
|
||||
this.commands_[name] = cmd;
|
||||
return this.commands_[name];
|
||||
}
|
||||
|
||||
dummyGui() {
|
||||
return {
|
||||
isDummy: () => {
|
||||
return true;
|
||||
},
|
||||
prompt: (initialText = '', promptString = '', options = null) => {
|
||||
return cliUtils.prompt(initialText, promptString, options);
|
||||
},
|
||||
showConsole: () => {},
|
||||
maximizeConsole: () => {},
|
||||
stdout: text => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(text);
|
||||
},
|
||||
fullScreen: () => {},
|
||||
exit: () => {},
|
||||
showModalOverlay: () => {},
|
||||
hideModalOverlay: () => {},
|
||||
stdoutMaxWidth: () => {
|
||||
return 100;
|
||||
},
|
||||
forceRender: () => {},
|
||||
termSaveState: () => {},
|
||||
termRestoreState: () => {},
|
||||
};
|
||||
}
|
||||
|
||||
async execCommand(argv) {
|
||||
if (!argv.length) return this.execCommand(['help']);
|
||||
// reg.logger().debug('execCommand()', argv);
|
||||
const commandName = argv[0];
|
||||
this.activeCommand_ = this.findCommandByName(commandName);
|
||||
|
||||
let outException = null;
|
||||
try {
|
||||
if (this.gui().isDummy() && !this.activeCommand_.supportsUi('cli')) throw new Error(_('The command "%s" is only available in GUI mode', this.activeCommand_.name()));
|
||||
const cmdArgs = cliUtils.makeCommandArgs(this.activeCommand_, argv);
|
||||
await this.activeCommand_.action(cmdArgs);
|
||||
} catch (error) {
|
||||
outException = error;
|
||||
}
|
||||
this.activeCommand_ = null;
|
||||
if (outException) throw outException;
|
||||
}
|
||||
|
||||
currentCommand() {
|
||||
return this.activeCommand_;
|
||||
}
|
||||
|
||||
async loadKeymaps() {
|
||||
const defaultKeyMap = [
|
||||
{ keys: [':'], type: 'function', command: 'enter_command_line_mode' },
|
||||
{ keys: ['TAB'], type: 'function', command: 'focus_next' },
|
||||
{ keys: ['SHIFT_TAB'], type: 'function', command: 'focus_previous' },
|
||||
{ keys: ['UP'], type: 'function', command: 'move_up' },
|
||||
{ keys: ['DOWN'], type: 'function', command: 'move_down' },
|
||||
{ keys: ['PAGE_UP'], type: 'function', command: 'page_up' },
|
||||
{ keys: ['PAGE_DOWN'], type: 'function', command: 'page_down' },
|
||||
{ keys: ['ENTER'], type: 'function', command: 'activate' },
|
||||
{ keys: ['DELETE', 'BACKSPACE'], type: 'function', command: 'delete' },
|
||||
{ keys: ['n'], type: 'function', command: 'next_link' },
|
||||
{ keys: ['b'], type: 'function', command: 'previous_link' },
|
||||
{ keys: ['o'], type: 'function', command: 'open_link' },
|
||||
{ keys: [' '], command: 'todo toggle $n' },
|
||||
{ keys: ['tc'], type: 'function', command: 'toggle_console' },
|
||||
{ keys: ['tm'], type: 'function', command: 'toggle_metadata' },
|
||||
{ keys: ['ti'], type: 'function', command: 'toggle_ids' },
|
||||
{ keys: ['/'], type: 'prompt', command: 'search ""', cursorPosition: -2 },
|
||||
{ keys: ['mn'], type: 'prompt', command: 'mknote ""', cursorPosition: -2 },
|
||||
{ keys: ['mt'], type: 'prompt', command: 'mktodo ""', cursorPosition: -2 },
|
||||
{ keys: ['mb'], type: 'prompt', command: 'mkbook ""', cursorPosition: -2 },
|
||||
{ keys: ['yn'], type: 'prompt', command: 'cp $n ""', cursorPosition: -2 },
|
||||
{ keys: ['dn'], type: 'prompt', command: 'mv $n ""', cursorPosition: -2 },
|
||||
];
|
||||
|
||||
// Filter the keymap item by command so that items in keymap.json can override
|
||||
// the default ones.
|
||||
const itemsByCommand = {};
|
||||
|
||||
for (let i = 0; i < defaultKeyMap.length; i++) {
|
||||
itemsByCommand[defaultKeyMap[i].command] = defaultKeyMap[i];
|
||||
}
|
||||
|
||||
const filePath = `${Setting.value('profileDir')}/keymap.json`;
|
||||
if (await fs.pathExists(filePath)) {
|
||||
try {
|
||||
let configString = await fs.readFile(filePath, 'utf-8');
|
||||
configString = configString.replace(/^\s*\/\/.*/, ''); // Strip off comments
|
||||
const keymap = JSON.parse(configString);
|
||||
for (let keymapIndex = 0; keymapIndex < keymap.length; keymapIndex++) {
|
||||
const item = keymap[keymapIndex];
|
||||
itemsByCommand[item.command] = item;
|
||||
}
|
||||
} catch (error) {
|
||||
let msg = error.message ? error.message : '';
|
||||
msg = `Could not load keymap ${filePath}\n${msg}`;
|
||||
error.message = msg;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const output = [];
|
||||
for (const n in itemsByCommand) {
|
||||
if (!itemsByCommand.hasOwnProperty(n)) continue;
|
||||
output.push(itemsByCommand[n]);
|
||||
}
|
||||
|
||||
// Map reserved shortcuts to their equivalent key
|
||||
// https://github.com/cronvel/terminal-kit/issues/101
|
||||
for (let i = 0; i < output.length; i++) {
|
||||
const newKeys = output[i].keys.map(k => {
|
||||
k = k.replace(/CTRL_H/g, 'BACKSPACE');
|
||||
k = k.replace(/CTRL_I/g, 'TAB');
|
||||
k = k.replace(/CTRL_M/g, 'ENTER');
|
||||
return k;
|
||||
});
|
||||
output[i].keys = newKeys;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
async commandList(argv) {
|
||||
if (argv.length && argv[0] === 'batch') {
|
||||
const commands = [];
|
||||
const commandLines = splitCommandBatch(await fs.readFile(argv[1], 'utf-8'));
|
||||
|
||||
for (const commandLine of commandLines) {
|
||||
if (!commandLine.trim()) continue;
|
||||
const splitted = splitCommandString(commandLine.trim());
|
||||
commands.push(splitted);
|
||||
}
|
||||
return commands;
|
||||
} else {
|
||||
return [argv];
|
||||
}
|
||||
}
|
||||
|
||||
// We need this special case here because by the time the `version` command
|
||||
// runs, the keychain has already been setup.
|
||||
checkIfKeychainEnabled(argv) {
|
||||
return argv.indexOf('version') < 0;
|
||||
}
|
||||
|
||||
async start(argv) {
|
||||
const keychainEnabled = this.checkIfKeychainEnabled(argv);
|
||||
|
||||
argv = await super.start(argv, { keychainEnabled });
|
||||
|
||||
cliUtils.setStdout(object => {
|
||||
return this.stdout(object);
|
||||
});
|
||||
|
||||
this.initRedux();
|
||||
|
||||
// If we have some arguments left at this point, it's a command
|
||||
// so execute it.
|
||||
if (argv.length) {
|
||||
this.gui_ = this.dummyGui();
|
||||
|
||||
this.currentFolder_ = await Folder.load(Setting.value('activeFolderId'));
|
||||
|
||||
await this.applySettingsSideEffects();
|
||||
|
||||
try {
|
||||
const commands = await this.commandList(argv);
|
||||
for (const command of commands) {
|
||||
await this.execCommand(command);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.showStackTraces_) {
|
||||
console.error(error);
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(error.message);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await Setting.saveAll();
|
||||
|
||||
// Need to call exit() explicitly, otherwise Node wait for any timeout to complete
|
||||
// https://stackoverflow.com/questions/18050095
|
||||
process.exit(0);
|
||||
} else {
|
||||
// Otherwise open the GUI
|
||||
const keymap = await this.loadKeymaps();
|
||||
|
||||
const AppGui = require('./app-gui.js');
|
||||
this.gui_ = new AppGui(this, this.store(), keymap);
|
||||
this.gui_.setLogger(this.logger());
|
||||
await this.gui_.start();
|
||||
|
||||
// Since the settings need to be loaded before the store is created, it will never
|
||||
// receive the SETTING_UPDATE_ALL even, which mean state.settings will not be
|
||||
// initialised. So we manually call dispatchUpdateAll() to force an update.
|
||||
Setting.dispatchUpdateAll();
|
||||
|
||||
await refreshFolders((action) => { this.store().dispatch(action); });
|
||||
|
||||
const tags = await Tag.allWithNotes();
|
||||
|
||||
ResourceService.runInBackground();
|
||||
|
||||
RevisionService.instance().runInBackground();
|
||||
|
||||
this.dispatch({
|
||||
type: 'TAG_UPDATE_ALL',
|
||||
items: tags,
|
||||
});
|
||||
|
||||
this.store().dispatch({
|
||||
type: 'FOLDER_SELECT',
|
||||
id: Setting.value('activeFolderId'),
|
||||
});
|
||||
|
||||
this.startRotatingLogMaintenance(Setting.value('profileDir'));
|
||||
}
|
||||
}
|
||||
const { splitCommandBatch } = require('@joplin/lib/string-utils');
|
||||
class Application extends BaseApplication_1.default {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.commands_ = {};
|
||||
this.commandMetadata_ = null;
|
||||
this.activeCommand_ = null;
|
||||
this.allCommandsLoaded_ = false;
|
||||
this.gui_ = null;
|
||||
this.cache_ = new Cache();
|
||||
}
|
||||
gui() {
|
||||
return this.gui_;
|
||||
}
|
||||
commandStdoutMaxWidth() {
|
||||
return this.gui().stdoutMaxWidth();
|
||||
}
|
||||
guessTypeAndLoadItem(pattern, options = null) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let type = BaseModel_1.default.TYPE_NOTE;
|
||||
if (pattern.indexOf('/') === 0) {
|
||||
type = BaseModel_1.default.TYPE_FOLDER;
|
||||
pattern = pattern.substr(1);
|
||||
}
|
||||
return this.loadItem(type, pattern, options);
|
||||
});
|
||||
}
|
||||
loadItem(type, pattern, options = null) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const output = yield this.loadItems(type, pattern, options);
|
||||
if (output.length > 1) {
|
||||
// output.sort((a, b) => { return a.user_updated_time < b.user_updated_time ? +1 : -1; });
|
||||
// let answers = { 0: _('[Cancel]') };
|
||||
// for (let i = 0; i < output.length; i++) {
|
||||
// answers[i + 1] = output[i].title;
|
||||
// }
|
||||
// Not really useful with new UI?
|
||||
throw new Error((0, locale_1._)('More than one item match "%s". Please narrow down your query.', pattern));
|
||||
// let msg = _('More than one item match "%s". Please select one:', pattern);
|
||||
// const response = await cliUtils.promptMcq(msg, answers);
|
||||
// if (!response) return null;
|
||||
// return output[response - 1];
|
||||
}
|
||||
else {
|
||||
return output.length ? output[0] : null;
|
||||
}
|
||||
});
|
||||
}
|
||||
loadItems(type, pattern, options = null) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (type === 'folderOrNote') {
|
||||
const folders = yield this.loadItems(BaseModel_1.default.TYPE_FOLDER, pattern, options);
|
||||
if (folders.length)
|
||||
return folders;
|
||||
return yield this.loadItems(BaseModel_1.default.TYPE_NOTE, pattern, options);
|
||||
}
|
||||
pattern = pattern ? pattern.toString() : '';
|
||||
if (type === BaseModel_1.default.TYPE_FOLDER && (pattern === Folder_1.default.conflictFolderTitle() || pattern === Folder_1.default.conflictFolderId()))
|
||||
return [Folder_1.default.conflictFolder()];
|
||||
if (!options)
|
||||
options = {};
|
||||
const parent = options.parent ? options.parent : app().currentFolder();
|
||||
const ItemClass = BaseItem_1.default.itemClass(type);
|
||||
if (type === BaseModel_1.default.TYPE_NOTE && pattern.indexOf('*') >= 0) {
|
||||
// Handle it as pattern
|
||||
if (!parent)
|
||||
throw new Error((0, locale_1._)('No notebook selected.'));
|
||||
return yield Note_1.default.previews(parent.id, { titlePattern: pattern });
|
||||
}
|
||||
else {
|
||||
// Single item
|
||||
let item = null;
|
||||
if (type === BaseModel_1.default.TYPE_NOTE) {
|
||||
if (!parent)
|
||||
throw new Error((0, locale_1._)('No notebook has been specified.'));
|
||||
item = yield ItemClass.loadFolderNoteByField(parent.id, 'title', pattern);
|
||||
}
|
||||
else {
|
||||
item = yield ItemClass.loadByTitle(pattern);
|
||||
}
|
||||
if (item)
|
||||
return [item];
|
||||
item = yield ItemClass.load(pattern); // Load by id
|
||||
if (item)
|
||||
return [item];
|
||||
if (pattern.length >= 2) {
|
||||
return yield ItemClass.loadByPartialId(pattern);
|
||||
}
|
||||
}
|
||||
return [];
|
||||
});
|
||||
}
|
||||
setupCommand(cmd) {
|
||||
return (0, setupCommand_1.default)(cmd, (t) => this.stdout(t), () => this.store(), () => this.gui());
|
||||
}
|
||||
stdout(text) {
|
||||
return this.gui().stdout(text);
|
||||
}
|
||||
exit(code = 0) {
|
||||
const _super = Object.create(null, {
|
||||
exit: { get: () => super.exit }
|
||||
});
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const doExit = () => __awaiter(this, void 0, void 0, function* () {
|
||||
this.gui().exit();
|
||||
yield _super.exit.call(this, code);
|
||||
});
|
||||
// Give it a few seconds to cancel otherwise exit anyway
|
||||
shim_1.default.setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
||||
yield doExit();
|
||||
}), 5000);
|
||||
if (yield registry_js_1.reg.syncTarget().syncStarted()) {
|
||||
this.stdout((0, locale_1._)('Cancelling background synchronisation... Please wait.'));
|
||||
const sync = yield registry_js_1.reg.syncTarget().synchronizer();
|
||||
yield sync.cancel();
|
||||
}
|
||||
yield doExit();
|
||||
});
|
||||
}
|
||||
commands(uiType = null) {
|
||||
if (!this.allCommandsLoaded_) {
|
||||
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied
|
||||
(0, fs_extra_1.readdirSync)(__dirname).forEach(path => {
|
||||
if (path.indexOf('command-') !== 0)
|
||||
return;
|
||||
if (path.endsWith('.test.js'))
|
||||
return;
|
||||
const ext = (0, path_utils_1.fileExtension)(path);
|
||||
if (ext !== 'js')
|
||||
return;
|
||||
const CommandClass = require(`./${path}`);
|
||||
let cmd = new CommandClass();
|
||||
if (!cmd.enabled())
|
||||
return;
|
||||
cmd = this.setupCommand(cmd);
|
||||
this.commands_[cmd.name()] = cmd;
|
||||
});
|
||||
this.allCommandsLoaded_ = true;
|
||||
}
|
||||
if (uiType !== null) {
|
||||
const temp = {};
|
||||
for (const n in this.commands_) {
|
||||
if (!this.commands_.hasOwnProperty(n))
|
||||
continue;
|
||||
const c = this.commands_[n];
|
||||
if (!c.supportsUi(uiType))
|
||||
continue;
|
||||
temp[n] = c;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
return this.commands_;
|
||||
}
|
||||
commandNames() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const metadata = yield this.commandMetadata();
|
||||
const output = [];
|
||||
for (const n in metadata) {
|
||||
if (!metadata.hasOwnProperty(n))
|
||||
continue;
|
||||
output.push(n);
|
||||
}
|
||||
return output;
|
||||
});
|
||||
}
|
||||
commandMetadata() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.commandMetadata_)
|
||||
return this.commandMetadata_;
|
||||
let output = yield this.cache_.getItem('metadata');
|
||||
if (output) {
|
||||
this.commandMetadata_ = output;
|
||||
return Object.assign({}, this.commandMetadata_);
|
||||
}
|
||||
const commands = this.commands();
|
||||
output = {};
|
||||
for (const n in commands) {
|
||||
if (!commands.hasOwnProperty(n))
|
||||
continue;
|
||||
const cmd = commands[n];
|
||||
output[n] = cmd.metadata();
|
||||
}
|
||||
yield this.cache_.setItem('metadata', output, 1000 * 60 * 60 * 24);
|
||||
this.commandMetadata_ = output;
|
||||
return Object.assign({}, this.commandMetadata_);
|
||||
});
|
||||
}
|
||||
hasGui() {
|
||||
return this.gui() && !this.gui().isDummy();
|
||||
}
|
||||
findCommandByName(name) {
|
||||
if (this.commands_[name])
|
||||
return this.commands_[name];
|
||||
let CommandClass = null;
|
||||
try {
|
||||
CommandClass = require(`${__dirname}/command-${name}.js`);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.message && error.message.indexOf('Cannot find module') >= 0) {
|
||||
const e = new Error((0, locale_1._)('No such command: %s', name));
|
||||
e.type = 'notFound';
|
||||
throw e;
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
let cmd = new CommandClass();
|
||||
cmd = this.setupCommand(cmd);
|
||||
this.commands_[name] = cmd;
|
||||
return this.commands_[name];
|
||||
}
|
||||
dummyGui() {
|
||||
return {
|
||||
isDummy: () => {
|
||||
return true;
|
||||
},
|
||||
prompt: (initialText = '', promptString = '', options = null) => {
|
||||
return cliUtils.prompt(initialText, promptString, options);
|
||||
},
|
||||
showConsole: () => { },
|
||||
maximizeConsole: () => { },
|
||||
stdout: (text) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(text);
|
||||
},
|
||||
fullScreen: () => { },
|
||||
exit: () => { },
|
||||
showModalOverlay: () => { },
|
||||
hideModalOverlay: () => { },
|
||||
stdoutMaxWidth: () => {
|
||||
return 100;
|
||||
},
|
||||
forceRender: () => { },
|
||||
termSaveState: () => { },
|
||||
termRestoreState: () => { },
|
||||
};
|
||||
}
|
||||
execCommand(argv) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!argv.length)
|
||||
return this.execCommand(['help']);
|
||||
// reg.logger().debug('execCommand()', argv);
|
||||
const commandName = argv[0];
|
||||
this.activeCommand_ = this.findCommandByName(commandName);
|
||||
let outException = null;
|
||||
try {
|
||||
if (this.gui().isDummy() && !this.activeCommand_.supportsUi('cli'))
|
||||
throw new Error((0, locale_1._)('The command "%s" is only available in GUI mode', this.activeCommand_.name()));
|
||||
const cmdArgs = cliUtils.makeCommandArgs(this.activeCommand_, argv);
|
||||
yield this.activeCommand_.action(cmdArgs);
|
||||
}
|
||||
catch (error) {
|
||||
outException = error;
|
||||
}
|
||||
this.activeCommand_ = null;
|
||||
if (outException)
|
||||
throw outException;
|
||||
});
|
||||
}
|
||||
currentCommand() {
|
||||
return this.activeCommand_;
|
||||
}
|
||||
loadKeymaps() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const defaultKeyMap = [
|
||||
{ keys: [':'], type: 'function', command: 'enter_command_line_mode' },
|
||||
{ keys: ['TAB'], type: 'function', command: 'focus_next' },
|
||||
{ keys: ['SHIFT_TAB'], type: 'function', command: 'focus_previous' },
|
||||
{ keys: ['UP'], type: 'function', command: 'move_up' },
|
||||
{ keys: ['DOWN'], type: 'function', command: 'move_down' },
|
||||
{ keys: ['PAGE_UP'], type: 'function', command: 'page_up' },
|
||||
{ keys: ['PAGE_DOWN'], type: 'function', command: 'page_down' },
|
||||
{ keys: ['ENTER'], type: 'function', command: 'activate' },
|
||||
{ keys: ['DELETE', 'BACKSPACE'], type: 'function', command: 'delete' },
|
||||
{ keys: ['n'], type: 'function', command: 'next_link' },
|
||||
{ keys: ['b'], type: 'function', command: 'previous_link' },
|
||||
{ keys: ['o'], type: 'function', command: 'open_link' },
|
||||
{ keys: [' '], type: 'prompt', command: 'todo toggle $n' },
|
||||
{ keys: ['tc'], type: 'function', command: 'toggle_console' },
|
||||
{ keys: ['tm'], type: 'function', command: 'toggle_metadata' },
|
||||
{ keys: ['ti'], type: 'function', command: 'toggle_ids' },
|
||||
{ keys: ['/'], type: 'prompt', command: 'search ""', cursorPosition: -2 },
|
||||
{ keys: ['mn'], type: 'prompt', command: 'mknote ""', cursorPosition: -2 },
|
||||
{ keys: ['mt'], type: 'prompt', command: 'mktodo ""', cursorPosition: -2 },
|
||||
{ keys: ['mb'], type: 'prompt', command: 'mkbook ""', cursorPosition: -2 },
|
||||
{ keys: ['yn'], type: 'prompt', command: 'cp $n ""', cursorPosition: -2 },
|
||||
{ keys: ['dn'], type: 'prompt', command: 'mv $n ""', cursorPosition: -2 },
|
||||
];
|
||||
// Filter the keymap item by command so that items in keymap.json can override
|
||||
// the default ones.
|
||||
const itemsByCommand = {};
|
||||
for (let i = 0; i < defaultKeyMap.length; i++) {
|
||||
itemsByCommand[defaultKeyMap[i].command] = defaultKeyMap[i];
|
||||
}
|
||||
const filePath = `${Setting_1.default.value('profileDir')}/keymap.json`;
|
||||
if (yield (0, fs_extra_1.pathExists)(filePath)) {
|
||||
try {
|
||||
let configString = yield (0, fs_extra_1.readFile)(filePath, 'utf-8');
|
||||
configString = configString.replace(/^\s*\/\/.*/, ''); // Strip off comments
|
||||
const keymap = JSON.parse(configString);
|
||||
for (let keymapIndex = 0; keymapIndex < keymap.length; keymapIndex++) {
|
||||
const item = keymap[keymapIndex];
|
||||
itemsByCommand[item.command] = item;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
let msg = error.message ? error.message : '';
|
||||
msg = `Could not load keymap ${filePath}\n${msg}`;
|
||||
error.message = msg;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const output = [];
|
||||
for (const n in itemsByCommand) {
|
||||
if (!itemsByCommand.hasOwnProperty(n))
|
||||
continue;
|
||||
output.push(itemsByCommand[n]);
|
||||
}
|
||||
// Map reserved shortcuts to their equivalent key
|
||||
// https://github.com/cronvel/terminal-kit/issues/101
|
||||
for (let i = 0; i < output.length; i++) {
|
||||
const newKeys = output[i].keys.map(k => {
|
||||
k = k.replace(/CTRL_H/g, 'BACKSPACE');
|
||||
k = k.replace(/CTRL_I/g, 'TAB');
|
||||
k = k.replace(/CTRL_M/g, 'ENTER');
|
||||
return k;
|
||||
});
|
||||
output[i].keys = newKeys;
|
||||
}
|
||||
return output;
|
||||
});
|
||||
}
|
||||
commandList(argv) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (argv.length && argv[0] === 'batch') {
|
||||
const commands = [];
|
||||
const commandLines = splitCommandBatch(yield (0, fs_extra_1.readFile)(argv[1], 'utf-8'));
|
||||
for (const commandLine of commandLines) {
|
||||
if (!commandLine.trim())
|
||||
continue;
|
||||
const splitted = (0, utils_1.splitCommandString)(commandLine.trim());
|
||||
commands.push(splitted);
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
else {
|
||||
return [argv];
|
||||
}
|
||||
});
|
||||
}
|
||||
// We need this special case here because by the time the `version` command
|
||||
// runs, the keychain has already been setup.
|
||||
checkIfKeychainEnabled(argv) {
|
||||
return argv.indexOf('version') < 0;
|
||||
}
|
||||
start(argv) {
|
||||
const _super = Object.create(null, {
|
||||
start: { get: () => super.start }
|
||||
});
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const keychainEnabled = this.checkIfKeychainEnabled(argv);
|
||||
argv = yield _super.start.call(this, argv, { keychainEnabled });
|
||||
cliUtils.setStdout((object) => {
|
||||
return this.stdout(object);
|
||||
});
|
||||
this.initRedux();
|
||||
// If we have some arguments left at this point, it's a command
|
||||
// so execute it.
|
||||
if (argv.length) {
|
||||
this.gui_ = this.dummyGui();
|
||||
this.currentFolder_ = yield Folder_1.default.load(Setting_1.default.value('activeFolderId'));
|
||||
yield this.applySettingsSideEffects();
|
||||
try {
|
||||
const commands = yield this.commandList(argv);
|
||||
for (const command of commands) {
|
||||
yield this.execCommand(command);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
if (this.showStackTraces_) {
|
||||
console.error(error);
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(error.message);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
yield Setting_1.default.saveAll();
|
||||
// Need to call exit() explicitly, otherwise Node wait for any timeout to complete
|
||||
// https://stackoverflow.com/questions/18050095
|
||||
process.exit(0);
|
||||
}
|
||||
else {
|
||||
// Otherwise open the GUI
|
||||
const keymap = yield this.loadKeymaps();
|
||||
const AppGui = require('./app-gui.js');
|
||||
this.gui_ = new AppGui(this, this.store(), keymap);
|
||||
this.gui_.setLogger(this.logger());
|
||||
yield this.gui_.start();
|
||||
// Since the settings need to be loaded before the store is created, it will never
|
||||
// receive the SETTING_UPDATE_ALL even, which mean state.settings will not be
|
||||
// initialised. So we manually call dispatchUpdateAll() to force an update.
|
||||
Setting_1.default.dispatchUpdateAll();
|
||||
yield (0, folders_screen_utils_js_1.refreshFolders)((action) => this.store().dispatch(action));
|
||||
const tags = yield Tag_1.default.allWithNotes();
|
||||
ResourceService_1.default.runInBackground();
|
||||
RevisionService_1.default.instance().runInBackground();
|
||||
this.dispatch({
|
||||
type: 'TAG_UPDATE_ALL',
|
||||
items: tags,
|
||||
});
|
||||
this.store().dispatch({
|
||||
type: 'FOLDER_SELECT',
|
||||
id: Setting_1.default.value('activeFolderId'),
|
||||
});
|
||||
this.startRotatingLogMaintenance(Setting_1.default.value('profileDir'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let application_ = null;
|
||||
|
||||
function app() {
|
||||
if (application_) return application_;
|
||||
application_ = new Application();
|
||||
return application_;
|
||||
if (application_)
|
||||
return application_;
|
||||
application_ = new Application();
|
||||
return application_;
|
||||
}
|
||||
|
||||
module.exports = { app };
|
||||
exports.default = app;
|
||||
//# sourceMappingURL=app.js.map
|
472
packages/app-cli/app/app.ts
Normal file
472
packages/app-cli/app/app.ts
Normal file
@@ -0,0 +1,472 @@
|
||||
import BaseApplication from '@joplin/lib/BaseApplication';
|
||||
import { refreshFolders } from '@joplin/lib/folders-screen-utils.js';
|
||||
import ResourceService from '@joplin/lib/services/ResourceService';
|
||||
import BaseModel, { ModelType } from '@joplin/lib/BaseModel';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
import BaseItem from '@joplin/lib/models/BaseItem';
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
import Tag from '@joplin/lib/models/Tag';
|
||||
import Setting from '@joplin/lib/models/Setting';
|
||||
import { reg } from '@joplin/lib/registry.js';
|
||||
import { fileExtension } from '@joplin/lib/path-utils';
|
||||
import { splitCommandString } from '@joplin/utils';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { pathExists, readFile, readdirSync } from 'fs-extra';
|
||||
import RevisionService from '@joplin/lib/services/RevisionService';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import setupCommand from './setupCommand';
|
||||
import { FolderEntity, NoteEntity } from '@joplin/lib/services/database/types';
|
||||
const { cliUtils } = require('./cli-utils.js');
|
||||
const Cache = require('@joplin/lib/Cache');
|
||||
const { splitCommandBatch } = require('@joplin/lib/string-utils');
|
||||
|
||||
class Application extends BaseApplication {
|
||||
|
||||
private commands_: Record<string, any> = {};
|
||||
private commandMetadata_: any = null;
|
||||
private activeCommand_: any = null;
|
||||
private allCommandsLoaded_ = false;
|
||||
private gui_: any = null;
|
||||
private cache_ = new Cache();
|
||||
|
||||
public gui() {
|
||||
return this.gui_;
|
||||
}
|
||||
|
||||
public commandStdoutMaxWidth() {
|
||||
return this.gui().stdoutMaxWidth();
|
||||
}
|
||||
|
||||
public async guessTypeAndLoadItem(pattern: string, options: any = null) {
|
||||
let type = BaseModel.TYPE_NOTE;
|
||||
if (pattern.indexOf('/') === 0) {
|
||||
type = BaseModel.TYPE_FOLDER;
|
||||
pattern = pattern.substr(1);
|
||||
}
|
||||
return this.loadItem(type, pattern, options);
|
||||
}
|
||||
|
||||
public async loadItem(type: ModelType | 'folderOrNote', pattern: string, options: any = null) {
|
||||
const output = await this.loadItems(type, pattern, options);
|
||||
|
||||
if (output.length > 1) {
|
||||
// output.sort((a, b) => { return a.user_updated_time < b.user_updated_time ? +1 : -1; });
|
||||
|
||||
// let answers = { 0: _('[Cancel]') };
|
||||
// for (let i = 0; i < output.length; i++) {
|
||||
// answers[i + 1] = output[i].title;
|
||||
// }
|
||||
|
||||
// Not really useful with new UI?
|
||||
throw new Error(_('More than one item match "%s". Please narrow down your query.', pattern));
|
||||
|
||||
// let msg = _('More than one item match "%s". Please select one:', pattern);
|
||||
// const response = await cliUtils.promptMcq(msg, answers);
|
||||
// if (!response) return null;
|
||||
|
||||
// return output[response - 1];
|
||||
} else {
|
||||
return output.length ? output[0] : null;
|
||||
}
|
||||
}
|
||||
|
||||
public async loadItems(type: ModelType | 'folderOrNote', pattern: string, options: any = null): Promise<(FolderEntity | NoteEntity)[]> {
|
||||
if (type === 'folderOrNote') {
|
||||
const folders: FolderEntity[] = await this.loadItems(BaseModel.TYPE_FOLDER, pattern, options);
|
||||
if (folders.length) return folders;
|
||||
return await this.loadItems(BaseModel.TYPE_NOTE, pattern, options);
|
||||
}
|
||||
|
||||
pattern = pattern ? pattern.toString() : '';
|
||||
|
||||
if (type === BaseModel.TYPE_FOLDER && (pattern === Folder.conflictFolderTitle() || pattern === Folder.conflictFolderId())) return [Folder.conflictFolder()];
|
||||
|
||||
if (!options) options = {};
|
||||
|
||||
const parent = options.parent ? options.parent : app().currentFolder();
|
||||
const ItemClass = BaseItem.itemClass(type);
|
||||
|
||||
if (type === BaseModel.TYPE_NOTE && pattern.indexOf('*') >= 0) {
|
||||
// Handle it as pattern
|
||||
if (!parent) throw new Error(_('No notebook selected.'));
|
||||
return await Note.previews(parent.id, { titlePattern: pattern });
|
||||
} else {
|
||||
// Single item
|
||||
let item = null;
|
||||
if (type === BaseModel.TYPE_NOTE) {
|
||||
if (!parent) throw new Error(_('No notebook has been specified.'));
|
||||
item = await ItemClass.loadFolderNoteByField(parent.id, 'title', pattern);
|
||||
} else {
|
||||
item = await ItemClass.loadByTitle(pattern);
|
||||
}
|
||||
if (item) return [item];
|
||||
|
||||
item = await ItemClass.load(pattern); // Load by id
|
||||
if (item) return [item];
|
||||
|
||||
if (pattern.length >= 2) {
|
||||
return await ItemClass.loadByPartialId(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public setupCommand(cmd: string) {
|
||||
return setupCommand(cmd, (t: string) => this.stdout(t), () => this.store(), () => this.gui());
|
||||
}
|
||||
|
||||
public stdout(text: string) {
|
||||
return this.gui().stdout(text);
|
||||
}
|
||||
|
||||
public async exit(code = 0) {
|
||||
const doExit = async () => {
|
||||
this.gui().exit();
|
||||
await super.exit(code);
|
||||
};
|
||||
|
||||
// Give it a few seconds to cancel otherwise exit anyway
|
||||
shim.setTimeout(async () => {
|
||||
await doExit();
|
||||
}, 5000);
|
||||
|
||||
if (await reg.syncTarget().syncStarted()) {
|
||||
this.stdout(_('Cancelling background synchronisation... Please wait.'));
|
||||
const sync = await reg.syncTarget().synchronizer();
|
||||
await sync.cancel();
|
||||
}
|
||||
|
||||
await doExit();
|
||||
}
|
||||
|
||||
public commands(uiType: string = null) {
|
||||
if (!this.allCommandsLoaded_) {
|
||||
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied
|
||||
readdirSync(__dirname).forEach(path => {
|
||||
if (path.indexOf('command-') !== 0) return;
|
||||
if (path.endsWith('.test.js')) return;
|
||||
const ext = fileExtension(path);
|
||||
if (ext !== 'js') return;
|
||||
|
||||
const CommandClass = require(`./${path}`);
|
||||
let cmd = new CommandClass();
|
||||
if (!cmd.enabled()) return;
|
||||
cmd = this.setupCommand(cmd);
|
||||
this.commands_[cmd.name()] = cmd;
|
||||
});
|
||||
|
||||
this.allCommandsLoaded_ = true;
|
||||
}
|
||||
|
||||
if (uiType !== null) {
|
||||
const temp: Record<string, any> = {};
|
||||
for (const n in this.commands_) {
|
||||
if (!this.commands_.hasOwnProperty(n)) continue;
|
||||
const c = this.commands_[n];
|
||||
if (!c.supportsUi(uiType)) continue;
|
||||
temp[n] = c;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
return this.commands_;
|
||||
}
|
||||
|
||||
public async commandNames() {
|
||||
const metadata = await this.commandMetadata();
|
||||
const output = [];
|
||||
for (const n in metadata) {
|
||||
if (!metadata.hasOwnProperty(n)) continue;
|
||||
output.push(n);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public async commandMetadata() {
|
||||
if (this.commandMetadata_) return this.commandMetadata_;
|
||||
|
||||
let output = await this.cache_.getItem('metadata');
|
||||
if (output) {
|
||||
this.commandMetadata_ = output;
|
||||
return { ...this.commandMetadata_ };
|
||||
}
|
||||
|
||||
const commands = this.commands();
|
||||
|
||||
output = {};
|
||||
for (const n in commands) {
|
||||
if (!commands.hasOwnProperty(n)) continue;
|
||||
const cmd = commands[n];
|
||||
output[n] = cmd.metadata();
|
||||
}
|
||||
|
||||
await this.cache_.setItem('metadata', output, 1000 * 60 * 60 * 24);
|
||||
|
||||
this.commandMetadata_ = output;
|
||||
return { ...this.commandMetadata_ };
|
||||
}
|
||||
|
||||
public hasGui() {
|
||||
return this.gui() && !this.gui().isDummy();
|
||||
}
|
||||
|
||||
public findCommandByName(name: string) {
|
||||
if (this.commands_[name]) return this.commands_[name];
|
||||
|
||||
let CommandClass = null;
|
||||
try {
|
||||
CommandClass = require(`${__dirname}/command-${name}.js`);
|
||||
} catch (error) {
|
||||
if (error.message && error.message.indexOf('Cannot find module') >= 0) {
|
||||
const e: any = new Error(_('No such command: %s', name));
|
||||
e.type = 'notFound';
|
||||
throw e;
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
let cmd = new CommandClass();
|
||||
cmd = this.setupCommand(cmd);
|
||||
this.commands_[name] = cmd;
|
||||
return this.commands_[name];
|
||||
}
|
||||
|
||||
public dummyGui() {
|
||||
return {
|
||||
isDummy: () => {
|
||||
return true;
|
||||
},
|
||||
prompt: (initialText = '', promptString = '', options: any = null) => {
|
||||
return cliUtils.prompt(initialText, promptString, options);
|
||||
},
|
||||
showConsole: () => {},
|
||||
maximizeConsole: () => {},
|
||||
stdout: (text: string) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(text);
|
||||
},
|
||||
fullScreen: () => {},
|
||||
exit: () => {},
|
||||
showModalOverlay: () => {},
|
||||
hideModalOverlay: () => {},
|
||||
stdoutMaxWidth: () => {
|
||||
return 100;
|
||||
},
|
||||
forceRender: () => {},
|
||||
termSaveState: () => {},
|
||||
termRestoreState: () => {},
|
||||
};
|
||||
}
|
||||
|
||||
public async execCommand(argv: string[]): Promise<any> {
|
||||
if (!argv.length) return this.execCommand(['help']);
|
||||
// reg.logger().debug('execCommand()', argv);
|
||||
const commandName = argv[0];
|
||||
this.activeCommand_ = this.findCommandByName(commandName);
|
||||
|
||||
let outException = null;
|
||||
try {
|
||||
if (this.gui().isDummy() && !this.activeCommand_.supportsUi('cli')) throw new Error(_('The command "%s" is only available in GUI mode', this.activeCommand_.name()));
|
||||
const cmdArgs = cliUtils.makeCommandArgs(this.activeCommand_, argv);
|
||||
await this.activeCommand_.action(cmdArgs);
|
||||
} catch (error) {
|
||||
outException = error;
|
||||
}
|
||||
this.activeCommand_ = null;
|
||||
if (outException) throw outException;
|
||||
}
|
||||
|
||||
public currentCommand() {
|
||||
return this.activeCommand_;
|
||||
}
|
||||
|
||||
public async loadKeymaps() {
|
||||
interface KeyMapItem {
|
||||
keys: string[];
|
||||
type: 'function' | 'prompt';
|
||||
command: string;
|
||||
cursorPosition?: number;
|
||||
}
|
||||
|
||||
const defaultKeyMap: KeyMapItem[] = [
|
||||
{ keys: [':'], type: 'function', command: 'enter_command_line_mode' },
|
||||
{ keys: ['TAB'], type: 'function', command: 'focus_next' },
|
||||
{ keys: ['SHIFT_TAB'], type: 'function', command: 'focus_previous' },
|
||||
{ keys: ['UP'], type: 'function', command: 'move_up' },
|
||||
{ keys: ['DOWN'], type: 'function', command: 'move_down' },
|
||||
{ keys: ['PAGE_UP'], type: 'function', command: 'page_up' },
|
||||
{ keys: ['PAGE_DOWN'], type: 'function', command: 'page_down' },
|
||||
{ keys: ['ENTER'], type: 'function', command: 'activate' },
|
||||
{ keys: ['DELETE', 'BACKSPACE'], type: 'function', command: 'delete' },
|
||||
{ keys: ['n'], type: 'function', command: 'next_link' },
|
||||
{ keys: ['b'], type: 'function', command: 'previous_link' },
|
||||
{ keys: ['o'], type: 'function', command: 'open_link' },
|
||||
{ keys: [' '], type: 'prompt', command: 'todo toggle $n' },
|
||||
{ keys: ['tc'], type: 'function', command: 'toggle_console' },
|
||||
{ keys: ['tm'], type: 'function', command: 'toggle_metadata' },
|
||||
{ keys: ['ti'], type: 'function', command: 'toggle_ids' },
|
||||
{ keys: ['/'], type: 'prompt', command: 'search ""', cursorPosition: -2 },
|
||||
{ keys: ['mn'], type: 'prompt', command: 'mknote ""', cursorPosition: -2 },
|
||||
{ keys: ['mt'], type: 'prompt', command: 'mktodo ""', cursorPosition: -2 },
|
||||
{ keys: ['mb'], type: 'prompt', command: 'mkbook ""', cursorPosition: -2 },
|
||||
{ keys: ['yn'], type: 'prompt', command: 'cp $n ""', cursorPosition: -2 },
|
||||
{ keys: ['dn'], type: 'prompt', command: 'mv $n ""', cursorPosition: -2 },
|
||||
];
|
||||
|
||||
// Filter the keymap item by command so that items in keymap.json can override
|
||||
// the default ones.
|
||||
const itemsByCommand: Record<string, KeyMapItem> = {};
|
||||
|
||||
for (let i = 0; i < defaultKeyMap.length; i++) {
|
||||
itemsByCommand[defaultKeyMap[i].command] = defaultKeyMap[i];
|
||||
}
|
||||
|
||||
const filePath = `${Setting.value('profileDir')}/keymap.json`;
|
||||
if (await pathExists(filePath)) {
|
||||
try {
|
||||
let configString = await readFile(filePath, 'utf-8');
|
||||
configString = configString.replace(/^\s*\/\/.*/, ''); // Strip off comments
|
||||
const keymap = JSON.parse(configString);
|
||||
for (let keymapIndex = 0; keymapIndex < keymap.length; keymapIndex++) {
|
||||
const item = keymap[keymapIndex];
|
||||
itemsByCommand[item.command] = item;
|
||||
}
|
||||
} catch (error) {
|
||||
let msg = error.message ? error.message : '';
|
||||
msg = `Could not load keymap ${filePath}\n${msg}`;
|
||||
error.message = msg;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const output = [];
|
||||
for (const n in itemsByCommand) {
|
||||
if (!itemsByCommand.hasOwnProperty(n)) continue;
|
||||
output.push(itemsByCommand[n]);
|
||||
}
|
||||
|
||||
// Map reserved shortcuts to their equivalent key
|
||||
// https://github.com/cronvel/terminal-kit/issues/101
|
||||
for (let i = 0; i < output.length; i++) {
|
||||
const newKeys = output[i].keys.map(k => {
|
||||
k = k.replace(/CTRL_H/g, 'BACKSPACE');
|
||||
k = k.replace(/CTRL_I/g, 'TAB');
|
||||
k = k.replace(/CTRL_M/g, 'ENTER');
|
||||
return k;
|
||||
});
|
||||
output[i].keys = newKeys;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public async commandList(argv: string[]) {
|
||||
if (argv.length && argv[0] === 'batch') {
|
||||
const commands = [];
|
||||
const commandLines = splitCommandBatch(await readFile(argv[1], 'utf-8'));
|
||||
|
||||
for (const commandLine of commandLines) {
|
||||
if (!commandLine.trim()) continue;
|
||||
const splitted = splitCommandString(commandLine.trim());
|
||||
commands.push(splitted);
|
||||
}
|
||||
return commands;
|
||||
} else {
|
||||
return [argv];
|
||||
}
|
||||
}
|
||||
|
||||
// We need this special case here because by the time the `version` command
|
||||
// runs, the keychain has already been setup.
|
||||
public checkIfKeychainEnabled(argv: string[]) {
|
||||
return argv.indexOf('version') < 0;
|
||||
}
|
||||
|
||||
public async start(argv: string[]) {
|
||||
const keychainEnabled = this.checkIfKeychainEnabled(argv);
|
||||
|
||||
argv = await super.start(argv, { keychainEnabled });
|
||||
|
||||
cliUtils.setStdout((object: any) => {
|
||||
return this.stdout(object);
|
||||
});
|
||||
|
||||
this.initRedux();
|
||||
|
||||
// If we have some arguments left at this point, it's a command
|
||||
// so execute it.
|
||||
if (argv.length) {
|
||||
this.gui_ = this.dummyGui();
|
||||
|
||||
this.currentFolder_ = await Folder.load(Setting.value('activeFolderId'));
|
||||
|
||||
await this.applySettingsSideEffects();
|
||||
|
||||
try {
|
||||
const commands = await this.commandList(argv);
|
||||
for (const command of commands) {
|
||||
await this.execCommand(command);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.showStackTraces_) {
|
||||
console.error(error);
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(error.message);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await Setting.saveAll();
|
||||
|
||||
// Need to call exit() explicitly, otherwise Node wait for any timeout to complete
|
||||
// https://stackoverflow.com/questions/18050095
|
||||
process.exit(0);
|
||||
} else {
|
||||
// Otherwise open the GUI
|
||||
const keymap = await this.loadKeymaps();
|
||||
|
||||
const AppGui = require('./app-gui.js');
|
||||
this.gui_ = new AppGui(this, this.store(), keymap);
|
||||
this.gui_.setLogger(this.logger());
|
||||
await this.gui_.start();
|
||||
|
||||
// Since the settings need to be loaded before the store is created, it will never
|
||||
// receive the SETTING_UPDATE_ALL even, which mean state.settings will not be
|
||||
// initialised. So we manually call dispatchUpdateAll() to force an update.
|
||||
Setting.dispatchUpdateAll();
|
||||
|
||||
await refreshFolders((action: any) => this.store().dispatch(action));
|
||||
|
||||
const tags = await Tag.allWithNotes();
|
||||
|
||||
ResourceService.runInBackground();
|
||||
|
||||
RevisionService.instance().runInBackground();
|
||||
|
||||
this.dispatch({
|
||||
type: 'TAG_UPDATE_ALL',
|
||||
items: tags,
|
||||
});
|
||||
|
||||
this.store().dispatch({
|
||||
type: 'FOLDER_SELECT',
|
||||
id: Setting.value('activeFolderId'),
|
||||
});
|
||||
|
||||
this.startRotatingLogMaintenance(Setting.value('profileDir'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let application_: Application = null;
|
||||
|
||||
function app() {
|
||||
if (application_) return application_;
|
||||
application_ = new Application();
|
||||
return application_;
|
||||
}
|
||||
|
||||
export default app;
|
@@ -1,4 +1,4 @@
|
||||
const { app } = require('./app.js');
|
||||
const app = require('./app').default;
|
||||
const Note = require('@joplin/lib/models/Note').default;
|
||||
const Folder = require('@joplin/lib/models/Folder').default;
|
||||
const Tag = require('@joplin/lib/models/Tag').default;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import shim from '@joplin/lib/shim';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import BaseItem from '@joplin/lib/models/BaseItem';
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import BaseCommand from './base-command';
|
||||
import { _, setLocale } from '@joplin/lib/locale';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import * as fs from 'fs-extra';
|
||||
import Setting, { AppType } from '@joplin/lib/models/Setting';
|
||||
import { ReadStream } from 'tty';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
import time from '@joplin/lib/time';
|
||||
import { NoteEntity } from '@joplin/lib/services/database/types';
|
||||
|
||||
class Command extends BaseCommand {
|
||||
public override usage() {
|
||||
@@ -15,7 +16,7 @@ class Command extends BaseCommand {
|
||||
}
|
||||
|
||||
public static async handleAction(commandInstance: BaseCommand, args: any, isCompleted: boolean) {
|
||||
const note = await app().loadItem(BaseModel.TYPE_NOTE, args.note);
|
||||
const note: NoteEntity = await app().loadItem(BaseModel.TYPE_NOTE, args.note);
|
||||
commandInstance.encryptionCheck(note);
|
||||
if (!note) throw new Error(_('Cannot find "%s".', args.note));
|
||||
if (!note.is_todo) throw new Error(_('Note is not a to-do: "%s"', args.note));
|
||||
|
@@ -2,7 +2,7 @@ import * as fs from 'fs-extra';
|
||||
import BaseCommand from './base-command';
|
||||
import { splitCommandString } from '@joplin/utils';
|
||||
import uuid from '@joplin/lib/uuid';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
import Setting from '@joplin/lib/models/Setting';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
|
||||
class Command extends BaseCommand {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import Setting from '@joplin/lib/models/Setting';
|
||||
import ReportService from '@joplin/lib/services/ReportService';
|
||||
import * as fs from 'fs-extra';
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import BaseCommand from './base-command';
|
||||
import InteropService from '@joplin/lib/services/interop/InteropService';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { ExportOptions } from '@joplin/lib/services/interop/types';
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
const { renderCommandHelp } = require('./help-utils.js');
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
const { cliUtils } = require('./cli-utils.js');
|
||||
|
@@ -2,7 +2,7 @@ import BaseCommand from './base-command';
|
||||
import InteropService from '@joplin/lib/services/interop/InteropService';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
const { cliUtils } = require('./cli-utils.js');
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { ImportOptions } from '@joplin/lib/services/interop/types';
|
||||
import { unique } from '@joplin/lib/array';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
const BaseCommand = require('./base-command').default;
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
const BaseCommand = require('./base-command').default;
|
||||
const { app } = require('./app.js');
|
||||
const app = require('./app').default;
|
||||
const { _ } = require('@joplin/lib/locale');
|
||||
const Note = require('@joplin/lib/models/Note').default;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
const BaseCommand = require('./base-command').default;
|
||||
const { app } = require('./app.js');
|
||||
const app = require('./app').default;
|
||||
const { _ } = require('@joplin/lib/locale');
|
||||
const Note = require('@joplin/lib/models/Note').default;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
import Database from '@joplin/lib/database';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
const BaseCommand = require('./base-command').default;
|
||||
const { app } = require('./app.js');
|
||||
const app = require('./app').default;
|
||||
const Setting = require('@joplin/lib/models/Setting').default;
|
||||
const { _ } = require('@joplin/lib/locale');
|
||||
const ReportService = require('@joplin/lib/services/ReportService').default;
|
||||
|
@@ -7,7 +7,7 @@ import Synchronizer from '@joplin/lib/Synchronizer';
|
||||
import { masterKeysWithoutPassword } from '@joplin/lib/services/e2ee/utils';
|
||||
import { appTypeToLockType } from '@joplin/lib/services/synchronizer/LockHandler';
|
||||
const BaseCommand = require('./base-command').default;
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
const { OneDriveApiNodeUtils } = require('@joplin/lib/onedrive-api-node-utils.js');
|
||||
import { reg } from '@joplin/lib/registry';
|
||||
const { cliUtils } = require('./cli-utils.js');
|
||||
|
@@ -1,5 +1,5 @@
|
||||
const BaseCommand = require('./base-command').default;
|
||||
const { app } = require('./app.js');
|
||||
const app = require('./app').default;
|
||||
const { _ } = require('@joplin/lib/locale');
|
||||
const Tag = require('@joplin/lib/models/Tag').default;
|
||||
const BaseModel = require('@joplin/lib/BaseModel').default;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
const BaseCommand = require('./base-command').default;
|
||||
const { app } = require('./app.js');
|
||||
const app = require('./app').default;
|
||||
const { _ } = require('@joplin/lib/locale');
|
||||
const BaseModel = require('@joplin/lib/BaseModel').default;
|
||||
const Note = require('@joplin/lib/models/Note').default;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import BaseCommand from './base-command';
|
||||
const { app } = require('./app.js');
|
||||
import app from './app';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import BaseModel from '@joplin/lib/BaseModel';
|
||||
|
||||
|
@@ -10,7 +10,7 @@ if (compareVersion(nodeVersion, '10.0.0') < 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const { app } = require('./app.js');
|
||||
const app = require('./app').default;
|
||||
const Folder = require('@joplin/lib/models/Folder').default;
|
||||
const Resource = require('@joplin/lib/models/Resource').default;
|
||||
const BaseItem = require('@joplin/lib/models/BaseItem').default;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
const { app } = require('../app');
|
||||
import app from '../app';
|
||||
import Folder from '@joplin/lib/models/Folder';
|
||||
import BaseCommand from '../base-command';
|
||||
import setupCommand from '../setupCommand';
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
yarn run build && NODE_PATH=build node build/build-doc.js
|
||||
yarn build && NODE_PATH=build node build/build-doc.js
|
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
yarn run build && NODE_PATH="build/" node build/cli-integration-tests.js
|
||||
yarn build && NODE_PATH="build/" node build/cli-integration-tests.js
|
@@ -2,7 +2,7 @@
|
||||
|
||||
# Start the server with:
|
||||
#
|
||||
# JOPLIN_IS_TESTING=1 yarn run start-dev
|
||||
# JOPLIN_IS_TESTING=1 yarn start-dev
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
set -e
|
||||
yarn run build && NODE_PATH="build/" node build/fuzzing.js
|
||||
yarn build && NODE_PATH="build/" node build/fuzzing.js
|
@@ -73,7 +73,7 @@
|
||||
"@joplin/tools": "~2.14",
|
||||
"@types/fs-extra": "11.0.4",
|
||||
"@types/jest": "29.5.8",
|
||||
"@types/node": "18.18.14",
|
||||
"@types/node": "18.19.6",
|
||||
"@types/proper-lockfile": "^4.1.2",
|
||||
"gulp": "4.0.2",
|
||||
"jest": "29.7.0",
|
||||
|
@@ -1,5 +1,6 @@
|
||||
|
||||
import MarkupToHtml, { MarkupLanguage, RenderResult } from '@joplin/renderer/MarkupToHtml';
|
||||
import MarkupToHtml, { MarkupLanguage } from '@joplin/renderer/MarkupToHtml';
|
||||
import { RenderResult } from '@joplin/renderer/types';
|
||||
|
||||
describe('MarkupToHtml', () => {
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
<p>
|
||||
SVG image:
|
||||
|
||||
<img src="data:image/svg+xml;utf8,
|
||||
<svg width="1700" height="1536" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m0,0%20l100,1000%20l200,0%20z"/>
|
||||
</svg>"/>
|
||||
</p>
|
||||
<p>PNG image: <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAR0lEQVQIW4XLMQoAIQwF0flpBEHwtOlUsPW6gZTushfYqd8IuHtvxhhI4pyD1lq3905EYGa01tB9m3N+IjNxd/S711oppfAAOjQiFPMurHkAAAAASUVORK5CYII="></p>
|
3
packages/app-cli/tests/html_to_md/image_utf8_data_url.md
Normal file
3
packages/app-cli/tests/html_to_md/image_utf8_data_url.md
Normal file
@@ -0,0 +1,3 @@
|
||||
SVG image: 
|
||||
|
||||
PNG image: 
|
@@ -0,0 +1,2 @@
|
||||
<p>SVG image: <img src="data:image/svg+xml;utf8,%3Csvg%20width=%221700%22%20height=%221536%22%20xmlns=%22http://www.w3.org/2000/svg%22%3E%20%3Cpath%20d=%22m0,0%20l100,1000%20l200,0%20z%22/%3E%20%3C/svg%3E" alt=""></p>
|
||||
<p>PNG image: <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAR0lEQVQIW4XLMQoAIQwF0flpBEHwtOlUsPW6gZTushfYqd8IuHtvxhhI4pyD1lq3905EYGa01tB9m3N+IjNxd/S711oppfAAOjQiFPMurHkAAAAASUVORK5CYII=" alt=""></p>
|
3
packages/app-cli/tests/md_to_html/image_with_data_url.md
Normal file
3
packages/app-cli/tests/md_to_html/image_with_data_url.md
Normal file
@@ -0,0 +1,3 @@
|
||||
SVG image: 
|
||||
|
||||
PNG image: 
|
BIN
packages/app-cli/tests/ocr_samples/multi_page__embedded_text.pdf
Normal file
BIN
packages/app-cli/tests/ocr_samples/multi_page__embedded_text.pdf
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
import PluginRunner from '../../../app/services/plugins/PluginRunner';
|
||||
import PluginService from '@joplin/lib/services/plugins/PluginService';
|
||||
import PluginService, { PluginSettings } from '@joplin/lib/services/plugins/PluginService';
|
||||
import { ContentScriptType } from '@joplin/lib/services/plugins/api/types';
|
||||
import MdToHtml from '@joplin/renderer/MdToHtml';
|
||||
import shim from '@joplin/lib/shim';
|
||||
@@ -304,4 +304,33 @@ describe('services_PluginService', () => {
|
||||
expect(JSON.parse(folders[0].title)).toBe(expectedPath);
|
||||
}));
|
||||
|
||||
it('should uninstall multiple plugins', async () => {
|
||||
const service = newPluginService();
|
||||
const pluginId1 = 'org.joplinapp.FirstJplPlugin';
|
||||
const pluginId2 = 'org.joplinapp.plugins.TocDemo';
|
||||
const pluginPath1 = `${testPluginDir}/jpl_test/${pluginId1}.jpl`;
|
||||
const pluginPath2 = `${testPluginDir}/toc/${pluginId2}.jpl`;
|
||||
|
||||
await service.installPlugin(pluginPath1);
|
||||
await service.installPlugin(pluginPath2);
|
||||
|
||||
// Both should be installed
|
||||
expect(await fs.pathExists(`${Setting.value('pluginDir')}/${pluginId1}.jpl`)).toBe(true);
|
||||
expect(await fs.pathExists(`${Setting.value('pluginDir')}/${pluginId2}.jpl`)).toBe(true);
|
||||
|
||||
const pluginSettings: PluginSettings = {
|
||||
[pluginId1]: { enabled: true, deleted: true, hasBeenUpdated: false },
|
||||
[pluginId2]: { enabled: true, deleted: true, hasBeenUpdated: false },
|
||||
};
|
||||
|
||||
const newPluginSettings = await service.uninstallPlugins(pluginSettings);
|
||||
|
||||
// Should have deleted plugins
|
||||
expect(await fs.pathExists(`${Setting.value('pluginDir')}/${pluginId1}.jpl`)).toBe(false);
|
||||
expect(await fs.pathExists(`${Setting.value('pluginDir')}${pluginId2}.jpl`)).toBe(false);
|
||||
|
||||
// Should clear deleted plugins from settings
|
||||
expect(newPluginSettings[pluginId1]).toBe(undefined);
|
||||
expect(newPluginSettings[pluginId2]).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
@@ -36,7 +36,7 @@ describe('defaultPluginsUtils', () => {
|
||||
});
|
||||
|
||||
it('should load default plugins when nor previously installed', (async () => {
|
||||
const testPluginDir = `${supportDir}/pluginRepo/plugins`;
|
||||
const testPluginDir = `${supportDir}/testDefaultPlugins`;
|
||||
Setting.setValue('installedDefaultPlugins', []);
|
||||
|
||||
const service = newPluginService('2.1');
|
||||
@@ -57,7 +57,7 @@ describe('defaultPluginsUtils', () => {
|
||||
}));
|
||||
|
||||
it('should keep already created default plugins disabled with previous default plugins installed', (async () => {
|
||||
const testPluginDir = `${supportDir}/pluginRepo/plugins`;
|
||||
const testPluginDir = `${supportDir}/testDefaultPlugins`;
|
||||
Setting.setValue('installedDefaultPlugins', ['org.joplinapp.plugins.ToggleSidebars']);
|
||||
Setting.setValue('plugins.states', {
|
||||
'org.joplinapp.plugins.ToggleSidebars': { ...defaultPluginSetting(), enabled: false },
|
||||
|
@@ -0,0 +1,5 @@
|
||||
|
||||
.cm-gutter {
|
||||
background-color: var(--joplin-background-color3);
|
||||
color: var(--joplin-color3);
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
// This is necessary. Having multiple copies of the CodeMirror libraries loaded can cause
|
||||
// the editor to not work properly.
|
||||
//
|
||||
import { lineNumbers } from '@codemirror/view';
|
||||
import { lineNumbers, highlightActiveLineGutter, } from '@codemirror/view';
|
||||
//
|
||||
// For the above import to work, you may also need to add @codemirror/view as a dev dependency
|
||||
// to package.json. (For the type information only).
|
||||
@@ -22,10 +22,37 @@ export default (_context: { contentScriptId: string }) => {
|
||||
// We add the extension to CodeMirror using a helper method:
|
||||
codeMirrorWrapper.addExtension([
|
||||
lineNumbers(),
|
||||
|
||||
// We can include multiple extensions here:
|
||||
highlightActiveLineGutter(),
|
||||
]);
|
||||
|
||||
// See https://codemirror.net/ for more built-in extensions and configuration
|
||||
// options.
|
||||
},
|
||||
|
||||
// There are two main ways to style the CodeMirror editor:
|
||||
// 1. With a CodeMirror6 theme extension (see https://codemirror.net/examples/styling/#themes)
|
||||
// 2. With CSS assets
|
||||
//
|
||||
// CSS assets can be added by exporting an `assets` function:
|
||||
assets: () => [
|
||||
// We can include styles by either referencing a file
|
||||
{ name: './assets/style.css' },
|
||||
|
||||
// or including the style sheet inline
|
||||
{
|
||||
inline: true,
|
||||
mime: 'text/css',
|
||||
text: `
|
||||
/* This CSS class is added by the highlightActiveLineGutter extension: */
|
||||
.cm-gutter .cm-activeLineGutter {
|
||||
text-decoration: underline;
|
||||
color: var(--joplin-color2);
|
||||
background-color: var(--joplin-background-color2);
|
||||
}
|
||||
`,
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
|
@@ -4,4 +4,4 @@
|
||||
# - Run the below command
|
||||
# - Then the file /manifests.json also needs to be updated with the new manifest file
|
||||
|
||||
yarn run dist && cp publish/org.joplinapp.plugins.RegisterCommandDemo.jpl ~/src/joplin-plugins-test/plugins/org.joplinapp.plugins.RegisterCommandDemo/plugin.jpl && cp publish/org.joplinapp.plugins.RegisterCommandDemo.json ~/src/joplin-plugins-test/plugins/org.joplinapp.plugins.RegisterCommandDemo/plugin.json
|
||||
yarn dist && cp publish/org.joplinapp.plugins.RegisterCommandDemo.jpl ~/src/joplin-plugins-test/plugins/org.joplinapp.plugins.RegisterCommandDemo/plugin.jpl && cp publish/org.joplinapp.plugins.RegisterCommandDemo.json ~/src/joplin-plugins-test/plugins/org.joplinapp.plugins.RegisterCommandDemo/plugin.json
|
Binary file not shown.
Binary file not shown.
@@ -8,7 +8,7 @@
|
||||
// - Run the Postgres database -- `sudo docker-compose --file docker-compose.db-dev.yml up`
|
||||
// - Update the DB parameters in ~/joplin-credentials/server.env to use the dev
|
||||
// database
|
||||
// - Run the server - `JOPLIN_IS_TESTING=1 yarn run start-dev`
|
||||
// - Run the server - `JOPLIN_IS_TESTING=1 yarn start-dev`
|
||||
// - Then run this script - `node populateDatabase.js`
|
||||
//
|
||||
// Currently it doesn't actually create the users, so that should be done using:
|
||||
|
@@ -307,7 +307,7 @@
|
||||
cleanUpElement(convertToMarkup, cleanDocument, imageSizes, imageIndexes);
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const stylesheets = convertToMarkup === 'html' ? getStyleSheets(document) : null;
|
||||
const stylesheets = convertToMarkup === 'html' ? getStyleSheets(document) : [];
|
||||
|
||||
// The <BODY> tag may have a style in the CSS stylesheets. This
|
||||
// style can be overriden by setting the `style` attribute on the
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "@joplin/app-clipper",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"postinstall": "cd popup && npm install"
|
||||
"build": "cd popup && npm install"
|
||||
},
|
||||
"version": "1.0.8",
|
||||
"description": "Joplin Web Clipper",
|
||||
|
3160
packages/app-clipper/popup/package-lock.json
generated
3160
packages/app-clipper/popup/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
1
packages/app-desktop/.gitignore
vendored
1
packages/app-desktop/.gitignore
vendored
@@ -23,3 +23,4 @@ integration-tests/test-profile/
|
||||
build/defaultPlugins/
|
||||
build/7zip/7za
|
||||
build/7zip/7za.exe
|
||||
sentry.properties
|
||||
|
@@ -75,6 +75,8 @@ export default class ElectronAppWrapper {
|
||||
// Assumes that the renderer process may be in an invalid state and so cannot
|
||||
// be accessed.
|
||||
public async handleAppFailure(errorMessage: string, canIgnore: boolean, isTesting?: boolean) {
|
||||
await bridge().captureException(new Error(errorMessage));
|
||||
|
||||
const buttons = [];
|
||||
buttons.push(_('Quit'));
|
||||
const exitIndex = 0;
|
||||
|
@@ -6,11 +6,12 @@ import { ExportModule } from '@joplin/lib/services/interop/Module';
|
||||
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { PluginStates } from '@joplin/lib/services/plugins/reducer';
|
||||
const bridge = require('@electron/remote').require('./bridge').default;
|
||||
import bridge from './services/bridge';
|
||||
import Setting from '@joplin/lib/models/Setting';
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
const { friendlySafeFilename } = require('@joplin/lib/path-utils');
|
||||
import time from '@joplin/lib/time';
|
||||
import { BrowserWindow } from 'electron';
|
||||
const md5 = require('md5');
|
||||
const url = require('url');
|
||||
|
||||
@@ -45,7 +46,7 @@ export default class InteropServiceHelper {
|
||||
}
|
||||
|
||||
private static async exportNoteTo_(target: string, noteId: string, options: ExportNoteOptions = {}) {
|
||||
let win: any = null;
|
||||
let win: BrowserWindow|null = null;
|
||||
let htmlFile: string = null;
|
||||
|
||||
const cleanup = () => {
|
||||
@@ -83,8 +84,8 @@ export default class InteropServiceHelper {
|
||||
// contents of the tag are visible in printed
|
||||
// pdfs.
|
||||
// https://github.com/laurent22/joplin/issues/6254.
|
||||
win.webContents.executeJavaScript('document.querySelectorAll(\'details\').forEach(el=>el.setAttribute(\'open\',\'\'))');
|
||||
const data = await win.webContents.printToPDF(options);
|
||||
await win.webContents.executeJavaScript('document.querySelectorAll(\'details\').forEach(el=>el.setAttribute(\'open\',\'\'))');
|
||||
const data = await win.webContents.printToPDF(options as any);
|
||||
resolve(data);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
@@ -104,21 +105,39 @@ export default class InteropServiceHelper {
|
||||
// https://github.com/electron/electron/issues/28192
|
||||
// Still doesn't work but at least it doesn't crash
|
||||
// the app.
|
||||
//
|
||||
// 2024-01-31: Printing with webContents.print still
|
||||
// fails on Linux (even if run in the main process).
|
||||
// As such, we use window.print(), which seems to work.
|
||||
|
||||
win.webContents.print(options, (success: boolean, reason: string) => {
|
||||
// TODO: This is correct but broken in Electron 4. Need to upgrade to 5+
|
||||
// It calls the callback right away with "false" even if the document hasn't be print yet.
|
||||
if (shim.isLinux()) {
|
||||
await win.webContents.executeJavaScript(`
|
||||
// Blocks while the print dialog is open
|
||||
window.print();
|
||||
`);
|
||||
|
||||
cleanup();
|
||||
if (!success && reason !== 'cancelled') reject(new Error(`Could not print: ${reason}`));
|
||||
resolve(null);
|
||||
});
|
||||
shim.setTimeout(() => {
|
||||
// To prevent a crash, the window can only be closed after a timeout.
|
||||
// This timeout can't be too small, or else it may still crash (e.g. 100ms
|
||||
// is too short).
|
||||
//
|
||||
// See https://github.com/electron/electron/issues/31635 for details
|
||||
cleanup();
|
||||
resolve(null);
|
||||
}, 1000);
|
||||
} else {
|
||||
win.webContents.print(options as any, (success: boolean, reason: string) => {
|
||||
cleanup();
|
||||
if (!success && reason !== 'cancelled') reject(new Error(`Could not print: ${reason}`));
|
||||
resolve(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
});
|
||||
|
||||
win.loadURL(url.format({
|
||||
void win.loadURL(url.format({
|
||||
pathname: htmlFile,
|
||||
protocol: 'file:',
|
||||
slashes: true,
|
||||
|
@@ -129,6 +129,10 @@ class Application extends BaseApplication {
|
||||
this.setupOcrService();
|
||||
}
|
||||
|
||||
if (action.type === 'SETTING_UPDATE_ONE' && action.key === 'autoUploadCrashDumps') {
|
||||
bridge().setAutoUploadCrashDumps(action.value);
|
||||
}
|
||||
|
||||
if (action.type === 'SETTING_UPDATE_ONE' && action.key === 'style.editor.fontFamily' || action.type === 'SETTING_UPDATE_ALL') {
|
||||
this.updateEditorFont();
|
||||
}
|
||||
@@ -248,26 +252,6 @@ class Application extends BaseApplication {
|
||||
});
|
||||
}
|
||||
|
||||
private async checkForLegacyTemplates() {
|
||||
const templatesDir = `${Setting.value('profileDir')}/templates`;
|
||||
if (await shim.fsDriver().exists(templatesDir)) {
|
||||
try {
|
||||
const files = await shim.fsDriver().readDirStats(templatesDir);
|
||||
for (const file of files) {
|
||||
if (file.path.endsWith('.md')) {
|
||||
// There is at least one template.
|
||||
this.store().dispatch({
|
||||
type: 'CONTAINS_LEGACY_TEMPLATES',
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
reg.logger().error(`Failed to read templates directory: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async initPluginService() {
|
||||
if (this.initPluginServiceDone_) return;
|
||||
this.initPluginServiceDone_ = true;
|
||||
@@ -406,7 +390,7 @@ class Application extends BaseApplication {
|
||||
|
||||
argv = await super.start(argv);
|
||||
|
||||
// this.crashDetectionHandler();
|
||||
bridge().setAutoUploadCrashDumps(Setting.value('autoUploadCrashDumps'));
|
||||
|
||||
await this.applySettingsSideEffects();
|
||||
|
||||
@@ -545,8 +529,6 @@ class Application extends BaseApplication {
|
||||
value: Setting.value('flagOpenDevTools'),
|
||||
});
|
||||
|
||||
await this.checkForLegacyTemplates();
|
||||
|
||||
// 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
|
||||
|
@@ -2,6 +2,10 @@ import ElectronAppWrapper from './ElectronAppWrapper';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import { _, setLocale } from '@joplin/lib/locale';
|
||||
import { BrowserWindow, nativeTheme, nativeImage } from 'electron';
|
||||
import * as Sentry from '@sentry/electron/main';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { homedir } from 'os';
|
||||
import { msleep } from '@joplin/utils/time';
|
||||
const { dirname, toSystemSlashes } = require('@joplin/lib/path-utils');
|
||||
|
||||
interface LastSelectedPath {
|
||||
@@ -20,6 +24,7 @@ export class Bridge {
|
||||
|
||||
private electronWrapper_: ElectronAppWrapper;
|
||||
private lastSelectedPaths_: LastSelectedPath;
|
||||
private autoUploadCrashDumps_ = false;
|
||||
|
||||
public constructor(electronWrapper: ElectronAppWrapper) {
|
||||
this.electronWrapper_ = electronWrapper;
|
||||
@@ -27,6 +32,24 @@ export class Bridge {
|
||||
file: null,
|
||||
directory: null,
|
||||
};
|
||||
|
||||
Sentry.init({
|
||||
dsn: 'https://cceec550871b1e8a10fee4c7a28d5cf2@o4506576757522432.ingest.sentry.io/4506594281783296',
|
||||
beforeSend: event => {
|
||||
try {
|
||||
const date = (new Date()).toISOString().replace(/[:-]/g, '').split('.')[0];
|
||||
writeFileSync(`${homedir()}/joplin_crash_dump_${date}.json`, JSON.stringify(event, null, '\t'), 'utf-8');
|
||||
} catch (error) {
|
||||
// Ignore the error since we can't handle it here
|
||||
}
|
||||
|
||||
if (!this.autoUploadCrashDumps_) {
|
||||
return null;
|
||||
} else {
|
||||
return event;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public electronApp() {
|
||||
@@ -37,6 +60,17 @@ export class Bridge {
|
||||
return !this.electronApp().electronApp().isPackaged;
|
||||
}
|
||||
|
||||
public async captureException(error: any) {
|
||||
Sentry.captureException(error);
|
||||
// We wait to give the "beforeSend" event handler time to process the crash dump and write
|
||||
// it to file.
|
||||
await msleep(10);
|
||||
}
|
||||
|
||||
public setAutoUploadCrashDumps(v: boolean) {
|
||||
this.autoUploadCrashDumps_ = v;
|
||||
}
|
||||
|
||||
// The build directory contains additional external files that are going to
|
||||
// be packaged by Electron Builder. This is for files that need to be
|
||||
// accessed outside of the Electron app (for example the application icon).
|
||||
|
@@ -37,12 +37,11 @@ const StyledTitle = styled.span`
|
||||
|
||||
`;
|
||||
|
||||
// const buttonSizePx = 32;
|
||||
|
||||
export const buttonSizePx = (props: Props) => {
|
||||
if (!props.size || props.size === ButtonSize.Normal) return 32;
|
||||
if (props.size === ButtonSize.Small) return 26;
|
||||
throw new Error(`Unknown size: ${props.size}`);
|
||||
export const buttonSizePx = (props: Props | ButtonSize) => {
|
||||
const buttonSize = typeof props === 'number' ? props : props.size;
|
||||
if (!buttonSize || buttonSize === ButtonSize.Normal) return 32;
|
||||
if (buttonSize === ButtonSize.Small) return 26;
|
||||
throw new Error(`Unknown size: ${buttonSize}`);
|
||||
};
|
||||
|
||||
const isSquare = (props: Props) => {
|
||||
|
@@ -10,7 +10,7 @@ import EncryptionConfigScreen from '../EncryptionConfigScreen/EncryptionConfigSc
|
||||
import { reg } from '@joplin/lib/registry';
|
||||
const { connect } = require('react-redux');
|
||||
const { themeStyle } = require('@joplin/lib/theme');
|
||||
const pathUtils = require('@joplin/lib/path-utils');
|
||||
import * as pathUtils from '@joplin/lib/path-utils';
|
||||
import SyncTargetRegistry from '@joplin/lib/SyncTargetRegistry';
|
||||
import * as shared from '@joplin/lib/components/shared/config/config-shared.js';
|
||||
import ClipperConfigScreen from '../ClipperConfigScreen';
|
||||
@@ -68,7 +68,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
|
||||
public componentDidMount() {
|
||||
if (this.props.defaultSection) {
|
||||
this.setState({ selectedSectionName: this.props.defaultSection }, () => {
|
||||
this.switchSection(this.props.defaultSection);
|
||||
void this.switchSection(this.props.defaultSection);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
|
||||
throw new Error(`Invalid screen name: ${screenName}`);
|
||||
}
|
||||
|
||||
public switchSection(name: string) {
|
||||
public async switchSection(name: string) {
|
||||
const section = this.sectionByName(name);
|
||||
let screenName = '';
|
||||
if (section.isScreen) {
|
||||
@@ -120,7 +120,9 @@ class ConfigScreenComponent extends React.Component<any, any> {
|
||||
|
||||
if (this.hasChanges()) {
|
||||
const ok = confirm(_('This will open a new screen. Save your current changes?'));
|
||||
if (ok) shared.saveSettings(this);
|
||||
if (ok) {
|
||||
await shared.saveSettings(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
|
||||
}
|
||||
|
||||
private sidebar_selectionChange(event: any) {
|
||||
this.switchSection(event.section.name);
|
||||
void this.switchSection(event.section.name);
|
||||
}
|
||||
|
||||
public renderSectionDescription(section: any) {
|
||||
@@ -655,12 +657,15 @@ class ConfigScreenComponent extends React.Component<any, any> {
|
||||
}
|
||||
|
||||
public async onApplyClick() {
|
||||
shared.saveSettings(this);
|
||||
const done = await shared.saveSettings(this);
|
||||
if (!done) return;
|
||||
|
||||
await this.checkNeedRestart();
|
||||
}
|
||||
|
||||
public async onSaveClick() {
|
||||
shared.saveSettings(this);
|
||||
const done = await shared.saveSettings(this);
|
||||
if (!done) return;
|
||||
await this.checkNeedRestart();
|
||||
this.props.dispatch({ type: 'NAV_BACK' });
|
||||
}
|
||||
|
@@ -11,7 +11,12 @@ const DialogModalLayer = styled.div`
|
||||
background-color: rgba(0,0,0,0.6);
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
|
||||
overflow: auto;
|
||||
scrollbar-width: none;
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
|
||||
const DialogRoot = styled.div`
|
||||
|
@@ -63,8 +63,6 @@ export default function(props: Props) {
|
||||
const folder: FolderEntity = {
|
||||
title: folderTitle,
|
||||
icon: Folder.serializeIcon(folderIcon),
|
||||
is_shared: 0,
|
||||
share_id: '',
|
||||
};
|
||||
|
||||
if (!isNew) folder.id = props.folderId;
|
||||
|
@@ -72,7 +72,6 @@ interface Props {
|
||||
showMissingMasterKeyMessage: boolean;
|
||||
showNeedUpgradingMasterKeyMessage: boolean;
|
||||
showShouldReencryptMessage: boolean;
|
||||
showInstallTemplatesPlugin: boolean;
|
||||
themeId: number;
|
||||
settingEditorCodeView: boolean;
|
||||
pluginsLegacy: any;
|
||||
@@ -84,6 +83,7 @@ interface Props {
|
||||
processingShareInvitationResponse: boolean;
|
||||
isResettingLayout: boolean;
|
||||
listRendererId: string;
|
||||
mustUpgradeAppMessage: string;
|
||||
}
|
||||
|
||||
interface ShareFolderDialogOptions {
|
||||
@@ -521,10 +521,12 @@ class MainScreenComponent extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
private renderNotificationMessage(message: string, callForAction: string, callForActionHandler: Function, callForAction2: string = null, callForActionHandler2: Function = null) {
|
||||
private renderNotificationMessage(message: string, callForAction: string = null, callForActionHandler: Function = null, callForAction2: string = null, callForActionHandler2: Function = null) {
|
||||
const theme = themeStyle(this.props.themeId);
|
||||
const urlStyle: any = { color: theme.colorWarnUrl, textDecoration: 'underline' };
|
||||
|
||||
if (!callForAction) return <span>{message}</span>;
|
||||
|
||||
const cfa = (
|
||||
<a href="#" style={urlStyle} onClick={() => callForActionHandler()}>
|
||||
{callForAction}
|
||||
@@ -575,16 +577,6 @@ class MainScreenComponent extends React.Component<Props, State> {
|
||||
});
|
||||
};
|
||||
|
||||
const onViewPluginScreen = () => {
|
||||
this.props.dispatch({
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Config',
|
||||
props: {
|
||||
defaultSection: 'plugins',
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const onRestartAndUpgrade = async () => {
|
||||
Setting.setValue('sync.upgradeState', Setting.SYNC_UPGRADE_STATE_MUST_DO);
|
||||
await Setting.saveAll();
|
||||
@@ -665,12 +657,8 @@ class MainScreenComponent extends React.Component<Props, State> {
|
||||
_('Set the password'),
|
||||
onViewEncryptionConfigScreen,
|
||||
);
|
||||
} else if (this.props.showInstallTemplatesPlugin) {
|
||||
msg = this.renderNotificationMessage(
|
||||
'The template feature has been moved to a plugin called "Templates".',
|
||||
'Install plugin',
|
||||
onViewPluginScreen,
|
||||
);
|
||||
} else if (this.props.mustUpgradeAppMessage) {
|
||||
msg = this.renderNotificationMessage(this.props.mustUpgradeAppMessage);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -682,7 +670,17 @@ class MainScreenComponent extends React.Component<Props, State> {
|
||||
|
||||
public messageBoxVisible(props: Props = null) {
|
||||
if (!props) props = this.props;
|
||||
return props.hasDisabledSyncItems || props.showMissingMasterKeyMessage || props.hasMissingSyncCredentials || props.showNeedUpgradingMasterKeyMessage || props.showShouldReencryptMessage || props.hasDisabledEncryptionItems || this.props.shouldUpgradeSyncTarget || props.isSafeMode || this.showShareInvitationNotification(props) || this.props.needApiAuth || this.props.showInstallTemplatesPlugin;
|
||||
return props.hasDisabledSyncItems ||
|
||||
props.showMissingMasterKeyMessage ||
|
||||
props.hasMissingSyncCredentials ||
|
||||
props.showNeedUpgradingMasterKeyMessage ||
|
||||
props.showShouldReencryptMessage ||
|
||||
props.hasDisabledEncryptionItems ||
|
||||
this.props.shouldUpgradeSyncTarget ||
|
||||
props.isSafeMode ||
|
||||
this.showShareInvitationNotification(props) ||
|
||||
this.props.needApiAuth ||
|
||||
!!this.props.mustUpgradeAppMessage;
|
||||
}
|
||||
|
||||
public registerCommands() {
|
||||
@@ -918,9 +916,9 @@ const mapStateToProps = (state: AppState) => {
|
||||
isSafeMode: state.settings.isSafeMode,
|
||||
enableBetaMarkdownEditor: state.settings['editor.beta'],
|
||||
needApiAuth: state.needApiAuth,
|
||||
showInstallTemplatesPlugin: state.hasLegacyTemplates && !state.pluginService.plugins['joplin.plugin.templates'],
|
||||
isResettingLayout: state.isResettingLayout,
|
||||
listRendererId: state.settings['notes.listRendererId'],
|
||||
mustUpgradeAppMessage: state.mustUpgradeAppMessage,
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -29,6 +29,12 @@ export const runtime = (): CommandRuntime => {
|
||||
type: 'NOTE_SELECT',
|
||||
id: newNote.id,
|
||||
});
|
||||
|
||||
// Immediately sort the note list so that the new note is positioned correctly before
|
||||
// scrolling to it.
|
||||
utils.store.dispatch({
|
||||
type: 'NOTE_SORT',
|
||||
});
|
||||
},
|
||||
enabledCondition: 'oneFolderSelected && !inConflictFolder && !folderIsReadOnly',
|
||||
};
|
||||
|
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
const setupVim = (CodeMirror) => {
|
||||
CodeMirror.Vim.defineAction('swapLineDown', CodeMirror.commands.swapLineDown);
|
||||
CodeMirror.Vim.mapCommand('<A-j>', 'action', 'swapLineDown', {}, { context: 'normal', isEdit: true });
|
||||
CodeMirror.Vim.defineAction('swapLineUp', CodeMirror.commands.swapLineUp);
|
||||
CodeMirror.Vim.mapCommand('<A-k>', 'action', 'swapLineUp', {}, { context: 'normal', isEdit: true });
|
||||
CodeMirror.Vim.defineAction('insertListElement', CodeMirror.commands.vimInsertListElement);
|
||||
CodeMirror.Vim.mapCommand('o', 'action', 'insertListElement', { after: true }, { context: 'normal', isEdit: true, interlaceInsertRepeat: true });
|
||||
};
|
||||
exports.default = setupVim;
|
||||
// # sourceMappingURL=setupVim.js.map
|
@@ -4,7 +4,7 @@ import KeymapService, { KeymapItem } from '@joplin/lib/services/KeymapService';
|
||||
import { EditorCommand } from '../../../utils/types';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import { reg } from '@joplin/lib/registry';
|
||||
import setupVim from './setupVim';
|
||||
import setupVim from '@joplin/editor/CodeMirror/util/setupVim';
|
||||
import { EventName } from '@joplin/lib/eventManager';
|
||||
|
||||
export default function useKeymap(CodeMirror: any) {
|
||||
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
||||
import { useState, useEffect, useRef, forwardRef, useCallback, useImperativeHandle, useMemo, ForwardedRef } from 'react';
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
import { EditorCommand, NoteBodyEditorProps, NoteBodyEditorRef } from '../../../utils/types';
|
||||
import { EditorCommand, MarkupToHtmlOptions, NoteBodyEditorProps, NoteBodyEditorRef } from '../../../utils/types';
|
||||
import { commandAttachFileToBody, getResourcesFromPasteEvent } from '../../../utils/resourceHandling';
|
||||
import { ScrollOptions, ScrollOptionTypes } from '../../../utils/types';
|
||||
import { CommandValue } from '../../../utils/types';
|
||||
@@ -29,7 +29,6 @@ const debounce = require('debounce');
|
||||
|
||||
import { reg } from '@joplin/lib/registry';
|
||||
import ErrorBoundary from '../../../../ErrorBoundary';
|
||||
import { MarkupToHtmlOptions } from '../../../utils/useMarkupToHtml';
|
||||
import useStyles from '../utils/useStyles';
|
||||
import useContextMenu from '../utils/useContextMenu';
|
||||
import useWebviewIpcMessage from '../utils/useWebviewIpcMessage';
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import { useState, useEffect, useRef, forwardRef, useCallback, useImperativeHandle, useMemo, ForwardedRef } from 'react';
|
||||
|
||||
import { EditorCommand, NoteBodyEditorProps, NoteBodyEditorRef, OnChangeEvent } from '../../../utils/types';
|
||||
import { EditorCommand, MarkupToHtmlOptions, NoteBodyEditorProps, NoteBodyEditorRef, OnChangeEvent } from '../../../utils/types';
|
||||
import { getResourcesFromPasteEvent } from '../../../utils/resourceHandling';
|
||||
import { ScrollOptions, ScrollOptionTypes } from '../../../utils/types';
|
||||
import NoteTextViewer from '../../../../NoteTextViewer';
|
||||
@@ -16,7 +16,6 @@ import { MarkupToHtml } from '@joplin/renderer';
|
||||
const { clipboard } = require('electron');
|
||||
import { reg } from '@joplin/lib/registry';
|
||||
import ErrorBoundary from '../../../../ErrorBoundary';
|
||||
import { MarkupToHtmlOptions } from '../../../utils/useMarkupToHtml';
|
||||
import { EditorKeymap, EditorLanguageType, EditorSettings } from '@joplin/editor/types';
|
||||
import useStyles from '../utils/useStyles';
|
||||
import { EditorEvent, EditorEventType } from '@joplin/editor/events';
|
||||
|
@@ -8,7 +8,8 @@ import { PluginStates } from '@joplin/lib/services/plugins/reducer';
|
||||
import { ContentScriptType } from '@joplin/lib/services/plugins/api/types';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import PluginService from '@joplin/lib/services/plugins/PluginService';
|
||||
import setupVim from '../utils/setupVim';
|
||||
import setupVim from '@joplin/editor/CodeMirror/util/setupVim';
|
||||
import { dirname } from 'path';
|
||||
|
||||
interface Props extends EditorProps {
|
||||
style: React.CSSProperties;
|
||||
@@ -66,6 +67,11 @@ const Editor = (props: Props, ref: ForwardedRef<CodeMirrorControl>) => {
|
||||
pluginId,
|
||||
contentScriptId: contentScript.id,
|
||||
contentScriptJs: () => shim.fsDriver().readFile(contentScript.path),
|
||||
loadCssAsset: (name: string) => {
|
||||
const assetPath = dirname(contentScript.path);
|
||||
const path = shim.fsDriver().resolveRelativePathWithinDir(assetPath, name);
|
||||
return shim.fsDriver().readFile(path, 'utf8');
|
||||
},
|
||||
postMessageHandler: (message: any) => {
|
||||
const plugin = PluginService.instance().pluginById(pluginId);
|
||||
return plugin.emitContentScriptMessage(contentScript.id, message);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { useState, useEffect, useCallback, useRef, forwardRef, useImperativeHandle } from 'react';
|
||||
import { ScrollOptions, ScrollOptionTypes, EditorCommand, NoteBodyEditorProps, ResourceInfos } from '../../utils/types';
|
||||
import { ScrollOptions, ScrollOptionTypes, EditorCommand, NoteBodyEditorProps, ResourceInfos, HtmlToMarkdownHandler } from '../../utils/types';
|
||||
import { resourcesStatus, commandAttachFileToBody, getResourcesFromPasteEvent, processPastedHtml, attachedResources } from '../../utils/resourceHandling';
|
||||
import useScroll from './utils/useScroll';
|
||||
import styles_ from './styles';
|
||||
@@ -20,7 +20,6 @@ import BaseItem from '@joplin/lib/models/BaseItem';
|
||||
import setupToolbarButtons from './utils/setupToolbarButtons';
|
||||
import { plainTextToHtml } from '@joplin/lib/htmlUtils';
|
||||
import openEditDialog from './utils/openEditDialog';
|
||||
import { MarkupToHtmlOptions } from '../../utils/useMarkupToHtml';
|
||||
import { themeStyle } from '@joplin/lib/theme';
|
||||
import { loadScript } from '../../../utils/loadScript';
|
||||
import bridge from '../../../../services/bridge';
|
||||
@@ -30,25 +29,12 @@ import { joplinCommandToTinyMceCommands, TinyMceCommand } from './utils/joplinCo
|
||||
import shouldPasteResources from './utils/shouldPasteResources';
|
||||
import lightTheme from '@joplin/lib/themes/light';
|
||||
import { Options as NoteStyleOptions } from '@joplin/renderer/noteStyle';
|
||||
import markupRenderOptions from '../../utils/markupRenderOptions';
|
||||
import { DropHandler } from '../../utils/useDropHandler';
|
||||
const md5 = require('md5');
|
||||
const { clipboard } = require('electron');
|
||||
const supportedLocales = require('./supportedLocales');
|
||||
|
||||
function markupRenderOptions(override: MarkupToHtmlOptions = null): MarkupToHtmlOptions {
|
||||
return {
|
||||
plugins: {
|
||||
checkbox: {
|
||||
checkboxRenderingType: 2,
|
||||
},
|
||||
link_open: {
|
||||
linkRenderingType: 2,
|
||||
},
|
||||
},
|
||||
replaceResourceInternalToExternalLinks: true,
|
||||
...override,
|
||||
};
|
||||
}
|
||||
|
||||
// In TinyMCE 5.2, when setting the body to '<div id="rendered-md"></div>',
|
||||
// it would end up as '<div id="rendered-md"><br/></div>' once rendered
|
||||
// (an additional <br/> was inserted).
|
||||
@@ -63,10 +49,17 @@ function markupRenderOptions(override: MarkupToHtmlOptions = null): MarkupToHtml
|
||||
// so as a workaround we manually add this <br> for empty documents,
|
||||
// which fixes the issue.
|
||||
//
|
||||
// However,
|
||||
// <div id="rendered-md"><br/></div>
|
||||
// breaks newline behaviour in new notes (see https://github.com/laurent22/joplin/issues/9786).
|
||||
// Thus, we instead use
|
||||
// <div id="rendered-md"><p></p></div>
|
||||
// which also seems to work around the list issue.
|
||||
//
|
||||
// Perhaps upgrading the list plugin (which is a fork of TinyMCE own list plugin)
|
||||
// would help?
|
||||
function awfulBrHack(html: string): string {
|
||||
return html === '<div id="rendered-md"></div>' ? '<div id="rendered-md"><br/></div>' : html;
|
||||
function awfulInitHack(html: string): string {
|
||||
return html === '<div id="rendered-md"></div>' ? '<div id="rendered-md"><p></p></div>' : html;
|
||||
}
|
||||
|
||||
function findEditableContainer(node: any): any {
|
||||
@@ -101,7 +94,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
const props_onMessage = useRef(null);
|
||||
props_onMessage.current = props.onMessage;
|
||||
|
||||
const props_onDrop = useRef(null);
|
||||
const props_onDrop = useRef<DropHandler|null>(null);
|
||||
props_onDrop.current = props.onDrop;
|
||||
|
||||
const markupToHtml = useRef(null);
|
||||
@@ -123,7 +116,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
const { scrollToPercent } = useScroll({ editor, onScroll: props.onScroll });
|
||||
|
||||
usePluginServiceRegistration(ref);
|
||||
useContextMenu(editor, props.plugins, props.dispatch);
|
||||
useContextMenu(editor, props.plugins, props.dispatch, props.htmlToMarkdown, props.markupToHtml);
|
||||
|
||||
const dispatchDidUpdate = (editor: any) => {
|
||||
if (dispatchDidUpdateIID_) shim.clearTimeout(dispatchDidUpdateIID_);
|
||||
@@ -623,13 +616,21 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
localization_function: _,
|
||||
contextmenu: false,
|
||||
browser_spellcheck: true,
|
||||
|
||||
// Work around an issue where images with a base64 SVG data URL would be broken.
|
||||
//
|
||||
// See https://github.com/tinymce/tinymce/issues/3864
|
||||
//
|
||||
// This was fixed in TinyMCE 6.1, so remove it when we upgrade.
|
||||
images_dataimg_filter: (img: HTMLImageElement) => !img.src.startsWith('data:'),
|
||||
|
||||
formats: {
|
||||
joplinHighlight: { inline: 'mark', remove: 'all' },
|
||||
joplinStrikethrough: { inline: 's', remove: 'all' },
|
||||
joplinInsert: { inline: 'ins', remove: 'all' },
|
||||
joplinSub: { inline: 'sub', remove: 'all' },
|
||||
joplinSup: { inline: 'sup', remove: 'all' },
|
||||
code: { inline: 'code', remove: 'all', attributes: { spellcheck: false } },
|
||||
code: { inline: 'code', remove: 'all', attributes: { spellcheck: 'false' } },
|
||||
forecolor: { inline: 'span', styles: { color: '%value' } },
|
||||
},
|
||||
setup: (editor: Editor) => {
|
||||
@@ -706,16 +707,21 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
if (editable) openEditDialog(editor, markupToHtml, dispatchDidUpdate, editable);
|
||||
});
|
||||
|
||||
// This is triggered when an external file is dropped on the editor
|
||||
editor.on('drop', (event) => {
|
||||
// Prevent the message "Dropped file type is not
|
||||
// supported" to show up. It was added in a recent
|
||||
// TinyMCE version and doesn't apply since we do support
|
||||
// Prevent the message "Dropped file type is not supported" from showing up.
|
||||
// It was added in TinyMCE 5.4 and doesn't apply since we do support
|
||||
// the file type.
|
||||
// https://stackoverflow.com/questions/64782955/tinymce-inline-drag-and-drop-image-upload-not-working
|
||||
event.preventDefault();
|
||||
|
||||
props_onDrop.current(event);
|
||||
//
|
||||
// See https://stackoverflow.com/questions/64782955/tinymce-inline-drag-and-drop-image-upload-not-working
|
||||
//
|
||||
// The other suggested solution, setting block_unsupported_drop to false,
|
||||
// causes all dropped files to be placed at the top of the document.
|
||||
//
|
||||
// Because .preventDefault cancels TinyMCE's own drop handler, we only
|
||||
// call .preventDefault if Joplin handled the event:
|
||||
if (props_onDrop.current(event)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('ObjectResized', (event) => {
|
||||
@@ -882,7 +888,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
);
|
||||
if (cancelled) return;
|
||||
|
||||
editor.setContent(awfulBrHack(result.html));
|
||||
editor.setContent(awfulInitHack(result.html));
|
||||
|
||||
if (lastOnChangeEventInfo.current.contentKey !== props.contentKey) {
|
||||
// Need to clear UndoManager to avoid this problem:
|
||||
@@ -978,7 +984,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
props_onChangeRef.current = props.onChange;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
const prop_htmlToMarkdownRef = useRef<Function>();
|
||||
const prop_htmlToMarkdownRef = useRef<HtmlToMarkdownHandler>();
|
||||
prop_htmlToMarkdownRef.current = props.htmlToMarkdown;
|
||||
|
||||
const nextOnChangeEventInfo = useRef<any>(null);
|
||||
@@ -1136,7 +1142,11 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
editor.insertContent(result.html);
|
||||
} else { // Paste regular text
|
||||
if (pastedHtml) { // Handles HTML
|
||||
const modifiedHtml = await processPastedHtml(pastedHtml);
|
||||
const modifiedHtml = await processPastedHtml(
|
||||
pastedHtml,
|
||||
prop_htmlToMarkdownRef.current,
|
||||
markupToHtml.current,
|
||||
);
|
||||
editor.insertContent(modifiedHtml);
|
||||
} else { // Handles plain text
|
||||
pasteAsPlainText(pastedText);
|
||||
|
@@ -12,6 +12,7 @@ import Setting from '@joplin/lib/models/Setting';
|
||||
|
||||
import Resource from '@joplin/lib/models/Resource';
|
||||
import { TinyMceEditorEvents } from './types';
|
||||
import { HtmlToMarkdownHandler, MarkupToHtmlHandler } from '../../../utils/types';
|
||||
|
||||
const menuUtils = new MenuUtils(CommandService.instance());
|
||||
|
||||
@@ -42,11 +43,11 @@ interface ContextMenuActionOptions {
|
||||
const contextMenuActionOptions: ContextMenuActionOptions = { current: null };
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
export default function(editor: any, plugins: PluginStates, dispatch: Function) {
|
||||
export default function(editor: any, plugins: PluginStates, dispatch: Function, htmlToMd: HtmlToMarkdownHandler, mdToHtml: MarkupToHtmlHandler) {
|
||||
useEffect(() => {
|
||||
if (!editor) return () => {};
|
||||
|
||||
const contextMenuItems = menuItems(dispatch);
|
||||
const contextMenuItems = menuItems(dispatch, htmlToMd, mdToHtml);
|
||||
|
||||
function onContextMenu(_event: any, params: any) {
|
||||
const element = contextMenuElement(editor, params.x, params.y);
|
||||
@@ -82,6 +83,8 @@ export default function(editor: any, plugins: PluginStates, dispatch: Function)
|
||||
fireEditorEvent: (event: TinyMceEditorEvents) => {
|
||||
editor.fire(event);
|
||||
},
|
||||
htmlToMd,
|
||||
mdToHtml,
|
||||
};
|
||||
|
||||
let template = [];
|
||||
@@ -118,5 +121,5 @@ export default function(editor: any, plugins: PluginStates, dispatch: Function)
|
||||
bridge().window().webContents.off('context-menu', onContextMenu);
|
||||
}
|
||||
};
|
||||
}, [editor, plugins, dispatch]);
|
||||
}, [editor, plugins, dispatch, htmlToMd, mdToHtml]);
|
||||
}
|
||||
|
@@ -341,7 +341,7 @@ function NoteEditor(props: NoteEditorProps) {
|
||||
// eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied
|
||||
}, [formNote, handleProvisionalFlag]);
|
||||
|
||||
const onMessage = useMessageHandler(scrollWhenReady, setScrollWhenReady, editorRef, setLocalSearchResultCount, props.dispatch, formNote);
|
||||
const onMessage = useMessageHandler(scrollWhenReady, setScrollWhenReady, editorRef, setLocalSearchResultCount, props.dispatch, formNote, htmlToMarkdown, markupToHtml);
|
||||
|
||||
const externalEditWatcher_noteChange = useCallback((event: any) => {
|
||||
if (event.id === formNote.id) {
|
||||
|
@@ -14,6 +14,7 @@ import { TinyMceEditorEvents } from '../NoteBody/TinyMCE/utils/types';
|
||||
import { itemIsReadOnlySync, ItemSlice } from '@joplin/lib/models/utils/readOnly';
|
||||
import Setting from '@joplin/lib/models/Setting';
|
||||
import ItemChange from '@joplin/lib/models/ItemChange';
|
||||
import { HtmlToMarkdownHandler, MarkupToHtmlHandler } from './types';
|
||||
const fs = require('fs-extra');
|
||||
const { writeFile } = require('fs-extra');
|
||||
const { clipboard } = require('electron');
|
||||
@@ -77,7 +78,7 @@ export async function openItemById(itemId: string, dispatch: Function, hash = ''
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
export function menuItems(dispatch: Function): ContextMenuItems {
|
||||
export function menuItems(dispatch: Function, htmlToMd: HtmlToMarkdownHandler, mdToHtml: MarkupToHtmlHandler): ContextMenuItems {
|
||||
return {
|
||||
open: {
|
||||
label: _('Open...'),
|
||||
@@ -179,7 +180,7 @@ export function menuItems(dispatch: Function): ContextMenuItems {
|
||||
let content = pastedHtml ? pastedHtml : clipboard.readText();
|
||||
|
||||
if (pastedHtml) {
|
||||
content = await processPastedHtml(pastedHtml);
|
||||
content = await processPastedHtml(pastedHtml, htmlToMd, mdToHtml);
|
||||
}
|
||||
|
||||
options.insertContent(content);
|
||||
@@ -207,7 +208,7 @@ export function menuItems(dispatch: Function): ContextMenuItems {
|
||||
export default async function contextMenu(options: ContextMenuOptions, dispatch: Function) {
|
||||
const menu = new Menu();
|
||||
|
||||
const items = menuItems(dispatch);
|
||||
const items = menuItems(dispatch, options.htmlToMd, options.mdToHtml);
|
||||
|
||||
if (!('readyOnly' in options)) options.isReadOnly = true;
|
||||
for (const itemKey in items) {
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import Resource from '@joplin/lib/models/Resource';
|
||||
import Logger from '@joplin/utils/Logger';
|
||||
import { HtmlToMarkdownHandler, MarkupToHtmlHandler } from './types';
|
||||
|
||||
const logger = Logger.create('contextMenuUtils');
|
||||
|
||||
export enum ContextMenuItemType {
|
||||
None = '',
|
||||
Image = 'image',
|
||||
@@ -22,6 +25,8 @@ export interface ContextMenuOptions {
|
||||
isReadOnly?: boolean;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
fireEditorEvent: Function;
|
||||
htmlToMd: HtmlToMarkdownHandler;
|
||||
mdToHtml: MarkupToHtmlHandler;
|
||||
}
|
||||
|
||||
export interface ContextMenuItem {
|
||||
|
@@ -0,0 +1,16 @@
|
||||
import { MarkupToHtmlOptions } from './types';
|
||||
|
||||
export default (override: MarkupToHtmlOptions = null): MarkupToHtmlOptions => {
|
||||
return {
|
||||
plugins: {
|
||||
checkbox: {
|
||||
checkboxRenderingType: 2,
|
||||
},
|
||||
link_open: {
|
||||
linkRenderingType: 2,
|
||||
},
|
||||
},
|
||||
replaceResourceInternalToExternalLinks: true,
|
||||
...override,
|
||||
};
|
||||
};
|
@@ -1,5 +1,8 @@
|
||||
import Setting from '@joplin/lib/models/Setting';
|
||||
import { processPastedHtml } from './resourceHandling';
|
||||
import markupLanguageUtils from '@joplin/lib/markupLanguageUtils';
|
||||
import HtmlToMd from '@joplin/lib/HtmlToMd';
|
||||
import { HtmlToMarkdownHandler, MarkupToHtmlHandler } from './types';
|
||||
|
||||
describe('resourceHandling', () => {
|
||||
it('should sanitize pasted HTML', async () => {
|
||||
@@ -19,7 +22,32 @@ describe('resourceHandling', () => {
|
||||
];
|
||||
|
||||
for (const [html, expected] of testCases) {
|
||||
expect(await processPastedHtml(html)).toBe(expected);
|
||||
expect(await processPastedHtml(html, null, null)).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
it('should clean up pasted HTML', async () => {
|
||||
const markupToHtml: MarkupToHtmlHandler = async (markupLanguage, markup, options) => {
|
||||
const conv = markupLanguageUtils.newMarkupToHtml({}, {
|
||||
resourceBaseUrl: `file://${Setting.value('resourceDir')}/`,
|
||||
customCss: '',
|
||||
});
|
||||
return conv.render(markupLanguage, markup, {}, options);
|
||||
};
|
||||
|
||||
const htmlToMd: HtmlToMarkdownHandler = async (_markupLanguage, html, _originalCss) => {
|
||||
const conv = new HtmlToMd();
|
||||
return conv.parse(html);
|
||||
};
|
||||
|
||||
const testCases = [
|
||||
['<p style="background-color: red">Hello</p><p style="display: hidden;">World</p>', '<p>Hello</p>\n<p>World</p>\n'],
|
||||
['', ''],
|
||||
];
|
||||
|
||||
for (const [html, expected] of testCases) {
|
||||
expect(await processPastedHtml(html, htmlToMd, markupToHtml)).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -10,6 +10,8 @@ import rendererHtmlUtils, { extractHtmlBody } from '@joplin/renderer/htmlUtils';
|
||||
import Logger from '@joplin/utils/Logger';
|
||||
import { fileUriToPath } from '@joplin/utils/url';
|
||||
import { MarkupLanguage } from '@joplin/renderer';
|
||||
import { HtmlToMarkdownHandler, MarkupToHtmlHandler } from './types';
|
||||
import markupRenderOptions from './markupRenderOptions';
|
||||
const joplinRendererUtils = require('@joplin/renderer').utils;
|
||||
const { clipboard } = require('electron');
|
||||
const mimeUtils = require('@joplin/lib/mime-utils.js').mime;
|
||||
@@ -135,7 +137,7 @@ export async function getResourcesFromPasteEvent(event: any) {
|
||||
return output;
|
||||
}
|
||||
|
||||
export async function processPastedHtml(html: string) {
|
||||
export async function processPastedHtml(html: string, htmlToMd: HtmlToMarkdownHandler | null, mdToHtml: MarkupToHtmlHandler | null) {
|
||||
const allImageUrls: string[] = [];
|
||||
const mappedResources: Record<string, string> = {};
|
||||
|
||||
@@ -179,6 +181,15 @@ export async function processPastedHtml(html: string) {
|
||||
}
|
||||
}
|
||||
|
||||
// TinyMCE can accept any type of HTML, including HTML that may not be preserved once saved as
|
||||
// Markdown. For example the content may have a dark background which would be supported by
|
||||
// TinyMCE, but lost once the note is saved. So here we convert the HTML to Markdown then back
|
||||
// to HTML to ensure that the content we paste will be handled correctly by the app.
|
||||
if (htmlToMd && mdToHtml) {
|
||||
const md = await htmlToMd(MarkupLanguage.Markdown, html, '');
|
||||
html = (await mdToHtml(MarkupLanguage.Markdown, md, markupRenderOptions({ bodyOnly: true }))).html;
|
||||
}
|
||||
|
||||
return extractHtmlBody(rendererHtmlUtils.sanitizeHtml(
|
||||
htmlUtils.replaceImageUrls(html, (src: string) => {
|
||||
return mappedResources[src];
|
||||
|
@@ -2,10 +2,10 @@ import AsyncActionQueue from '@joplin/lib/AsyncActionQueue';
|
||||
import { ToolbarButtonInfo } from '@joplin/lib/services/commands/ToolbarButtonUtils';
|
||||
import { PluginStates } from '@joplin/lib/services/plugins/reducer';
|
||||
import { MarkupLanguage } from '@joplin/renderer';
|
||||
import { RenderResult, RenderResultPluginAsset } from '@joplin/renderer/MarkupToHtml';
|
||||
import { MarkupToHtmlOptions } from './useMarkupToHtml';
|
||||
import { RenderResult, RenderResultPluginAsset } from '@joplin/renderer/types';
|
||||
import { Dispatch } from 'redux';
|
||||
import { ProcessResultsRow } from '@joplin/lib/services/search/SearchEngine';
|
||||
import { DropHandler } from './useDropHandler';
|
||||
|
||||
export interface AllAssetsOptions {
|
||||
contentMaxWidthTarget?: string;
|
||||
@@ -61,6 +61,24 @@ export interface NoteBodyEditorRef {
|
||||
execCommand(command: CommandValue): Promise<void>;
|
||||
}
|
||||
|
||||
export interface MarkupToHtmlOptions {
|
||||
replaceResourceInternalToExternalLinks?: boolean;
|
||||
resourceInfos?: ResourceInfos;
|
||||
contentMaxWidth?: number;
|
||||
plugins?: Record<string, any>;
|
||||
bodyOnly?: boolean;
|
||||
mapsToLine?: boolean;
|
||||
useCustomPdfViewer?: boolean;
|
||||
noteId?: string;
|
||||
vendorDir?: string;
|
||||
platformName?: string;
|
||||
allowedFilePrefixes?: string[];
|
||||
whiteBackgroundNoteRendering?: boolean;
|
||||
}
|
||||
|
||||
export type MarkupToHtmlHandler = (markupLanguage: MarkupLanguage, markup: string, options: MarkupToHtmlOptions)=> Promise<RenderResult>;
|
||||
export type HtmlToMarkdownHandler = (markupLanguage: number, html: string, originalCss: string)=> Promise<string>;
|
||||
|
||||
export interface NoteBodyEditorProps {
|
||||
style: any;
|
||||
ref: any;
|
||||
@@ -81,9 +99,8 @@ export interface NoteBodyEditorProps {
|
||||
onWillChange(event: any): void;
|
||||
onMessage(event: any): void;
|
||||
onScroll(event: { percent: number }): void;
|
||||
markupToHtml: (markupLanguage: MarkupLanguage, markup: string, options: MarkupToHtmlOptions)=> Promise<RenderResult>;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
htmlToMarkdown: Function;
|
||||
markupToHtml: MarkupToHtmlHandler;
|
||||
htmlToMarkdown: HtmlToMarkdownHandler;
|
||||
allAssets: (markupLanguage: MarkupLanguage, options: AllAssetsOptions)=> Promise<RenderResultPluginAsset[]>;
|
||||
disabled: boolean;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
@@ -97,7 +114,7 @@ export interface NoteBodyEditorProps {
|
||||
resourceDirectory: string;
|
||||
locale: string;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
onDrop: Function;
|
||||
onDrop: DropHandler;
|
||||
noteToolbarButtonInfos: ToolbarButtonInfo[];
|
||||
plugins: PluginStates;
|
||||
fontSize: number;
|
||||
|
@@ -1,36 +1,44 @@
|
||||
import { useCallback } from 'react';
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
import { DragEvent as ReactDragEvent } from 'react';
|
||||
|
||||
interface HookDependencies {
|
||||
editorRef: any;
|
||||
}
|
||||
|
||||
export default function useDropHandler(dependencies: HookDependencies) {
|
||||
// Returns true if Joplin handled the event
|
||||
export type DropHandler = (event: DragEvent|ReactDragEvent)=> boolean;
|
||||
|
||||
export default function useDropHandler(dependencies: HookDependencies): DropHandler {
|
||||
const { editorRef } = dependencies;
|
||||
|
||||
return useCallback(async (event: any) => {
|
||||
if (!event.dataTransfer) return;
|
||||
return useCallback((event: DragEvent|ReactDragEvent) => {
|
||||
if (!event.dataTransfer) return false;
|
||||
|
||||
const dt = event.dataTransfer;
|
||||
const createFileURL = event.altKey;
|
||||
|
||||
if (dt.types.indexOf('text/x-jop-note-ids') >= 0) {
|
||||
const noteIds = JSON.parse(dt.getData('text/x-jop-note-ids'));
|
||||
const noteMarkdownTags = [];
|
||||
for (let i = 0; i < noteIds.length; i++) {
|
||||
const note = await Note.load(noteIds[i]);
|
||||
noteMarkdownTags.push(Note.markdownTag(note));
|
||||
}
|
||||
|
||||
editorRef.current.execCommand({
|
||||
name: 'dropItems',
|
||||
value: {
|
||||
type: 'notes',
|
||||
markdownTags: noteMarkdownTags,
|
||||
},
|
||||
});
|
||||
const dropNotes = async () => {
|
||||
const noteMarkdownTags = [];
|
||||
for (let i = 0; i < noteIds.length; i++) {
|
||||
const note = await Note.load(noteIds[i]);
|
||||
noteMarkdownTags.push(Note.markdownTag(note));
|
||||
}
|
||||
|
||||
return;
|
||||
editorRef.current.execCommand({
|
||||
name: 'dropItems',
|
||||
value: {
|
||||
type: 'notes',
|
||||
markdownTags: noteMarkdownTags,
|
||||
},
|
||||
});
|
||||
};
|
||||
void dropNotes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const files = dt.files;
|
||||
@@ -50,7 +58,10 @@ export default function useDropHandler(dependencies: HookDependencies) {
|
||||
createFileURL: createFileURL,
|
||||
},
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
// eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied
|
||||
}, []);
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
import { PluginStates } from '@joplin/lib/services/plugins/reducer';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { ResourceInfos } from './types';
|
||||
import markupLanguageUtils from '../../../utils/markupLanguageUtils';
|
||||
import Setting from '@joplin/lib/models/Setting';
|
||||
import shim from '@joplin/lib/shim';
|
||||
|
||||
const { themeStyle } = require('@joplin/lib/theme');
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
import { MarkupToHtmlOptions } from './types';
|
||||
|
||||
interface HookDependencies {
|
||||
themeId: number;
|
||||
@@ -16,21 +16,6 @@ interface HookDependencies {
|
||||
whiteBackgroundNoteRendering: boolean;
|
||||
}
|
||||
|
||||
export interface MarkupToHtmlOptions {
|
||||
replaceResourceInternalToExternalLinks?: boolean;
|
||||
resourceInfos?: ResourceInfos;
|
||||
contentMaxWidth?: number;
|
||||
plugins?: Record<string, any>;
|
||||
bodyOnly?: boolean;
|
||||
mapsToLine?: boolean;
|
||||
useCustomPdfViewer?: boolean;
|
||||
noteId?: string;
|
||||
vendorDir?: string;
|
||||
platformName?: string;
|
||||
allowedFilePrefixes?: string[];
|
||||
whiteBackgroundNoteRendering?: boolean;
|
||||
}
|
||||
|
||||
export default function useMarkupToHtml(deps: HookDependencies) {
|
||||
const { themeId, customCss, plugins, whiteBackgroundNoteRendering } = deps;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { useCallback } from 'react';
|
||||
import { FormNote } from './types';
|
||||
import { FormNote, HtmlToMarkdownHandler, MarkupToHtmlHandler } from './types';
|
||||
import contextMenu from './contextMenu';
|
||||
import CommandService from '@joplin/lib/services/CommandService';
|
||||
import PostMessageService from '@joplin/lib/services/PostMessageService';
|
||||
@@ -8,7 +8,7 @@ import { reg } from '@joplin/lib/registry';
|
||||
const bridge = require('@electron/remote').require('./bridge').default;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
||||
export default function useMessageHandler(scrollWhenReady: any, setScrollWhenReady: Function, editorRef: any, setLocalSearchResultCount: Function, dispatch: Function, formNote: FormNote) {
|
||||
export default function useMessageHandler(scrollWhenReady: any, setScrollWhenReady: Function, editorRef: any, setLocalSearchResultCount: Function, dispatch: Function, formNote: FormNote, htmlToMd: HtmlToMarkdownHandler, mdToHtml: MarkupToHtmlHandler) {
|
||||
return useCallback(async (event: any) => {
|
||||
const msg = event.channel ? event.channel : '';
|
||||
const args = event.args;
|
||||
@@ -44,6 +44,8 @@ export default function useMessageHandler(scrollWhenReady: any, setScrollWhenRea
|
||||
htmlToCopy: '',
|
||||
insertContent: () => { console.warn('insertContent() not implemented'); },
|
||||
fireEditorEvent: () => { console.warn('fireEditorEvent() not implemented'); },
|
||||
htmlToMd,
|
||||
mdToHtml,
|
||||
}, dispatch);
|
||||
|
||||
menu.popup({ window: bridge().window() });
|
||||
|
@@ -76,16 +76,6 @@ const NoteList = (props: Props) => {
|
||||
props.notes,
|
||||
);
|
||||
|
||||
// const renderedNotes = useRenderedNotes(
|
||||
// startNoteIndex,
|
||||
// endNoteIndex,
|
||||
// props.notes,
|
||||
// props.selectedNoteIds,
|
||||
// listRenderer,
|
||||
// props.highlightedWords,
|
||||
// props.watchedNoteFiles,
|
||||
// );
|
||||
|
||||
const noteItemStyle = useMemo(() => {
|
||||
return {
|
||||
width: 'auto',
|
||||
|
@@ -30,3 +30,17 @@ export interface Props {
|
||||
parentFolderIsReadOnly: boolean;
|
||||
listRenderer: ListRenderer;
|
||||
}
|
||||
|
||||
export enum BaseBreakpoint {
|
||||
Sm = 75,
|
||||
Md = 80,
|
||||
Lg = 120,
|
||||
Xl = 474,
|
||||
}
|
||||
|
||||
export interface Breakpoints {
|
||||
Sm: number;
|
||||
Md: number;
|
||||
Lg: number;
|
||||
Xl: number;
|
||||
}
|
||||
|
@@ -35,6 +35,9 @@ const useScroll = (itemsPerLine: number, noteCount: number, itemSize: Size, list
|
||||
if (setScrollTopLikeYouMeanItTimer.current) shim.clearInterval(setScrollTopLikeYouMeanItTimer.current);
|
||||
setScrollTopLikeYouMeanItStartTime.current = Date.now();
|
||||
|
||||
listRef.current.scrollTop = newScrollTop;
|
||||
lastScrollSetTime.current = Date.now();
|
||||
|
||||
setScrollTopLikeYouMeanItTimer.current = shim.setInterval(() => {
|
||||
if (!listRef.current) {
|
||||
shim.clearInterval(setScrollTopLikeYouMeanItTimer.current);
|
||||
@@ -45,7 +48,7 @@ const useScroll = (itemsPerLine: number, noteCount: number, itemSize: Size, list
|
||||
listRef.current.scrollTop = newScrollTop;
|
||||
lastScrollSetTime.current = Date.now();
|
||||
|
||||
if (Date.now() - setScrollTopLikeYouMeanItStartTime.current > 500) {
|
||||
if (Date.now() - setScrollTopLikeYouMeanItStartTime.current > 1000) {
|
||||
shim.clearInterval(setScrollTopLikeYouMeanItTimer.current);
|
||||
setScrollTopLikeYouMeanItTimer.current = null;
|
||||
}
|
||||
@@ -59,9 +62,9 @@ const useScroll = (itemsPerLine: number, noteCount: number, itemSize: Size, list
|
||||
|
||||
const makeItemIndexVisible = useCallback((itemIndex: number) => {
|
||||
const lineTopFloat = scrollTop / itemSize.height;
|
||||
const topFloat = lineTopFloat * itemsPerLine; // scrollTop / itemSize.height;
|
||||
const topFloat = lineTopFloat * itemsPerLine;
|
||||
const lineBottomFloat = (scrollTop + listSize.height - itemSize.height) / itemSize.height;
|
||||
const bottomFloat = lineBottomFloat * itemsPerLine; // (scrollTop + listSize.height - itemSize.height) / itemSize.height;
|
||||
const bottomFloat = lineBottomFloat * itemsPerLine;
|
||||
const top = Math.min(noteCount - 1, Math.floor(topFloat) + 1);
|
||||
const bottom = Math.max(0, Math.floor(bottomFloat));
|
||||
|
||||
@@ -85,7 +88,7 @@ const useScroll = (itemsPerLine: number, noteCount: number, itemSize: Size, list
|
||||
|
||||
const onScroll = useCallback((event: any) => {
|
||||
// Ignore the scroll event if it has just been set programmatically.
|
||||
if (Date.now() - lastScrollSetTime.current < 100) return;
|
||||
if (Date.now() - lastScrollSetTime.current < 500) return;
|
||||
setScrollTop(event.target.scrollTop);
|
||||
}, []);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user