page.js 3.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
import { defineStore } from 'pinia'

export const usePageStore = defineStore('page', {
  state: () => ({
    mode: 'view',
    editor: 'wysiwyg',
    editorMode: 'edit',
    id: 0,
    authorId: 0,
    authorName: 'Unknown',
    createdAt: '',
    description: 'How to install Wiki.js on Ubuntu 18.04 / 20.04',
    isPublished: true,
    showInTree: true,
    locale: 'en',
    path: '',
    publishEndDate: '',
    publishStartDate: '',
    tags: ['cities', 'canada'],
    title: 'Ubuntu',
    icon: 'lab la-empire',
    updatedAt: '',
    relations: [],
    scriptJsLoad: '',
    scriptJsUnload: '',
    scriptStyles: '',
    allowComments: false,
    allowContributions: true,
    allowRatings: true,
    showSidebar: true,
    showToc: true,
    showTags: true,
    tocDepth: {
      min: 1,
      max: 2
    },
    breadcrumbs: [
      {
        id: 1,
        title: 'Installation',
        icon: 'las la-file-alt',
        locale: 'en',
        path: 'installation'
      },
      {
        id: 2,
        title: 'Ubuntu',
        icon: 'lab la-ubuntu',
        locale: 'en',
        path: 'installation/ubuntu'
      }
    ],
    effectivePermissions: {
      comments: {
        read: false,
        write: false,
        manage: false
      },
      history: {
        read: false
      },
      source: {
        read: false
      },
      pages: {
        write: false,
        manage: false,
        delete: false,
        script: false,
        style: false
      },
      system: {
        manage: false
      }
    },
    commentsCount: 0,
    content: '',
    render: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
  }),
  getters: {},
  actions: {
    /**
     * PAGE - CREATE
     */
    pageCreate ({ editor, locale, path }) {
      // -> Editor View
      this.editor = editor
      this.editorMode = 'create'

      // if (['markdown', 'api'].includes(editor)) {
      //   commit('site/SET_SHOW_SIDE_NAV', false, { root: true })
      // } else {
      //   commit('site/SET_SHOW_SIDE_NAV', true, { root: true })
      // }

      // if (['markdown', 'channel', 'api'].includes(editor)) {
      //   commit('site/SET_SHOW_SIDEBAR', false, { root: true })
      // } else {
      //   commit('site/SET_SHOW_SIDEBAR', true, { root: true })
      // }

      // -> Page Data
      this.id = 0
      this.locale = locale || this.locale
      if (path) {
        this.path = path
      } else {
        this.path = this.path.length < 2 ? 'new-page' : `${this.path}/new-page`
      }
      this.title = ''
      this.description = ''
      this.icon = 'las la-file-alt'
      this.isPublished = false
      this.relations = []
      this.tags = []
      this.breadcrumbs = []

      this.content = ''
      this.render = ''

      // -> View Mode
      this.mode = 'edit'
    },
    generateToc () {

    }
  }
})