Browse Source

added prettierrc

pull/383/head
Viktor Vaczi 3 years ago
parent
commit
6049213661
4 changed files with 22 additions and 4 deletions
  1. +12
    -0
      package-lock.json
  2. +4
    -0
      prose/.prettierrc
  3. +5
    -3
      prose/prose.js
  4. +1
    -1
      static/js/prose.bundle.js

+ 12
- 0
package-lock.json 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
- 0
prose/.prettierrc View File

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

+ 5
- 3
prose/prose.js 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);
},
});


+ 1
- 1
static/js/prose.bundle.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save