1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-09-05 20:56:22 +02:00

Compare commits

...

3 Commits

6 changed files with 64 additions and 39 deletions

View File

@@ -110,8 +110,8 @@ android {
applicationId "net.cozic.joplin"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2097728
versionName "2.13.8"
versionCode 2097729
versionName "2.13.9"
ndk {
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}

View File

@@ -156,10 +156,6 @@ export const createJsDrawEditor = (
// Load from a template if no initial data
if (svgData === '') {
await applyTemplateToEditor(editor, templateData);
// The editor expects to be saved initially (without
// unsaved changes). Save now.
saveNow();
} else {
await editor.loadFromSVG(svgData);
}

View File

@@ -749,7 +749,11 @@ class NoteScreenComponent extends BaseScreenComponent {
if (this.useEditorBeta()) {
// The beta editor needs to be explicitly informed of changes
// to the note's body
this.editorRef.current.insertText(newText);
if (this.editorRef.current) {
this.editorRef.current.insertText(newText);
} else {
logger.error(`Tried to attach resource ${resource.id} to the note when the editor is not visible!`);
}
}
} else {
newNote.body += `\n${resourceTag}`;
@@ -814,31 +818,34 @@ class NoteScreenComponent extends BaseScreenComponent {
}, 'image');
}
private drawPicture_onPress = async () => {
// Create a new empty drawing and attach it now.
const resource = await this.attachNewDrawing('');
await this.editDrawing(resource);
};
private async updateDrawing(svgData: string) {
let resource: ResourceEntity|null = this.state.imageEditorResource;
if (!resource) {
throw new Error('No resource is loaded in the editor');
resource = await this.attachNewDrawing(svgData);
// Set resouce and file path to allow
// 1. subsequent saves to update the resource
// 2. the editor to load from the resource's filepath (can happen
// if the webview is reloaded).
this.setState({
imageEditorResourceFilepath: Resource.fullPath(resource),
imageEditorResource: resource,
});
} else {
logger.info('Saving drawing to resource', resource.id);
const tempFilePath = join(Setting.value('tempDir'), uuid.createNano());
await shim.fsDriver().writeFile(tempFilePath, svgData, 'utf8');
resource = await Resource.updateResourceBlobContent(
resource.id,
tempFilePath,
);
await shim.fsDriver().remove(tempFilePath);
await this.refreshResource(resource);
}
logger.info('Saving drawing to resource', resource.id);
const tempFilePath = join(Setting.value('tempDir'), uuid.createNano());
await shim.fsDriver().writeFile(tempFilePath, svgData, 'utf8');
resource = await Resource.updateResourceBlobContent(
resource.id,
tempFilePath,
);
await shim.fsDriver().remove(tempFilePath);
await this.refreshResource(resource);
}
private onSaveDrawing = async (svgData: string) => {
@@ -849,6 +856,23 @@ class NoteScreenComponent extends BaseScreenComponent {
this.setState({ showImageEditor: false });
};
private drawPicture_onPress = async () => {
if (this.state.mode === 'edit') {
// Create a new empty drawing and attach it now, before the image editor is opened.
// With the present structure of Note.tsx, the we can't use this.editorRef while
// the image editor is open, and thus can't attach drawings at the cursor locaiton.
const resource = await this.attachNewDrawing('');
await this.editDrawing(resource);
} else {
logger.info('Showing image editor...');
this.setState({
showImageEditor: true,
imageEditorResourceFilepath: null,
imageEditorResource: null,
});
}
};
private async editDrawing(item: BaseItem) {
const filePath = Resource.fullPath(item);
this.setState({

View File

@@ -88,7 +88,7 @@
"@babel/preset-env": "7.20.2",
"@babel/runtime": "7.20.0",
"@joplin/tools": "~2.13",
"@js-draw/material-icons": "1.11.2",
"@js-draw/material-icons": "1.13.2",
"@lezer/highlight": "1.1.4",
"@testing-library/jest-native": "5.4.3",
"@testing-library/react-native": "12.3.1",
@@ -106,7 +106,7 @@
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jetifier": "2.0.0",
"js-draw": "1.11.2",
"js-draw": "1.13.2",
"jsdom": "22.1.0",
"metro-react-native-babel-preset": "0.73.9",
"nodemon": "3.0.1",

View File

@@ -1,5 +1,10 @@
# Joplin Android Changelog
## [android-v2.13.9](https://github.com/laurent22/joplin/releases/tag/android-v2.13.9) (Pre-release) - 2023-11-30T17:55:54Z
- Improved: Don't attach empty drawings when a user exits without saving (#9386) (#9377 by Henry Heino)
- Fixed: Fix tooltips don't disappear on some devices (upgrade to js-draw 1.13.2) (#9401) (#9374 by Henry Heino)
## [android-v2.13.8](https://github.com/laurent22/joplin/releases/tag/android-v2.13.8) (Pre-release) - 2023-11-26T12:37:00Z
- Fixed: Fix to-dos options toggle don't toggle a rerender (#9364) (#9361 by [@pedr](https://github.com/pedr))

View File

@@ -6293,7 +6293,7 @@ __metadata:
"@joplin/renderer": ~2.13
"@joplin/tools": ~2.13
"@joplin/utils": ~2.13
"@js-draw/material-icons": 1.11.2
"@js-draw/material-icons": 1.13.2
"@lezer/highlight": 1.1.4
"@react-native-community/clipboard": 1.5.1
"@react-native-community/datetimepicker": 7.6.1
@@ -6323,7 +6323,7 @@ __metadata:
jest: 29.7.0
jest-environment-jsdom: 29.7.0
jetifier: 2.0.0
js-draw: 1.11.2
js-draw: 1.13.2
jsc-android: 241213.1.0
jsdom: 22.1.0
lodash: 4.17.21
@@ -6990,12 +6990,12 @@ __metadata:
languageName: node
linkType: hard
"@js-draw/material-icons@npm:1.11.2":
version: 1.11.2
resolution: "@js-draw/material-icons@npm:1.11.2"
"@js-draw/material-icons@npm:1.13.2":
version: 1.13.2
resolution: "@js-draw/material-icons@npm:1.13.2"
peerDependencies:
js-draw: ^1.0.1
checksum: 6a6bbdf936d3a97fab43321d807672f157b12201290a98bd3fd33a7e53966647ed9c5a8aba5dfd6d743bfc37ab9ddff14cbb7fc3f4ffb8b79ff7617a7e886160
checksum: a442d10926b9218b959a2c5d441998c009d72be9b1c3c48a35501be74a27f107963e1c02dfa6c5c075d474de164a8d4571d0cb00a79645205c988f89a8ae5ea8
languageName: node
linkType: hard
@@ -26295,13 +26295,13 @@ __metadata:
languageName: node
linkType: hard
"js-draw@npm:1.11.2":
version: 1.11.2
resolution: "js-draw@npm:1.11.2"
"js-draw@npm:1.13.2":
version: 1.13.2
resolution: "js-draw@npm:1.13.2"
dependencies:
"@js-draw/math": ^1.11.1
"@melloware/coloris": 0.22.0
checksum: 59669bbe37f4c980f8532b96ec7a80880966beca3a82973fa0681c3988d8ed12745d5c1b27645853806087664c14fa49530fc8815a471346f03b3ef7c4366ea9
checksum: 22dc85634f5717c015f31d0e6daabe8eb189930dc102a96b1a49f548e9b208d302e014822ed04b82931a5ba2bacd3a33d9407d8d0a329966595e83e118075fa7
languageName: node
linkType: hard