2019-07-19 13:51:57 -07:00
|
|
|
<template>
|
2019-12-19 21:50:50 -08:00
|
|
|
<!-- change class to .master-note-edit to have it popup on the screen -->
|
2019-07-29 00:22:47 -07:00
|
|
|
<div
|
2019-12-19 21:50:50 -08:00
|
|
|
id="InputNotes"
|
|
|
|
class="master-note-edit"
|
2019-07-29 00:22:47 -07:00
|
|
|
@keyup.esc="close"
|
|
|
|
:class="[{'size-down':(sizeDown == true)}, 'position-'+position ]"
|
2019-12-19 21:50:50 -08:00
|
|
|
:style="{ 'background-color':styleObject['noteBackground'], 'color':styleObject['noteText']}"
|
2019-07-29 00:22:47 -07:00
|
|
|
>
|
2019-09-10 11:10:11 -07:00
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
<!-- Loading indicator -->
|
2019-09-10 11:10:11 -07:00
|
|
|
<div v-if="loading" class="loading-note">
|
|
|
|
<div class="ui active dimmer">
|
2019-12-19 21:50:50 -08:00
|
|
|
<div class="ui text loader">{{loadingMessage}}</div>
|
2019-09-10 11:10:11 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-01-02 17:26:55 -08:00
|
|
|
<span class="note-status-indicator" v-on:click="save()">{{statusText}}</span>
|
2019-12-19 21:50:50 -08:00
|
|
|
|
2020-01-02 17:26:55 -08:00
|
|
|
<div class="tinymce-container">
|
|
|
|
<textarea :id="noteid+'-tinymce-editor'">{{noteText}}</textarea>
|
2019-09-10 11:10:11 -07:00
|
|
|
</div>
|
2019-07-29 00:22:47 -07:00
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
<color-picker
|
|
|
|
v-if="colorPickerVisible"
|
|
|
|
:location="colorPickerLocation"
|
|
|
|
@changeColor="onChangeColor"
|
|
|
|
:style-object="styleObject"
|
2019-07-29 00:22:47 -07:00
|
|
|
/>
|
|
|
|
|
2020-01-02 17:26:55 -08:00
|
|
|
<div v-if="$store.getters.getIsNoteSettingsOpen">
|
|
|
|
|
|
|
|
<div class="all-settings">
|
|
|
|
<div class="ui grid">
|
|
|
|
<div class="row">
|
|
|
|
<div class="sixteen wide column">
|
|
|
|
|
|
|
|
<note-tag-edit :noteId="noteid" :key="'tags-for-note-'+noteid"/><br>
|
|
|
|
|
|
|
|
<!-- close button -->
|
|
|
|
<div class="ui small compact basic icon button" v-on:click="$store.commit('toggleNoteSettingsPane')">
|
|
|
|
<i class="close icon"></i> Close Settings
|
|
|
|
</div>
|
|
|
|
<!-- Pin Button -->
|
|
|
|
<div @click="onToggleArchived" class="ui small compact basic icon button">
|
|
|
|
<i class="archive icon" :class="{green:(archived == 1)}"></i>
|
|
|
|
{{(archived == 1)?'Archived':'Archive'}}
|
|
|
|
</div>
|
|
|
|
<!-- archive button -->
|
|
|
|
<div @click="onTogglePinned" class="ui small compact basic icon button">
|
|
|
|
<i class="pin icon" :class="{green:(pinned == 1)}"></i>
|
|
|
|
{{(pinned == 1)?'Pinned':'Pin'}}
|
|
|
|
</div>
|
|
|
|
<!-- colors button -->
|
|
|
|
<span class="relative" v-on:click="showColorPicker">
|
|
|
|
<span class="ui small compact basic icon button">
|
|
|
|
<i class="paint brush icon"></i>
|
|
|
|
Colors
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<!-- attachment button -->
|
|
|
|
<div v-if="attachmentCount > 0" class="ui small compact basic icon button" v-on:click="openEditAttachment">
|
|
|
|
<i class="folder icon"></i> Attachments
|
|
|
|
</div>
|
|
|
|
<!-- file upload button -->
|
|
|
|
<file-upload-button :noteId="noteid" />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- <div class="shade" v-on:click="showAllSettings = false"></div> -->
|
|
|
|
</div>
|
2019-07-19 13:51:57 -07:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'InputNotes',
|
2019-07-20 16:07:22 -07:00
|
|
|
props: [ 'noteid', 'position' ],
|
2019-07-19 13:51:57 -07:00
|
|
|
components:{
|
2019-12-19 21:50:50 -08:00
|
|
|
'note-tag-edit': require('@/components/NoteTagEdit.vue').default,
|
|
|
|
'color-picker': require('@/components/ColorPicker.vue').default,
|
|
|
|
'file-upload-button': require('@/components/FileUploadButton.vue').default,
|
2020-01-02 17:26:55 -08:00
|
|
|
'delete-button': require('@/components/NoteDeleteButtonComponent.vue').default,
|
2019-07-19 13:51:57 -07:00
|
|
|
},
|
|
|
|
data(){
|
|
|
|
return {
|
2019-09-10 11:10:11 -07:00
|
|
|
loading: true,
|
|
|
|
loadingMessage: 'Loading Note',
|
2019-07-19 13:51:57 -07:00
|
|
|
currentNoteId: 0,
|
|
|
|
noteText: '',
|
2019-07-29 00:22:47 -07:00
|
|
|
statusText: 'Saved',
|
2019-07-19 13:51:57 -07:00
|
|
|
lastNoteHash: null,
|
2019-07-24 11:06:50 -07:00
|
|
|
saveDebounce: null, //Prevent save from being called numerous times quickly
|
2019-07-19 13:51:57 -07:00
|
|
|
updated: 'Never',
|
|
|
|
editDebounce: null,
|
2019-12-19 21:50:50 -08:00
|
|
|
keyPressesCounter: 0, //Determen keys pressed between saves
|
2019-09-10 11:10:11 -07:00
|
|
|
pinned: 0,
|
|
|
|
archived: 0,
|
2019-12-19 21:50:50 -08:00
|
|
|
attachmentCount: 0,
|
|
|
|
styleObject: { 'noteText':null,'noteBackground':null, 'noteIcon':null, 'iconColor':null }, //Style object. Determines colors and badges
|
|
|
|
|
|
|
|
sizeDown: false, //Used to animate close state
|
|
|
|
colorPickerVisible: false,
|
|
|
|
colorPickerLocation: null,
|
|
|
|
|
|
|
|
tinymce: null, //Initialized editor instance
|
2020-01-02 17:26:55 -08:00
|
|
|
|
|
|
|
//Settings vars
|
|
|
|
showAllSettings: true,
|
|
|
|
lastVisibilityState: null,
|
2019-07-19 13:51:57 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
noteid:function(newVal, oldVal){
|
|
|
|
|
|
|
|
if(newVal == this.currentNoteId){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(newVal == oldVal){
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.currentNoteId = newVal
|
|
|
|
this.loadNote(this.currentNoteId)
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount(){
|
2020-01-02 17:26:55 -08:00
|
|
|
//Load tinymce into the page only do it once
|
|
|
|
if(document.querySelectorAll('[data-mceload]').length == 0){
|
|
|
|
let tinyMceIncluder = document.createElement('script')
|
|
|
|
tinyMceIncluder.setAttribute('src', '/api/static/assets/tinymce/tinymce.min.js')
|
|
|
|
tinyMceIncluder.setAttribute('data-mceload','loaded')
|
|
|
|
document.head.appendChild(tinyMceIncluder)
|
|
|
|
}
|
2019-07-19 13:51:57 -07:00
|
|
|
},
|
|
|
|
beforeDestroy(){
|
2020-01-02 17:26:55 -08:00
|
|
|
|
|
|
|
document.removeEventListener('visibilitychange', this.visibiltyChangeAction)
|
|
|
|
|
|
|
|
this.$off() // Remove all event listeners
|
|
|
|
this.$bus.$off()
|
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
//Trash editor instance on close
|
|
|
|
this.tinymce.remove()
|
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
},
|
|
|
|
mounted: function() {
|
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
//Change TinyMce styles on nightmored change
|
|
|
|
this.$bus.$on('toggle_night_mode', this.setEditorTextColor )
|
|
|
|
|
2020-01-02 17:26:55 -08:00
|
|
|
document.addEventListener('visibilitychange', this.checkForUpdatedNote)
|
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
this.$nextTick(() => {
|
|
|
|
this.loadNote(this.noteid)
|
|
|
|
})
|
2019-07-19 13:51:57 -07:00
|
|
|
},
|
|
|
|
methods: {
|
2019-12-19 21:50:50 -08:00
|
|
|
initTinyMce(){
|
|
|
|
|
|
|
|
// image_list: [
|
|
|
|
// {title: 'My image 1', value: 'https://www.tinymce.com/my1.gif'},
|
|
|
|
// {title: 'My image 2', value: 'http://www.moxiecode.com/my2.gif'}
|
|
|
|
// ]
|
|
|
|
|
2020-01-02 17:26:55 -08:00
|
|
|
//Default plugin options for big browsers
|
|
|
|
let toolbarOptions = 'customCloseButton | mceTogglePinned | forecolor styleselect | bold italic underline | link | bullist numlist | outdent indent table | h | image'
|
|
|
|
let pluginOptions = 'paste, link, code, lists, table, hr, image'
|
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
//Tweak doc height for mobile
|
2020-01-02 17:26:55 -08:00
|
|
|
let docHeight = 'calc(100vh - 1px)'
|
2019-12-19 21:50:50 -08:00
|
|
|
if(this.$store.getters.getIsUserOnMobile){
|
2020-01-02 17:26:55 -08:00
|
|
|
docHeight = 'calc(100vh - 1px)'
|
|
|
|
|
|
|
|
toolbarOptions = 'customCloseButton | bullist numlist | mceTogglePinned'
|
|
|
|
pluginOptions = 'lists'
|
2019-07-21 09:28:07 -07:00
|
|
|
}
|
2019-12-19 21:50:50 -08:00
|
|
|
|
|
|
|
//setup skin as dark if night mode is enabled
|
|
|
|
let skin = 'oxide'
|
|
|
|
if(this.$store.getters.getIsNightMode){
|
|
|
|
skin = 'oxide-dark'
|
|
|
|
}
|
|
|
|
|
|
|
|
const editorId = '#'+this.noteid+'-tinymce-editor'
|
2020-01-02 17:26:55 -08:00
|
|
|
let vm = this
|
2019-12-19 21:50:50 -08:00
|
|
|
|
|
|
|
//Globally defined included in index HTML
|
|
|
|
tinymce.init({
|
|
|
|
selector: editorId,
|
2020-01-02 17:26:55 -08:00
|
|
|
toolbar: toolbarOptions,
|
|
|
|
plugins: pluginOptions,
|
2019-12-19 21:50:50 -08:00
|
|
|
browser_spellcheck: true,
|
|
|
|
menubar: false,
|
|
|
|
branding: false,
|
|
|
|
statusbar: false,
|
|
|
|
height: docHeight,
|
|
|
|
skin: skin,
|
|
|
|
contextmenu: false,
|
|
|
|
init_instance_callback: this.editorInitCallback,
|
|
|
|
imagetools_toolbar: "imageoptions",
|
2020-01-02 17:26:55 -08:00
|
|
|
setup: editor => {
|
|
|
|
//Add custom buttons to tinymce instance
|
|
|
|
editor.ui.registry.addButton('customCloseButton', {
|
|
|
|
text: 'Close',
|
|
|
|
icon: 'close',
|
|
|
|
onAction: function (_) {
|
|
|
|
vm.close()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
//Add custom buttons to tinymce instance
|
|
|
|
editor.ui.registry.addButton('mceTogglePinned', {
|
|
|
|
text: 'Note Settings',
|
|
|
|
icon: 'settings',
|
|
|
|
onAction: function (_) {
|
|
|
|
vm.$store.commit('toggleNoteSettingsPane')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2019-12-19 21:50:50 -08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
editorInitCallback(editor){
|
|
|
|
|
|
|
|
this.loading = false //Turn off loading screed when editor is loaded
|
|
|
|
this.tinymce = editor
|
|
|
|
|
|
|
|
this.setEditorTextColor()
|
|
|
|
|
|
|
|
editor
|
|
|
|
.on('Change', this.onKeyup )
|
|
|
|
.on('keyup', this.onKeyup )
|
|
|
|
.on('blur', this.save )
|
|
|
|
|
|
|
|
},
|
|
|
|
setEditorTextColor(){
|
|
|
|
//Only Set editor text color, background is transparent and set on parent element
|
|
|
|
|
|
|
|
//There may be scenarios where editor has not been set up
|
|
|
|
if(this.tinymce){
|
|
|
|
//Set editor color to color from app, change with night mode
|
|
|
|
this.tinymce.getBody().style.color = getComputedStyle(document.documentElement)
|
|
|
|
.getPropertyValue('--text_color');
|
|
|
|
|
|
|
|
//Overwrite set color if theme is set for note.
|
|
|
|
if(this.styleObject && this.styleObject.noteText){
|
|
|
|
this.tinymce.getBody().style.color = this.styleObject.noteText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-02 17:26:55 -08:00
|
|
|
},
|
|
|
|
setText(inText){
|
|
|
|
return this.tinymce.setContent(inText)
|
2019-12-19 21:50:50 -08:00
|
|
|
},
|
|
|
|
getText(){
|
|
|
|
//Return text from tinyMce Editor
|
|
|
|
return this.tinymce.getContent()
|
|
|
|
},
|
|
|
|
showColorPicker(event){
|
|
|
|
this.colorPickerVisible = !this.colorPickerVisible
|
|
|
|
this.colorPickerLocation = {'x':event.clientX, 'y':event.clientY}
|
|
|
|
},
|
|
|
|
openEditAttachment(){
|
|
|
|
this.$router.push('/attachments/note/'+this.currentNoteId)
|
2019-07-21 09:28:07 -07:00
|
|
|
},
|
2019-09-10 11:10:11 -07:00
|
|
|
onTogglePinned(){
|
|
|
|
if(this.pinned == 0){
|
|
|
|
this.pinned = 1
|
|
|
|
} else {
|
|
|
|
this.pinned = 0;
|
|
|
|
}
|
|
|
|
//Update last note hash, this will tell note to save next update
|
|
|
|
this.lastNoteHash = 0
|
2019-12-19 21:50:50 -08:00
|
|
|
this.save()
|
2019-09-10 11:10:11 -07:00
|
|
|
},
|
|
|
|
onToggleArchived(){
|
|
|
|
if(this.archived == 0){
|
|
|
|
this.archived = 1
|
|
|
|
} else {
|
|
|
|
this.archived = 0;
|
|
|
|
}
|
|
|
|
//Update last note hash, this will tell note to save next update
|
|
|
|
this.lastNoteHash = 0
|
2019-12-19 21:50:50 -08:00
|
|
|
this.save()
|
2019-09-10 11:10:11 -07:00
|
|
|
},
|
2019-12-19 21:50:50 -08:00
|
|
|
onChangeColor(newStyleObject){
|
|
|
|
|
|
|
|
//Set new style object for note, page will use some styles, styles will be saved to database
|
|
|
|
this.styleObject = newStyleObject
|
|
|
|
|
|
|
|
this.setEditorTextColor()
|
2019-07-21 09:28:07 -07:00
|
|
|
|
|
|
|
this.lastNoteHash = 0 //Update hash to force note update on next save
|
|
|
|
this.save()
|
|
|
|
},
|
2019-07-19 13:51:57 -07:00
|
|
|
loadNote(noteId){
|
2019-09-10 11:10:11 -07:00
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
let vm = this
|
2019-09-10 11:10:11 -07:00
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
let doing = ['Loading','Loading','Getting','Fetching','Grabbing','Sequencing','Organizing','Untangling','Processing','Refining','Extracting','Fusing','Pruning','Expanding','Enlarging','Transfiguring','Quantizing','Ingratiating','Lumping']
|
2019-09-10 11:10:11 -07:00
|
|
|
let thing = ['Note','Note','Note','Note','Data','Text','Document','Algorithm','Buffer','Client','Download','File','Frame','Graphics','Hardware','HTML','Interface','Logic','Mainframe','Memory','Media','Nodes','Network','Chaos']
|
|
|
|
let p1 = doing[Math.floor(Math.random() * doing.length)]
|
|
|
|
let p2 = thing[Math.floor(Math.random() * thing.length)]
|
|
|
|
vm.loadingMessage = p1 + ' ' + p2
|
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
//Component is activated with NoteId in place, lookup text with associated ID
|
|
|
|
if(this.$store.getters.getLoggedIn){
|
2019-07-30 12:21:12 -07:00
|
|
|
axios.post('/api/note/get', {'noteId': noteId})
|
2019-07-19 13:51:57 -07:00
|
|
|
.then(response => {
|
2019-07-21 09:28:07 -07:00
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
//Set up local data
|
|
|
|
vm.currentNoteId = noteId
|
|
|
|
vm.noteText = response.data.text
|
|
|
|
vm.updated = response.data.updated
|
|
|
|
vm.lastNoteHash = vm.hashString(response.data.text)
|
2019-12-19 21:50:50 -08:00
|
|
|
if(response.data.color){
|
|
|
|
vm.styleObject = JSON.parse(response.data.color) //Load styles json from DB
|
|
|
|
}
|
|
|
|
|
2019-09-10 11:10:11 -07:00
|
|
|
if(response.data.pinned != null){
|
|
|
|
vm.pinned = response.data.pinned
|
|
|
|
}
|
|
|
|
vm.archived = response.data.archived
|
2019-12-19 21:50:50 -08:00
|
|
|
vm.attachmentCount = response.data.attachment_count
|
2019-07-24 11:06:50 -07:00
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
vm.$nextTick(() => {
|
2019-12-19 21:50:50 -08:00
|
|
|
this.initTinyMce()
|
2019-07-19 13:51:57 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
console.log('Could not fetch note')
|
|
|
|
}
|
|
|
|
},
|
2019-12-19 21:50:50 -08:00
|
|
|
onKeyup(){
|
2019-07-19 13:51:57 -07:00
|
|
|
|
2019-12-19 21:50:50 -08:00
|
|
|
this.statusText = 'Modified'
|
2019-07-19 13:51:57 -07:00
|
|
|
|
2019-07-21 09:28:07 -07:00
|
|
|
//Each note, save after 5 seconds, focus lost or 30 characters typed.
|
2019-12-19 21:50:50 -08:00
|
|
|
clearTimeout(this.editDebounce)
|
|
|
|
this.editDebounce = setTimeout(() => {
|
|
|
|
this.save()
|
2019-07-21 09:28:07 -07:00
|
|
|
}, 5000)
|
2019-12-19 21:50:50 -08:00
|
|
|
|
2019-07-29 00:22:47 -07:00
|
|
|
//Save after 30 keystrokes
|
2019-12-19 21:50:50 -08:00
|
|
|
this.keyPressesCounter = (this.keyPressesCounter + 1)
|
|
|
|
if(this.keyPressesCounter > 30){
|
|
|
|
this.keyPressesCounter = 0
|
|
|
|
this.save()
|
2019-07-21 09:28:07 -07:00
|
|
|
}
|
|
|
|
},
|
2019-07-19 13:51:57 -07:00
|
|
|
save(){
|
2019-07-29 00:22:47 -07:00
|
|
|
return new Promise((resolve, reject) => {
|
2019-12-19 21:50:50 -08:00
|
|
|
//Clear other debounced events to prevent double calling of save
|
2020-01-02 17:26:55 -08:00
|
|
|
// clearTimeout(this.editDebounce)
|
2019-07-29 00:22:47 -07:00
|
|
|
|
|
|
|
//Don't save note if its hash doesn't change
|
2019-12-19 21:50:50 -08:00
|
|
|
const currentNoteText = this.getText()
|
|
|
|
if( this.lastNoteHash == this.hashString( currentNoteText )){
|
2020-01-02 17:26:55 -08:00
|
|
|
this.statusText = 'Saved'
|
2019-12-19 21:50:50 -08:00
|
|
|
return resolve(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
//If user accidentally clears note, it won't delete it
|
|
|
|
if(currentNoteText == ''){
|
|
|
|
this.statusText = 'Empty'
|
|
|
|
console.log('Prevented from saving empty note.')
|
|
|
|
return resolve(true)
|
2019-07-29 00:22:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const postData = {
|
|
|
|
'noteId':this.currentNoteId,
|
2019-12-19 21:50:50 -08:00
|
|
|
'text': currentNoteText,
|
|
|
|
'color': JSON.stringify(this.styleObject), //Save little json color object
|
2019-09-10 11:10:11 -07:00
|
|
|
'pinned': this.pinned,
|
|
|
|
'archived':this.archived,
|
2019-07-29 00:22:47 -07:00
|
|
|
}
|
2019-07-20 16:07:22 -07:00
|
|
|
|
2019-07-29 00:22:47 -07:00
|
|
|
let vm = this
|
2019-12-19 21:50:50 -08:00
|
|
|
//Debounce save to prevent spamming
|
|
|
|
// clearTimeout(this.saveDebounce)
|
|
|
|
// this.saveDebounce = setTimeout(() => {
|
2019-07-29 00:22:47 -07:00
|
|
|
//Only notify user if saving - may help with debugging in the future
|
|
|
|
vm.statusText = 'Saving'
|
2019-07-30 12:21:12 -07:00
|
|
|
axios.post('/api/note/update', postData).then( response => {
|
2019-07-29 00:22:47 -07:00
|
|
|
vm.statusText = 'Saved'
|
|
|
|
vm.updated = Math.round((+new Date)/1000)
|
|
|
|
|
|
|
|
//Update last saved note hash
|
2019-12-19 21:50:50 -08:00
|
|
|
vm.lastNoteHash = vm.hashString( currentNoteText )
|
|
|
|
return resolve(true)
|
2019-07-29 00:22:47 -07:00
|
|
|
})
|
2019-12-19 21:50:50 -08:00
|
|
|
// }, 300)
|
2019-07-29 00:22:47 -07:00
|
|
|
})
|
2019-07-24 11:06:50 -07:00
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
},
|
2020-01-02 17:26:55 -08:00
|
|
|
checkForUpdatedNote(){
|
|
|
|
|
|
|
|
//If user leaves page then returns to page, reload the first batch
|
|
|
|
if(this.lastVisibilityState == 'hidden' && document.visibilityState == 'visible'){
|
|
|
|
console.log('Checking for changes is note data')
|
|
|
|
const postData = {
|
|
|
|
noteId:this.currentNoteId,
|
|
|
|
text:this.getText(),
|
|
|
|
updated: this.updated
|
|
|
|
}
|
|
|
|
|
|
|
|
axios.post('/api/note/difftext', postData)
|
|
|
|
.then( ({data}) => {
|
|
|
|
|
|
|
|
//Don't do anything if nothing has changed
|
|
|
|
if(data == ''){ return }
|
|
|
|
|
|
|
|
if(data.diffs > 0){
|
|
|
|
//Update text and last updated time for note
|
|
|
|
this.setText(data.updatedText)
|
|
|
|
this.updated = data.updated
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//Track visibility state
|
|
|
|
this.lastVisibilityState = document.visibilityState
|
|
|
|
},
|
2019-07-19 13:51:57 -07:00
|
|
|
hashString(text){
|
2019-12-19 21:50:50 -08:00
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
var hash = 0;
|
|
|
|
if (text.length == 0) {
|
|
|
|
return hash;
|
|
|
|
}
|
2019-12-19 21:50:50 -08:00
|
|
|
|
|
|
|
//Simplified for speed
|
|
|
|
return text.length
|
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
for (let i = 0; i < text.length; i++) {
|
|
|
|
let char = text.charCodeAt(i);
|
|
|
|
hash = ((hash<<5)-hash)+char;
|
|
|
|
hash = hash & hash; // Convert to 32bit integer
|
|
|
|
}
|
2019-12-19 21:50:50 -08:00
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
return hash;
|
|
|
|
},
|
|
|
|
close(){
|
2019-12-19 21:50:50 -08:00
|
|
|
|
|
|
|
// this.loading = true
|
|
|
|
// this.loadingMessage = 'Save and Close'
|
|
|
|
|
2019-07-30 13:46:24 -07:00
|
|
|
this.save().then( result => {
|
2019-12-19 21:50:50 -08:00
|
|
|
|
|
|
|
this.sizeDown = true
|
|
|
|
//This timeout allows animation to play before closing
|
|
|
|
setTimeout(() => {
|
2020-01-02 17:26:55 -08:00
|
|
|
this.$bus.$emit('close_active_note', {position: this.position, noteId: this.noteid})
|
2019-07-30 13:46:24 -07:00
|
|
|
return
|
2019-12-19 21:50:50 -08:00
|
|
|
}, 300)
|
2019-07-29 00:22:47 -07:00
|
|
|
})
|
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style type="text/css" scoped>
|
2019-07-21 09:28:07 -07:00
|
|
|
|
2020-01-02 17:26:55 -08:00
|
|
|
/*Settings manager styles */
|
|
|
|
.all-settings {
|
|
|
|
position: absolute;
|
|
|
|
bottom: -5px;
|
|
|
|
right: 10px;
|
|
|
|
left: 10px;
|
|
|
|
z-index: 99;
|
|
|
|
border: 1px solid;
|
|
|
|
background-color: var(--background_color);
|
|
|
|
border-color: var(--border_color);
|
|
|
|
box-sizing: border-box;
|
|
|
|
border-radius: 7px;
|
|
|
|
box-shadow: 0px 3px 7px 0px rgba(140,140,140,1);
|
|
|
|
padding: 1em;
|
|
|
|
}
|
|
|
|
/*End Settings manager styles */
|
|
|
|
|
|
|
|
.tinymce-container {
|
|
|
|
/* Uncomment this to see the */
|
|
|
|
/*border-bottom: 2px solid green !important;*/
|
|
|
|
}
|
|
|
|
|
2019-09-10 11:10:11 -07:00
|
|
|
.note-top-menu {
|
|
|
|
width: 100%;
|
|
|
|
display: inline-block;
|
2019-12-19 21:50:50 -08:00
|
|
|
height: 37px;
|
|
|
|
border-left: 3px solid var(--border_color);
|
|
|
|
}
|
|
|
|
.note-top-menu .ui.basic.button {
|
|
|
|
border-radius: 0;
|
|
|
|
border: none;
|
|
|
|
border-right: 1px solid var(--border_color);
|
|
|
|
margin: 0px -2px;
|
|
|
|
padding-left: 15px;
|
|
|
|
padding-right: 15px;
|
2019-09-10 11:10:11 -07:00
|
|
|
}
|
2019-07-21 09:28:07 -07:00
|
|
|
|
|
|
|
/* container styles change based on mobile and number of open screens */
|
2019-07-19 13:51:57 -07:00
|
|
|
.master-note-edit {
|
|
|
|
position: fixed;
|
|
|
|
bottom: 0;
|
2019-07-29 00:22:47 -07:00
|
|
|
background: var(--background_color);
|
|
|
|
/*color: var(--text_color);*/
|
2019-07-21 09:28:07 -07:00
|
|
|
height: 100vh;
|
2019-07-19 13:51:57 -07:00
|
|
|
box-shadow: 0px 0px 5px 2px rgba(140,140,140,1);
|
2019-09-10 11:10:11 -07:00
|
|
|
z-index: 1001;
|
2019-12-19 21:50:50 -08:00
|
|
|
/*overflow-x: scroll;*/
|
2019-09-10 11:10:11 -07:00
|
|
|
}
|
|
|
|
.loading-note {
|
|
|
|
position: absolute;
|
2019-12-19 21:50:50 -08:00
|
|
|
top: 0;
|
2019-09-10 11:10:11 -07:00
|
|
|
left: 0;
|
|
|
|
right: 0;
|
2019-12-19 21:50:50 -08:00
|
|
|
bottom: 0;
|
2019-07-19 13:51:57 -07:00
|
|
|
}
|
2019-07-20 16:07:22 -07:00
|
|
|
/* One note open, in the middle of the screen */
|
|
|
|
.master-note-edit.position-0 {
|
2019-12-19 21:50:50 -08:00
|
|
|
left: 50%;
|
2019-09-10 11:10:11 -07:00
|
|
|
right: 0;
|
2019-07-20 16:07:22 -07:00
|
|
|
}
|
2019-07-21 09:28:07 -07:00
|
|
|
@media only screen and (max-width: 740px) {
|
|
|
|
.master-note-edit.position-0 {
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-20 16:07:22 -07:00
|
|
|
/* Two Notes Open, each takes up 50% of the space */
|
|
|
|
.master-note-edit.position-1 {
|
|
|
|
left: 50%;
|
|
|
|
right: 0%;
|
|
|
|
}
|
|
|
|
.master-note-edit.position-2 {
|
|
|
|
left: 0%;
|
|
|
|
right: 50%;
|
|
|
|
}
|
2019-07-19 13:51:57 -07:00
|
|
|
|
2019-07-29 00:22:47 -07:00
|
|
|
.size-down {
|
2019-07-30 13:27:26 -07:00
|
|
|
animation: size-down 0.5s ease;
|
2019-07-29 00:22:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes size-down {
|
|
|
|
0% {
|
2019-12-19 21:50:50 -08:00
|
|
|
/*opacity: 1;*/
|
|
|
|
/*top: 0;*/
|
2019-07-29 00:22:47 -07:00
|
|
|
top: 0;
|
|
|
|
}
|
|
|
|
100% {
|
2019-12-19 21:50:50 -08:00
|
|
|
/*opacity: 0;*/
|
|
|
|
/*top: 30vh;*/
|
|
|
|
top: 150vh;
|
2019-07-29 00:22:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-19 13:51:57 -07:00
|
|
|
</style>
|