@duffcloudservices/cms 0.3.12 → 0.3.13

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.
@@ -33,6 +33,8 @@ var imageEditIconElements = [];
33
33
  var imageEditIconTargets = [];
34
34
  var reviewEditIconElement = null;
35
35
  var reviewEditIconTarget = null;
36
+ var managedFormEditIconElement = null;
37
+ var managedFormEditIconTarget = null;
36
38
  var editingEnabled = true;
37
39
  var originalTextValues = /* @__PURE__ */ new Map();
38
40
  var sectionResizeObserver = null;
@@ -239,6 +241,33 @@ function applyEditorToElements() {
239
241
  removeReviewEditIcon();
240
242
  });
241
243
  });
244
+ const managedFormElements = document.querySelectorAll("[data-form-key]");
245
+ managedFormElements.forEach((formEl) => {
246
+ formEl.classList.add("dcs-managed-form");
247
+ if (!initializedManagedFormElements.has(formEl)) {
248
+ initializedManagedFormElements.add(formEl);
249
+ const openManagedForm = (e) => {
250
+ if (!editingEnabled) return;
251
+ e.preventDefault();
252
+ e.stopPropagation();
253
+ e.stopImmediatePropagation();
254
+ postToParent("dcs:managed-form-click", {
255
+ formId: formEl.dataset.formKey ?? null
256
+ });
257
+ };
258
+ formEl.addEventListener("click", openManagedForm, true);
259
+ formEl.addEventListener("dblclick", openManagedForm, true);
260
+ formEl.addEventListener("mouseenter", () => {
261
+ if (activeEditElement) return;
262
+ showManagedFormEditIcon(formEl);
263
+ });
264
+ formEl.addEventListener("mouseleave", (e) => {
265
+ const related = e.relatedTarget;
266
+ if (related && (related.classList?.contains("dcs-managed-form-edit-icon") || related.closest?.(".dcs-managed-form-edit-icon"))) return;
267
+ removeManagedFormEditIcon();
268
+ });
269
+ }
270
+ });
242
271
  const sections = document.querySelectorAll("[data-section]");
243
272
  sections.forEach((el) => {
244
273
  if (initializedSections.has(el)) return;
@@ -317,23 +346,6 @@ function applyEditorToElements() {
317
346
  summaryEl?.classList.add("dcs-blog-metadata");
318
347
  }
319
348
  }
320
- const managedFormElements = document.querySelectorAll("[data-form-key]");
321
- managedFormElements.forEach((formEl) => {
322
- formEl.classList.add("dcs-managed-form");
323
- if (initializedManagedFormElements.has(formEl)) return;
324
- initializedManagedFormElements.add(formEl);
325
- const openManagedForm = (e) => {
326
- if (!editingEnabled) return;
327
- e.preventDefault();
328
- e.stopPropagation();
329
- e.stopImmediatePropagation();
330
- postToParent("dcs:managed-form-click", {
331
- formId: formEl.dataset.formKey ?? null
332
- });
333
- };
334
- formEl.addEventListener("click", openManagedForm, true);
335
- formEl.addEventListener("dblclick", openManagedForm, true);
336
- });
337
349
  }
338
350
  function handleTextKeyDblClick(e) {
339
351
  if (!editingEnabled) return;
@@ -553,6 +565,53 @@ function removeReviewEditIcon() {
553
565
  }
554
566
  reviewEditIconTarget = null;
555
567
  }
