Merge branch 'dev' of github.com:laurent22/joplin into dev

pull/4306/head
Laurent Cozic 2021-01-07 17:04:04 +00:00
commit ec29f791ba
6 changed files with 55 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import markdownUtils from '@joplin/lib/markdownUtils';
import Setting from '@joplin/lib/models/Setting';
// Helper functions that use the cursor
export default function useCursorUtils(CodeMirror: any) {
@ -120,8 +121,12 @@ export default function useCursorUtils(CodeMirror: any) {
return -1;
};
// CodeMirror coordsChar doesn't properly scale values when zoomed
// we need to manually apply the zoom
const zoomFactor = Setting.value('windowContentZoomFactor') / 100;
const selectionText = params.selectionText;
const coords = this.coordsChar({ left: params.x, top: params.y });
const coords = this.coordsChar({ left: params.x / zoomFactor, top: params.y / zoomFactor });
const { anchor, head } = this.findWordAt(coords);
const selectedWord = this.getRange(anchor, head);

View File

@ -44,3 +44,6 @@ LogBox.ignoreLogs([
]);
AppRegistry.registerComponent('Joplin', () => Root);
// Using streams on react-native requires to polyfill process.nextTick()
global.process.nextTick = setImmediate;

View File

@ -8379,6 +8379,27 @@
"emitter-component": "^1.1.1"
}
},
"stream-browserify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz",
"integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==",
"requires": {
"inherits": "~2.0.4",
"readable-stream": "^3.5.0"
},
"dependencies": {
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
}
}
},
"stream-buffers": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-2.2.0.tgz",

View File

