* Fixed cursor clicking ToDo lists clicking to early
* Added login form to home page with focus on load * Tags update after editing tags from title card * Fixed uploading of images/files * Fixed images not appearing when opening images tab * Search hits all categories on search, like archived * Got rid of brand icons to reduce size * Got rid of DiffPatchMatch and Crypto from note input panel to reduce size * Disabled animation on io events so they don't annoy the shit out of people on other computers
This commit is contained in:
@@ -153,7 +153,7 @@
|
||||
/>
|
||||
|
||||
<!-- Side slide menus for colors, tags, images and other options -->
|
||||
<side-slide-menu v-show="colors" v-on:close="colors = false" name="colors">
|
||||
<side-slide-menu v-if="colors" v-on:close="colors = false" name="colors">
|
||||
<color-picker
|
||||
@changeColor="onChangeColor"
|
||||
@close="colors = false"
|
||||
@@ -161,13 +161,13 @@
|
||||
/>
|
||||
</side-slide-menu>
|
||||
|
||||
<side-slide-menu v-show="tags" v-on:close="tags = false" name="tags" :style-object="styleObject">
|
||||
<side-slide-menu v-if="tags" v-on:close="tags = false" name="tags" :style-object="styleObject">
|
||||
<div class="ui basic segment">
|
||||
<note-tag-edit :noteId="noteid" :key="'tags-for-note-'+noteid"/>
|
||||
</div>
|
||||
</side-slide-menu>
|
||||
|
||||
<side-slide-menu v-show="images" v-on:close="images = false" name="images" :style-object="styleObject">
|
||||
<side-slide-menu v-if="images" v-on:close="images = false" name="images" :style-object="styleObject">
|
||||
<div class="ui basic segment">
|
||||
<simple-attachment-note
|
||||
v-on:close="images = false"
|
||||
@@ -233,8 +233,8 @@
|
||||
<script>
|
||||
|
||||
import axios from 'axios'
|
||||
const crypto = require('crypto')
|
||||
const DiffMatchPatch = require('../../../server/helpers/DiffMatchPatch')
|
||||
// const crypto = require('crypto')
|
||||
// const DiffMatchPatch = require('../../../server/helpers/DiffMatchPatch')
|
||||
|
||||
export default {
|
||||
name: 'InputNotes',
|
||||
@@ -443,19 +443,14 @@
|
||||
|
||||
let el = e.target
|
||||
|
||||
//Adjust ofset by 40 px
|
||||
let correction = 40
|
||||
|
||||
//Determine if element was clicked or area before it, before means checkbox was clicked
|
||||
if (e.offsetX > e.target.offsetLeft - correction) {
|
||||
//Element was clicked
|
||||
} else {
|
||||
|
||||
//Will hide keyboard if clicked, much better for mobile
|
||||
this.editor.blur()
|
||||
//If the offset is triggered with a negative offset, it means the before element was clicked
|
||||
if(e.offsetX < -5){
|
||||
//Will hide keyboard if clicked on mobile
|
||||
if(this.$store.getters.getIsUserOnMobile){
|
||||
this.editor.blur()
|
||||
}
|
||||
|
||||
//Area before element was clicked, they clicked the checkbox
|
||||
this.onKeyup()
|
||||
if (el.className === 'active'){
|
||||
el.className = 'inactive';
|
||||
} else {
|
||||
@@ -869,171 +864,6 @@
|
||||
console.log('Could not fetch note')
|
||||
}
|
||||
},
|
||||
diffText(){
|
||||
|
||||
return
|
||||
|
||||
// dont emit to one user
|
||||
if(this.usersOnNote <= 1){
|
||||
return
|
||||
}
|
||||
|
||||
//Post latest diff to server, server will emit change event to all connected clients
|
||||
// clearTimeout(this.emitChangeDebounce)
|
||||
this.emitChangeDebounce = setTimeout(i => {
|
||||
|
||||
//caldulate text diff
|
||||
let oldText = this.diffNoteText
|
||||
let newText = this.getText()
|
||||
|
||||
if(oldText == newText){
|
||||
return
|
||||
}
|
||||
|
||||
const dmp = new DiffMatchPatch.diff_match_patch()
|
||||
const diff = dmp.diff_main(oldText, newText)
|
||||
// dmp.diff_cleanupSemantic(diff)
|
||||
const patch_list = dmp.patch_make(oldText, newText, diff);
|
||||
const patch_text = dmp.patch_toText(patch_list);
|
||||
|
||||
|
||||
var patches = dmp.patch_fromText(patch_text);
|
||||
var results = dmp.patch_apply(patches, oldText);
|
||||
|
||||
const computedText = results[0]
|
||||
|
||||
//Save computed diff text
|
||||
this.noteText = computedText
|
||||
this.diffNoteText = computedText
|
||||
|
||||
if(patch_text == ''){
|
||||
return
|
||||
}
|
||||
|
||||
// console.log(patch_text)
|
||||
this.$io.emit('note_diff', {
|
||||
id: this.rawTextId,
|
||||
diff: patch_text
|
||||
})
|
||||
|
||||
|
||||
}, 5)
|
||||
},
|
||||
patchText(patch_text){
|
||||
|
||||
return
|
||||
|
||||
//
|
||||
// Capture x,y of caret and position into string
|
||||
//
|
||||
|
||||
let currentSelection = this.editor.getSelection()
|
||||
let lineText = currentSelection.startContainer.textContent
|
||||
// console.log(lineText)
|
||||
let cursorOffset = parseInt(currentSelection.startOffset) //number of characters in
|
||||
let path = this.xpath(currentSelection.commonAncestorContainer.parentElement)
|
||||
// console.log(path)
|
||||
|
||||
|
||||
//
|
||||
//Set up text to process diff
|
||||
//
|
||||
|
||||
let currentText = this.editor._getHTML()
|
||||
const startingLines = (currentText.match(/<br>/g) || '').length + 1
|
||||
// console.log('1')
|
||||
|
||||
const dmp = new DiffMatchPatch.diff_match_patch()
|
||||
var patches = dmp.patch_fromText(patch_text);
|
||||
var results = dmp.patch_apply(patches, currentText);
|
||||
let newText = results[0]
|
||||
// console.log('2')
|
||||
|
||||
this.noteText = newText
|
||||
this.diffNoteText = newText
|
||||
// console.log('3')
|
||||
// this.editor._setHTML(newText)
|
||||
this.editor.setHTML(newText)
|
||||
|
||||
// console.log('4')
|
||||
|
||||
//
|
||||
// I user hasn't selected the document, we are done here
|
||||
// @TODO add code to halt execution
|
||||
//
|
||||
|
||||
const endingLines = (newText.match(/<br>/g) || '').length + 1
|
||||
|
||||
// if(this.pastFocusedNode != null || true){
|
||||
setTimeout( ()=>{
|
||||
|
||||
var root = this.editor.getRoot()
|
||||
//Get node under current x,y on dom (may break on scroll)
|
||||
// let node = document.elementFromPoint(mouse.x, mouse.y)
|
||||
let node = this.getElementByXPath(path)
|
||||
|
||||
if(node.firstChild){
|
||||
node = node.firstChild
|
||||
}
|
||||
|
||||
//If the number of lines changed
|
||||
if(startingLines != endingLines){
|
||||
|
||||
//Line diff may be +1 or -1
|
||||
let lineDiff = endingLines - startingLines
|
||||
console.log('Line Diff => ', lineDiff)
|
||||
|
||||
//Pull out node number from path
|
||||
var nodeNumber = path.match(/\d+/)
|
||||
let modifyNode = null
|
||||
if(nodeNumber.length == 1){
|
||||
modifyNode = parseInt(nodeNumber[0])
|
||||
}
|
||||
|
||||
path = path.replace(modifyNode, modifyNode + lineDiff )
|
||||
console.log(path)
|
||||
let maybeNext = this.getElementByXPath(path)
|
||||
if(maybeNext && maybeNext.firstChild){
|
||||
maybeNext = maybeNext.firstChild
|
||||
}
|
||||
|
||||
if(maybeNext && maybeNext.textContent == lineText){
|
||||
node = maybeNext
|
||||
console.log('The Node Moved!')
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('Targeting Node')
|
||||
// console.log(node)
|
||||
|
||||
//Create and set range
|
||||
let squireRange = this.editor.createRange(node, cursorOffset)
|
||||
squireRange.collapse(true)
|
||||
this.editor.setSelection(squireRange)
|
||||
// console.log('cursor set')
|
||||
|
||||
}, 20)
|
||||
// }
|
||||
},
|
||||
xpath(el) {
|
||||
//Skip things we can't use
|
||||
if (typeof el == "string") return document.evaluate(el, document, null, 0, null)
|
||||
if (!el || el.nodeType != 1) return ''
|
||||
|
||||
//Anchor xpath using Ids or test-ids
|
||||
const testId = el.getAttribute('test-id')
|
||||
if (el.id) return "//*[@id='" + el.id + "']"
|
||||
|
||||
//Continue to build path
|
||||
const sames = [].filter.call(el.parentNode.children, function (x) { return x.tagName == el.tagName })
|
||||
return this.xpath(el.parentNode) + '/' + el.tagName.toLowerCase() + (sames.length > 1 ? '['+([].indexOf.call(sames, el)+1)+']' : '')
|
||||
},
|
||||
getElementByXPath(xpath){
|
||||
|
||||
return new XPathEvaluator()
|
||||
.createExpression(xpath)
|
||||
.evaluate(document, XPathResult.FIRST_ORDERED_NODE_TYPE) .singleNodeValue
|
||||
},
|
||||
onKeyup(){
|
||||
|
||||
this.statusText = 'modified'
|
||||
@@ -1198,7 +1028,7 @@
|
||||
|
||||
//Server will hand deliver diffs from other notes to this one
|
||||
this.$io.on('incoming_diff', incomingDiffData => {
|
||||
this.patchText(incomingDiffData)
|
||||
// this.patchText(incomingDiffData)
|
||||
})
|
||||
},
|
||||
titleResize(){
|
||||
|
Reference in New Issue
Block a user