added prettierrc

This commit is contained in:
Viktor Vaczi 2021-01-08 01:41:36 +01:00
parent 9a55d38e4b
commit 6049213661
4 changed files with 22 additions and 4 deletions

12
package-lock.json generated Normal file
View file

@ -0,0 +1,12 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"prettier": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz",
"integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
"dev": true
}
}
}

4
prose/.prettierrc Normal file
View file

@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}

View file

@ -28,6 +28,7 @@ let $content = document.querySelector("#content");
class ProseMirrorView {
constructor(target, content) {
let typingTimer;
let localDraft = localStorage.getItem(window.draftKey);
if (localDraft != null) {
content = localDraft;
@ -66,8 +67,9 @@ class ProseMirrorView {
],
}),
dispatchTransaction(transaction) {
let newState = this.state.apply(transaction);
const newContent = writeAsMarkdownSerializer
.serialize(transaction.doc)
.serialize(newState.doc)
// Replace all \\\ns ( not followed by a \n ) with \n
.replaceAll(/\\\n(?!\n)/g, "\n");
$content.value = newContent;
@ -76,8 +78,8 @@ class ProseMirrorView {
draft = "# " + $title.value + "\n\n";
}
draft += newContent;
localStorage.setItem(window.draftKey, draft);
let newState = this.state.apply(transaction);
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
this.updateState(newState);
},
});

File diff suppressed because one or more lines are too long