@ -53,14 +53,15 @@
"redux": "4.0.0",
"rn-fetch-blob": "^0.12.0",
"stream": "0.0.2",
"stream-browserify": "^3.0.0",
"string-natural-compare": "^2.0.2",
"timers": "^0.1.1",
"valid-url": "^1.0.9"
},
"devDependencies": {
"@joplin/tools": "^1.0.9",
"@babel/core": "^7.11.6",
"@babel/runtime": "^7.11.2",
"@joplin/tools": "^1.0.9",
"@types/node": "^14.14.6",
"@types/react": "^16.9.55",
"execa": "^4.0.0",

View File

@ -1,6 +1,8 @@
const RNFS = require('react-native-fs');
const FsDriverBase = require('@joplin/lib/fs-driver-base').default;
const RNFetchBlob = require('rn-fetch-blob').default;
const { Writable } = require('stream-browserify');
const { Buffer } = require('buffer');
class FsDriverRN extends FsDriverBase {
appendFileSync() {
@ -24,8 +26,25 @@ class FsDriverRN extends FsDriverBase {
return await this.unlink(path);
}
writeBinaryFile() {
throw new Error('Not implemented');
writeBinaryFile(path, content) {
const buffer = Buffer.from(content);
return RNFetchBlob.fs.writeStream(path, 'base64').then(stream => {
const fileStream = new Writable({
write(chunk, encoding, callback) {
this.stream.write(chunk.toString('base64'));
callback();
},
final(callback) {
this.stream.close();
callback();
},
});
// using options.construct is not implemented in readable-stream so lets
// pass the stream from RNFetchBlob to the Writable instance here
fileStream.stream = stream;
fileStream.write(buffer);
fileStream.end();
});
}
// Returns a format compatible with Node.js format

View File

@ -148,6 +148,8 @@ Note that the functionality added by these plugins is not part of the CommonMark
| Typographer | See [typographer](https://markdown-it.github.io/#md3=%7B%22source%22%3A%22%23%20Typographic%20replacements%5Cn%5Cn%28c%29%20%28C%29%20%28r%29%20%28R%29%20%28tm%29%20%28TM%29%20%28p%29%20%28P%29%20%2B-%5Cn%5Cntest..%20test...%20test.....%20test%3F.....%20test!....%5Cn%5Cn!!!!!!%20%3F%3F%3F%3F%20%2C%2C%20%20--%20---%5Cn%5Cn%5C%22Smartypants%2C%20double%20quotes%5C%22%20and%20%27single%20quotes%27%5Cn%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D) markdown-it demo | Does typographic replacements, (c) -> © and so on | no | [View](https://joplinapp.org/images/md_plugins/typographer_plugin.jpg) |
| Linkify | See [linkify](https://markdown-it.github.io/#md3=%7B%22source%22%3A%22Use%20the%20Linkify%20checkbox%20to%20switch%20link-detection%20on%20and%20off.%5Cn%5Cn%2A%2AThese%20links%20are%20auto-detected%3A%2A%2A%5Cn%5Cnhttps%3A%2F%2Fexample.com%5Cn%5Cnexample.com%5Cn%5Cntest%40example.com%5Cn%5Cn%2A%2AThese%20are%20always%20links%3A%2A%2A%5Cn%5Cn%5Blink%5D%28https%3A%2F%2Fjoplinapp.org%29%5Cn%5Cn%3Chttps%3A%2F%2Fexample.com%3E%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D) markdown-it demo | Auto-detects URLs and convert them to clickable links | yes | |
| [Katex](https://katex.org) | `$$math expr$$` or `$math$` | [See above](#math-notation) | yes | [View](https://joplinapp.org/images/md_plugins/katex_plugin.jpg) |
| [Fountain](https://fountain.io) | <code>\`\`\`fountain</code><br/>Your screenplay...<br/><code>\`\`\`</code> | Adds support for the Fountain markup language, a plain text markup language for screenwriting | no | [View](https://joplinapp.org/images/md_plugins/fountain_plugin.jpg) |
| [Mermaid](https://mermaid-js.github.io/mermaid/) | <code>\`\`\`mermaid</code><br/>mermaid syntax...<br/><code>\`\`\`</code> | See [plugin page](https://mermaid-js.github.io/mermaid/#/examples) for full description | no | [View](https://joplinapp.org/images/md_plugins/mermaid.jpg) |
| [Mark](https://github.com/markdown-it/markdown-it-mark) | `==marked==` | Transforms into `<mark>marked</mark>` (highlighted) | yes | [View](https://joplinapp.org/images/md_plugins/mark_plugin.jpg) |
| [Footnote](https://github.com/markdown-it/markdown-it-footnote) | `Simples inline footnote ^[I'm inline!]` | See [plugin page](https://github.com/markdown-it/markdown-it-footnote) for full description | yes | [View](https://joplinapp.org/images/md_plugins/footnote_plugin.jpg) |
| [TOC](https://github.com/nagaozen/markdown-it-toc-done-right) | Any of `${toc}, [[toc]], [toc], [[_toc_]]` | Adds a table of contents to the location of the toc page. Based on headings and sub-headings | no | [View](https://joplinapp.org/images/md_plugins/toc_plugin.jpg) |
@ -158,5 +160,3 @@ Note that the functionality added by these plugins is not part of the CommonMark
| [Emoji](https://github.com/markdown-it/markdown-it-emoji) | `:smile:` | Transforms into 😄. See [this list](https://gist.github.com/rxaviers/7360908) for more emojis | no |[View](https://joplinapp.org/images/md_plugins/emoji_plugin.jpg) |
| [Insert](https://github.com/markdown-it/markdown-it-ins) | `++inserted++` | Transforms into `<ins>inserted</ins>` (<ins>inserted</ins>) | no | [View](https://joplinapp.org/images/md_plugins/insert_plugin.jpg) |
| [Multitable](https://github.com/RedBug312/markdown-it-multimd-table) | See [MultiMarkdown](https://fletcher.github.io/MultiMarkdown-6/syntax/tables.html) page | Adds more power and customization to markdown tables | no | [View](https://joplinapp.org/images/md_plugins/multitable_plugin.jpg) |
| [Fountain](https://fountain.io) | <code>\`\`\`fountain</code><br/>Your screenplay...<br/><code>\`\`\`</code> | Adds support for the Fountain markup language, a plain text markup language for screenwriting | no | [View](https://joplinapp.org/images/md_plugins/fountain_plugin.jpg) |
| [Mermaid](https://mermaid-js.github.io/mermaid/) | <code>\`\`\`mermaid</code><br/>mermaid syntax...<br/><code>\`\`\`</code> | See [plugin page](https://mermaid-js.github.io/mermaid/#/examples) for full description | no | [View](https://joplinapp.org/images/md_plugins/mermaid.jpg) |