You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

792 lines
27 KiB

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