maglevcms 2.0.0.beta1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82bc9958b22dec5a92e3f9e3fab438418f666479d868e9196c6c96fe350d082c
4
- data.tar.gz: 975cf8a2f8b11ce2c2f3cfad7c38ba7db2c7ab351d1e5a83a1f563e903a9def2
3
+ metadata.gz: f5927f846b9b6ff6238c335be6238e4d6a6f821ff938f703d3e52c371059d3c3
4
+ data.tar.gz: 6e7293b7cfd56fb7ed7c95571a08b8fa9b27bb6837175926d9ac24e51133d337
5
5
  SHA512:
6
- metadata.gz: 8a5ec523921178fdbecbec37ff7ddccab1fc9f1e26fd6d1fd270b7bf231ab28af1b111a7ecfc71b132abdce46f39ff785bc6630d6c98925c106bc266c6432037
7
- data.tar.gz: 52b7d06da150eb80b06ec8006fa5960f8e77543cd7d054786a19d4875fed86b50946e2820567b402455df561b25fb1302e5e3a7be1adfa7b8f4b8b8d75dad417
6
+ metadata.gz: 2d800cf00c89cec1d2bc92b8106eb2bff7fc42db0abfbb80e528df13ab72133211ab6b6ccec6e27ad6bbf293cdc100c058c99ed17f67f0881532cc5756e0767a
7
+ data.tar.gz: aba0b9aaf8a65f6119a23e3f15e618ad657832fc9bbf0f20cad4bef1a72355b4fe7085948c86a5453a46723f8f13aff06fdcbf2732c4bafd42b04ea0b4ed64c1
@@ -73,11 +73,11 @@ export default {
73
73
  methods: {
74
74
  onPreviewScroll(event) {
75
75
  this.isScrolling = true
76
- this.boundingRect = event.detail.boundingRect
76
+ this.boundingRect = event.detail.boundingRect
77
77
  this.waitUntilScrollingDone()
78
78
  },
79
79
  onEndPreviewScrolling() {
80
- this.isScrolling = false
80
+ this.isScrolling = false
81
81
  this.applyStyle(this.boundingRect)
82
82
  },
83
83
  applyStyle(boundingRect) {
@@ -9,7 +9,11 @@
9
9
  </template>
10
10
 
11
11
  <template v-slot:slide-pane>
12
- <transition name="slide" mode="out-in">
12
+ <transition
13
+ name="slide"
14
+ mode="out-in"
15
+ v-on:before-enter="beforeEnter"
16
+ v-on:after-enter="afterEnter">
13
17
  <router-view name="slide-pane" />
14
18
  </transition>
15
19
  </template>
@@ -26,5 +30,13 @@ import SidebarNav from '@/components/sidebar-nav/index.vue'
26
30
  export default {
27
31
  name: 'AppLayout',
28
32
  components: { Layout, HeaderNav, SidebarNav },
33
+ methods: {
34
+ beforeEnter() {
35
+ this.services.livePreview.simulateFakeScroll()
36
+ },
37
+ afterEnter() {
38
+ this.services.livePreview.pingSection(this.currentSection?.id)
39
+ },
40
+ },
29
41
  }
30
42
  </script>
@@ -26,6 +26,12 @@ export const removeSection = (sectionId) => {
26
26
  postMessage('section:remove', { sectionId })
27
27
  }
28
28
 
29
+ export const pingSection = (sectionId) => {
30
+ if (!sectionId) return
31
+ postMessage('section:ping', { sectionId })
32
+ }
33
+
34
+
29
35
  // === Block related actions ===
30
36
  export const addBlock = (content, section, sectionBlock) => {
31
37
  postMessage('block:add', { content, section, sectionBlock })
@@ -43,6 +49,10 @@ export const removeBlock = (content, section, sectionBlockId) => {
43
49
  postMessage('block:remove', { content, section, sectionBlockId })
44
50
  }
45
51
 
52
+ export const simulateFakeScroll = () => {
53
+ notifyScrolling(null)
54
+ }
55
+
46
56
  // === Other actions ===
47
57
 
48
58
  export const updateStyle = (content, style) => {
@@ -113,7 +123,7 @@ const openSettingPane = (name, params) => {
113
123
  })
114
124
  }
115
125
 
116
- const notifyScrolling = (boundingRect) => {
126
+ export const notifyScrolling = (boundingRect) => {
117
127
  const event = new CustomEvent('maglev:preview:scroll', {
118
128
  detail: { boundingRect },
119
129
  })
@@ -62,8 +62,9 @@ const selectHoveredSectionAtStartup = (previewDocument, stickySectionIds) => {
62
62
  setTimeout(() => {
63
63
  const section = previewDocument.querySelector('[data-maglev-section-id]:hover')
64
64
 
65
- if (section)
66
- onSectionHovered(previewDocument, section, stickySectionIds)
65
+ if (section) {
66
+ onSectionHovered(previewDocument, section, stickySectionIds, true)
67
+ }
67
68
  }, 200)
68
69
  }
69
70
 
@@ -116,10 +117,10 @@ const listenScrolling = (previewDocument) => {
116
117
  addEventListener(previewDocument, 'scroll', scrollNotifier)
117
118
  }
118
119
 
119
- const onSectionHovered = (previewDocument, el, stickySectionIds) => {
120
+ const onSectionHovered = (previewDocument, el, stickySectionIds, force = false) => {
120
121
  const sectionId = el.dataset.maglevSectionId
121
122
 
122
- if (hoveredSectionId !== sectionId) {
123
+ if (hoveredSectionId !== sectionId || force) {
123
124
  postMessage('section:hover', {
124
125
  sectionId,
125
126
  sectionRect: el.getBoundingClientRect(),
@@ -21,6 +21,7 @@ export const listenMessages = () => {
21
21
  case 'section:move':
22
22
  case 'section:update':
23
23
  case 'section:remove':
24
+ case 'section:ping':
24
25
  case 'block:add':
25
26
  case 'block:move':
26
27
  case 'block:update':
@@ -1,6 +1,7 @@
1
1
  import axios from 'axios'
2
2
  import { debounce } from './utils'
3
3
  import runScripts from './run-scripts'
4
+ import { postMessage } from './message'
4
5
 
5
6
  const parentDocument = window.parent.document
6
7
  const previewDocument = window.document
@@ -21,6 +22,7 @@ const start = () => {
21
22
  window.addEventListener('maglev:section:move', moveSections)
22
23
  window.addEventListener('maglev:section:update', updateSection)
23
24
  window.addEventListener('maglev:section:remove', removeSection)
25
+ window.addEventListener('maglev:section:ping', pingSection)
24
26
  window.addEventListener('maglev:block:add', replaceSection)
25
27
  window.addEventListener('maglev:block:move', replaceSection)
26
28
  window.addEventListener('maglev:block:update', updateBlock)
@@ -71,10 +73,18 @@ const updateSection = (event) => {
71
73
  const removeSection = (event) => {
72
74
  const { sectionId } = event.detail
73
75
  const selector = `[data-maglev-section-id='${sectionId}']`
74
- let element = previewDocument.querySelector(selector)
76
+ const element = previewDocument.querySelector(selector)
75
77
  element.remove()
76
78
  }
77
79
 
80
+ const pingSection = (event) => {
81
+ const { sectionId } = event.detail
82
+ const selector = `[data-maglev-section-id='${sectionId}']`
83
+ const element = previewDocument.querySelector(selector)
84
+ // hack to force the highlighter bar to be updated with the correct dimensions
85
+ postMessage('scroll', { boundingRect: element.getBoundingClientRect() })
86
+ }
87
+
78
88
  // === Block related actions ===
79
89
 
80
90
  const updateBlock = (event) => {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Maglev
4
- VERSION = '2.0.0.beta1'
4
+ VERSION = '2.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maglevcms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue