You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2026-01-14 00:29:38 +02:00
Compare commits
10 Commits
plugin-gen
...
user_data
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
051d628250 | ||
|
|
d8f365834b | ||
|
|
6dc6acc644 | ||
|
|
30e1164df9 | ||
|
|
a8821dfcb5 | ||
|
|
54b15a1917 | ||
|
|
e2d27275db | ||
|
|
b90cb89e0f | ||
|
|
a6516c5f14 | ||
|
|
249a744e9d |
@@ -225,7 +225,6 @@ packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useScrollHandler.j
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useScrollUtils.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/joplinCommandToTinyMceCommands.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/openEditDialog.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/setupToolbarButtons.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/types.js
|
||||
@@ -357,7 +356,6 @@ packages/app-desktop/services/sortOrder/PerFolderSortOrderService.test.js
|
||||
packages/app-desktop/services/sortOrder/notesSortOrderUtils.js
|
||||
packages/app-desktop/services/sortOrder/notesSortOrderUtils.test.js
|
||||
packages/app-desktop/services/spellChecker/SpellCheckerServiceDriverNative.js
|
||||
packages/app-desktop/tools/notarizeMacApp.js
|
||||
packages/app-desktop/utils/markupLanguageUtils.js
|
||||
packages/app-mobile/PluginAssetsLoader.js
|
||||
packages/app-mobile/components/ActionButton.js
|
||||
|
||||
2
.github/workflows/cla.yml
vendored
2
.github/workflows/cla.yml
vendored
@@ -33,5 +33,5 @@ jobs:
|
||||
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
|
||||
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
|
||||
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
|
||||
lock-pullrequest-aftermerge: false
|
||||
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
|
||||
#use-dco-flag: true - If you are using DCO instead of CLA
|
||||
|
||||
32
.github/workflows/github-actions-main.yml
vendored
32
.github/workflows/github-actions-main.yml
vendored
@@ -176,35 +176,3 @@ jobs:
|
||||
# Basic test to ensure that the created build is valid. It should exit with
|
||||
# code 0 if it works.
|
||||
docker run joplin/server:0.0.0-beta node dist/app.js migrate list
|
||||
|
||||
- name: Check HTTP request
|
||||
run: |
|
||||
# Need to pass environment variables:
|
||||
docker run -p 22300:22300 joplin/server:0.0.0-beta node dist/app.js --env dev &
|
||||
|
||||
# Wait for server to start
|
||||
sleep 10
|
||||
|
||||
# Check if status code is correct
|
||||
# if the actual_status DOES NOT include the expected_status
|
||||
# it exits the process with code 1
|
||||
|
||||
expected_status="HTTP/1.1 200 OK"
|
||||
actual_status=$(curl -I -X GET http://localhost:22300/api/ping | head -n 1)
|
||||
if [[ ! "$actual_status" =~ "$expected_status" ]]; then
|
||||
echo 'Failed while checking the status code after request to /api/ping'
|
||||
echo 'expected: ' $expected_status
|
||||
echo 'actual: ' $actual_status
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Check if the body response is correct
|
||||
# if the actual_body is different of expected_body exit with code 1
|
||||
expected_body='{"status":"ok","message":"Joplin Server is running"}'
|
||||
actual_body=$(curl http://localhost:22300/api/ping)
|
||||
|
||||
if [[ "$actual_body" != "$expected_body" ]]; then
|
||||
echo 'Failed while checking the body response after request to /api/ping'
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -210,7 +210,6 @@ packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useScrollHandler.j
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useScrollUtils.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/joplinCommandToTinyMceCommands.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/openEditDialog.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/setupToolbarButtons.js
|
||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/types.js
|
||||
@@ -342,7 +341,6 @@ packages/app-desktop/services/sortOrder/PerFolderSortOrderService.test.js
|
||||
packages/app-desktop/services/sortOrder/notesSortOrderUtils.js
|
||||
packages/app-desktop/services/sortOrder/notesSortOrderUtils.test.js
|
||||
packages/app-desktop/services/spellChecker/SpellCheckerServiceDriverNative.js
|
||||
packages/app-desktop/tools/notarizeMacApp.js
|
||||
packages/app-desktop/utils/markupLanguageUtils.js
|
||||
packages/app-mobile/PluginAssetsLoader.js
|
||||
packages/app-mobile/components/ActionButton.js
|
||||
|
||||
@@ -36,7 +36,7 @@ index 6afcbbf0cc8ca2d69dd78077d61e59a90b2136bb..9f8d72b4ec5b2b3d290975d6a255917c
|
||||
def kotlin_version = getExtOrDefault('kotlinVersion')
|
||||
|
||||
diff --git a/android/src/main/java/com/reactnativevosk/VoskModule.kt b/android/src/main/java/com/reactnativevosk/VoskModule.kt
|
||||
index 0e2b6595b1b2cf1ee01c6c64239c4b0ea37fce19..5a8539b9cce8951967640dba755e29a4e3ff404a 100644
|
||||
index 0e2b6595b1b2cf1ee01c6c64239c4b0ea37fce19..f3da440bc2863a59db6d2d1691c54d8d4870cb3f 100644
|
||||
--- a/android/src/main/java/com/reactnativevosk/VoskModule.kt
|
||||
+++ b/android/src/main/java/com/reactnativevosk/VoskModule.kt
|
||||
@@ -19,13 +19,25 @@ class VoskModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
||||
@@ -66,25 +66,7 @@ index 0e2b6595b1b2cf1ee01c6c64239c4b0ea37fce19..5a8539b9cce8951967640dba755e29a4
|
||||
sendEvent("onResult", text)
|
||||
}
|
||||
}
|
||||
@@ -93,12 +105,11 @@ class VoskModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
||||
@ReactMethod
|
||||
fun loadModel(path: String, promise: Promise) {
|
||||
cleanModel();
|
||||
- StorageService.unpack(context, path, "models",
|
||||
- { model: Model? ->
|
||||
- this.model = model
|
||||
- promise.resolve("Model successfully loaded")
|
||||
- }
|
||||
- ) { e: IOException ->
|
||||
+
|
||||
+ try {
|
||||
+ this.model = Model(path);
|
||||
+ promise.resolve("Model successfully loaded")
|
||||
+ } catch (e: IOException) {
|
||||
this.model = null
|
||||
promise.reject(e)
|
||||
}
|
||||
@@ -153,6 +164,25 @@ class VoskModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
||||
@@ -153,6 +165,25 @@ class VoskModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
||||
cleanRecognizer();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ Three types of applications are available: for **desktop** (Windows, macOS and L
|
||||
|
||||
Operating System | Download
|
||||
---|---
|
||||
Windows (32 and 64-bit) | <a href='https://objects.joplinusercontent.com/v2.11.11/Joplin-Setup-2.11.11.exe?source=JoplinWebsite&type=New'><img alt='Get it on Windows' width="134px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeWindows.png'/></a>
|
||||
macOS | <a href='https://objects.joplinusercontent.com/v2.11.11/Joplin-2.11.11.dmg?source=JoplinWebsite&type=New'><img alt='Get it on macOS' width="134px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeMacOS.png'/></a>
|
||||
Linux | <a href='https://objects.joplinusercontent.com/v2.11.11/Joplin-2.11.11.AppImage?source=JoplinWebsite&type=New'><img alt='Get it on Linux' width="134px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeLinux.png'/></a>
|
||||
Windows (32 and 64-bit) | <a href='https://objects.joplinusercontent.com/v2.10.19/Joplin-Setup-2.10.19.exe?source=JoplinWebsite&type=New'><img alt='Get it on Windows' width="134px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeWindows.png'/></a>
|
||||
macOS | <a href='https://objects.joplinusercontent.com/v2.10.19/Joplin-2.10.19.dmg?source=JoplinWebsite&type=New'><img alt='Get it on macOS' width="134px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeMacOS.png'/></a>
|
||||
Linux | <a href='https://objects.joplinusercontent.com/v2.10.19/Joplin-2.10.19.AppImage?source=JoplinWebsite&type=New'><img alt='Get it on Linux' width="134px" src='https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/WebsiteAssets/images/BadgeLinux.png'/></a>
|
||||
|
||||
**On Windows**, you may also use the <a href='https://objects.joplinusercontent.com/v2.11.11/JoplinPortable.exe?source=JoplinWebsite&type=New'>Portable version</a>. The [portable application](https://en.wikipedia.org/wiki/Portable_application) allows installing the software on a portable device such as a USB key. Simply copy the file JoplinPortable.exe in any directory on that USB key ; the application will then create a directory called "JoplinProfile" next to the executable file.
|
||||
**On Windows**, you may also use the <a href='https://objects.joplinusercontent.com/v2.10.19/JoplinPortable.exe?source=JoplinWebsite&type=New'>Portable version</a>. The [portable application](https://en.wikipedia.org/wiki/Portable_application) allows installing the software on a portable device such as a USB key. Simply copy the file JoplinPortable.exe in any directory on that USB key ; the application will then create a directory called "JoplinProfile" next to the executable file.
|
||||
|
||||
**On Linux**, the recommended way is to use the following installation script as it will handle the desktop icon too:
|
||||
|
||||
|
||||
@@ -353,43 +353,5 @@
|
||||
"web/bundles/": true,
|
||||
"web/env.php": true,
|
||||
}
|
||||
},
|
||||
"tasks": {
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "transpile-server",
|
||||
"type": "shell",
|
||||
"command": "cd ${workspaceFolder}/packages/server && yarn tsc",
|
||||
"group": "build",
|
||||
}
|
||||
]
|
||||
},
|
||||
"launch": {
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Server",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "transpile-server",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js",
|
||||
"!**/node_modules/**"
|
||||
],
|
||||
"program": "${workspaceFolder}/packages/server/src/app.ts",
|
||||
"args": [
|
||||
"--env", "dev"
|
||||
],
|
||||
"env": {
|
||||
"JOPLIN_IS_TESTING": "1",
|
||||
"TERMS_URL": "https://example.com",
|
||||
"PRIVACY_URL": "https://example.com",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
"buildSequential": "yarn workspaces foreach --verbose --interlaced --topological run build && yarn run tsc",
|
||||
"buildApiDoc": "yarn workspace joplin start apidoc ../../readme/api/references/rest_api.md",
|
||||
"buildCommandIndex": "node packages/tools/gulp/tasks/buildCommandIndexRun.js",
|
||||
"buildPluginDoc": "cd packages/generate-plugin-doc && yarn run buildPluginDoc_",
|
||||
"buildPluginDoc": "typedoc --name 'Joplin Plugin API Documentation' --mode file -theme './Assets/PluginDocTheme/' --readme './Assets/PluginDocTheme/index.md' --excludeNotExported --excludeExternals --excludePrivate --excludeProtected --out ../joplin-website/docs/api/references/plugin_api packages/lib/services/plugins/api/",
|
||||
"updateMarkdownDoc": "node ./packages/tools/updateMarkdownDoc",
|
||||
"updateNews": "node ./packages/tools/website/updateNews",
|
||||
"buildSettingJsonSchema": "yarn workspace joplin start settingschema ../../../joplin-website/docs/schema/settings.json",
|
||||
@@ -84,6 +84,7 @@
|
||||
"lint-staged": "13.2.2",
|
||||
"madge": "6.0.0",
|
||||
"npm-package-json-lint": "6.4.0",
|
||||
"typedoc": "0.17.8",
|
||||
"typescript": "5.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
],
|
||||
"owner": "Laurent Cozic"
|
||||
},
|
||||
"version": "2.11.1",
|
||||
"version": "2.11.0",
|
||||
"bin": "./main.js",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<a data-from-md title='<style>' href='&#x22&#x2c&#x22&#x61&#x22&#x29&#x3b&#x74&#x6f&#x70&#x2e&#x72&#x65&#x71&#x75&#x69&#x72&#x65&#x28&#x27&#x63&#x68&#x69&#x6c&#x64&#x5f&#x70&#x72&#x6f&#x63&#x65&#x73&#x73&#x27&#x29&#x2e&#x65&#x78&#x65&#x63&#x28&#x27&#x6f&#x70&#x65&#x6e&#x20&#x2f&#x53&#x79&#x73&#x74&#x65&#x6d&#x2f&#x41&#x70&#x70&#x6c&#x69&#x63&#x61&#x74&#x69&#x6f&#x6e&#x73&#x2f&#x43&#x61&#x6c&#x63&#x75&#x6c&#x61&#x74&#x6f&#x72&#x2e&#x61&#x70&#x70&#x27&#x29&#x3b&#x2f&#x2f' onclick='postMessage("&#x22&#x2c&#x22&#x61&#x22&#x29&#x3b&#x74&#x6f&#x70&#x2e&#x72&#x65&#x71&#x75&#x69&#x72&#x65&#x28&#x27&#x63&#x68&#x69&#x6c&#x64&#x5f&#x70&#x72&#x6f&#x63&#x65&#x73&#x73&#x27&#x29&#x2e&#x65&#x78&#x65&#x63&#x28&#x27&#x6f&#x70&#x65&#x6e&#x20&#x2f&#x53&#x79&#x73&#x74&#x65&#x6d&#x2f&#x41&#x70&#x70&#x6c&#x69&#x63&#x61&#x74&#x69&#x6f&#x6e&#x73&#x2f&#x43&#x61&#x6c&#x63&#x75&#x6c&#x61&#x74&#x6f&#x72&#x2e&#x61&#x70&#x70&#x27&#x29&#x3b&#x2f&#x2f", { resourceId: "" }); return false;'>xxxxx</a>
|
||||
@@ -1 +0,0 @@
|
||||
[xxxxx](","a");top.require('child_process').exec('open /System/Applications/Calculator.app');// '<style>')
|
||||
@@ -34,7 +34,7 @@ import ShareFolderDialog from '../ShareFolderDialog/ShareFolderDialog';
|
||||
import { ShareInvitation } from '@joplin/lib/services/share/reducer';
|
||||
import removeKeylessItems from '../ResizableLayout/utils/removeKeylessItems';
|
||||
import { localSyncInfoFromState } from '@joplin/lib/services/synchronizer/syncInfoUtils';
|
||||
import { isCallbackUrl, parseCallbackUrl } from '@joplin/lib/callbackUrlUtils';
|
||||
import { parseCallbackUrl } from '@joplin/lib/callbackUrlUtils';
|
||||
import ElectronAppWrapper from '../../ElectronAppWrapper';
|
||||
import { showMissingMasterKeyMessage } from '@joplin/lib/services/e2ee/utils';
|
||||
import { MasterKeyEntity } from '@joplin/lib/services/e2ee/types';
|
||||
@@ -173,7 +173,6 @@ class MainScreenComponent extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
private openCallbackUrl(url: string) {
|
||||
if (!isCallbackUrl(url)) throw new Error(`Invalid callback URL: ${url}`);
|
||||
const { command, params } = parseCallbackUrl(url);
|
||||
void CommandService.instance().execute(command.toString(), params.id);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import { loadScript } from '../../../utils/loadScript';
|
||||
import bridge from '../../../../services/bridge';
|
||||
import { TinyMceEditorEvents } from './utils/types';
|
||||
import type { Editor } from 'tinymce';
|
||||
import { joplinCommandToTinyMceCommands, TinyMceCommand } from './utils/joplinCommandToTinyMceCommands';
|
||||
const { clipboard } = require('electron');
|
||||
const supportedLocales = require('./supportedLocales');
|
||||
|
||||
@@ -79,6 +78,23 @@ function stripMarkup(markupLanguage: number, markup: string, options: any = null
|
||||
return markupToHtml_.stripMarkup(markupLanguage, markup, options);
|
||||
}
|
||||
|
||||
interface TinyMceCommand {
|
||||
name: string;
|
||||
value?: any;
|
||||
ui?: boolean;
|
||||
}
|
||||
|
||||
interface JoplinCommandToTinyMceCommands {
|
||||
[key: string]: TinyMceCommand;
|
||||
}
|
||||
|
||||
const joplinCommandToTinyMceCommands: JoplinCommandToTinyMceCommands = {
|
||||
'textBold': { name: 'mceToggleFormat', value: 'bold' },
|
||||
'textItalic': { name: 'mceToggleFormat', value: 'italic' },
|
||||
'textLink': { name: 'mceLink' },
|
||||
'search': { name: 'SearchReplace' },
|
||||
};
|
||||
|
||||
interface LastOnChangeEventInfo {
|
||||
content: string;
|
||||
resourceInfos: ResourceInfos;
|
||||
@@ -258,17 +274,11 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (joplinCommandToTinyMceCommands[cmd.name] === true) {
|
||||
// Already handled in useWindowCommandHandlers.ts
|
||||
} else if (joplinCommandToTinyMceCommands[cmd.name] === false) {
|
||||
// Explicitely not supported
|
||||
} else {
|
||||
const tinyMceCmd: TinyMceCommand = { ...(joplinCommandToTinyMceCommands[cmd.name] as TinyMceCommand) };
|
||||
if (!('ui' in tinyMceCmd)) tinyMceCmd.ui = false;
|
||||
if (!('value' in tinyMceCmd)) tinyMceCmd.value = null;
|
||||
const tinyMceCmd: TinyMceCommand = { ...joplinCommandToTinyMceCommands[cmd.name] };
|
||||
if (!('ui' in tinyMceCmd)) tinyMceCmd.ui = false;
|
||||
if (!('value' in tinyMceCmd)) tinyMceCmd.value = null;
|
||||
|
||||
editor.execCommand(tinyMceCmd.name, tinyMceCmd.ui, tinyMceCmd.value);
|
||||
}
|
||||
editor.execCommand(tinyMceCmd.name, tinyMceCmd.ui, tinyMceCmd.value);
|
||||
|
||||
return true;
|
||||
},
|
||||
@@ -593,15 +603,11 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
joplinSup: { inline: 'sup', remove: 'all' },
|
||||
},
|
||||
setup: (editor: Editor) => {
|
||||
editor.addCommand('joplinAttach', () => {
|
||||
insertResourcesIntoContentRef.current();
|
||||
});
|
||||
|
||||
editor.ui.registry.addButton('joplinAttach', {
|
||||
tooltip: _('Attach file'),
|
||||
icon: 'paperclip',
|
||||
onAction: async function() {
|
||||
editor.execCommand('joplinAttach');
|
||||
insertResourcesIntoContentRef.current();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1106,12 +1112,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
}
|
||||
|
||||
function onPasteAsText() {
|
||||
// clipboard.readText returns Markdown instead of text when copying content from
|
||||
// the Rich Text Editor. When the user "Paste as text" he does not expect to see
|
||||
// anything besides text, that is why we are stripping here before pasting
|
||||
// https://github.com/laurent22/joplin/pull/8351
|
||||
const clipboardWithoutMarkdown = stripMarkup(MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN, clipboard.readText());
|
||||
pasteAsPlainText(clipboardWithoutMarkdown);
|
||||
pasteAsPlainText(null);
|
||||
}
|
||||
|
||||
editor.on(TinyMceEditorEvents.KeyUp, onKeyUp);
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
export interface TinyMceCommand {
|
||||
name: string;
|
||||
value?: any;
|
||||
ui?: boolean;
|
||||
}
|
||||
|
||||
interface JoplinCommandToTinyMceCommands {
|
||||
[key: string]: TinyMceCommand | boolean;
|
||||
}
|
||||
|
||||
// If the mapping is simply `true` it means that the command is supported via
|
||||
// useWindowCommandHandlers.ts. We still add it here to have the complete list
|
||||
// of supported commands.
|
||||
export const joplinCommandToTinyMceCommands: JoplinCommandToTinyMceCommands = {
|
||||
'textBold': { name: 'mceToggleFormat', value: 'bold' },
|
||||
'textItalic': { name: 'mceToggleFormat', value: 'italic' },
|
||||
'textCode': { name: 'mceToggleFormat', value: 'code' },
|
||||
'textLink': { name: 'mceLink' },
|
||||
'search': { name: 'SearchReplace' },
|
||||
'attachFile': { name: 'joplinAttach' },
|
||||
'insertDateTime': true,
|
||||
};
|
||||
@@ -4,7 +4,6 @@ import editorCommandDeclarations from '../editorCommandDeclarations';
|
||||
import CommandService, { CommandDeclaration, CommandRuntime, CommandContext } from '@joplin/lib/services/CommandService';
|
||||
import time from '@joplin/lib/time';
|
||||
import { reg } from '@joplin/lib/registry';
|
||||
import { joplinCommandToTinyMceCommands } from '../NoteBody/TinyMCE/utils/joplinCommandToTinyMceCommands';
|
||||
|
||||
const commandsWithDependencies = [
|
||||
require('../commands/showLocalSearch'),
|
||||
@@ -25,8 +24,6 @@ interface HookDependencies {
|
||||
}
|
||||
|
||||
function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any, setFormNote: Function): CommandRuntime {
|
||||
const markdownEditorOnly = !Object.keys(joplinCommandToTinyMceCommands).includes(declaration.name);
|
||||
|
||||
return {
|
||||
execute: async (_context: CommandContext, ...args: any[]) => {
|
||||
if (!editorRef.current) {
|
||||
@@ -68,7 +65,7 @@ function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any, s
|
||||
// currently selected text.
|
||||
//
|
||||
// https://github.com/laurent22/joplin/issues/5707
|
||||
enabledCondition: `(!modalDialogVisible || gotoAnythingVisible) ${markdownEditorOnly ? '&& markdownEditorPaneVisible' : ''} && oneNoteSelected && noteIsMarkdown`,
|
||||
enabledCondition: '(!modalDialogVisible || gotoAnythingVisible) && markdownEditorPaneVisible && oneNoteSelected && noteIsMarkdown',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/app-desktop",
|
||||
"version": "2.11.11",
|
||||
"version": "2.11.9",
|
||||
"description": "Joplin for Desktop",
|
||||
"main": "main.js",
|
||||
"private": true,
|
||||
@@ -117,6 +117,7 @@
|
||||
"@types/styled-components": "5.1.26",
|
||||
"electron": "19.1.4",
|
||||
"electron-builder": "22.11.7",
|
||||
"electron-notarize": "1.2.2",
|
||||
"electron-rebuild": "3.2.9",
|
||||
"glob": "8.1.0",
|
||||
"gulp": "4.0.2",
|
||||
@@ -133,8 +134,7 @@
|
||||
"7zip-bin-win": "^2.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/notarize": "1.2.4",
|
||||
"@electron/remote": "2.0.10",
|
||||
"@electron/remote": "2.0.9",
|
||||
"@fortawesome/fontawesome-free": "5.15.4",
|
||||
"@joeattardi/emoji-button": "4.6.4",
|
||||
"@joplin/lib": "~2.11",
|
||||
@@ -162,7 +162,7 @@
|
||||
"react": "18.2.0",
|
||||
"react-datetime": "3.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-redux": "8.0.7",
|
||||
"react-redux": "8.0.5",
|
||||
"react-select": "5.7.3",
|
||||
"react-toggle-button": "2.2.0",
|
||||
"react-tooltip": "4.5.1",
|
||||
@@ -171,7 +171,7 @@
|
||||
"roboto-fontface": "0.10.0",
|
||||
"smalltalk": "2.5.1",
|
||||
"sqlite3": "5.1.6",
|
||||
"styled-components": "5.3.11",
|
||||
"styled-components": "5.3.10",
|
||||
"styled-system": "5.1.5",
|
||||
"taboverride": "4.0.3",
|
||||
"tinymce": "5.10.6"
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
import { existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { notarize } from '@electron/notarize';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const electron_notarize = require('electron-notarize');
|
||||
const execCommand = require('./execCommand');
|
||||
|
||||
function isDesktopAppTag(tagName: string) {
|
||||
function isDesktopAppTag(tagName) {
|
||||
if (!tagName) return false;
|
||||
return tagName[0] === 'v';
|
||||
}
|
||||
|
||||
interface Params {
|
||||
appOutDir: string;
|
||||
packager: {
|
||||
appInfo: {
|
||||
productFilename: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export default async (params: Params) => {
|
||||
module.exports = async function(params) {
|
||||
if (process.platform !== 'darwin') return;
|
||||
|
||||
console.info('Checking if notarization should be done...');
|
||||
@@ -35,8 +26,8 @@ export default async (params: Params) => {
|
||||
// Same appId in electron-builder.
|
||||
const appId = 'net.cozic.joplin-desktop';
|
||||
|
||||
const appPath = join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`);
|
||||
if (!existsSync(appPath)) {
|
||||
const appPath = path.join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`);
|
||||
if (!fs.existsSync(appPath)) {
|
||||
throw new Error(`Cannot find application at: ${appPath}`);
|
||||
}
|
||||
|
||||
@@ -49,7 +40,7 @@ export default async (params: Params) => {
|
||||
}, 60000);
|
||||
|
||||
try {
|
||||
await notarize({
|
||||
await electron_notarize.notarize({
|
||||
appBundleId: appId,
|
||||
appPath: appPath,
|
||||
|
||||
@@ -67,12 +58,7 @@ export default async (params: Params) => {
|
||||
// Use this to get it:
|
||||
//
|
||||
// xcrun altool --list-providers -u APPLE_ID -p APPLE_ID_PASSWORD
|
||||
// ascProvider: process.env.APPLE_ASC_PROVIDER,
|
||||
|
||||
// In our case, the team ID is the same as the legacy ASC_PROVIDER
|
||||
teamId: process.env.APPLE_ASC_PROVIDER,
|
||||
|
||||
tool: 'notarytool',
|
||||
ascProvider: process.env.APPLE_ASC_PROVIDER,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -110,8 +110,8 @@ android {
|
||||
applicationId "net.cozic.joplin"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 2097716
|
||||
versionName "2.11.31"
|
||||
versionCode 2097712
|
||||
versionName "2.11.27"
|
||||
// ndk {
|
||||
// abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
|
||||
// }
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
French small model for Vosk
|
||||
|
||||
WER
|
||||
|
||||
%WER 23.95 [ 37203 / 155330, 5373 ins, 4427 del, 27403 sub ] exp/chain_a/tdnn/decode_test_cv/wer_12_0.0
|
||||
%WER 19.30 [ 2975 / 15412, 683 ins, 672 del, 1620 sub ] exp/chain_a/tdnn/decode_test_mtedx/wer_10_0.0
|
||||
%WER 27.25 [ 20208 / 74145, 2647 ins, 5852 del, 11709 sub ] exp/chain_a/tdnn/decode_test_podcast_reseg/wer_10_0.0
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
--use-energy=false
|
||||
--sample-frequency=16000
|
||||
--num-mel-bins=40
|
||||
--num-ceps=40
|
||||
--low-freq=40
|
||||
--high-freq=-200
|
||||
--allow-upsample=true
|
||||
--allow-downsample=true
|
||||
@@ -0,0 +1,10 @@
|
||||
--min-active=200
|
||||
--max-active=7000
|
||||
--beam=13.0
|
||||
--lattice-beam=4.0
|
||||
--acoustic-scale=1.0
|
||||
--frame-subsampling-factor=3
|
||||
--endpoint.silence-phones=1:2:3:4:5:6:7:8:9:10
|
||||
--endpoint.rule2.min-trailing-silence=0.5
|
||||
--endpoint.rule3.min-trailing-silence=1.0
|
||||
--endpoint.rule4.min-trailing-silence=2.0
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,76 @@
|
||||
9365
|
||||
9366
|
||||
9367
|
||||
9368
|
||||
9369
|
||||
9370
|
||||
9371
|
||||
9372
|
||||
9373
|
||||
9374
|
||||
9375
|
||||
9376
|
||||
9377
|
||||
9378
|
||||
9379
|
||||
9380
|
||||
9381
|
||||
9382
|
||||
9383
|
||||
9384
|
||||
9385
|
||||
9386
|
||||
9387
|
||||
9388
|
||||
9389
|
||||
9390
|
||||
9391
|
||||
9392
|
||||
9393
|
||||
9394
|
||||
9395
|
||||
9396
|
||||
9397
|
||||
9398
|
||||
9399
|
||||
9400
|
||||
9401
|
||||
9402
|
||||
9403
|
||||
9404
|
||||
9405
|
||||
9406
|
||||
9407
|
||||
9408
|
||||
9409
|
||||
9410
|
||||
9411
|
||||
9412
|
||||
9413
|
||||
9414
|
||||
9415
|
||||
9416
|
||||
9417
|
||||
9418
|
||||
9419
|
||||
9420
|
||||
9421
|
||||
9422
|
||||
9423
|
||||
9424
|
||||
9425
|
||||
9426
|
||||
9427
|
||||
9428
|
||||
9429
|
||||
9430
|
||||
9431
|
||||
9432
|
||||
9433
|
||||
9434
|
||||
9435
|
||||
9436
|
||||
9437
|
||||
9438
|
||||
9439
|
||||
9440
|
||||
@@ -0,0 +1,154 @@
|
||||
1 nonword
|
||||
2 begin
|
||||
3 end
|
||||
4 internal
|
||||
5 singleton
|
||||
6 nonword
|
||||
7 begin
|
||||
8 end
|
||||
9 internal
|
||||
10 singleton
|
||||
11 begin
|
||||
12 end
|
||||
13 internal
|
||||
14 singleton
|
||||
15 begin
|
||||
16 end
|
||||
17 internal
|
||||
18 singleton
|
||||
19 begin
|
||||
20 end
|
||||
21 internal
|
||||
22 singleton
|
||||
23 begin
|
||||
24 end
|
||||
25 internal
|
||||
26 singleton
|
||||
27 begin
|
||||
28 end
|
||||
29 internal
|
||||
30 singleton
|
||||
31 begin
|
||||
32 end
|
||||
33 internal
|
||||
34 singleton
|
||||
35 begin
|
||||
36 end
|
||||
37 internal
|
||||
38 singleton
|
||||
39 begin
|
||||
40 end
|
||||
41 internal
|
||||
42 singleton
|
||||
43 begin
|
||||
44 end
|
||||
45 internal
|
||||
46 singleton
|
||||
47 begin
|
||||
48 end
|
||||
49 internal
|
||||
50 singleton
|
||||
51 begin
|
||||
52 end
|
||||
53 internal
|
||||
54 singleton
|
||||
55 begin
|
||||
56 end
|
||||
57 internal
|
||||
58 singleton
|
||||
59 begin
|
||||
60 end
|
||||
61 internal
|
||||
62 singleton
|
||||
63 begin
|
||||
64 end
|
||||
65 internal
|
||||
66 singleton
|
||||
67 begin
|
||||
68 end
|
||||
69 internal
|
||||
70 singleton
|
||||
71 begin
|
||||
72 end
|
||||
73 internal
|
||||
74 singleton
|
||||
75 begin
|
||||
76 end
|
||||
77 internal
|
||||
78 singleton
|
||||
79 begin
|
||||
80 end
|
||||
81 internal
|
||||
82 singleton
|
||||
83 begin
|
||||
84 end
|
||||
85 internal
|
||||
86 singleton
|
||||
87 begin
|
||||
88 end
|
||||
89 internal
|
||||
90 singleton
|
||||
91 begin
|
||||
92 end
|
||||
93 internal
|
||||
94 singleton
|
||||
95 begin
|
||||
96 end
|
||||
97 internal
|
||||
98 singleton
|
||||
99 begin
|
||||
100 end
|
||||
101 internal
|
||||
102 singleton
|
||||
103 begin
|
||||
104 end
|
||||
105 internal
|
||||
106 singleton
|
||||
107 begin
|
||||
108 end
|
||||
109 internal
|
||||
110 singleton
|
||||
111 begin
|
||||
112 end
|
||||
113 internal
|
||||
114 singleton
|
||||
115 begin
|
||||
116 end
|
||||
117 internal
|
||||
118 singleton
|
||||
119 begin
|
||||
120 end
|
||||
121 internal
|
||||
122 singleton
|
||||
123 begin
|
||||
124 end
|
||||
125 internal
|
||||
126 singleton
|
||||
127 begin
|
||||
128 end
|
||||
129 internal
|
||||
130 singleton
|
||||
131 begin
|
||||
132 end
|
||||
133 internal
|
||||
134 singleton
|
||||
135 begin
|
||||
136 end
|
||||
137 internal
|
||||
138 singleton
|
||||
139 begin
|
||||
140 end
|
||||
141 internal
|
||||
142 singleton
|
||||
143 begin
|
||||
144 end
|
||||
145 internal
|
||||
146 singleton
|
||||
147 begin
|
||||
148 end
|
||||
149 internal
|
||||
150 singleton
|
||||
151 begin
|
||||
152 end
|
||||
153 internal
|
||||
154 singleton
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
[
|
||||
1.022245e+11 -6.33291e+09 -2.480997e+09 8.290258e+09 -9.084483e+09 -8.092173e+09 -1.4735e+10 -7.041795e+09 -1.171205e+10 -2.976464e+08 -1.009425e+10 -6765179 -7.821326e+09 1.449499e+09 -6.413975e+09 -5.303802e+08 -4.998635e+09 9.521598e+07 -3.073041e+09 1.56756e+08 -1.287956e+09 1.738752e+08 -2.382392e+08 -2.716675e+07 4.404485e+08 -1.913359e+08 7.780919e+08 -4.006922e+08 7.895809e+08 -5.401082e+08 5.17605e+08 -6.227134e+08 6.58271e+08 -6.204593e+07 5.187754e+08 -4.497048e+08 4.219366e+07 -2.78742e+08 -1.797385e+07 -3.604475e+07 1.053647e+09
|
||||
1.040194e+13 6.245521e+11 4.223293e+11 6.831219e+11 6.078478e+11 6.3425e+11 7.943839e+11 6.013323e+11 6.781652e+11 5.272091e+11 5.810814e+11 4.353831e+11 4.473305e+11 3.42063e+11 3.083377e+11 2.14257e+11 1.892057e+11 1.163827e+11 8.367058e+10 4.203224e+10 2.297476e+10 7.596307e+09 1.099877e+09 2.886651e+08 3.797438e+09 9.372847e+09 1.629059e+10 2.196351e+10 2.747149e+10 3.072878e+10 3.238528e+10 3.330232e+10 3.407238e+10 3.230687e+10 2.676914e+10 2.252055e+10 1.914305e+10 1.565974e+10 1.224627e+10 8.415393e+09 0 ]
|
||||
@@ -0,0 +1,2 @@
|
||||
--left-context=3
|
||||
--right-context=3
|
||||
@@ -0,0 +1 @@
|
||||
1b7180e6-e500-4818-adc8-a41fe97a84ce
|
||||
@@ -46,7 +46,6 @@ import { NoteEntity } from '@joplin/lib/services/database/types';
|
||||
import Logger from '@joplin/lib/Logger';
|
||||
import VoiceTypingDialog from '../voiceTyping/VoiceTypingDialog';
|
||||
import { voskEnabled } from '../../services/voiceTyping/vosk';
|
||||
import { isSupportedLanguage } from '../../services/voiceTyping/vosk.android';
|
||||
const urlUtils = require('@joplin/lib/urlUtils');
|
||||
|
||||
// import Vosk from 'react-native-vosk';
|
||||
@@ -1001,7 +1000,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
});
|
||||
|
||||
// Voice typing is enabled only for French language and on Android for now
|
||||
if (voskEnabled && shim.mobilePlatform() === 'android' && isSupportedLanguage(currentLocale())) {
|
||||
if (voskEnabled && shim.mobilePlatform() === 'android' && currentLocale() === 'fr_FR') {
|
||||
output.push({
|
||||
title: _('Voice typing...'),
|
||||
onPress: () => {
|
||||
@@ -1308,7 +1307,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
const renderVoiceTypingDialog = () => {
|
||||
if (!this.state.voiceTypingDialogShown) return null;
|
||||
return <VoiceTypingDialog locale={currentLocale()} onText={this.voiceTypingDialog_onText} onDismiss={this.voiceTypingDialog_onDismiss}/>;
|
||||
return <VoiceTypingDialog onText={this.voiceTypingDialog_onText} onDismiss={this.voiceTypingDialog_onDismiss}/>;
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { Banner, ActivityIndicator, Modal } from 'react-native-paper';
|
||||
import { _, languageName } from '@joplin/lib/locale';
|
||||
import { Banner, ActivityIndicator } from 'react-native-paper';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import useAsyncEffect, { AsyncEffectEvent } from '@joplin/lib/hooks/useAsyncEffect';
|
||||
import { getVosk, Recorder, startRecording, Vosk } from '../../services/voiceTyping/vosk';
|
||||
import { IconSource } from 'react-native-paper/lib/typescript/src/components/Icon';
|
||||
import { modelIsDownloaded } from '../../services/voiceTyping/vosk.android';
|
||||
|
||||
interface Props {
|
||||
locale: string;
|
||||
onDismiss: ()=> void;
|
||||
onText: (text: string)=> void;
|
||||
}
|
||||
@@ -18,39 +16,30 @@ enum RecorderState {
|
||||
Recording = 2,
|
||||
Processing = 3,
|
||||
Error = 4,
|
||||
Downloading = 5,
|
||||
}
|
||||
|
||||
const useVosk = (locale: string): [Error | null, boolean, Vosk|null] => {
|
||||
const useVosk = (): [Error | null, Vosk|null] => {
|
||||
const [vosk, setVosk] = useState<Vosk>(null);
|
||||
const [error, setError] = useState<Error>(null);
|
||||
const [mustDownloadModel, setMustDownloadModel] = useState<boolean | null>(null);
|
||||
|
||||
useAsyncEffect(async (event: AsyncEffectEvent) => {
|
||||
if (mustDownloadModel === null) return;
|
||||
|
||||
try {
|
||||
const v = await getVosk(locale);
|
||||
const v = await getVosk();
|
||||
if (event.cancelled) return;
|
||||
setVosk(v);
|
||||
} catch (error) {
|
||||
setError(error);
|
||||
} finally {
|
||||
setMustDownloadModel(false);
|
||||
}
|
||||
}, [locale, mustDownloadModel]);
|
||||
}, []);
|
||||
|
||||
useAsyncEffect(async (_event: AsyncEffectEvent) => {
|
||||
setMustDownloadModel(!(await modelIsDownloaded(locale)));
|
||||
}, [locale]);
|
||||
|
||||
return [error, mustDownloadModel, vosk];
|
||||
return [error, vosk];
|
||||
};
|
||||
|
||||
export default (props: Props) => {
|
||||
const [recorder, setRecorder] = useState<Recorder>(null);
|
||||
const [recorderState, setRecorderState] = useState<RecorderState>(RecorderState.Loading);
|
||||
const [voskError, mustDownloadModel, vosk] = useVosk(props.locale);
|
||||
|
||||
const [voskError, vosk] = useVosk();
|
||||
|
||||
useEffect(() => {
|
||||
if (voskError) {
|
||||
@@ -60,12 +49,6 @@ export default (props: Props) => {
|
||||
}
|
||||
}, [vosk, voskError]);
|
||||
|
||||
useEffect(() => {
|
||||
if (mustDownloadModel) {
|
||||
setRecorderState(RecorderState.Downloading);
|
||||
}
|
||||
}, [mustDownloadModel]);
|
||||
|
||||
useEffect(() => {
|
||||
if (recorderState === RecorderState.Recording) {
|
||||
setRecorder(startRecording(vosk, {
|
||||
@@ -77,7 +60,7 @@ export default (props: Props) => {
|
||||
}, [recorderState, vosk, props.onText]);
|
||||
|
||||
const onDismiss = useCallback(() => {
|
||||
if (recorder) recorder.cleanup();
|
||||
recorder.cleanup();
|
||||
props.onDismiss();
|
||||
}, [recorder, props.onDismiss]);
|
||||
|
||||
@@ -86,7 +69,6 @@ export default (props: Props) => {
|
||||
[RecorderState.Loading]: () => _('Loading...'),
|
||||
[RecorderState.Recording]: () => _('Please record your voice...'),
|
||||
[RecorderState.Processing]: () => _('Converting speech to text...'),
|
||||
[RecorderState.Downloading]: () => _('Downloading %s language files...', languageName(props.locale)),
|
||||
[RecorderState.Error]: () => _('Error: %s', voskError.message),
|
||||
};
|
||||
|
||||
@@ -98,7 +80,6 @@ export default (props: Props) => {
|
||||
[RecorderState.Loading]: ({ size }: { size: number }) => <ActivityIndicator animating={true} style={{ width: size, height: size }} />,
|
||||
[RecorderState.Recording]: 'microphone',
|
||||
[RecorderState.Processing]: 'microphone',
|
||||
[RecorderState.Downloading]: ({ size }: { size: number }) => <ActivityIndicator animating={true} style={{ width: size, height: size }} />,
|
||||
[RecorderState.Error]: 'alert-circle-outline',
|
||||
};
|
||||
|
||||
@@ -106,18 +87,16 @@ export default (props: Props) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal visible={true} style={{ display: 'flex', flexDirection: 'column', justifyContent: 'flex-end' }}>
|
||||
<Banner
|
||||
visible={true}
|
||||
icon={renderIcon()}
|
||||
actions={[
|
||||
{
|
||||
label: _('Done'),
|
||||
onPress: onDismiss,
|
||||
},
|
||||
]}>
|
||||
{`${_('Voice typing...')}\n${renderContent()}`}
|
||||
</Banner>
|
||||
</Modal>
|
||||
<Banner
|
||||
visible={true}
|
||||
icon={renderIcon()}
|
||||
actions={[
|
||||
{
|
||||
label: _('Done'),
|
||||
onPress: onDismiss,
|
||||
},
|
||||
]}>
|
||||
{`${_('Voice typing...')}\n${renderContent()}`}
|
||||
</Banner>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -517,13 +517,13 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Joplin/Joplin.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 94;
|
||||
CURRENT_PROJECT_VERSION = 92;
|
||||
DEVELOPMENT_TEAM = A9BXAFS6CT;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Joplin/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MARKETING_VERSION = 12.11.5;
|
||||
MARKETING_VERSION = 12.11.3;
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
"-ObjC",
|
||||
@@ -546,12 +546,12 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Joplin/Joplin.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 94;
|
||||
CURRENT_PROJECT_VERSION = 92;
|
||||
DEVELOPMENT_TEAM = A9BXAFS6CT;
|
||||
INFOPLIST_FILE = Joplin/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MARKETING_VERSION = 12.11.5;
|
||||
MARKETING_VERSION = 12.11.3;
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
"-ObjC",
|
||||
@@ -698,14 +698,14 @@
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 94;
|
||||
CURRENT_PROJECT_VERSION = 92;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEVELOPMENT_TEAM = A9BXAFS6CT;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
INFOPLIST_FILE = ShareExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 12.11.5;
|
||||
MARKETING_VERSION = 12.11.3;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.cozic.joplin.ShareExtension;
|
||||
@@ -729,14 +729,14 @@
|
||||
CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 94;
|
||||
CURRENT_PROJECT_VERSION = 92;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEVELOPMENT_TEAM = A9BXAFS6CT;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
INFOPLIST_FILE = ShareExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
MARKETING_VERSION = 12.11.5;
|
||||
MARKETING_VERSION = 12.11.3;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.cozic.joplin.ShareExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
||||
@@ -347,7 +347,7 @@ PODS:
|
||||
- React-Core
|
||||
- react-native-fingerprint-scanner (6.0.0):
|
||||
- React
|
||||
- react-native-geolocation (3.0.6):
|
||||
- react-native-geolocation (2.1.0):
|
||||
- React-Core
|
||||
- react-native-get-random-values (1.8.0):
|
||||
- React-Core
|
||||
@@ -465,7 +465,7 @@ PODS:
|
||||
- React-Core
|
||||
- RNCPushNotificationIOS (1.11.0):
|
||||
- React-Core
|
||||
- RNDateTimePicker (7.1.0):
|
||||
- RNDateTimePicker (7.0.1):
|
||||
- React-Core
|
||||
- RNExitApp (1.1.0):
|
||||
- React
|
||||
@@ -483,15 +483,7 @@ PODS:
|
||||
- React-Core
|
||||
- RNVectorIcons (9.2.0):
|
||||
- React-Core
|
||||
- RNZipArchive (6.0.9):
|
||||
- React-Core
|
||||
- RNZipArchive/Core (= 6.0.9)
|
||||
- SSZipArchive (~> 2.2)
|
||||
- RNZipArchive/Core (6.0.9):
|
||||
- React-Core
|
||||
- SSZipArchive (~> 2.2)
|
||||
- SocketRocket (0.6.0)
|
||||
- SSZipArchive (2.4.3)
|
||||
- Yoga (1.14.0)
|
||||
- YogaKit (1.18.1):
|
||||
- Yoga (~> 1.14)
|
||||
@@ -585,7 +577,6 @@ DEPENDENCIES:
|
||||
- RNSecureRandom (from `../node_modules/react-native-securerandom`)
|
||||
- RNShare (from `../node_modules/react-native-share`)
|
||||
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
|
||||
- RNZipArchive (from `../node_modules/react-native-zip-archive`)
|
||||
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
|
||||
|
||||
SPEC REPOS:
|
||||
@@ -604,7 +595,6 @@ SPEC REPOS:
|
||||
- libevent
|
||||
- OpenSSL-Universal
|
||||
- SocketRocket
|
||||
- SSZipArchive
|
||||
- YogaKit
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
@@ -734,8 +724,6 @@ EXTERNAL SOURCES:
|
||||
:path: "../node_modules/react-native-share"
|
||||
RNVectorIcons:
|
||||
:path: "../node_modules/react-native-vector-icons"
|
||||
RNZipArchive:
|
||||
:path: "../node_modules/react-native-zip-archive"
|
||||
Yoga:
|
||||
:path: "../node_modules/react-native/ReactCommon/yoga"
|
||||
|
||||
@@ -779,7 +767,7 @@ SPEC CHECKSUMS:
|
||||
react-native-camera: 3eae183c1d111103963f3dd913b65d01aef8110f
|
||||
react-native-document-picker: 69ca2094d8780cfc1e7e613894d15290fdc54bba
|
||||
react-native-fingerprint-scanner: ac6656f18c8e45a7459302b84da41a44ad96dbbe
|
||||
react-native-geolocation: 0f7fe8a4c2de477e278b0365cce27d089a8c5903
|
||||
react-native-geolocation: 69f4fd37650b8e7fee91816d395e62dd16f5ab8d
|
||||
react-native-get-random-values: a6ea6a8a65dc93e96e24a11105b1a9c8cfe1d72a
|
||||
react-native-image-picker: ec9b713e248760bfa0f879f0715391de4651a7cb
|
||||
react-native-image-resizer: d9fb629a867335bdc13230ac2a58702bb8c8828f
|
||||
@@ -807,7 +795,7 @@ SPEC CHECKSUMS:
|
||||
rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba
|
||||
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
|
||||
RNCPushNotificationIOS: 64218f3c776c03d7408284a819b2abfda1834bc8
|
||||
RNDateTimePicker: 7ecd54a97fc3749f38c3c89a171f6cbd52f3c142
|
||||
RNDateTimePicker: e073697ac3e8a378968d68ab0581fef542b8af8a
|
||||
RNExitApp: c4e052df2568b43bec8a37c7cd61194d4cfee2c3
|
||||
RNFileViewer: ce7ca3ac370e18554d35d6355cffd7c30437c592
|
||||
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
|
||||
@@ -816,9 +804,7 @@ SPEC CHECKSUMS:
|
||||
RNSecureRandom: 07efbdf2cd99efe13497433668e54acd7df49fef
|
||||
RNShare: d82e10f6b7677f4b0048c23709bd04098d5aee6c
|
||||
RNVectorIcons: fcc2f6cb32f5735b586e66d14103a74ce6ad61f8
|
||||
RNZipArchive: 68a0c6db4b1c103f846f1559622050df254a3ade
|
||||
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
|
||||
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
|
||||
Yoga: e7ea9e590e27460d28911403b894722354d73479
|
||||
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
"@joplin/react-native-saf-x": "~2.11",
|
||||
"@joplin/renderer": "~2.11",
|
||||
"@react-native-community/clipboard": "1.5.1",
|
||||
"@react-native-community/datetimepicker": "7.1.0",
|
||||
"@react-native-community/geolocation": "3.0.6",
|
||||
"@react-native-community/datetimepicker": "7.0.1",
|
||||
"@react-native-community/geolocation": "2.1.0",
|
||||
"@react-native-community/netinfo": "9.3.10",
|
||||
"@react-native-community/push-notification-ios": "1.11.0",
|
||||
"@react-native-community/slider": "4.4.2",
|
||||
@@ -69,8 +69,7 @@
|
||||
"react-native-version-info": "1.1.1",
|
||||
"react-native-vosk": "0.1.12",
|
||||
"react-native-webview": "12.4.0",
|
||||
"react-native-zip-archive": "6.0.9",
|
||||
"react-redux": "8.0.7",
|
||||
"react-redux": "7.2.9",
|
||||
"redux": "4.2.1",
|
||||
"rn-fetch-blob": "0.12.0",
|
||||
"stream": "0.0.2",
|
||||
@@ -117,7 +116,7 @@
|
||||
"metro-react-native-babel-preset": "0.73.9",
|
||||
"nodemon": "2.0.22",
|
||||
"ts-jest": "29.1.0",
|
||||
"ts-loader": "9.4.3",
|
||||
"ts-loader": "9.4.2",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "5.0.2",
|
||||
"uglify-js": "3.17.4",
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
import { languageCodeOnly } from '@joplin/lib/locale';
|
||||
import Logger from '@joplin/lib/Logger';
|
||||
import shim from '@joplin/lib/shim';
|
||||
import Vosk from 'react-native-vosk';
|
||||
import { unzip } from 'react-native-zip-archive';
|
||||
import RNFetchBlob from 'rn-fetch-blob';
|
||||
const md5 = require('md5');
|
||||
|
||||
const logger = Logger.create('voiceTyping/vosk');
|
||||
|
||||
enum State {
|
||||
Idle = 0,
|
||||
Recording,
|
||||
Completing,
|
||||
}
|
||||
|
||||
interface StartOptions {
|
||||
onResult: (text: string)=> void;
|
||||
}
|
||||
|
||||
let vosk_: Record<string, Vosk> = {};
|
||||
|
||||
let vosk_: Vosk|null = null;
|
||||
let state_: State = State.Idle;
|
||||
|
||||
export const voskEnabled = true;
|
||||
@@ -31,113 +23,12 @@ export interface Recorder {
|
||||
cleanup: ()=> void;
|
||||
}
|
||||
|
||||
const supportedLanguages = {
|
||||
'en': 'https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip',
|
||||
'cn': 'https://alphacephei.com/vosk/models/vosk-model-small-cn-0.22.zip',
|
||||
'ru': 'https://alphacephei.com/vosk/models/vosk-model-small-ru-0.22.zip',
|
||||
'fr': 'https://alphacephei.com/vosk/models/vosk-model-small-fr-0.22.zip',
|
||||
'de': 'https://alphacephei.com/vosk/models/vosk-model-small-de-0.15.zip',
|
||||
'es': 'https://alphacephei.com/vosk/models/vosk-model-small-es-0.42.zip',
|
||||
'pt': 'https://alphacephei.com/vosk/models/vosk-model-small-pt-0.3.zip',
|
||||
'tr': 'https://alphacephei.com/vosk/models/vosk-model-small-tr-0.3.zip',
|
||||
'vn': 'https://alphacephei.com/vosk/models/vosk-model-small-vn-0.4.zip',
|
||||
'it': 'https://alphacephei.com/vosk/models/vosk-model-small-it-0.22.zip',
|
||||
'nl': 'https://alphacephei.com/vosk/models/vosk-model-small-nl-0.22.zip',
|
||||
'uk': 'https://alphacephei.com/vosk/models/vosk-model-small-uk-v3-small.zip',
|
||||
'ja': 'https://alphacephei.com/vosk/models/vosk-model-small-ja-0.22.zip',
|
||||
'hi': 'https://alphacephei.com/vosk/models/vosk-model-small-hi-0.22.zip',
|
||||
'cs': 'https://alphacephei.com/vosk/models/vosk-model-small-cs-0.4-rhasspy.zip',
|
||||
'pl': 'https://alphacephei.com/vosk/models/vosk-model-small-pl-0.22.zip',
|
||||
'uz': 'https://alphacephei.com/vosk/models/vosk-model-small-uz-0.22.zip',
|
||||
'ko': 'https://alphacephei.com/vosk/models/vosk-model-small-ko-0.22.zip',
|
||||
};
|
||||
|
||||
export const isSupportedLanguage = (locale: string) => {
|
||||
const l = languageCodeOnly(locale).toLowerCase();
|
||||
return Object.keys(supportedLanguages).includes(l);
|
||||
};
|
||||
|
||||
// Where all the models files for all the languages are
|
||||
const getModelRootDir = () => {
|
||||
return `${RNFetchBlob.fs.dirs.DocumentDir}/vosk-models`;
|
||||
};
|
||||
|
||||
// Where we unzip a model after downloading it
|
||||
const getUnzipDir = (locale: string) => {
|
||||
return `${getModelRootDir()}/${locale}`;
|
||||
};
|
||||
|
||||
// Where the model for a particular language is
|
||||
const getModelDir = (locale: string) => {
|
||||
return `${getUnzipDir(locale)}/model`;
|
||||
};
|
||||
|
||||
const languageModelUrl = (locale: string) => {
|
||||
const l = languageCodeOnly(locale).toLowerCase();
|
||||
if (!(l in supportedLanguages)) throw new Error(`No language file for: ${locale}`);
|
||||
return (supportedLanguages as any)[l];
|
||||
};
|
||||
|
||||
export const modelIsDownloaded = async (locale: string) => {
|
||||
const uuidFile = `${getModelDir(locale)}/uuid`;
|
||||
return shim.fsDriver().exists(uuidFile);
|
||||
};
|
||||
|
||||
export const getVosk = async (locale: string) => {
|
||||
if (vosk_[locale]) return vosk_[locale];
|
||||
|
||||
const vosk = new Vosk();
|
||||
const modelDir = await downloadModel(locale);
|
||||
logger.info(`Loading model from ${modelDir}`);
|
||||
await shim.fsDriver().readDirStats(modelDir);
|
||||
const result = await vosk.loadModel(modelDir);
|
||||
export const getVosk = async () => {
|
||||
if (vosk_) return vosk_;
|
||||
vosk_ = new Vosk();
|
||||
const result = await vosk_.loadModel('model-fr-fr');
|
||||
logger.info('getVosk:', result);
|
||||
|
||||
vosk_ = { [locale]: vosk };
|
||||
|
||||
return vosk;
|
||||
};
|
||||
|
||||
const downloadModel = async (locale: string) => {
|
||||
const modelUrl = languageModelUrl(locale);
|
||||
const unzipDir = getUnzipDir(locale);
|
||||
const zipFilePath = `${unzipDir}.zip`;
|
||||
const modelDir = getModelDir(locale);
|
||||
const uuidFile = `${modelDir}/uuid`;
|
||||
|
||||
if (await modelIsDownloaded(locale)) {
|
||||
logger.info(`Model for ${locale} already exists at ${modelDir}`);
|
||||
return modelDir;
|
||||
}
|
||||
|
||||
await shim.fsDriver().remove(unzipDir);
|
||||
|
||||
logger.info(`Downloading model from: ${modelUrl}`);
|
||||
|
||||
await shim.fetchBlob(languageModelUrl(locale), {
|
||||
path: zipFilePath,
|
||||
});
|
||||
|
||||
logger.info(`Unzipping ${zipFilePath} => ${unzipDir}`);
|
||||
|
||||
await unzip(zipFilePath, unzipDir);
|
||||
|
||||
const dirs = await shim.fsDriver().readDirStats(unzipDir);
|
||||
if (dirs.length !== 1) {
|
||||
logger.error('Expected 1 directory but got', dirs);
|
||||
throw new Error(`Expected 1 directory, but got ${dirs.length}`);
|
||||
}
|
||||
|
||||
const fullUnzipPath = `${unzipDir}/${dirs[0].path}`;
|
||||
|
||||
logger.info(`Moving ${fullUnzipPath} => ${modelDir}`);
|
||||
await shim.fsDriver().rename(fullUnzipPath, modelDir);
|
||||
|
||||
await shim.fsDriver().writeFile(uuidFile, md5(modelUrl));
|
||||
|
||||
await shim.fsDriver().remove(zipFilePath);
|
||||
|
||||
return modelDir;
|
||||
return vosk_;
|
||||
};
|
||||
|
||||
export const startRecording = (vosk: Vosk, options: StartOptions): Recorder => {
|
||||
@@ -219,9 +110,8 @@ export const startRecording = (vosk: Vosk, options: StartOptions): Recorder => {
|
||||
});
|
||||
},
|
||||
cleanup: () => {
|
||||
if (state_ === State.Recording) {
|
||||
if (state_ !== State.Idle) {
|
||||
logger.info('Cancelling...');
|
||||
state_ = State.Completing;
|
||||
vosk.stopOnly();
|
||||
completeRecording('', null);
|
||||
}
|
||||
|
||||
@@ -13,15 +13,7 @@ export interface Recorder {
|
||||
cleanup: ()=> void;
|
||||
}
|
||||
|
||||
export const isSupportedLanguage = (_locale: string) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
export const modelIsDownloaded = async (_locale: string) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
export const getVosk = async (_locale: string) => {
|
||||
export const getVosk = async () => {
|
||||
return {} as any;
|
||||
};
|
||||
|
||||
|
||||
@@ -116,13 +116,6 @@ export default class FsDriverRN extends FsDriverBase {
|
||||
return RNFS.moveFile(source, dest);
|
||||
}
|
||||
|
||||
public async rename(source: string, dest: string) {
|
||||
if (isScopedUri(source) || isScopedUri(dest)) {
|
||||
await RNSAF.rename(source, dest);
|
||||
}
|
||||
return RNFS.moveFile(source, dest);
|
||||
}
|
||||
|
||||
public async exists(path: string) {
|
||||
if (isScopedUri(path)) {
|
||||
return RNSAF.exists(path);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@joplin/fork-htmlparser2",
|
||||
"description": "Fast & forgiving HTML/XML/RSS parser",
|
||||
"version": "4.1.44",
|
||||
"version": "4.1.43",
|
||||
"author": "Felix Boehm <me@feedic.com>",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -40,7 +40,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"domelementtype": "2.3.0",
|
||||
"domhandler": "5.0.3",
|
||||
"domhandler": "3.3.0",
|
||||
"domutils": "3.1.0",
|
||||
"entities": "2.2.0"
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@joplin/fork-sax",
|
||||
"description": "An evented streaming XML parser in JavaScript",
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"version": "1.2.48",
|
||||
"version": "1.2.47",
|
||||
"main": "lib/sax.js",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -16,7 +16,7 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"standard": "17.0.0",
|
||||
"tap": "16.3.6"
|
||||
"tap": "16.3.4"
|
||||
},
|
||||
"gitHead": "eb4b0e64eab40a51b0895d3a40a9d8c3cb7b1b14"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/fork-uslug",
|
||||
"version": "1.0.9",
|
||||
"version": "1.0.8",
|
||||
"description": "A permissive slug generator that works with unicode.",
|
||||
"author": "Jeremy Selier <jerem.selier@gmail.com>",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# generate-plugin-doc
|
||||
|
||||
This package is only to run the buildPluginDoc command. The version of typedoc we use needs an old version of typescript, so we cannot put the whole thing at the root, where it used to be.
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "generate-plugin-doc",
|
||||
"packageManager": "yarn@3.3.1",
|
||||
"scripts": {
|
||||
"buildPluginDoc_": "typedoc --name 'Joplin Plugin API Documentation' --mode file -theme '../../Assets/PluginDocTheme/' --readme '../../Assets/PluginDocTheme/index.md' --excludeNotExported --excludeExternals --excludePrivate --excludeProtected --out ../../../joplin-website/docs/api/references/plugin_api ../lib/services/plugins/api/"
|
||||
},
|
||||
"dependencies": {
|
||||
"typedoc": "0.17.8",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "generator-joplin",
|
||||
"version": "2.11.1",
|
||||
"version": "2.11.0",
|
||||
"description": "Scaffolds out a new Joplin plugin",
|
||||
"homepage": "https://github.com/laurent22/joplin/tree/dev/packages/generator-joplin",
|
||||
"author": {
|
||||
@@ -34,4 +34,4 @@
|
||||
"repository": "https://github.com/laurent22/generator-joplin",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"private": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/htmlpack",
|
||||
"version": "2.11.1",
|
||||
"version": "2.11.0",
|
||||
"description": "Pack an HTML file and all its linked resources into a single HTML file",
|
||||
"main": "dist/index.js",
|
||||
"types": "src/index.ts",
|
||||
@@ -14,7 +14,7 @@
|
||||
"author": "Laurent Cozic",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@joplin/fork-htmlparser2": "^4.1.44",
|
||||
"@joplin/fork-htmlparser2": "^4.1.43",
|
||||
"css": "3.0.0",
|
||||
"datauri": "4.1.0",
|
||||
"fs-extra": "11.1.1",
|
||||
|
||||
@@ -3,14 +3,13 @@ import * as callbackUrlUtils from './callbackUrlUtils';
|
||||
describe('callbackUrlUtils', () => {
|
||||
|
||||
it('should identify valid callback urls', () => {
|
||||
const url = 'joplin://x-callback-url/openFolder?a=b';
|
||||
const url = 'joplin://x-callback-url/123?a=b';
|
||||
expect(callbackUrlUtils.isCallbackUrl(url)).toBe(true);
|
||||
});
|
||||
|
||||
it('should identify invalid callback urls', () => {
|
||||
expect(callbackUrlUtils.isCallbackUrl('not-joplin://x-callback-url/123?a=b')).toBe(false);
|
||||
expect(callbackUrlUtils.isCallbackUrl('joplin://xcallbackurl/123?a=b')).toBe(false);
|
||||
expect(callbackUrlUtils.isCallbackUrl('joplin://x-callback-url/invalidCommand?a=b')).toBe(false);
|
||||
});
|
||||
|
||||
it('should build valid note callback urls', () => {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
const URL = require('url-parse');
|
||||
|
||||
export function isCallbackUrl(s: string) {
|
||||
return s.startsWith('joplin://x-callback-url/openNote?') ||
|
||||
s.startsWith('joplin://x-callback-url/openFolder?') ||
|
||||
s.startsWith('joplin://x-callback-url/openTag?');
|
||||
return s.startsWith('joplin://x-callback-url/');
|
||||
}
|
||||
|
||||
export function getNoteCallbackUrl(noteId: string) {
|
||||
|
||||
@@ -508,8 +508,7 @@ function languageNameInEnglish(languageCode: string) {
|
||||
return codeToLanguageE_[languageCode] ? codeToLanguageE_[languageCode] : '';
|
||||
}
|
||||
|
||||
function languageName(canonicalName: string, defaultToEnglish: boolean = true) {
|
||||
const languageCode = languageCodeOnly(canonicalName);
|
||||
function languageName(languageCode: string, defaultToEnglish: boolean = true) {
|
||||
if (codeToLanguage_[languageCode]) return codeToLanguage_[languageCode];
|
||||
if (defaultToEnglish) return languageNameInEnglish(languageCode);
|
||||
return '';
|
||||
@@ -604,4 +603,4 @@ const stringByLocale = (locale: string, s: string, ...args: any[]): string => {
|
||||
}
|
||||
};
|
||||
|
||||
export { _, _n, supportedLocales, languageName, currentLocale, localesFromLanguageCode, languageCodeOnly, countryDisplayName, localeStrings, setLocale, supportedLocalesToLanguages, defaultLocale, closestSupportedLocale, languageCode, countryCodeOnly };
|
||||
export { _, _n, supportedLocales, currentLocale, localesFromLanguageCode, languageCodeOnly, countryDisplayName, localeStrings, setLocale, supportedLocalesToLanguages, defaultLocale, closestSupportedLocale, languageCode, countryCodeOnly };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/lib",
|
||||
"version": "2.11.1",
|
||||
"version": "2.11.0",
|
||||
"description": "Joplin Core library",
|
||||
"author": "Laurent Cozic",
|
||||
"homepage": "",
|
||||
@@ -31,14 +31,14 @@
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "3.296.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.296.0",
|
||||
"@joplin/fork-htmlparser2": "^4.1.44",
|
||||
"@joplin/fork-sax": "^1.2.48",
|
||||
"@joplin/fork-uslug": "^1.0.9",
|
||||
"@joplin/htmlpack": "^2.11.1",
|
||||
"@joplin/renderer": "^2.11.1",
|
||||
"@joplin/turndown": "^4.0.66",
|
||||
"@joplin/turndown-plugin-gfm": "^1.0.48",
|
||||
"@joplin/utils": "^2.11.1",
|
||||
"@joplin/fork-htmlparser2": "^4.1.43",
|
||||
"@joplin/fork-sax": "^1.2.47",
|
||||
"@joplin/fork-uslug": "^1.0.8",
|
||||
"@joplin/htmlpack": "~2.11",
|
||||
"@joplin/renderer": "~2.11",
|
||||
"@joplin/turndown": "^4.0.65",
|
||||
"@joplin/turndown-plugin-gfm": "^1.0.47",
|
||||
"@joplin/utils": "~2.11",
|
||||
"@types/nanoid": "3.0.0",
|
||||
"async-mutex": "0.4.0",
|
||||
"base-64": "1.0.0",
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"jest-environment-jsdom": "29.5.0",
|
||||
"style-loader": "3.3.3",
|
||||
"ts-jest": "29.1.0",
|
||||
"ts-loader": "9.4.3",
|
||||
"ts-loader": "9.4.2",
|
||||
"typescript": "5.0.2",
|
||||
"webpack": "5.74.0",
|
||||
"webpack-cli": "4.10.0"
|
||||
@@ -44,6 +44,6 @@
|
||||
"pdfjs-dist": "2.16.105",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"styled-components": "5.3.11"
|
||||
"styled-components": "5.3.10"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/plugin-repo-cli",
|
||||
"version": "2.11.1",
|
||||
"version": "2.11.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"bin": "./dist/index.js",
|
||||
@@ -18,9 +18,9 @@
|
||||
"author": "",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@joplin/lib": "^2.11.1",
|
||||
"@joplin/tools": "^2.11.1",
|
||||
"@joplin/utils": "^2.11.1",
|
||||
"@joplin/lib": "~2.11",
|
||||
"@joplin/tools": "~2.11",
|
||||
"@joplin/utils": "~2.11",
|
||||
"fs-extra": "11.1.1",
|
||||
"gh-release-assets": "2.0.1",
|
||||
"node-fetch": "2.6.7",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/react-native-saf-x",
|
||||
"version": "2.11.1",
|
||||
"version": "2.11.0",
|
||||
"description": "a module to help work with scoped storages on android easily",
|
||||
"main": "src/index",
|
||||
"react-native": "src/index",
|
||||
|
||||
@@ -5,7 +5,7 @@ describe('linkReplacement', () => {
|
||||
|
||||
test('should handle non-resource links', () => {
|
||||
const r = linkReplacement('https://example.com/test').html;
|
||||
expect(r).toBe('<a data-from-md href=\'https://example.com/test\' onclick=\'postMessage("https://example.com/test", { resourceId: "" }); return false;\'>');
|
||||
expect(r).toBe('<a data-from-md href=\'https://example.com/test\' onclick=\'postMessage("https://example.com/test", { resourceId: "" }); return false;\'>');
|
||||
});
|
||||
|
||||
test('should handle non-resource links - simple rendering', () => {
|
||||
@@ -17,7 +17,7 @@ describe('linkReplacement', () => {
|
||||
// Handles a link such as:
|
||||
// [Google](https://www.goo'onclick=javascript:alert(/1/);f=')
|
||||
const r = linkReplacement('https://www.goo\'onclick=javascript:alert(/1/);f=\'', { linkRenderingType: 1 }).html;
|
||||
expect(r).toBe('<a data-from-md href=\'https://www.goo'onclick=javascript:alert(/1/);f='\' onclick=\'postMessage("https://www.goo%27onclick=javascript:alert(/1/);f=%27", { resourceId: "" }); return false;\'>');
|
||||
expect(r).toBe('<a data-from-md href=\'https://www.goo'onclick=javascript:alert(/1/);f='\' onclick=\'postMessage("https://www.goo%27onclick=javascript:alert(/1/);f=%27", { resourceId: "" }); return false;\'>');
|
||||
});
|
||||
|
||||
test('should handle resource links - downloaded status', () => {
|
||||
@@ -35,7 +35,7 @@ describe('linkReplacement', () => {
|
||||
},
|
||||
}).html;
|
||||
|
||||
expect(r).toBe(`<a data-from-md data-resource-id='${resourceId}' href='#' onclick='postMessage("joplin://${resourceId}", { resourceId: "${resourceId}" }); return false;'><span class="resource-icon fa-joplin"></span>`);
|
||||
expect(r).toBe(`<a data-from-md data-resource-id='${resourceId}' href='#' onclick='postMessage("joplin://${resourceId}", { resourceId: "${resourceId}" }); return false;'><span class="resource-icon fa-joplin"></span>`);
|
||||
});
|
||||
|
||||
test('should handle resource links - idle status', () => {
|
||||
|
||||
@@ -99,7 +99,7 @@ export default function(href: string, options: Options = null): LinkReplacementR
|
||||
postMessageSyntax: options.postMessageSyntax ?? 'void',
|
||||
}, onClick);
|
||||
} else {
|
||||
js = `onclick='${htmlentities(js)}'`;
|
||||
js = `onclick='${js}'`;
|
||||
}
|
||||
|
||||
if (hrefAttr.indexOf('#') === 0 && href.indexOf('#') === 0) js = ''; // If it's an internal anchor, don't add any JS since the webview is going to handle navigating to the right place
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/renderer",
|
||||
"version": "2.11.1",
|
||||
"version": "2.11.0",
|
||||
"description": "The Joplin note renderer, used the mobile and desktop application",
|
||||
"repository": "https://github.com/laurent22/joplin/tree/dev/packages/renderer",
|
||||
"main": "index.js",
|
||||
@@ -26,8 +26,8 @@
|
||||
"typescript": "5.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@joplin/fork-htmlparser2": "^4.1.44",
|
||||
"@joplin/fork-uslug": "^1.0.9",
|
||||
"@joplin/fork-htmlparser2": "^4.1.43",
|
||||
"@joplin/fork-uslug": "^1.0.8",
|
||||
"font-awesome-filetypes": "2.1.0",
|
||||
"fs-extra": "11.1.1",
|
||||
"highlight.js": "11.8.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@joplin/server",
|
||||
"version": "2.11.2",
|
||||
"version": "2.11.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start-dev": "yarn run build && JOPLIN_IS_TESTING=1 nodemon --config nodemon.json --ext ts,js,mustache,css,tsx dist/app.js --env dev",
|
||||
@@ -25,17 +25,17 @@
|
||||
"@fortawesome/fontawesome-free": "5.15.4",
|
||||
"@joplin/lib": "~2.11",
|
||||
"@joplin/renderer": "~2.11",
|
||||
"@koa/cors": "3.4.3",
|
||||
"@koa/cors": "3.1.0",
|
||||
"@types/uuid": "9.0.1",
|
||||
"bcryptjs": "2.4.3",
|
||||
"bulma": "0.9.4",
|
||||
"bulma-prefers-dark": "0.1.0-beta.1",
|
||||
"compare-versions": "3.6.0",
|
||||
"dayjs": "1.11.8",
|
||||
"formidable": "2.1.2",
|
||||
"dayjs": "1.11.7",
|
||||
"formidable": "2.1.1",
|
||||
"fs-extra": "11.1.1",
|
||||
"html-entities": "1.4.0",
|
||||
"jquery": "3.7.0",
|
||||
"jquery": "3.6.4",
|
||||
"knex": "2.4.2",
|
||||
"koa": "2.14.2",
|
||||
"markdown-it": "13.0.1",
|
||||
@@ -43,9 +43,9 @@
|
||||
"nanoid": "2.1.11",
|
||||
"node-cron": "3.0.2",
|
||||
"node-env-file": "0.1.8",
|
||||
"nodemailer": "6.9.3",
|
||||
"nodemailer": "6.9.2",
|
||||
"nodemon": "2.0.22",
|
||||
"pg": "8.11.0",
|
||||
"pg": "8.10.0",
|
||||
"pretty-bytes": "5.6.0",
|
||||
"prettycron": "0.10.0",
|
||||
"query-string": "7.1.3",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DbConnection, defaultAdminEmail, defaultAdminPassword } from '../db';
|
||||
import { hashPassword } from '../utils/auth';
|
||||
import uuidgen from '../utils/uuidgen';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('id', 32).unique().primary().notNullable();
|
||||
table.text('email', 'mediumtext').unique().notNullable();
|
||||
@@ -123,13 +123,13 @@ export const up = async (db: DbConnection) => {
|
||||
updated_time: now,
|
||||
created_time: now,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('users');
|
||||
await db.schema.dropTable('sessions');
|
||||
await db.schema.dropTable('permissions');
|
||||
await db.schema.dropTable('files');
|
||||
await db.schema.dropTable('api_clients');
|
||||
await db.schema.dropTable('changes');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('notifications', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('id', 32).unique().primary().notNullable();
|
||||
table.string('owner_id', 32).notNullable();
|
||||
@@ -17,8 +17,8 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('notifications', (table: Knex.CreateTableBuilder) => {
|
||||
table.unique(['owner_id', 'key']);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('notifications');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('shares', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('id', 32).unique().primary().notNullable();
|
||||
table.string('owner_id', 32).notNullable();
|
||||
@@ -10,8 +10,8 @@ export const up = async (db: DbConnection) => {
|
||||
table.bigInteger('updated_time').notNullable();
|
||||
table.bigInteger('created_time').notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('shares');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('share_users', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('id', 32).unique().primary().notNullable();
|
||||
table.string('share_id', 32).notNullable();
|
||||
@@ -38,8 +38,8 @@ export const up = async (db: DbConnection) => {
|
||||
table.bigInteger('updated_time').notNullable();
|
||||
table.bigInteger('created_time').notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('share_users');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('joplin_file_contents', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('id', 32).unique().primary().notNullable();
|
||||
table.string('owner_id', 32).notNullable();
|
||||
@@ -18,8 +18,8 @@ export const up = async (db: DbConnection) => {
|
||||
table.integer('content_type', 2).defaultTo(1).notNullable();
|
||||
table.string('content_id', 32).defaultTo('').notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('joplin_file_contents');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('shares', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('folder_id', 32).defaultTo('').notNullable();
|
||||
table.integer('is_auto', 1).defaultTo(0).notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('joplin_items');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import { DbConnection } from '../db';
|
||||
// is_shared: 1
|
||||
// type_: 1`;
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('id', 32).unique().primary().notNullable();
|
||||
table.text('name').notNullable();
|
||||
@@ -109,8 +109,8 @@ export const up = async (db: DbConnection) => {
|
||||
|
||||
await db.schema.dropTable('permissions');
|
||||
await db.schema.dropTable('joplin_file_contents');
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('items');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.integer('max_item_size').defaultTo(0).notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.integer('can_share').defaultTo(1).notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.integer('email_confirmed').defaultTo(0).notNullable();
|
||||
table.integer('must_set_password').defaultTo(0).notNullable();
|
||||
@@ -40,8 +40,8 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('tokens', (table: Knex.CreateTableBuilder) => {
|
||||
table.index(['value', 'user_id']);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.integer('account_type').defaultTo(0).notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.integer('can_upload').defaultTo(1).notNullable();
|
||||
});
|
||||
|
||||
await db('users').update({ can_upload: 1 });
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('subscriptions', (table: Knex.CreateTableBuilder) => {
|
||||
table.increments('id').unique().primary().notNullable();
|
||||
table.string('user_id', 32).notNullable();
|
||||
@@ -12,8 +12,8 @@ export const up = async (db: DbConnection) => {
|
||||
table.bigInteger('updated_time').notNullable();
|
||||
table.bigInteger('created_time').notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.bigInteger('jop_updated_time').defaultTo(0).notNullable();
|
||||
});
|
||||
@@ -22,8 +22,8 @@ export const up = async (db: DbConnection) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.renameColumn('can_share', 'can_share_folder');
|
||||
table.integer('can_share_note').defaultTo(1).notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ import { DbConnection } from '../db';
|
||||
// recreate it in the same migration. So this is split into two migrations.
|
||||
// https://github.com/knex/knex/issues/2581
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropColumn('max_item_size');
|
||||
table.dropColumn('can_share_folder');
|
||||
table.dropColumn('can_share_note');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.integer('max_item_size').defaultTo(null).nullable();
|
||||
table.specificType('can_share_folder', 'smallint').defaultTo(null).nullable();
|
||||
@@ -12,8 +12,8 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.integer('total_item_size').defaultTo(0).notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db('users').update({ email: db.raw('LOWER(email)') });
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropColumn('total_item_size');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.bigInteger('total_item_size').defaultTo(0).notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.specificType('enabled', 'smallint').defaultTo(1).nullable();
|
||||
});
|
||||
@@ -9,8 +9,8 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('subscriptions', (table: Knex.CreateTableBuilder) => {
|
||||
table.specificType('is_deleted', 'smallint').defaultTo(0).nullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
try {
|
||||
await db.schema.alterTable('emails', (table: Knex.CreateTableBuilder) => {
|
||||
table.text('key', 'mediumtext').defaultTo('').notNullable();
|
||||
@@ -13,8 +13,8 @@ export const up = async (db: DbConnection) => {
|
||||
// await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) {
|
||||
// table.unique(['recipient_email', 'key']);
|
||||
// });
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (_db: DbConnection) => {
|
||||
export async function up(_db: DbConnection): Promise<any> {
|
||||
// try {
|
||||
// await db.schema.alterTable('emails', function(table: Knex.CreateTableBuilder) {
|
||||
// table.dropUnique(['recipient_email', 'key']);
|
||||
@@ -9,8 +9,8 @@ export const up = async (_db: DbConnection) => {
|
||||
// } catch (error) {
|
||||
// // console.warn('Could not drop unique constraint - this is not an error.', error);
|
||||
// }
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (_db: DbConnection) => {
|
||||
export async function down(_db: DbConnection): Promise<any> {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('user_flags', (table: Knex.CreateTableBuilder) => {
|
||||
table.increments('id').unique().primary().notNullable();
|
||||
table.string('user_id', 32).notNullable();
|
||||
@@ -13,8 +13,8 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('user_flags', (table: Knex.CreateTableBuilder) => {
|
||||
table.unique(['user_id', 'type']);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('user_flags');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('share_users', (table: Knex.CreateTableBuilder) => {
|
||||
table.text('master_key', 'mediumtext').defaultTo('').notNullable();
|
||||
});
|
||||
@@ -9,9 +9,9 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('shares', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('master_key_id', 32).defaultTo('').notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('share_users', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropColumn('master_key');
|
||||
});
|
||||
@@ -19,4 +19,4 @@ export const down = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('shares', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropColumn('master_key_id');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('events', (table: Knex.CreateTableBuilder) => {
|
||||
table.uuid('id').unique().notNullable();
|
||||
table.increments('counter').unique().primary().notNullable();
|
||||
@@ -14,8 +14,8 @@ export const up = async (db: DbConnection) => {
|
||||
table.index('type');
|
||||
table.index('name');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('events');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
import { msleep } from '../utils/time';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
if (!(await db.schema.hasColumn('items', 'owner_id'))) {
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('owner_id', 32).defaultTo('').notNullable();
|
||||
@@ -58,10 +58,10 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('owner_id', 32).notNullable().alter();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropColumn('owner_id');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.unique(['name', 'owner_id']);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropUnique(['name', 'owner_id']);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('storages', (table: Knex.CreateTableBuilder) => {
|
||||
table.increments('id').unique().primary().notNullable();
|
||||
table.text('connection_string').notNullable();
|
||||
@@ -31,12 +31,12 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('storages', (table: Knex.CreateTableBuilder) => {
|
||||
table.unique(['connection_string']);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('storages');
|
||||
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropColumn('content_storage_id');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.index('content_storage_id');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('items', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropIndex('content_storage_id');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('user_deletions', (table: Knex.CreateTableBuilder) => {
|
||||
table.increments('id').unique().primary().notNullable();
|
||||
table.string('user_id', 32).notNullable();
|
||||
@@ -19,8 +19,8 @@ export const up = async (db: DbConnection) => {
|
||||
await db.schema.alterTable('user_deletions', (table: Knex.CreateTableBuilder) => {
|
||||
table.unique(['user_id']);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('user_deletions');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,16 +5,16 @@ import { DbConnection } from '../db';
|
||||
// it to an empty string by default, and update all rows that have "0" as
|
||||
// recipient_id.
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('emails', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('recipient_id', 32).defaultTo('').notNullable().alter();
|
||||
});
|
||||
|
||||
await db('emails').update({ recipient_id: '' }).where('recipient_id', '=', '0');
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('emails', (table: Knex.CreateTableBuilder) => {
|
||||
table.string('recipient_id', 32).defaultTo(0).notNullable().alter();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -38,17 +38,17 @@ export const disabledUserIds = async (db: DbConnection): Promise<string[]> => {
|
||||
return users.map(u => u.id);
|
||||
};
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.bigInteger('disabled_time').defaultTo(0).notNullable();
|
||||
});
|
||||
|
||||
const userIds = await disabledUserIds(db);
|
||||
await setUserAccountDisabledTimes(db, userIds);
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('users', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropColumn('disabled_time');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('backup_items', (table: Knex.CreateTableBuilder) => {
|
||||
table.increments('id').unique().primary().notNullable();
|
||||
table.integer('type').notNullable();
|
||||
@@ -10,8 +10,8 @@ export const up = async (db: DbConnection) => {
|
||||
table.binary('content').notNullable();
|
||||
table.bigInteger('created_time').notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('backup_items');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('shares', (table: Knex.CreateTableBuilder) => {
|
||||
table.specificType('recursive', 'smallint').defaultTo(0).nullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.alterTable('shares', (table: Knex.CreateTableBuilder) => {
|
||||
table.dropColumn('recursive');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { DbConnection } from '../db';
|
||||
|
||||
export const up = async (db: DbConnection) => {
|
||||
export async function up(db: DbConnection): Promise<any> {
|
||||
await db.schema.createTable('task_states', (table: Knex.CreateTableBuilder) => {
|
||||
table.increments('id').unique().primary().notNullable();
|
||||
table.integer('task_id').unique().notNullable();
|
||||
@@ -10,8 +10,8 @@ export const up = async (db: DbConnection) => {
|
||||
table.bigInteger('updated_time').notNullable();
|
||||
table.bigInteger('created_time').notNullable();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const down = async (db: DbConnection) => {
|
||||
export async function down(db: DbConnection): Promise<any> {
|
||||
await db.schema.dropTable('task_states');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ItemType, databaseSchema, Uuid, Item, ShareType, Share, ChangeType, Use
|
||||
import { defaultPagination, paginateDbQuery, PaginatedResults, Pagination } from './utils/pagination';
|
||||
import { isJoplinItemName, isJoplinResourceBlobPath, linkedResourceIds, serializeJoplinItem, unserializeJoplinItem } from '../utils/joplinUtils';
|
||||
import { ModelType } from '@joplin/lib/BaseModel';
|
||||
import { ApiError, CustomErrorCode, ErrorConflict, ErrorForbidden, ErrorPayloadTooLarge, ErrorUnprocessableEntity, ErrorCode } from '../utils/errors';
|
||||
import { ApiError, ErrorCode, ErrorConflict, ErrorForbidden, ErrorPayloadTooLarge, ErrorUnprocessableEntity } from '../utils/errors';
|
||||
import { Knex } from 'knex';
|
||||
import { ChangePreviousItem } from './ChangeModel';
|
||||
import { unique } from '../utils/array';
|
||||
@@ -311,7 +311,7 @@ export default class ItemModel extends BaseModel<Item> {
|
||||
try {
|
||||
content = await fromDriver.read(item.id, { models: this.models() });
|
||||
} catch (error) {
|
||||
if (error.code === CustomErrorCode.NotFound) {
|
||||
if (error.code === ErrorCode.NotFound) {
|
||||
logger.info(`Could not process item, because content was deleted: ${item.id}`);
|
||||
return;
|
||||
}
|
||||
@@ -537,10 +537,10 @@ export default class ItemModel extends BaseModel<Item> {
|
||||
return this.itemToJoplinItem(raw);
|
||||
}
|
||||
|
||||
public async saveFromRawContent(user: User, rawContentItemOrItems: SaveFromRawContentItem[] | SaveFromRawContentItem, options: ItemSaveOption = null): Promise<SaveFromRawContentResult> {
|
||||
public async saveFromRawContent(user: User, rawContentItems: SaveFromRawContentItem[] | SaveFromRawContentItem, options: ItemSaveOption = null): Promise<SaveFromRawContentResult> {
|
||||
options = options || {};
|
||||
|
||||
const rawContentItems = !Array.isArray(rawContentItemOrItems) ? [rawContentItemOrItems] : rawContentItemOrItems;
|
||||
if (!Array.isArray(rawContentItems)) rawContentItems = [rawContentItems];
|
||||
|
||||
// In this function, first we process the input items, which may be
|
||||
// serialized Joplin items or actual buffers (for resources) and convert
|
||||
@@ -555,78 +555,73 @@ export default class ItemModel extends BaseModel<Item> {
|
||||
joplinItem?: any;
|
||||
}
|
||||
|
||||
interface ExistingItem {
|
||||
id: Uuid;
|
||||
name: string;
|
||||
const existingItems = await this.loadByNames(user.id, rawContentItems.map(i => i.name));
|
||||
const itemsToProcess: Record<string, ItemToProcess> = {};
|
||||
|
||||
for (const rawItem of rawContentItems) {
|
||||
try {
|
||||
const isJoplinItem = isJoplinItemName(rawItem.name);
|
||||
let isNote = false;
|
||||
|
||||
const item: Item = {
|
||||
name: rawItem.name,
|
||||
};
|
||||
|
||||
let joplinItem: any = null;
|
||||
|
||||
let resourceIds: string[] = [];
|
||||
|
||||
if (isJoplinItem) {
|
||||
joplinItem = await unserializeJoplinItem(rawItem.body.toString());
|
||||
isNote = joplinItem.type_ === ModelType.Note;
|
||||
resourceIds = isNote ? linkedResourceIds(joplinItem.body) : [];
|
||||
|
||||
item.jop_id = joplinItem.id;
|
||||
item.jop_parent_id = joplinItem.parent_id || '';
|
||||
item.jop_type = joplinItem.type_;
|
||||
item.jop_encryption_applied = joplinItem.encryption_applied || 0;
|
||||
item.jop_share_id = joplinItem.share_id || '';
|
||||
item.jop_updated_time = joplinItem.updated_time;
|
||||
|
||||
const joplinItemToSave = { ...joplinItem };
|
||||
|
||||
delete joplinItemToSave.id;
|
||||
delete joplinItemToSave.parent_id;
|
||||
delete joplinItemToSave.share_id;
|
||||
delete joplinItemToSave.type_;
|
||||
delete joplinItemToSave.encryption_applied;
|
||||
delete joplinItemToSave.updated_time;
|
||||
|
||||
item.content = Buffer.from(JSON.stringify(joplinItemToSave));
|
||||
} else {
|
||||
item.content = rawItem.body;
|
||||
}
|
||||
|
||||
const existingItem = existingItems.find(i => i.name === rawItem.name);
|
||||
if (existingItem) item.id = existingItem.id;
|
||||
|
||||
if (options.shareId) item.jop_share_id = options.shareId;
|
||||
|
||||
await this.models().user().checkMaxItemSizeLimit(user, rawItem.body, item, joplinItem);
|
||||
|
||||
itemsToProcess[rawItem.name] = {
|
||||
item: item,
|
||||
error: null,
|
||||
resourceIds,
|
||||
isNote,
|
||||
joplinItem,
|
||||
};
|
||||
} catch (error) {
|
||||
itemsToProcess[rawItem.name] = {
|
||||
item: null,
|
||||
error: error,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return this.withTransaction(async () => {
|
||||
const existingItems = await this.loadByNames(user.id, rawContentItems.map(i => i.name), { fields: ['id', 'name'] }) as ExistingItem[];
|
||||
const itemsToProcess: Record<string, ItemToProcess> = {};
|
||||
|
||||
for (const rawItem of rawContentItems) {
|
||||
try {
|
||||
const isJoplinItem = isJoplinItemName(rawItem.name);
|
||||
let isNote = false;
|
||||
|
||||
const item: Item = {
|
||||
name: rawItem.name,
|
||||
};
|
||||
|
||||
let joplinItem: any = null;
|
||||
|
||||
let resourceIds: string[] = [];
|
||||
|
||||
if (isJoplinItem) {
|
||||
joplinItem = await unserializeJoplinItem(rawItem.body.toString());
|
||||
isNote = joplinItem.type_ === ModelType.Note;
|
||||
resourceIds = isNote ? linkedResourceIds(joplinItem.body) : [];
|
||||
|
||||
item.jop_id = joplinItem.id;
|
||||
item.jop_parent_id = joplinItem.parent_id || '';
|
||||
item.jop_type = joplinItem.type_;
|
||||
item.jop_encryption_applied = joplinItem.encryption_applied || 0;
|
||||
item.jop_share_id = joplinItem.share_id || '';
|
||||
item.jop_updated_time = joplinItem.updated_time;
|
||||
|
||||
const joplinItemToSave = { ...joplinItem };
|
||||
|
||||
delete joplinItemToSave.id;
|
||||
delete joplinItemToSave.parent_id;
|
||||
delete joplinItemToSave.share_id;
|
||||
delete joplinItemToSave.type_;
|
||||
delete joplinItemToSave.encryption_applied;
|
||||
delete joplinItemToSave.updated_time;
|
||||
|
||||
item.content = Buffer.from(JSON.stringify(joplinItemToSave));
|
||||
} else {
|
||||
item.content = rawItem.body;
|
||||
}
|
||||
|
||||
const existingItem = existingItems.find(i => i.name === rawItem.name);
|
||||
if (existingItem) item.id = existingItem.id;
|
||||
|
||||
if (options.shareId) item.jop_share_id = options.shareId;
|
||||
|
||||
await this.models().user().checkMaxItemSizeLimit(user, rawItem.body, item, joplinItem);
|
||||
|
||||
itemsToProcess[rawItem.name] = {
|
||||
item: item,
|
||||
error: null,
|
||||
resourceIds,
|
||||
isNote,
|
||||
joplinItem,
|
||||
};
|
||||
} catch (error) {
|
||||
itemsToProcess[rawItem.name] = {
|
||||
item: null,
|
||||
error: error,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const output: SaveFromRawContentResult = {};
|
||||
const output: SaveFromRawContentResult = {};
|
||||
|
||||
await this.withTransaction(async () => {
|
||||
for (const name of Object.keys(itemsToProcess)) {
|
||||
const o = itemsToProcess[name];
|
||||
|
||||
@@ -695,9 +690,9 @@ export default class ItemModel extends BaseModel<Item> {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}, 'ItemModel::saveFromRawContent');
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
protected async validate(item: Item, options: ValidateOptions = {}): Promise<Item> {
|
||||
@@ -789,7 +784,7 @@ export default class ItemModel extends BaseModel<Item> {
|
||||
// that shared folder. It returns null otherwise.
|
||||
public async joplinItemSharedRootInfo(jopId: string): Promise<SharedRootInfo | null> {
|
||||
const path = await this.joplinItemPath(jopId);
|
||||
if (!path.length) throw new ApiError(`Cannot retrieve path for item: ${jopId}`, null, ErrorCode.NoPathForItem);
|
||||
if (!path.length) throw new ApiError(`Cannot retrieve path for item: ${jopId}`, null, 'noPathForItem');
|
||||
const rootFolderItem = path[path.length - 1];
|
||||
const share = await this.models().share().itemShare(ShareType.Folder, rootFolderItem.id);
|
||||
if (!share) return null;
|
||||
|
||||
@@ -2,7 +2,7 @@ import BaseModel, { UuidType } from './BaseModel';
|
||||
import { Uuid } from '../services/database/types';
|
||||
import { LockType, Lock, LockClientType, defaultLockTtl, activeLock } from '@joplin/lib/services/synchronizer/LockHandler';
|
||||
import { Value } from './KeyValueModel';
|
||||
import { ErrorConflict, ErrorUnprocessableEntity, ErrorCode } from '../utils/errors';
|
||||
import { ErrorConflict, ErrorUnprocessableEntity } from '../utils/errors';
|
||||
import uuidgen from '../utils/uuidgen';
|
||||
|
||||
export default class LockModel extends BaseModel<Lock> {
|
||||
@@ -59,7 +59,7 @@ export default class LockModel extends BaseModel<Lock> {
|
||||
const exclusiveLock = activeLock(locks, new Date(), this.lockTtl, LockType.Exclusive);
|
||||
|
||||
if (exclusiveLock) {
|
||||
throw new ErrorConflict(`Cannot acquire lock because there is already an exclusive lock for client: ${exclusiveLock.clientType} #${exclusiveLock.clientId}`, ErrorCode.HasExclusiveSyncLock);
|
||||
throw new ErrorConflict(`Cannot acquire lock because there is already an exclusive lock for client: ${exclusiveLock.clientType} #${exclusiveLock.clientId}`, 'hasExclusiveLock');
|
||||
}
|
||||
|
||||
const syncLock = activeLock(locks, new Date(), this.lockTtl, LockType.Sync, clientType, clientId);
|
||||
@@ -111,7 +111,7 @@ export default class LockModel extends BaseModel<Lock> {
|
||||
|
||||
return JSON.stringify(locks);
|
||||
} else {
|
||||
throw new ErrorConflict(`Cannot acquire lock because there is already an exclusive lock for client: ${exclusiveLock.clientType} #${exclusiveLock.clientId}`, ErrorCode.HasExclusiveSyncLock);
|
||||
throw new ErrorConflict(`Cannot acquire lock because there is already an exclusive lock for client: ${exclusiveLock.clientType} #${exclusiveLock.clientId}`, 'hasExclusiveLock');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ export default class LockModel extends BaseModel<Lock> {
|
||||
if (syncLock.clientId === clientId) {
|
||||
locks = locks.filter(l => l.id !== syncLock.id);
|
||||
} else {
|
||||
throw new ErrorConflict(`Cannot acquire exclusive lock because there is an active sync lock for client: ${syncLock.clientType} #${syncLock.clientId}`, ErrorCode.HasSyncLock);
|
||||
throw new ErrorConflict(`Cannot acquire exclusive lock because there is an active sync lock for client: ${syncLock.clientType} #${syncLock.clientId}`, 'hasSyncLock');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// database (as a binary blob). For now the driver expects that the content is
|
||||
// stored in the same table as the items, as it originally was.
|
||||
|
||||
import { CustomError, CustomErrorCode } from '../../../utils/errors';
|
||||
import { CustomError, ErrorCode } from '../../../utils/errors';
|
||||
import { DatabaseConfigClient, StorageDriverConfig, StorageDriverType } from '../../../utils/types';
|
||||
import StorageDriverBase, { Context } from './StorageDriverBase';
|
||||
|
||||
@@ -41,7 +41,7 @@ export default class StorageDriverDatabase extends StorageDriverBase {
|
||||
|
||||
// Calling code should only call this handler if the row exists, so if
|
||||
// we find it doesn't, it's an error.
|
||||
if (!row) throw new CustomError(`No such row: ${itemId}`, CustomErrorCode.NotFound);
|
||||
if (!row) throw new CustomError(`No such row: ${itemId}`, ErrorCode.NotFound);
|
||||
|
||||
return row.content;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { mkdirp, pathExists, readFile, remove, writeFile } from 'fs-extra';
|
||||
import { CustomError, CustomErrorCode } from '../../../utils/errors';
|
||||
import { CustomError, ErrorCode } from '../../../utils/errors';
|
||||
import { StorageDriverConfig, StorageDriverType } from '../../../utils/types';
|
||||
import StorageDriverBase from './StorageDriverBase';
|
||||
|
||||
@@ -36,7 +36,7 @@ export default class StorageDriverFs extends StorageDriverBase {
|
||||
const result = await readFile(this.itemPath(itemId));
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') throw new CustomError(`Not found: ${itemId}`, CustomErrorCode.NotFound);
|
||||
if (error.code === 'ENOENT') throw new CustomError(`Not found: ${itemId}`, ErrorCode.NotFound);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export default class StorageDriverFs extends StorageDriverBase {
|
||||
try {
|
||||
await remove(this.itemPath(id));
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') throw new CustomError(`Not found: ${itemId}`, CustomErrorCode.NotFound);
|
||||
if (error.code === 'ENOENT') throw new CustomError(`Not found: ${itemId}`, ErrorCode.NotFound);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CustomError, CustomErrorCode } from '../../../utils/errors';
|
||||
import { CustomError, ErrorCode } from '../../../utils/errors';
|
||||
import { StorageDriverConfig, StorageDriverType } from '../../../utils/types';
|
||||
import StorageDriverBase from './StorageDriverBase';
|
||||
|
||||
@@ -15,7 +15,7 @@ export default class StorageDriverMemory extends StorageDriverBase {
|
||||
}
|
||||
|
||||
public async read(itemId: string): Promise<Buffer> {
|
||||
if (!(itemId in this.data_)) throw new CustomError(`No such item: ${itemId}`, CustomErrorCode.NotFound);
|
||||
if (!(itemId in this.data_)) throw new CustomError(`No such item: ${itemId}`, ErrorCode.NotFound);
|
||||
return this.data_[itemId];
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user