page.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <template lang="pug">
  2. v-app(v-scroll='upBtnScroll', :dark='$vuetify.theme.dark', :class='$vuetify.rtl ? `is-rtl` : `is-ltr`')
  3. nav-header(v-if='!printView')
  4. v-navigation-drawer(
  5. v-if='navMode !== `NONE` && !printView'
  6. :class='$vuetify.theme.dark ? `grey darken-4-d4` : `primary`'
  7. dark
  8. app
  9. clipped
  10. mobile-breakpoint='600'
  11. :temporary='$vuetify.breakpoint.smAndDown'
  12. v-model='navShown'
  13. :right='$vuetify.rtl'
  14. )
  15. vue-scroll(:ops='scrollStyle')
  16. nav-sidebar(:color='$vuetify.theme.dark ? `grey darken-4-d4` : `primary`', :items='sidebarDecoded', :nav-mode='navMode')
  17. v-fab-transition(v-if='navMode !== `NONE`')
  18. v-btn(
  19. fab
  20. color='primary'
  21. fixed
  22. bottom
  23. :right='$vuetify.rtl'
  24. :left='!$vuetify.rtl'
  25. small
  26. @click='navShown = !navShown'
  27. v-if='$vuetify.breakpoint.mdAndDown'
  28. v-show='!navShown'
  29. )
  30. v-icon mdi-menu
  31. v-main(ref='content')
  32. template(v-if='path !== `home`')
  33. v-toolbar(:color='$vuetify.theme.dark ? `grey darken-4-d3` : `grey lighten-3`', flat, dense, v-if='$vuetify.breakpoint.smAndUp')
  34. //- v-btn.pl-0(v-if='$vuetify.breakpoint.xsOnly', flat, @click='toggleNavigation')
  35. //- v-icon(color='grey darken-2', left) menu
  36. //- span Navigation
  37. v-breadcrumbs.breadcrumbs-nav.pl-0(
  38. :items='breadcrumbs'
  39. divider='/'
  40. )
  41. template(slot='item', slot-scope='props')
  42. v-icon(v-if='props.item.path === "/"', small, @click='goHome') mdi-home
  43. v-btn.ma-0(v-else, :href='props.item.path', small, text) {{props.item.name}}
  44. template(v-if='!isPublished')
  45. v-spacer
  46. .caption.red--text {{$t('common:page.unpublished')}}
  47. status-indicator.ml-3(negative, pulse)
  48. v-divider
  49. v-container.grey.pa-0(fluid, :class='$vuetify.theme.dark ? `darken-4-l3` : `lighten-4`')
  50. v-row.page-header-section(no-gutters, align-content='center', style='height: 90px;')
  51. v-col.page-col-content.is-page-header(offset-xl='2', offset-lg='3', style='margin-top: auto; margin-bottom: auto;', :class='$vuetify.rtl ? `pr-4` : `pl-4`')
  52. .headline.grey--text(:class='$vuetify.theme.dark ? `text--lighten-2` : `text--darken-3`') {{title}}
  53. .caption.grey--text.text--darken-1 {{description}}
  54. .page-edit-shortcuts(v-if='editShortcutsObj.editMenuBar')
  55. v-btn(
  56. v-if='editShortcutsObj.editMenuBtn'
  57. @click='pageEdit'
  58. depressed
  59. small
  60. )
  61. v-icon.mr-2(small) mdi-pencil
  62. span.text-none {{$t(`common:actions.edit`)}}
  63. v-btn(
  64. v-if='editShortcutsObj.editMenuExternalBtn'
  65. :href='editMenuExternalUrl'
  66. target='_blank'
  67. depressed
  68. small
  69. )
  70. v-icon.mr-2(small) {{ editShortcutsObj.editMenuExternalIcon }}
  71. span.text-none {{$t(`common:page.editExternal`, { name: editShortcutsObj.editMenuExternalName })}}
  72. v-divider
  73. v-container.pl-5.pt-4(fluid, grid-list-xl)
  74. v-layout(row)
  75. v-flex.page-col-sd(lg3, xl2, v-if='$vuetify.breakpoint.lgAndUp')
  76. v-card.page-toc-card.mb-5(v-if='tocDecoded.length')
  77. .overline.pa-5.pb-0(:class='$vuetify.theme.dark ? `blue--text text--lighten-2` : `primary--text`') {{$t('common:page.toc')}}
  78. v-list.pb-3(dense, nav, :class='$vuetify.theme.dark ? `darken-3-d3` : ``')
  79. template(v-for='(tocItem, tocIdx) in tocDecoded')
  80. v-list-item(@click='$vuetify.goTo(tocItem.anchor, scrollOpts)')
  81. v-icon(color='grey', small) {{ $vuetify.rtl ? `mdi-chevron-left` : `mdi-chevron-right` }}
  82. v-list-item-title.px-3 {{tocItem.title}}
  83. //- v-divider(v-if='tocIdx < toc.length - 1 || tocItem.children.length')
  84. template(v-for='tocSubItem in tocItem.children')
  85. v-list-item(@click='$vuetify.goTo(tocSubItem.anchor, scrollOpts)')
  86. v-icon.px-3(color='grey lighten-1', small) {{ $vuetify.rtl ? `mdi-chevron-left` : `mdi-chevron-right` }}
  87. v-list-item-title.px-3.caption.grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-1`') {{tocSubItem.title}}
  88. //- v-divider(inset, v-if='tocIdx < toc.length - 1')
  89. v-card.page-tags-card.mb-5(v-if='tags.length > 0')
  90. .pa-5
  91. .overline.teal--text.pb-2(:class='$vuetify.theme.dark ? `text--lighten-3` : ``') {{$t('common:page.tags')}}
  92. v-chip.mr-1.mb-1(
  93. label
  94. :color='$vuetify.theme.dark ? `teal darken-1` : `teal lighten-5`'
  95. v-for='(tag, idx) in tags'
  96. :href='`/t/` + tag.tag'
  97. :key='`tag-` + tag.tag'
  98. )
  99. v-icon(:color='$vuetify.theme.dark ? `teal lighten-3` : `teal`', left, small) mdi-tag
  100. span(:class='$vuetify.theme.dark ? `teal--text text--lighten-5` : `teal--text text--darken-2`') {{tag.title}}
  101. v-chip.mr-1.mb-1(
  102. label
  103. :color='$vuetify.theme.dark ? `teal darken-1` : `teal lighten-5`'
  104. :href='`/t/` + tags.map(t => t.tag).join(`/`)'
  105. :aria-label='$t(`common:page.tagsMatching`)'
  106. )
  107. v-icon(:color='$vuetify.theme.dark ? `teal lighten-3` : `teal`', size='20') mdi-tag-multiple
  108. v-card.page-comments-card.mb-5(v-if='commentsEnabled && commentsPerms.read')
  109. .pa-5
  110. .overline.pb-2.blue-grey--text.d-flex.align-center(:class='$vuetify.theme.dark ? `text--lighten-3` : `text--darken-2`')
  111. span {{$t('common:comments.sdTitle')}}
  112. //- v-spacer
  113. //- v-chip.text-center(
  114. //- v-if='!commentsExternal'
  115. //- label
  116. //- x-small
  117. //- :color='$vuetify.theme.dark ? `blue-grey darken-3` : `blue-grey darken-2`'
  118. //- dark
  119. //- style='min-width: 50px; justify-content: center;'
  120. //- )
  121. //- span {{commentsCount}}
  122. .d-flex
  123. v-btn.text-none(
  124. @click='goToComments()'
  125. :color='$vuetify.theme.dark ? `blue-grey` : `blue-grey darken-2`'
  126. outlined
  127. style='flex: 1 1 100%;'
  128. small
  129. )
  130. span.blue-grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-2`') {{$t('common:comments.viewDiscussion')}}
  131. v-tooltip(right, v-if='commentsPerms.write')
  132. template(v-slot:activator='{ on }')
  133. v-btn.ml-2(
  134. @click='goToComments(true)'
  135. v-on='on'
  136. outlined
  137. small
  138. :color='$vuetify.theme.dark ? `blue-grey` : `blue-grey darken-2`'
  139. :aria-label='$t(`common:comments.newComment`)'
  140. )
  141. v-icon(:color='$vuetify.theme.dark ? `blue-grey lighten-1` : `blue-grey darken-2`', dense) mdi-comment-plus
  142. span {{$t('common:comments.newComment')}}
  143. v-card.page-author-card.mb-5
  144. .pa-5
  145. .overline.indigo--text.d-flex(:class='$vuetify.theme.dark ? `text--lighten-3` : ``')
  146. span {{$t('common:page.lastEditedBy')}}
  147. v-spacer
  148. v-tooltip(right, v-if='isAuthenticated')
  149. template(v-slot:activator='{ on }')
  150. v-btn.btn-animate-edit(
  151. icon
  152. :href='"/h/" + locale + "/" + path'
  153. v-on='on'
  154. x-small
  155. v-if='hasReadHistoryPermission'
  156. :aria-label='$t(`common:header.history`)'
  157. )
  158. v-icon(color='indigo', dense) mdi-history
  159. span {{$t('common:header.history')}}
  160. .page-author-card-name.body-2.grey--text(:class='$vuetify.theme.dark ? `` : `text--darken-3`') {{ authorName }}
  161. .page-author-card-date.caption.grey--text.text--darken-1 {{ updatedAt | moment('calendar') }}
  162. //- v-card.mb-5
  163. //- .pa-5
  164. //- .overline.pb-2.yellow--text(:class='$vuetify.theme.dark ? `text--darken-3` : `text--darken-4`') Rating
  165. //- .text-center
  166. //- v-rating(
  167. //- v-model='rating'
  168. //- color='yellow darken-3'
  169. //- background-color='grey lighten-1'
  170. //- half-increments
  171. //- hover
  172. //- )
  173. //- .caption.grey--text 5 votes
  174. v-card.page-shortcuts-card(flat)
  175. v-toolbar(:color='$vuetify.theme.dark ? `grey darken-4-d3` : `grey lighten-3`', flat, dense)
  176. v-spacer
  177. v-tooltip(bottom)
  178. template(v-slot:activator='{ on }')
  179. v-btn(icon, tile, v-on='on', :aria-label='$t(`common:page.bookmark`)'): v-icon(color='grey') mdi-bookmark
  180. span {{$t('common:page.bookmark')}}
  181. v-menu(offset-y, bottom, min-width='300')
  182. template(v-slot:activator='{ on: menu }')
  183. v-tooltip(bottom)
  184. template(v-slot:activator='{ on: tooltip }')
  185. v-btn(icon, tile, v-on='{ ...menu, ...tooltip }', :aria-label='$t(`common:page.share`)'): v-icon(color='grey') mdi-share-variant
  186. span {{$t('common:page.share')}}
  187. social-sharing(
  188. :url='pageUrl'
  189. :title='title'
  190. :description='description'
  191. )
  192. v-tooltip(bottom)
  193. template(v-slot:activator='{ on }')
  194. v-btn(icon, tile, v-on='on', @click='print', :aria-label='$t(`common:page.printFormat`)')
  195. v-icon(:color='printView ? `primary` : `grey`') mdi-printer
  196. span {{$t('common:page.printFormat')}}
  197. v-spacer
  198. v-flex.page-col-content(xs12, lg9, xl10)
  199. v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl', v-if='hasAnyPagePermissions && editShortcutsObj.editFab')
  200. template(v-slot:activator='{ on: onEditActivator }')
  201. v-speed-dial(
  202. v-model='pageEditFab'
  203. direction='top'
  204. open-on-hover
  205. transition='scale-transition'
  206. bottom
  207. :right='!$vuetify.rtl'
  208. :left='$vuetify.rtl'
  209. fixed
  210. dark
  211. )
  212. template(v-slot:activator)
  213. v-btn.btn-animate-edit(
  214. fab
  215. color='primary'
  216. v-model='pageEditFab'
  217. @click='pageEdit'
  218. v-on='onEditActivator'
  219. :disabled='!hasWritePagesPermission'
  220. :aria-label='$t(`common:page.editPage`)'
  221. )
  222. v-icon mdi-pencil
  223. v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl', v-if='hasReadHistoryPermission')
  224. template(v-slot:activator='{ on }')
  225. v-btn(
  226. fab
  227. small
  228. color='white'
  229. light
  230. v-on='on'
  231. @click='pageHistory'
  232. )
  233. v-icon(size='20') mdi-history
  234. span {{$t('common:header.history')}}
  235. v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl', v-if='hasReadSourcePermission')
  236. template(v-slot:activator='{ on }')
  237. v-btn(
  238. fab
  239. small
  240. color='white'
  241. light
  242. v-on='on'
  243. @click='pageSource'
  244. )
  245. v-icon(size='20') mdi-code-tags
  246. span {{$t('common:header.viewSource')}}
  247. v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl', v-if='hasWritePagesPermission')
  248. template(v-slot:activator='{ on }')
  249. v-btn(
  250. fab
  251. small
  252. color='white'
  253. light
  254. v-on='on'
  255. @click='pageConvert'
  256. )
  257. v-icon(size='20') mdi-lightning-bolt
  258. span {{$t('common:header.convert')}}
  259. v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl', v-if='hasWritePagesPermission')
  260. template(v-slot:activator='{ on }')
  261. v-btn(
  262. fab
  263. small
  264. color='white'
  265. light
  266. v-on='on'
  267. @click='pageDuplicate'
  268. )
  269. v-icon(size='20') mdi-content-duplicate
  270. span {{$t('common:header.duplicate')}}
  271. v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl', v-if='hasManagePagesPermission')
  272. template(v-slot:activator='{ on }')
  273. v-btn(
  274. fab
  275. small
  276. color='white'
  277. light
  278. v-on='on'
  279. @click='pageMove'
  280. )
  281. v-icon(size='20') mdi-content-save-move-outline
  282. span {{$t('common:header.move')}}
  283. v-tooltip(:right='$vuetify.rtl', :left='!$vuetify.rtl', v-if='hasDeletePagesPermission')
  284. template(v-slot:activator='{ on }')
  285. v-btn(
  286. fab
  287. dark
  288. small
  289. color='red'
  290. v-on='on'
  291. @click='pageDelete'
  292. )
  293. v-icon(size='20') mdi-trash-can-outline
  294. span {{$t('common:header.delete')}}
  295. span {{$t('common:page.editPage')}}
  296. v-alert.mb-5(v-if='!isPublished', color='red', outlined, icon='mdi-minus-circle', dense)
  297. .caption {{$t('common:page.unpublishedWarning')}}
  298. .contents(ref='container')
  299. slot(name='contents')
  300. .comments-container#discussion(v-if='commentsEnabled && commentsPerms.read && !printView')
  301. .comments-header
  302. v-icon.mr-2(dark) mdi-comment-text-outline
  303. span {{$t('common:comments.title')}}
  304. .comments-main
  305. slot(name='comments')
  306. nav-footer
  307. notify
  308. search-results
  309. v-fab-transition
  310. v-btn(
  311. v-if='upBtnShown'
  312. fab
  313. fixed
  314. bottom
  315. :right='$vuetify.rtl'
  316. :left='!$vuetify.rtl'
  317. small
  318. :depressed='this.$vuetify.breakpoint.mdAndUp'
  319. @click='$vuetify.goTo(0, scrollOpts)'
  320. color='primary'
  321. dark
  322. :style='upBtnPosition'
  323. :aria-label='$t(`common:actions.returnToTop`)'
  324. )
  325. v-icon mdi-arrow-up
  326. </template>
  327. <script>
  328. import { StatusIndicator } from 'vue-status-indicator'
  329. import Tabset from './tabset.vue'
  330. import NavSidebar from './nav-sidebar.vue'
  331. import Prism from 'prismjs'
  332. import mermaid from 'mermaid'
  333. import { get, sync } from 'vuex-pathify'
  334. import _ from 'lodash'
  335. import ClipboardJS from 'clipboard'
  336. import Vue from 'vue'
  337. Vue.component('Tabset', Tabset)
  338. Prism.plugins.autoloader.languages_path = '/_assets/js/prism/'
  339. Prism.plugins.NormalizeWhitespace.setDefaults({
  340. 'remove-trailing': true,
  341. 'remove-indent': true,
  342. 'left-trim': true,
  343. 'right-trim': true,
  344. 'remove-initial-line-feed': true,
  345. 'tabs-to-spaces': 2
  346. })
  347. Prism.plugins.toolbar.registerButton('copy-to-clipboard', (env) => {
  348. let linkCopy = document.createElement('button')
  349. linkCopy.textContent = 'Copy'
  350. const clip = new ClipboardJS(linkCopy, {
  351. text: () => { return env.code }
  352. })
  353. clip.on('success', () => {
  354. linkCopy.textContent = 'Copied!'
  355. resetClipboardText()
  356. })
  357. clip.on('error', () => {
  358. linkCopy.textContent = 'Press Ctrl+C to copy'
  359. resetClipboardText()
  360. })
  361. return linkCopy
  362. function resetClipboardText() {
  363. setTimeout(() => {
  364. linkCopy.textContent = 'Copy'
  365. }, 5000)
  366. }
  367. })
  368. export default {
  369. components: {
  370. NavSidebar,
  371. StatusIndicator
  372. },
  373. props: {
  374. pageId: {
  375. type: Number,
  376. default: 0
  377. },
  378. locale: {
  379. type: String,
  380. default: 'en'
  381. },
  382. path: {
  383. type: String,
  384. default: 'home'
  385. },
  386. title: {
  387. type: String,
  388. default: 'Untitled Page'
  389. },
  390. description: {
  391. type: String,
  392. default: ''
  393. },
  394. createdAt: {
  395. type: String,
  396. default: ''
  397. },
  398. updatedAt: {
  399. type: String,
  400. default: ''
  401. },
  402. tags: {
  403. type: Array,
  404. default: () => ([])
  405. },
  406. authorName: {
  407. type: String,
  408. default: 'Unknown'
  409. },
  410. authorId: {
  411. type: Number,
  412. default: 0
  413. },
  414. editor: {
  415. type: String,
  416. default: ''
  417. },
  418. isPublished: {
  419. type: Boolean,
  420. default: false
  421. },
  422. toc: {
  423. type: String,
  424. default: ''
  425. },
  426. sidebar: {
  427. type: String,
  428. default: ''
  429. },
  430. navMode: {
  431. type: String,
  432. default: 'MIXED'
  433. },
  434. commentsEnabled: {
  435. type: Boolean,
  436. default: false
  437. },
  438. effectivePermissions: {
  439. type: String,
  440. default: ''
  441. },
  442. commentsExternal: {
  443. type: Boolean,
  444. default: false
  445. },
  446. editShortcuts: {
  447. type: String,
  448. default: ''
  449. },
  450. filename: {
  451. type: String,
  452. default: ''
  453. }
  454. },
  455. data() {
  456. return {
  457. navShown: false,
  458. navExpanded: false,
  459. upBtnShown: false,
  460. pageEditFab: false,
  461. scrollOpts: {
  462. duration: 1500,
  463. offset: 0,
  464. easing: 'easeInOutCubic'
  465. },
  466. scrollStyle: {
  467. vuescroll: {},
  468. scrollPanel: {
  469. initialScrollX: 0.01, // fix scrollbar not disappearing on load
  470. scrollingX: false,
  471. speed: 50
  472. },
  473. rail: {
  474. gutterOfEnds: '2px'
  475. },
  476. bar: {
  477. onlyShowBarOnScroll: false,
  478. background: '#42A5F5',
  479. hoverStyle: {
  480. background: '#64B5F6'
  481. }
  482. }
  483. },
  484. winWidth: 0
  485. }
  486. },
  487. computed: {
  488. isAuthenticated: get('user/authenticated'),
  489. commentsCount: get('page/commentsCount'),
  490. commentsPerms: get('page/effectivePermissions@comments'),
  491. editShortcutsObj: get('page/editShortcuts'),
  492. rating: {
  493. get () {
  494. return 3.5
  495. },
  496. set (val) {
  497. }
  498. },
  499. breadcrumbs() {
  500. return [{ path: '/', name: 'Home' }].concat(_.reduce(this.path.split('/'), (result, value, key) => {
  501. result.push({
  502. path: _.get(_.last(result), 'path', `/${this.locale}`) + `/${value}`,
  503. name: value
  504. })
  505. return result
  506. }, []))
  507. },
  508. pageUrl () { return window.location.href },
  509. upBtnPosition () {
  510. if (this.$vuetify.breakpoint.mdAndUp) {
  511. return this.$vuetify.rtl ? `right: 235px;` : `left: 235px;`
  512. } else {
  513. return this.$vuetify.rtl ? `right: 65px;` : `left: 65px;`
  514. }
  515. },
  516. sidebarDecoded () {
  517. return JSON.parse(Buffer.from(this.sidebar, 'base64').toString())
  518. },
  519. tocDecoded () {
  520. return JSON.parse(Buffer.from(this.toc, 'base64').toString())
  521. },
  522. hasAdminPermission: get('page/effectivePermissions@system.manage'),
  523. hasWritePagesPermission: get('page/effectivePermissions@pages.write'),
  524. hasManagePagesPermission: get('page/effectivePermissions@pages.manage'),
  525. hasDeletePagesPermission: get('page/effectivePermissions@pages.delete'),
  526. hasReadSourcePermission: get('page/effectivePermissions@source.read'),
  527. hasReadHistoryPermission: get('page/effectivePermissions@history.read'),
  528. hasAnyPagePermissions () {
  529. return this.hasAdminPermission || this.hasWritePagesPermission || this.hasManagePagesPermission ||
  530. this.hasDeletePagesPermission || this.hasReadSourcePermission || this.hasReadHistoryPermission
  531. },
  532. printView: sync('site/printView'),
  533. editMenuExternalUrl () {
  534. if (this.editShortcutsObj.editMenuBar && this.editShortcutsObj.editMenuExternalBtn) {
  535. return this.editShortcutsObj.editMenuExternalUrl.replace('{filename}', this.filename)
  536. } else {
  537. return ''
  538. }
  539. }
  540. },
  541. created() {
  542. this.$store.set('page/authorId', this.authorId)
  543. this.$store.set('page/authorName', this.authorName)
  544. this.$store.set('page/createdAt', this.createdAt)
  545. this.$store.set('page/description', this.description)
  546. this.$store.set('page/isPublished', this.isPublished)
  547. this.$store.set('page/id', this.pageId)
  548. this.$store.set('page/locale', this.locale)
  549. this.$store.set('page/path', this.path)
  550. this.$store.set('page/tags', this.tags)
  551. this.$store.set('page/title', this.title)
  552. this.$store.set('page/editor', this.editor)
  553. this.$store.set('page/updatedAt', this.updatedAt)
  554. if (this.effectivePermissions) {
  555. this.$store.set('page/effectivePermissions', JSON.parse(Buffer.from(this.effectivePermissions, 'base64').toString()))
  556. }
  557. if (this.editShortcuts) {
  558. this.$store.set('page/editShortcuts', JSON.parse(Buffer.from(this.editShortcuts, 'base64').toString()))
  559. }
  560. this.$store.set('page/mode', 'view')
  561. },
  562. mounted () {
  563. if (this.$vuetify.theme.dark) {
  564. this.scrollStyle.bar.background = '#424242'
  565. }
  566. // -> Check side navigation visibility
  567. this.handleSideNavVisibility()
  568. window.addEventListener('resize', _.debounce(() => {
  569. this.handleSideNavVisibility()
  570. }, 500))
  571. // -> Highlight Code Blocks
  572. Prism.highlightAllUnder(this.$refs.container)
  573. // -> Render Mermaid diagrams
  574. mermaid.mermaidAPI.initialize({
  575. startOnLoad: true,
  576. theme: this.$vuetify.theme.dark ? `dark` : `default`
  577. })
  578. // -> Handle anchor scrolling
  579. if (window.location.hash && window.location.hash.length > 1) {
  580. if (document.readyState === 'complete') {
  581. this.$nextTick(() => {
  582. this.$vuetify.goTo(decodeURIComponent(window.location.hash), this.scrollOpts)
  583. })
  584. } else {
  585. window.addEventListener('load', () => {
  586. this.$vuetify.goTo(decodeURIComponent(window.location.hash), this.scrollOpts)
  587. })
  588. }
  589. }
  590. // -> Handle anchor links within the page contents
  591. this.$nextTick(() => {
  592. this.$refs.container.querySelectorAll(`a[href^="#"], a[href^="${window.location.href.replace(window.location.hash, '')}#"]`).forEach(el => {
  593. el.onclick = ev => {
  594. ev.preventDefault()
  595. ev.stopPropagation()
  596. this.$vuetify.goTo(decodeURIComponent(ev.currentTarget.hash), this.scrollOpts)
  597. }
  598. })
  599. })
  600. },
  601. methods: {
  602. goHome () {
  603. window.location.assign('/')
  604. },
  605. toggleNavigation () {
  606. this.navOpen = !this.navOpen
  607. },
  608. upBtnScroll () {
  609. const scrollOffset = window.pageYOffset || document.documentElement.scrollTop
  610. this.upBtnShown = scrollOffset > window.innerHeight * 0.33
  611. },
  612. print () {
  613. if (this.printView) {
  614. this.printView = false
  615. } else {
  616. this.printView = true
  617. this.$nextTick(() => {
  618. window.print()
  619. })
  620. }
  621. },
  622. pageEdit () {
  623. this.$root.$emit('pageEdit')
  624. },
  625. pageHistory () {
  626. this.$root.$emit('pageHistory')
  627. },
  628. pageSource () {
  629. this.$root.$emit('pageSource')
  630. },
  631. pageConvert () {
  632. this.$root.$emit('pageConvert')
  633. },
  634. pageDuplicate () {
  635. this.$root.$emit('pageDuplicate')
  636. },
  637. pageMove () {
  638. this.$root.$emit('pageMove')
  639. },
  640. pageDelete () {
  641. this.$root.$emit('pageDelete')
  642. },
  643. handleSideNavVisibility () {
  644. if (window.innerWidth === this.winWidth) { return }
  645. this.winWidth = window.innerWidth
  646. if (this.$vuetify.breakpoint.mdAndUp) {
  647. this.navShown = true
  648. } else {
  649. this.navShown = false
  650. }
  651. },
  652. goToComments (focusNewComment = false) {
  653. this.$vuetify.goTo('#discussion', this.scrollOpts)
  654. if (focusNewComment) {
  655. document.querySelector('#discussion-new').focus()
  656. }
  657. }
  658. }
  659. }
  660. </script>
  661. <style lang="scss">
  662. .breadcrumbs-nav {
  663. .v-btn {
  664. min-width: 0;
  665. &__content {
  666. text-transform: none;
  667. }
  668. }
  669. .v-breadcrumbs__divider:nth-child(2n) {
  670. padding: 0 6px;
  671. }
  672. .v-breadcrumbs__divider:nth-child(2) {
  673. padding: 0 6px 0 12px;
  674. }
  675. }
  676. .page-col-sd {
  677. margin-top: -90px;
  678. align-self: flex-start;
  679. position: sticky;
  680. top: 64px;
  681. max-height: calc(100vh - 64px);
  682. overflow-y: auto;
  683. -ms-overflow-style: none;
  684. }
  685. .page-col-sd::-webkit-scrollbar {
  686. display: none;
  687. }
  688. .page-header-section {
  689. position: relative;
  690. .page-edit-shortcuts {
  691. position: absolute;
  692. bottom: -14px;
  693. right: 10px;
  694. .v-btn {
  695. border-right: 1px solid #DDD !important;
  696. border-bottom: 1px solid #DDD !important;
  697. border-radius: 0;
  698. color: #777;
  699. background-color: #FFF !important;
  700. @at-root .theme--dark & {
  701. background-color: #222 !important;
  702. border-right-color: #444 !important;
  703. border-bottom-color: #444 !important;
  704. color: #CCC;
  705. }
  706. .v-icon {
  707. color: mc('blue', '700');
  708. }
  709. &:first-child {
  710. border-top-left-radius: 5px;
  711. border-bottom-left-radius: 5px;
  712. }
  713. &:last-child {
  714. border-top-right-radius: 5px;
  715. border-bottom-right-radius: 5px;
  716. }
  717. }
  718. }
  719. }
  720. </style>