cms-renderer 0.6.11 → 0.6.12
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.
- package/dist/lib/block-renderer.js +43 -7
- package/dist/lib/block-renderer.js.map +1 -1
- package/dist/lib/block-toolbar.js +18 -4
- package/dist/lib/block-toolbar.js.map +1 -1
- package/dist/lib/client-editable-block.js +19 -5
- package/dist/lib/client-editable-block.js.map +1 -1
- package/dist/lib/markdown-utils.js +19 -2
- package/dist/lib/markdown-utils.js.map +1 -1
- package/dist/lib/parametric-route.js +43 -7
- package/dist/lib/parametric-route.js.map +1 -1
- package/dist/lib/renderer.js +43 -7
- package/dist/lib/renderer.js.map +1 -1
- package/package.json +3 -2
package/dist/lib/renderer.js
CHANGED
|
@@ -466,11 +466,14 @@ function generateCmsOverlayScript(cmsParentOrigin) {
|
|
|
466
466
|
var style = document.createElement('style');
|
|
467
467
|
style.setAttribute('data-cms-overlay', '');
|
|
468
468
|
style.textContent = \`
|
|
469
|
+
[data-cms-block],
|
|
469
470
|
[data-cms-editable] {
|
|
470
471
|
cursor: pointer;
|
|
472
|
+
}
|
|
473
|
+
[data-cms-editable] {
|
|
471
474
|
border-radius: 2px;
|
|
472
475
|
}
|
|
473
|
-
[data-cms-editable]:hover {
|
|
476
|
+
[data-cms-editable]:not([data-cms-block]):hover {
|
|
474
477
|
outline: 2px solid #3b82f6;
|
|
475
478
|
outline-offset: 2px;
|
|
476
479
|
}
|
|
@@ -484,7 +487,7 @@ function generateCmsOverlayScript(cmsParentOrigin) {
|
|
|
484
487
|
z-index: 99998;
|
|
485
488
|
}
|
|
486
489
|
#cms-overlay-root > * {
|
|
487
|
-
pointer-events:
|
|
490
|
+
pointer-events: none;
|
|
488
491
|
}
|
|
489
492
|
.cms-block-outline {
|
|
490
493
|
position: fixed;
|
|
@@ -580,7 +583,6 @@ function generateCmsOverlayScript(cmsParentOrigin) {
|
|
|
580
583
|
blockEl.setAttribute('data-cms-block', '');
|
|
581
584
|
blockEl.setAttribute('data-block-id', blockId);
|
|
582
585
|
blockEl.setAttribute('data-block-type', blockType);
|
|
583
|
-
blockEl.setAttribute('data-cms-editable', '');
|
|
584
586
|
});
|
|
585
587
|
}
|
|
586
588
|
|
|
@@ -638,6 +640,38 @@ function generateCmsOverlayScript(cmsParentOrigin) {
|
|
|
638
640
|
var toolbarVisible = false;
|
|
639
641
|
var selectedBlockId = null;
|
|
640
642
|
|
|
643
|
+
function decoratePreviewUrl(rawHref) {
|
|
644
|
+
if (!rawHref) return rawHref;
|
|
645
|
+
try {
|
|
646
|
+
var url = new URL(rawHref, window.location.href);
|
|
647
|
+
if (url.origin !== window.location.origin) return rawHref;
|
|
648
|
+
url.searchParams.set('edit_mode', 'true');
|
|
649
|
+
if (CMS_PARENT_ORIGIN) {
|
|
650
|
+
url.searchParams.set('cms_parent_origin', CMS_PARENT_ORIGIN);
|
|
651
|
+
}
|
|
652
|
+
return url.toString();
|
|
653
|
+
} catch (_) {
|
|
654
|
+
return rawHref;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function preserveEditParamsOnNavigation(e) {
|
|
659
|
+
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
var anchor = e.target.closest('a[href]');
|
|
664
|
+
if (!anchor || (anchor.target && anchor.target !== '_self') || anchor.hasAttribute('download')) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
var href = anchor.getAttribute('href');
|
|
669
|
+
var decorated = decoratePreviewUrl(href);
|
|
670
|
+
if (decorated && decorated !== href) {
|
|
671
|
+
anchor.setAttribute('href', decorated);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
641
675
|
function postToParent(message) {
|
|
642
676
|
if (!CMS_PARENT_ORIGIN || !window.parent || window.parent === window) {
|
|
643
677
|
return;
|
|
@@ -756,6 +790,8 @@ function generateCmsOverlayScript(cmsParentOrigin) {
|
|
|
756
790
|
});
|
|
757
791
|
|
|
758
792
|
document.addEventListener('click', function(e) {
|
|
793
|
+
preserveEditParamsOnNavigation(e);
|
|
794
|
+
|
|
759
795
|
if (toolbarVisible && !e.target.closest('[data-cms-toolbar]')) {
|
|
760
796
|
var block = e.target.closest('[data-cms-block]');
|
|
761
797
|
if (!block || block.getAttribute('data-block-id') !== currentBlockId) {
|
|
@@ -785,23 +821,23 @@ function generateCmsOverlayScript(cmsParentOrigin) {
|
|
|
785
821
|
contentPath: null
|
|
786
822
|
});
|
|
787
823
|
}
|
|
788
|
-
});
|
|
824
|
+
}, true);
|
|
789
825
|
|
|
790
826
|
toolbar.querySelector('.move-up').addEventListener('click', function() {
|
|
791
827
|
if (!currentBlockId) return;
|
|
792
|
-
postToParent({ type: 'cms-block-
|
|
828
|
+
postToParent({ type: 'cms-block-action', action: 'move-up', blockId: currentBlockId });
|
|
793
829
|
hideToolbar();
|
|
794
830
|
});
|
|
795
831
|
|
|
796
832
|
toolbar.querySelector('.move-down').addEventListener('click', function() {
|
|
797
833
|
if (!currentBlockId) return;
|
|
798
|
-
postToParent({ type: 'cms-block-
|
|
834
|
+
postToParent({ type: 'cms-block-action', action: 'move-down', blockId: currentBlockId });
|
|
799
835
|
hideToolbar();
|
|
800
836
|
});
|
|
801
837
|
|
|
802
838
|
toolbar.querySelector('.delete').addEventListener('click', function() {
|
|
803
839
|
if (!currentBlockId) return;
|
|
804
|
-
postToParent({ type: 'cms-block-delete', blockId: currentBlockId });
|
|
840
|
+
postToParent({ type: 'cms-block-action', action: 'delete', blockId: currentBlockId });
|
|
805
841
|
hideToolbar();
|
|
806
842
|
});
|
|
807
843
|
|