2
0

page.vue 27 KB

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