added prettierrc

pull/383/head
Viktor Vaczi 4 years ago
parent 9a55d38e4b
commit 6049213661
  1. 12
      package-lock.json
  2. 4
      prose/.prettierrc
  3. 8
      prose/prose.js
  4. 2
      static/js/prose.bundle.js

12
package-lock.json generated

@ -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
}
}
}

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

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

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save