frontend/src/store/index.js
konrad 3874355953 Add easymde & markdown preview for editing descriptions and comments (#183)
Make sure no text from previous mounts is left in the editor text field

Make preview not the default when rendering descrition settings

Add option to show editor by default while still having the option to show preview

Add option to show editor by default while still having the option to show preview

Use editor component for edit labels

Use editor component for edit team

Use editor component for edit namespace

Use editor component for edit list

Use editor component for edit task

Make sure we find all checkboxes

Fix checking wrong checkbox

Make finding and replacing checkboxes in a function actually work

Add upading text with checked checkboxes

Lazy load editor

Remove preview since we have a better one

Make easymde smaller by default

Add image upload from comments

Rename easymde component to editor

Only show preview button if editing is currently active

Make editor tabs look better when commenting

Make comments meta look better

Don't try to update if the value was initially set

Use editor to render and edit comments

Make preview optional

Make tabs look better

Don't switch to preview after editing

Centralize attachment state

Render markdown by default

Fix title being "null"

Fix loading attachment images

Add standalone preview

Fix callback url

Add onsuccess callback

Add file upload

Fix date parsing once and for all

Add more props for upload and such

Fix editor border color

Fix changing text after mounting

Add link to guide

Fix sizing of icons

Add timeout for changes

Add all easymde icons

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: vikunja/frontend#183
2020-07-14 19:26:05 +00:00

102 lines
2.7 KiB
JavaScript

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import {CURRENT_LIST, ERROR_MESSAGE, HAS_TASKS, IS_FULLPAGE, LOADING, ONLINE} from './mutation-types'
import config from './modules/config'
import auth from './modules/auth'
import namespaces from './modules/namespaces'
import kanban from './modules/kanban'
import tasks from './modules/tasks'
import lists from './modules/lists'
import attachments from './modules/attachments'
import ListService from '../services/list'
import {setTitle} from '../helpers/setTitle'
export const store = new Vuex.Store({
modules: {
config,
auth,
namespaces,
kanban,
tasks,
lists,
attachments,
},
state: {
loading: false,
errorMessage: '',
online: true,
isFullpage: false,
// This is used to highlight the current list in menu for all list related views
currentList: {id: 0},
background: '',
hasTasks: false,
},
mutations: {
[LOADING](state, loading) {
state.loading = loading
},
[ERROR_MESSAGE](state, error) {
state.errorMessage = error
},
[ONLINE](state, online) {
state.online = online
},
[IS_FULLPAGE](state, fullpage) {
state.isFullpage = fullpage
},
[CURRENT_LIST](state, currentList) {
setTitle(currentList.title)
// Not sure if this is the right way to do it but hey, it works
if (
// List changed
currentList.id !== state.currentList.id ||
// The current list got a new background and didn't have one previously
(
currentList.backgroundInformation &&
!state.currentList.backgroundInformation
) ||
// The current list got a new background and had one previously
(
currentList.backgroundInformation &&
currentList.backgroundInformation.unsplashId &&
state.currentList &&
state.currentList.backgroundInformation &&
state.currentList.backgroundInformation.unsplashId &&
currentList.backgroundInformation.unsplashId !== state.currentList.backgroundInformation.unsplashId
) ||
// The new list has a background which is not an unsplash one and did not have one previously
(
currentList.backgroundInformation &&
currentList.backgroundInformation.type &&
state.currentList &&
state.currentList.backgroundInformation &&
state.currentList.backgroundInformation.type
)
) {
if (currentList.backgroundInformation) {
const listService = new ListService()
listService.background(currentList)
.then(b => {
state.background = b
})
.catch(e => {
console.error('Error getting background image for list', currentList.id, e)
})
} else {
state.background = null
}
}
state.currentList = currentList
},
[HAS_TASKS](state, hasTasks) {
state.hasTasks = hasTasks
}
},
})