568
+ function createManagedFormEditIcon() {
569
+ const icon = document.createElement("button");
570
+ icon.className = "dcs-managed-form-edit-icon";
571
+ icon.setAttribute("type", "button");
572
+ icon.setAttribute("title", "Manage form");
573
+ icon.setAttribute("aria-label", "Manage form fields");
574
+ icon.innerHTML = `
575
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
576
+ <path d="M3 6h18"/><path d="M7 12h10"/><path d="M10 18h4"/>
577
+ </svg>
578
+ <span class="dcs-managed-form-edit-label">Manage form</span>
579
+ `;
580
+ icon.addEventListener("click", (e) => {
581
+ e.preventDefault();
582
+ e.stopPropagation();
583
+ e.stopImmediatePropagation();
584
+ if (!managedFormEditIconTarget) return;
585
+ postToParent("dcs:managed-form-click", {
586
+ formId: managedFormEditIconTarget.dataset.formKey ?? null
587
+ });
588
+ removeManagedFormEditIcon();
589
+ }, true);
590
+ icon.addEventListener("mouseleave", (e) => {
591
+ const related = e.relatedTarget;
592
+ if (related && managedFormEditIconTarget && (related === managedFormEditIconTarget || managedFormEditIconTarget.contains(related))) return;
593
+ removeManagedFormEditIcon();
594
+ });
595
+ return icon;
596
+ }
597
+ function showManagedFormEditIcon(el) {
598
+ if (!editingEnabled) return;
599
+ if (!managedFormEditIconElement) {
600
+ managedFormEditIconElement = createManagedFormEditIcon();
601
+ document.body.appendChild(managedFormEditIconElement);
602
+ }
603
+ managedFormEditIconTarget = el;
604
+ const rect = el.getBoundingClientRect();
605
+ managedFormEditIconElement.style.top = `${rect.top + scrollY + 8}px`;
606
+ managedFormEditIconElement.style.left = `${rect.left + scrollX + 8}px`;
607
+ managedFormEditIconElement.style.display = "flex";
608
+ }
609
+ function removeManagedFormEditIcon() {
610
+ if (managedFormEditIconElement) {
611
+ managedFormEditIconElement.style.display = "none";
612
+ }
613
+ managedFormEditIconTarget = null;
614
+ }
556
615
  function createImageEditIcon(label) {
557
616
  const icon = document.createElement("button");
558
617
  icon.className = "dcs-image-edit-icon";
@@ -766,6 +825,46 @@ function injectEditorStyles() {
766
825
  transform: scale(1.1);
767
826
  }
768
827
 
828
+ .dcs-managed-form-edit-icon {
829
+ position: absolute;
830
+ z-index: 99999;
831
+ display: none;
832
+ align-items: center;
833
+ justify-content: center;
834
+ gap: 4px;
835
+ min-width: 24px;
836
+ height: 24px;
837
+ padding: 0 8px;
838
+ margin: 0;
839
+ border: 1.5px solid hsl(271 91% 65%);
840
+ border-radius: 4px;
841
+ background: hsl(271 91% 65% / 0.12);
842
+ backdrop-filter: blur(4px);
843
+ color: hsl(271 91% 65%);
844
+ cursor: pointer;
845
+ pointer-events: auto;
846
+ transition: background 0.15s, transform 0.1s;
847
+ box-shadow: 0 1px 3px rgba(0,0,0,0.12);
848
+ font-size: 11px;
849
+ font-weight: 600;
850
+ line-height: 1;
851
+ white-space: nowrap;
852
+ }
853
+
854
+ .dcs-managed-form-edit-icon:hover {
855
+ background: hsl(271 91% 65% / 0.24);
856
+ transform: scale(1.03);
857
+ }
858
+
859
+ .dcs-managed-form-edit-icon svg {
860
+ display: block;
861
+ flex-shrink: 0;
862
+ }
863
+
864
+ .dcs-managed-form-edit-label {
865
+ white-space: nowrap;
866
+ }
867
+
769
868
  /* Floating image edit icon button \u2014 green to distinguish from text (blue) and array (violet) */
770
869
  .dcs-image-edit-icon {
771
870
  position: absolute;
@@ -853,33 +952,11 @@ function injectEditorStyles() {
853
952
  }
854
953
 
855
954
  [data-form-key].dcs-managed-form:hover {
856
- outline: 2px solid hsl(271 91% 65% / 0.65) !important;
857
- outline-offset: 10px;
955
+ outline: 2px dashed hsl(271 91% 65% / 0.65) !important;
956
+ outline-offset: 4px;
858
957
  background-color: hsl(271 91% 65% / 0.04);
859
958
  }
860
959
 
861
- [data-form-key].dcs-managed-form::after {
862
- content: 'Click to manage form';
863
- position: absolute;
864
- top: -28px;
865
- left: 8px;
866
- font-size: 11px;
867
- font-weight: 600;
868
- color: hsl(271 91% 65%);
869
- background: hsl(271 91% 65% / 0.12);
870
- border: 1px solid hsl(271 91% 65% / 0.3);
871
- padding: 2px 8px;
872
- border-radius: 4px;
873
- opacity: 0;
874
- transition: opacity 0.2s;
875
- pointer-events: none;
876
- white-space: nowrap;
877
- }
878
-
879
- [data-form-key].dcs-managed-form:hover::after {
880
- opacity: 1;
881
- }
882
-
883
960
  /* Blog metadata (title / summary) \u2014 click to edit */
884
961
  .dcs-blog-metadata {
885
962
  cursor: pointer;
@@ -940,6 +1017,7 @@ function handleMessage(event) {
940
1017
  removeEditIcon();
941
1018
  removeArrayEditIcon();
942
1019
  removeReviewEditIcon();
1020
+ removeManagedFormEditIcon();
943
1021
  removeAllImageEditIcons();
944
1022
  document.querySelectorAll(".dcs-editable").forEach((el) => {
945
1023
  el.classList.remove("dcs-editable");