Compare commits
No commits in common. "main" and "new-interface" have entirely different histories.
main
...
new-interf
39 changed files with 184 additions and 1828 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1833,6 +1833,7 @@
|
|||
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
|
|
@ -2011,6 +2012,7 @@
|
|||
"integrity": "sha512-+VUy01yfDqNmIVMd/LLKl2TTtY0ovZN0rTonh+FhKr65mFwIYgU9WzgIZKS7U9/SPCQvWTsTGx9jyt+qRm/XFw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.5.0",
|
||||
"buffer-builder": "^0.2.0",
|
||||
|
|
@ -2489,6 +2491,7 @@
|
|||
"integrity": "sha512-NL8jTlbo0Tn4dUEXEsUg8KeyG/Lkmc4Fnzb8JXN/Ykm9G4HNImjtABMJgkQoVjOBN/j2WAwDTRytdqJbZsah7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"fdir": "^6.5.0",
|
||||
|
|
@ -2563,6 +2566,7 @@
|
|||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.25.tgz",
|
||||
"integrity": "sha512-YLVdgv2K13WJ6n+kD5owehKtEXwdwXuj2TTyJMsO7pSeKw2bfRNZGjhB7YzrpbMYj5b5QsUebHpOqR3R3ziy/g==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.5.25",
|
||||
"@vue/compiler-sfc": "3.5.25",
|
||||
|
|
|
|||
|
|
@ -192,47 +192,6 @@
|
|||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.block-image.element-hovered,
|
||||
.geoformat-cover-image.element-hovered,
|
||||
.block-carte.element-hovered {
|
||||
outline: 2px solid #0d996050 !important;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
.block-image.element-selected,
|
||||
.geoformat-cover-image.element-selected,
|
||||
.block-carte.element-selected {
|
||||
outline: 2px dashed #0d9960 !important;
|
||||
}
|
||||
|
||||
.image-hover-label {
|
||||
position: absolute;
|
||||
background: #0d9960;
|
||||
color: white;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
opacity: 0.3;
|
||||
pointer-events: none;
|
||||
z-index: 9999;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.carte-hover-label {
|
||||
position: absolute;
|
||||
background: #0d9960;
|
||||
color: white;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
opacity: 0.3;
|
||||
pointer-events: none;
|
||||
z-index: 9999;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
/* Marks (to delete when merge in paged.js) */
|
||||
|
||||
.pagedjs_marks-crop {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ═══════════════════════════════════════════════════════════
|
||||
projet.css
|
||||
Grille des récits — template project.php
|
||||
Grille des récits — template projet.php
|
||||
|
||||
⚠ Ce fichier utilise UNIQUEMENT les variables définies dans
|
||||
style.css → --color-*, --sans-serif, --mono, --border-radius, --space-*
|
||||
|
|
@ -14,8 +14,8 @@
|
|||
/* ───────────────────────────────────────────
|
||||
BASE BODY
|
||||
─────────────────────────────────────────── */
|
||||
body[data-template="project"] {
|
||||
background-color: var(--background-color);
|
||||
body[data-template="projet"] {
|
||||
background-color: var(--nw-paper);
|
||||
color: var(--nw-ink);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
|
@ -143,7 +143,6 @@ body[data-template="project"] {
|
|||
/*overflow: hidden;*/
|
||||
transition: transform var(--nw-transition), box-shadow var(--nw-transition);
|
||||
border: 1px solid var(--nw-rule);
|
||||
background: var(--nw-paper);
|
||||
|
||||
/* Animation d'entrée en cascade */
|
||||
opacity: 0;
|
||||
|
|
@ -390,11 +389,12 @@ body[data-template="project"] {
|
|||
@media (max-width: 900px) {
|
||||
.pj-header__content { padding: 2rem 1.5rem 2.5rem; }
|
||||
.pj-main { padding: 0 0 4rem; }
|
||||
.pj-grid { grid-template-columns: 1fr; padding: 0 1rem;}
|
||||
.pj-grid { grid-template-columns: 1fr; gap: 1px; }
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.pj-card__cover { height: 180px; }
|
||||
.pj-card__footer { flex-direction: column; align-items: stretch; }
|
||||
.pj-btn { justify-content: center; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,18 +102,4 @@
|
|||
--color-700: #6930f5;
|
||||
--color-800: #5d28e6;
|
||||
--color-900: #5223d6;
|
||||
}
|
||||
|
||||
|
||||
[data-color-type="image"]{
|
||||
--color-050: #f0faf5;
|
||||
--color-100: #d9f2e6;
|
||||
--color-200: #b3e5cd;
|
||||
--color-300: #7dd4b0;
|
||||
--color-400: #43c08e;
|
||||
--color-500: #1aad74;
|
||||
--color-600: #0d9960;
|
||||
--color-700: #0a8452;
|
||||
--color-800: #087043;
|
||||
--color-900: #065c35;
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
}
|
||||
|
||||
.toggle-setting:checked + label{
|
||||
background: var(--color-700);
|
||||
background: var(--color-purple);
|
||||
|
||||
&::after {
|
||||
transform: translateX(10px);
|
||||
|
|
|
|||
|
|
@ -189,19 +189,6 @@
|
|||
--color-900: #5223d6;
|
||||
}
|
||||
|
||||
[data-color-type=image] {
|
||||
--color-050: #f0faf5;
|
||||
--color-100: #d9f2e6;
|
||||
--color-200: #b3e5cd;
|
||||
--color-300: #7dd4b0;
|
||||
--color-400: #43c08e;
|
||||
--color-500: #1aad74;
|
||||
--color-600: #0d9960;
|
||||
--color-700: #0a8452;
|
||||
--color-800: #087043;
|
||||
--color-900: #065c35;
|
||||
}
|
||||
|
||||
body,
|
||||
html {
|
||||
padding: 0;
|
||||
|
|
@ -660,7 +647,7 @@ input[type=number] {
|
|||
}
|
||||
|
||||
.toggle-setting:checked + label {
|
||||
background: var(--color-700);
|
||||
background: var(--color-purple);
|
||||
}
|
||||
.toggle-setting:checked + label::after {
|
||||
transform: translateX(10px);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -87,6 +87,7 @@
|
|||
}
|
||||
|
||||
.nw-sidenav__label {
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.89rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.04em;
|
||||
|
|
@ -100,7 +101,6 @@
|
|||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.nw-sidenav__link:hover .nw-sidenav__label,
|
||||
|
|
@ -158,6 +158,7 @@
|
|||
}
|
||||
|
||||
.nw-sidenav__sub-label {
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.03em;
|
||||
|
|
@ -215,7 +216,6 @@
|
|||
top: 20px;
|
||||
left: 20px;
|
||||
transition: transform 0.2s linear;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.nw-prev-btn a{
|
||||
|
|
@ -282,6 +282,7 @@
|
|||
}
|
||||
|
||||
.nw-hero__author {
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.875rem;
|
||||
color: rgba(255,255,255,0.75);
|
||||
letter-spacing: 0.06em;
|
||||
|
|
@ -303,19 +304,29 @@
|
|||
/* ───────────────────────────────────────────
|
||||
INTRODUCTION
|
||||
─────────────────────────────────────────── */
|
||||
.nw-introduction__body {
|
||||
font-family: var(--nw-font-display);
|
||||
color: #fff;
|
||||
font-size: 1.4rem;
|
||||
line-height: 1.4;
|
||||
margin: 2rem 0 0;
|
||||
text-shadow: 0 2px 20px rgba(0,0,0,0.3);
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
.nw-introduction {
|
||||
padding: 4rem 1rem;
|
||||
background: var(--nw-paper);
|
||||
}
|
||||
|
||||
.nw-introduction__body p{
|
||||
margin-bottom: 0;
|
||||
.nw-introduction__body {
|
||||
font-size: 1.4rem;
|
||||
line-height: 1.8;
|
||||
color: var(--nw-ink-soft);
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
border-left: 3px solid var(--nw-accent);
|
||||
padding-left: 2rem;
|
||||
}
|
||||
|
||||
.nw-introduction__body p:first-child::first-letter {
|
||||
font-family: var(--nw-font-display);
|
||||
font-size: 5.7rem;
|
||||
font-weight: 800;
|
||||
line-height: 0.8;
|
||||
float: left;
|
||||
margin: 0.05em 0.12em 0 0;
|
||||
color: var(--nw-accent);
|
||||
}
|
||||
|
||||
/* ───────────────────────────────────────────
|
||||
|
|
@ -399,6 +410,7 @@
|
|||
}
|
||||
|
||||
.nw-tag {
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
|
|
@ -413,7 +425,7 @@
|
|||
PROSE (writer fields)
|
||||
─────────────────────────────────────────── */
|
||||
.nw-prose {
|
||||
font-size: 1.4rem;
|
||||
font-size: 1.3rem;
|
||||
line-height: 1.8;
|
||||
color: var(--nw-ink-soft);
|
||||
margin-bottom: 2rem;
|
||||
|
|
@ -439,29 +451,16 @@
|
|||
background: var(--nw-paper-warm);
|
||||
}
|
||||
|
||||
.nw-section--map__wrapper{
|
||||
margin: 0 auto;
|
||||
max-width: var(--nw-max-w);
|
||||
|
||||
}
|
||||
|
||||
/*.nw-section--map__wrapper{
|
||||
display: flex;
|
||||
}*/
|
||||
|
||||
.nw-section__header__wrapper{
|
||||
/*width: 33.3333%;*/
|
||||
}
|
||||
|
||||
.nw-map-part{
|
||||
/*width: 66.6666%;*/
|
||||
margin: 1.5rem 0rem 4rem 0;
|
||||
.nw-section--map .nw-container {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.nw-map-wrap {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: clamp(400px, 55vh, 700px);
|
||||
border: 1px solid var(--nw-rule);
|
||||
margin: 5rem 0 2rem;
|
||||
border-top: 3px solid var(--nw-accent);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
|
@ -531,6 +530,7 @@
|
|||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.06em;
|
||||
|
|
@ -647,7 +647,7 @@
|
|||
|
||||
/* Corps texte du marqueur */
|
||||
.nw-map-marker__body {
|
||||
padding: 1rem 0 2rem 3rem;
|
||||
padding: 2rem 0 2rem 3rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
|
@ -676,7 +676,6 @@
|
|||
color: var(--nw-ink-soft);
|
||||
}
|
||||
|
||||
.nw-map-marker__content a { color: var(--nw-accent); }
|
||||
.nw-map-marker__content p { margin: 0 0 1.1em; }
|
||||
|
||||
.nw-map-marker__content h2,
|
||||
|
|
@ -715,6 +714,7 @@
|
|||
}
|
||||
|
||||
.nw-map-marker__content figcaption {
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.78rem;
|
||||
color: var(--nw-ink-muted);
|
||||
font-style: italic;
|
||||
|
|
@ -740,13 +740,14 @@
|
|||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
padding-top: 1rem;
|
||||
padding-top: 1.5rem;
|
||||
}
|
||||
|
||||
.nw-file {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
color: var(--nw-ink-soft);
|
||||
|
|
@ -845,6 +846,7 @@
|
|||
gap: 0.5rem;
|
||||
text-decoration: none;
|
||||
color: var(--nw-ink-soft);
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 500;
|
||||
transition: color var(--nw-transition);
|
||||
|
|
@ -891,6 +893,7 @@
|
|||
}
|
||||
|
||||
.nw-chapitre__num {
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.1em;
|
||||
|
|
@ -962,6 +965,7 @@
|
|||
}
|
||||
|
||||
.nw-chapitre__body figcaption {
|
||||
font-family: var(--nw-font-ui);
|
||||
font-size: 0.8rem;
|
||||
color: var(--nw-ink-muted);
|
||||
padding: 0.5rem 1rem 0;
|
||||
|
|
@ -988,18 +992,15 @@
|
|||
@media (max-width: 768px) {
|
||||
.nw-hero__content { padding: 4rem 1.25rem 2.5rem; }
|
||||
.nw-container { padding: 0 1.25rem; }
|
||||
.nw-section__header__wrapper {width: 100%;}
|
||||
.nw-map-part {width: 100%;}
|
||||
.nw-map-wrap { height: 320px; }
|
||||
.nw-chapitre__body figure { margin: 1.5rem 0; }
|
||||
.nw-geoformat-hero { min-height: 35vh; }
|
||||
.nw-geoformat-hero__content { padding: 2rem 1.25rem; }
|
||||
.nw-chap-nav { flex-direction: column; }
|
||||
.nw-section--map__wrapper { flex-wrap: wrap;}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.nw-introduction__body { font-size: 1rem; }
|
||||
.nw-introduction__body { padding-left: 1rem; font-size: 1rem; }
|
||||
.nw-section { padding: 3rem 0; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 5.5L9 2.5L15 5.5L22 2.5V18.5L15 21.5L9 18.5L2 21.5V5.5ZM15 19.261V7.058L9 4.058V16.261L15 19.261ZM17 19.261L21 17.594V5.739L17 7.406V19.261ZM7 16.261V4.406L3 6.073V17.928L7 16.261Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 282 B |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918ZM20 15V5H4V19L14 9L20 15ZM20 17.8284L14 11.8284L6.82843 19H20V17.8284ZM8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 441 B |
|
|
@ -31,12 +31,14 @@ body {
|
|||
}
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
font-size: 22px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 28px;
|
||||
line-height: 38px;
|
||||
background: rgba(60, 143, 66, 0.52);
|
||||
padding-top: 10px;
|
||||
padding-right: 20px;
|
||||
padding-bottom: 10px;
|
||||
|
|
@ -47,14 +49,13 @@ h1 {
|
|||
font-weight: normal;
|
||||
margin-right: 0mm;
|
||||
margin-left: 0mm;
|
||||
color: rgb(224, 9, 9);
|
||||
border-style: solid;
|
||||
border-color: #e01b1b;
|
||||
border-width: 3px;
|
||||
text-align: right;
|
||||
font-style: italic;
|
||||
font-size: 28px;
|
||||
border-style: solid;
|
||||
border- border-width: 3px;
|
||||
border-
|
||||
border- border-color: normal;
|
||||
background: rgba(60, 143, 66, 0.52);}
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,4 @@ Cover: - file://glu48yweigbs4wds
|
|||
|
||||
----
|
||||
|
||||
Background: #fff3e5
|
||||
|
||||
----
|
||||
|
||||
Uuid: eybhqikol6kaorby
|
||||
|
|
@ -1,9 +1,4 @@
|
|||
title: Chapitre
|
||||
buttons:
|
||||
- open
|
||||
- settings
|
||||
- status
|
||||
- languages
|
||||
|
||||
tabs:
|
||||
contentTab:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
title: Géoformat
|
||||
buttons:
|
||||
- open
|
||||
- settings
|
||||
- status
|
||||
- languages
|
||||
|
||||
tabs:
|
||||
contentTab:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
title: Carte
|
||||
buttons:
|
||||
- open
|
||||
- settings
|
||||
- status
|
||||
- languages
|
||||
|
||||
columns:
|
||||
main:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
title: Marqueur
|
||||
icon: location
|
||||
buttons:
|
||||
- open
|
||||
- settings
|
||||
- status
|
||||
- languages
|
||||
|
||||
tabs:
|
||||
content:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
title: Récit
|
||||
buttons:
|
||||
- open
|
||||
- settings
|
||||
- status
|
||||
- languages
|
||||
|
||||
tabs:
|
||||
contentTab:
|
||||
|
|
@ -27,7 +22,7 @@ tabs:
|
|||
text: "{{ file.coverLabel }}"
|
||||
multiple: false
|
||||
width: 1/2
|
||||
pdf:
|
||||
pdf:
|
||||
label: PDF de la publication
|
||||
type: files
|
||||
multiple: false
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
title: Projet
|
||||
buttons:
|
||||
- open
|
||||
- settings
|
||||
- status
|
||||
- languages
|
||||
|
||||
columns:
|
||||
main:
|
||||
|
|
@ -32,9 +27,3 @@ columns:
|
|||
files:
|
||||
label: Fichiers
|
||||
type: files
|
||||
meta:
|
||||
type: fields
|
||||
fields:
|
||||
background:
|
||||
label: Couleur de fond
|
||||
type: color
|
||||
|
|
|
|||
|
|
@ -1,5 +1 @@
|
|||
<?php
|
||||
|
||||
$redirectedTemplates = ['map', 'marker', 'geoformat', 'chapter'];
|
||||
|
||||
if (in_array($page->intendedTemplate(), $redirectedTemplates)) go($page->parents()->findBy('template', 'narrative')->url(), 301);
|
||||
<h1><?= $page->title() ?></h1>
|
||||
|
|
|
|||
|
|
@ -123,15 +123,19 @@ foreach ($subpages as $subpage) {
|
|||
<?php if ($original->author()->isNotEmpty()): ?>
|
||||
<p class="nw-hero__author">Par <span><?= html($original->author()) ?></span></p>
|
||||
<?php endif ?>
|
||||
<!-- Introduction -->
|
||||
<?php if ($original->intro()->isNotEmpty()): ?>
|
||||
<div class="nw-introduction__body nw-container--narrow">
|
||||
<?= $original->intro() ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Introduction -->
|
||||
<?php if ($original->intro()->isNotEmpty()): ?>
|
||||
<section class="nw-introduction">
|
||||
<div class="nw-container nw-container--narrow">
|
||||
<div class="nw-introduction__body">
|
||||
<?= $original->intro() ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<!-- ═══════════════════════════════════════════
|
||||
SOUS-PAGES
|
||||
|
|
@ -146,47 +150,46 @@ foreach ($subpages as $subpage) {
|
|||
───────────────────────────────────────── -->
|
||||
<?php if ($tpl === 'map'): ?>
|
||||
<section class="nw-section nw-section--map" id="section-<?= $subpage->uid() ?>">
|
||||
<div class="nw-section--map__wrapper nw-container">
|
||||
<!-- <div class="nw-container nw-section__header__wrapper"> -->
|
||||
<header class="nw-section__header">
|
||||
<h2 class="nw-section__title"><?= html($subpage->title()) ?></h2>
|
||||
<?php if ($subpage->tags()->isNotEmpty()): ?>
|
||||
<div class="nw-tags">
|
||||
<?php foreach ($subpage->tags()->split(',') as $tag): ?>
|
||||
<span class="nw-tag"><?= html(trim($tag)) ?></span>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</header>
|
||||
<!-- Carte MapLibre inline -->
|
||||
<?php
|
||||
$markers = $subpage->children()->listed()->filterBy('intendedTemplate', 'marker');
|
||||
$mapId = 'map-' . $subpage->uid();
|
||||
?>
|
||||
<div class="nw-map-part">
|
||||
<div class="nw-map-wrap">
|
||||
<div id="<?= $mapId ?>" class="nw-map"></div>
|
||||
</div>
|
||||
<!-- Fichiers de la carte -->
|
||||
<?php if ($subpage->files()->isNotEmpty()): ?>
|
||||
<div class="nw-files">
|
||||
<?php foreach ($subpage->files() as $file): ?>
|
||||
<a href="<?= $file->url() ?>" class="nw-file" target="_blank">
|
||||
<span class="nw-file__icon">↓</span>
|
||||
<span class="nw-file__name"><?= html($file->filename()) ?></span>
|
||||
</a>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<div class="nw-container">
|
||||
<header class="nw-section__header">
|
||||
<h2 class="nw-section__title"><?= html($subpage->title()) ?></h2>
|
||||
<?php if ($subpage->tags()->isNotEmpty()): ?>
|
||||
<div class="nw-tags">
|
||||
<?php foreach ($subpage->tags()->split(',') as $tag): ?>
|
||||
<span class="nw-tag"><?= html(trim($tag)) ?></span>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
<?php if ($subpage->intro()->isNotEmpty()): ?>
|
||||
<div class="nw-prose"><?= $subpage->intro() ?></div>
|
||||
<?php endif ?>
|
||||
<!-- </div> -->
|
||||
</header>
|
||||
|
||||
<?php if ($subpage->intro()->isNotEmpty()): ?>
|
||||
<div class="nw-prose"><?= $subpage->intro() ?></div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
||||
<!-- Carte MapLibre inline -->
|
||||
<?php
|
||||
$markers = $subpage->children()->listed()->filterBy('intendedTemplate', 'marker');
|
||||
$mapId = 'map-' . $subpage->uid();
|
||||
?>
|
||||
<div class="nw-map-wrap">
|
||||
<div id="<?= $mapId ?>" class="nw-map"></div>
|
||||
</div>
|
||||
|
||||
<!-- Fichiers de la carte -->
|
||||
<?php if ($subpage->files()->isNotEmpty()): ?>
|
||||
<div class="nw-container">
|
||||
<div class="nw-files">
|
||||
<?php foreach ($subpage->files() as $file): ?>
|
||||
<a href="<?= $file->url() ?>" class="nw-file" target="_blank">
|
||||
<span class="nw-file__icon">↓</span>
|
||||
<span class="nw-file__name"><?= html($file->filename()) ?></span>
|
||||
</a>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<!-- ── Liste des marqueurs sous la carte ── -->
|
||||
<?php if ($markers->isNotEmpty()): ?>
|
||||
<div class="nw-map-marker-list nw-container">
|
||||
|
|
|
|||
|
|
@ -22,11 +22,7 @@
|
|||
<meta name="csrf" content="<?= csrf() ?>">
|
||||
<?php endif ?>
|
||||
</head>
|
||||
|
||||
<?php
|
||||
if($page->background()->isNotEmpty()){ $background = $page->background();}
|
||||
else{$background = "#FFF";}?>
|
||||
<body data-template="<?= $page->template() ?>" style="--background-color: <?= $background?>">
|
||||
<body data-template="<?= $page->template() ?>">
|
||||
|
||||
<!-- ═══════════════════════════════════════════
|
||||
EN-TÊTE PROJET
|
||||
|
|
|
|||
18
src/App.vue
18
src/App.vue
|
|
@ -2,8 +2,6 @@
|
|||
import PagedJsWrapper from './components/PagedJsWrapper.vue';
|
||||
import EditorPanel from './components/editor/EditorPanel.vue';
|
||||
import ElementPopup from './components/ElementPopup.vue';
|
||||
import ImagePopup from './components/ImagePopup.vue';
|
||||
import CartePopup from './components/CartePopup.vue';
|
||||
// import PagePopup from './components/PagePopup.vue'; // DISABLED: page template styling feature
|
||||
import PreviewLoader from './components/PreviewLoader.vue';
|
||||
import SaveButton from './components/SaveButton.vue';
|
||||
|
|
@ -25,8 +23,6 @@ const { loadFontsFromCss } = useProjectFonts();
|
|||
const previewFrame1 = ref(null);
|
||||
const previewFrame2 = ref(null);
|
||||
const elementPopup = ref(null);
|
||||
const imagePopup = ref(null);
|
||||
const cartePopup = ref(null);
|
||||
// const pagePopup = ref(null); // DISABLED: page template styling feature
|
||||
const activeTab = ref('');
|
||||
|
||||
|
|
@ -42,9 +38,7 @@ const {
|
|||
handleIframeClick,
|
||||
// handlePagePopupClose, // DISABLED: page template styling feature
|
||||
handleElementPopupClose,
|
||||
handleImagePopupClose,
|
||||
handleCartePopupClose,
|
||||
} = useIframeInteractions({ elementPopup, imagePopup, cartePopup });
|
||||
} = useIframeInteractions({ elementPopup });
|
||||
|
||||
// Setup preview renderer with double buffering
|
||||
const {
|
||||
|
|
@ -132,16 +126,6 @@ onMounted(async () => {
|
|||
:iframeRef="activeFrame"
|
||||
@close="handleElementPopupClose"
|
||||
/>
|
||||
|
||||
<ImagePopup
|
||||
ref="imagePopup"
|
||||
@close="handleImagePopupClose"
|
||||
/>
|
||||
|
||||
<CartePopup
|
||||
ref="cartePopup"
|
||||
@close="handleCartePopupClose"
|
||||
/>
|
||||
<!-- DISABLED: page template styling feature
|
||||
<PagePopup
|
||||
ref="pagePopup"
|
||||
|
|
|
|||
|
|
@ -1,481 +0,0 @@
|
|||
<template>
|
||||
<BasePopup
|
||||
ref="basePopup"
|
||||
id="carte-popup"
|
||||
color-type="image"
|
||||
:display-css="displayedCss"
|
||||
:editable-css="editableCss"
|
||||
:popup-width="440"
|
||||
:popup-height="550"
|
||||
:show-inheritance="false"
|
||||
@close="handleClose"
|
||||
@css-input="handleCssInput"
|
||||
>
|
||||
<template #header-left>
|
||||
<span class="carte-label">{{ selector.replace('.block-carte.', '.') || '' }}</span>
|
||||
</template>
|
||||
|
||||
<template #controls>
|
||||
|
||||
<!-- Largeur -->
|
||||
<div class="setting__section" data-setting="width" :class="{ 'setting-disabled': !widthEnabled }" @click="onWidthSectionClick">
|
||||
<div class="setting__header">
|
||||
<input type="checkbox" id="carte-toggle-width" class="toggle-setting" :checked="widthEnabled" @change="onToggleWidth($event.target.checked)" /><label for="carte-toggle-width" aria-label="Activer le réglage de largeur" @click.stop></label>
|
||||
<label class="label-with-tooltip" data-css="width">Largeur</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<InputWithUnit v-model="widthModel" :units="['%', 'px']" :min="1" :max="width.unit === 'px' ? 2000 : 200" showRange />
|
||||
</div>
|
||||
<p class="info-default">Valeur par défaut : {{ carteDefaults.width.value }}{{ carteDefaults.width.unit }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Hauteur -->
|
||||
<div class="setting__section" data-setting="height" :class="{ 'setting-disabled': !heightEnabled }" @click="onHeightSectionClick">
|
||||
<div class="setting__header">
|
||||
<input type="checkbox" id="carte-toggle-height" class="toggle-setting" :checked="heightEnabled" @change="onToggleHeight($event.target.checked)" /><label for="carte-toggle-height" aria-label="Activer le réglage de hauteur" @click.stop></label>
|
||||
<label class="label-with-tooltip" data-css="height">Hauteur</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<div class="field-checkbox" @click.stop>
|
||||
<input type="checkbox" id="carte-height-auto" :checked="heightAuto" @change="onToggleHeightAuto(!heightAuto)" />
|
||||
<label for="carte-height-auto">Auto</label>
|
||||
</div>
|
||||
<InputWithUnit v-if="!heightAuto" :model-value="{ value: heightPx.value, unit: heightPx.unit }" @update:model-value="onHeightValueChange" :units="['px']" :min="1" :max="800" showRange />
|
||||
</div>
|
||||
<p class="info-default">Valeur par défaut : {{ carteDefaults.height.auto ? 'auto' : carteDefaults.height.value + carteDefaults.height.unit }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Marges extérieures -->
|
||||
<div class="setting__section" data-setting="margin" :class="{ 'setting-disabled': !marginEnabled }" @click="onMarginSectionClick">
|
||||
<div class="setting__header">
|
||||
<input type="checkbox" id="carte-toggle-margin" class="toggle-setting" :checked="marginEnabled" @change="onToggleMargin($event.target.checked)" /><label for="carte-toggle-margin" aria-label="Activer les marges" @click.stop></label>
|
||||
<label class="label-with-tooltip" data-css="margin">Marges extérieures</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<div v-for="side in marginSides" :key="side.key" class="field field-margin">
|
||||
<label class="label-with-tooltip" :data-css="`margin-${side.key}`">{{ side.label }}</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput :modelValue="margin[side.key]" :min="0" :max="500" :step="1" @update:modelValue="onMarginChange(side.key, $event)" />
|
||||
<div class="unit-toggle"><button type="button" class="active">px</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Position relative -->
|
||||
<div class="setting__section" data-setting="position" :class="{ 'setting-disabled': !positionEnabled }" @click="onPositionSectionClick">
|
||||
<div class="setting__header">
|
||||
<input type="checkbox" id="carte-toggle-position" class="toggle-setting" :checked="positionEnabled" @change="onTogglePosition($event.target.checked)" /><label for="carte-toggle-position" aria-label="Activer la position relative" @click.stop></label>
|
||||
<label class="label-with-tooltip" data-css="position">Position relative</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<div class="field field-margin">
|
||||
<label class="label-with-tooltip" data-css="top">Haut</label>
|
||||
<InputWithUnit v-model="posTopModel" :units="['px']" :min="-500" :max="500" showRange />
|
||||
</div>
|
||||
<div class="field field-margin">
|
||||
<label class="label-with-tooltip" data-css="left">Gauche</label>
|
||||
<InputWithUnit v-model="posLeftModel" :units="['px']" :min="-500" :max="500" showRange />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</BasePopup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, watch, nextTick } from 'vue';
|
||||
import InputWithUnit from './ui/InputWithUnit.vue';
|
||||
import NumberInput from './ui/NumberInput.vue';
|
||||
import BasePopup from './ui/BasePopup.vue';
|
||||
import { useStylesheetStore } from '../stores/stylesheet';
|
||||
import { useCarteDefaults } from '../composables/useCarteDefaults';
|
||||
import { CARTE_DEFAULTS } from '../utils/defaults';
|
||||
import { useCssUpdater } from '../composables/useCssUpdater';
|
||||
import { useDebounce } from '../composables/useDebounce';
|
||||
|
||||
const emit = defineEmits(['close']);
|
||||
|
||||
const stylesheetStore = useStylesheetStore();
|
||||
const carteDefaults = useCarteDefaults();
|
||||
const { updateStyle, removeProperty } = useCssUpdater();
|
||||
const { debouncedUpdate } = useDebounce(400);
|
||||
|
||||
const basePopup = ref(null);
|
||||
const visible = computed(() => basePopup.value?.visible ?? false);
|
||||
const currentFigure = ref(null);
|
||||
const selector = ref('');
|
||||
|
||||
// --- Width ---
|
||||
const width = reactive({ value: 100, unit: '%' });
|
||||
const widthEnabled = ref(false);
|
||||
const widthCache = ref(null);
|
||||
|
||||
// --- Height ---
|
||||
const heightAuto = ref(true);
|
||||
const heightPx = reactive({ value: CARTE_DEFAULTS.height.value, unit: CARTE_DEFAULTS.height.unit });
|
||||
const heightEnabled = ref(false);
|
||||
const heightCache = ref(null);
|
||||
const measuredHeight = ref(null);
|
||||
|
||||
// --- Margin ---
|
||||
const margin = reactive({ top: 0, right: 0, bottom: 0, left: 0 });
|
||||
const marginEnabled = ref(false);
|
||||
const marginCache = ref(null);
|
||||
const marginSides = [
|
||||
{ key: 'top', label: 'Haut' }, { key: 'right', label: 'Droite' },
|
||||
{ key: 'bottom', label: 'Bas' }, { key: 'left', label: 'Gauche' },
|
||||
];
|
||||
|
||||
// --- Position ---
|
||||
const posTop = ref(0);
|
||||
const posLeft = ref(0);
|
||||
const positionEnabled = ref(false);
|
||||
const positionCache = ref(null);
|
||||
|
||||
const elementStates = new Map();
|
||||
let isUpdatingFromStore = false;
|
||||
|
||||
// --- Models ---
|
||||
const widthModel = computed({
|
||||
get: () => ({ value: width.value, unit: width.unit }),
|
||||
set: (v) => { width.value = v.value; width.unit = v.unit; },
|
||||
});
|
||||
|
||||
// --- Watchers ---
|
||||
watch(() => [width.value, width.unit], () => {
|
||||
if (isUpdatingFromStore || !widthEnabled.value || !selector.value) return;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, 'width', width.value, width.unit); saveState(); });
|
||||
});
|
||||
|
||||
watch(() => carteDefaults.width, (val) => {
|
||||
if (!widthEnabled.value && widthCache.value === null) {
|
||||
isUpdatingFromStore = true; width.value = val.value; width.unit = val.unit;
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
watch(() => carteDefaults.height, (val) => {
|
||||
if (!heightEnabled.value && heightCache.value === null) {
|
||||
isUpdatingFromStore = true; heightAuto.value = val.auto; heightPx.value = val.value; heightPx.unit = val.unit;
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
// --- Height handlers ---
|
||||
const onHeightValueChange = (v) => {
|
||||
heightPx.value = v.value; heightPx.unit = v.unit;
|
||||
if (isUpdatingFromStore || !heightEnabled.value || heightAuto.value || !selector.value) return;
|
||||
measuredHeight.value = v.value;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, 'height', heightPx.value, heightPx.unit); saveState(); });
|
||||
};
|
||||
|
||||
const getActualImageHeight = () => {
|
||||
if (currentFigure.value) {
|
||||
const img = currentFigure.value.querySelector('img');
|
||||
if (img) { const h = Math.round(img.getBoundingClientRect().height); if (h > 0) return Math.min(h, 800); }
|
||||
const figH = Math.round(currentFigure.value.getBoundingClientRect().height);
|
||||
if (figH > 0) return Math.min(figH, 800);
|
||||
}
|
||||
return CARTE_DEFAULTS.height.value;
|
||||
};
|
||||
|
||||
// --- Toggle Width ---
|
||||
const onWidthSectionClick = () => { if (!widthEnabled.value) onToggleWidth(true); };
|
||||
const onToggleWidth = (enabled) => {
|
||||
isUpdatingFromStore = true; widthEnabled.value = enabled;
|
||||
if (enabled) {
|
||||
if (widthCache.value) { width.value = widthCache.value.value; width.unit = widthCache.value.unit; widthCache.value = null; }
|
||||
stylesheetStore.updateProperty(selector.value, 'width', width.value, width.unit);
|
||||
} else {
|
||||
widthCache.value = { value: width.value, unit: width.unit };
|
||||
removeProp('width'); width.value = carteDefaults.width.value; width.unit = carteDefaults.width.unit;
|
||||
}
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- Toggle Height ---
|
||||
const onHeightSectionClick = () => { if (!heightEnabled.value) onToggleHeight(true); };
|
||||
const onToggleHeight = (enabled) => {
|
||||
isUpdatingFromStore = true; heightEnabled.value = enabled;
|
||||
if (enabled) {
|
||||
if (heightCache.value) { heightAuto.value = heightCache.value.auto; heightPx.value = heightCache.value.value; heightPx.unit = heightCache.value.unit; heightCache.value = null; }
|
||||
applyHeight();
|
||||
if (!heightAuto.value) updateStyle(`${selector.value} img`, 'height', '100%');
|
||||
} else {
|
||||
heightCache.value = { auto: heightAuto.value, value: heightPx.value, unit: heightPx.unit };
|
||||
removeProp('height'); removeProperty(`${selector.value} img`, 'height');
|
||||
heightAuto.value = carteDefaults.height.auto; heightPx.value = carteDefaults.height.value; heightPx.unit = carteDefaults.height.unit;
|
||||
}
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
const onToggleHeightAuto = (auto) => {
|
||||
if (!heightEnabled.value) return;
|
||||
isUpdatingFromStore = true;
|
||||
if (!auto && heightAuto.value) { if (measuredHeight.value === null) measuredHeight.value = getActualImageHeight(); heightPx.value = measuredHeight.value; heightPx.unit = 'px'; }
|
||||
heightAuto.value = auto; applyHeight();
|
||||
if (!auto) { updateStyle(`${selector.value} img`, 'height', '100%'); } else { removeProperty(`${selector.value} img`, 'height'); }
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- Toggle Margin ---
|
||||
const onMarginSectionClick = () => { if (!marginEnabled.value) onToggleMargin(true); };
|
||||
const onToggleMargin = (enabled) => {
|
||||
isUpdatingFromStore = true; marginEnabled.value = enabled;
|
||||
if (enabled) {
|
||||
if (marginCache.value) { Object.assign(margin, marginCache.value); marginCache.value = null; }
|
||||
applyMargin();
|
||||
} else {
|
||||
marginCache.value = { ...margin };
|
||||
removeMarginProps();
|
||||
margin.top = 0; margin.right = 0; margin.bottom = 0; margin.left = 0;
|
||||
}
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
const onMarginChange = (side, val) => {
|
||||
margin[side] = val;
|
||||
if (isUpdatingFromStore || !marginEnabled.value || !selector.value) return;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, `margin-${side}`, val, 'px'); saveState(); });
|
||||
};
|
||||
|
||||
// --- Position models ---
|
||||
const posTopModel = computed({
|
||||
get: () => ({ value: posTop.value, unit: 'px' }),
|
||||
set: (v) => { posTop.value = v.value; },
|
||||
});
|
||||
const posLeftModel = computed({
|
||||
get: () => ({ value: posLeft.value, unit: 'px' }),
|
||||
set: (v) => { posLeft.value = v.value; },
|
||||
});
|
||||
|
||||
watch(posTop, (val) => {
|
||||
if (isUpdatingFromStore || !positionEnabled.value || !selector.value) return;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, 'top', val, 'px'); saveState(); });
|
||||
});
|
||||
watch(posLeft, (val) => {
|
||||
if (isUpdatingFromStore || !positionEnabled.value || !selector.value) return;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, 'left', val, 'px'); saveState(); });
|
||||
});
|
||||
|
||||
// --- Toggle Position ---
|
||||
const onPositionSectionClick = () => { if (!positionEnabled.value) onTogglePosition(true); };
|
||||
const onTogglePosition = (enabled) => {
|
||||
isUpdatingFromStore = true; positionEnabled.value = enabled;
|
||||
if (enabled) {
|
||||
if (positionCache.value) { posTop.value = positionCache.value.top; posLeft.value = positionCache.value.left; positionCache.value = null; }
|
||||
applyPosition();
|
||||
} else {
|
||||
positionCache.value = { top: posTop.value, left: posLeft.value };
|
||||
removeProp('position'); removeProp('top'); removeProp('left');
|
||||
posTop.value = 0; posLeft.value = 0;
|
||||
}
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- CSS helpers ---
|
||||
const applyHeight = () => {
|
||||
if (!selector.value) return;
|
||||
if (heightAuto.value) { stylesheetStore.updateProperty(selector.value, 'height', 'auto'); }
|
||||
else { stylesheetStore.updateProperty(selector.value, 'height', heightPx.value, heightPx.unit); }
|
||||
};
|
||||
const applyMargin = () => {
|
||||
if (!selector.value) return;
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) {
|
||||
stylesheetStore.updateProperty(selector.value, `margin-${side}`, margin[side], 'px');
|
||||
}
|
||||
};
|
||||
const applyPosition = () => {
|
||||
if (!selector.value) return;
|
||||
stylesheetStore.updateProperty(selector.value, 'position', 'relative');
|
||||
stylesheetStore.updateProperty(selector.value, 'top', posTop.value, 'px');
|
||||
stylesheetStore.updateProperty(selector.value, 'left', posLeft.value, 'px');
|
||||
};
|
||||
const removeMarginProps = () => {
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) removeProp(`margin-${side}`);
|
||||
};
|
||||
const removeProp = (prop) => {
|
||||
if (!selector.value) return;
|
||||
const block = stylesheetStore.extractBlock(selector.value);
|
||||
if (!block || !stylesheetStore.customCss.includes(block)) return;
|
||||
const escaped = prop.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const newBlock = block.replace(new RegExp(`[ \\t]*${escaped}\\s*:[^;]*;[ \\t]*\\n?`, 'g'), '');
|
||||
const inner = newBlock.replace(/^[^{]*\{/, '').replace(/\}[^}]*$/, '');
|
||||
if (!inner.trim()) { stylesheetStore.replaceInCustomCss(block, ''); } else { stylesheetStore.replaceBlock(block, newBlock); }
|
||||
};
|
||||
|
||||
// --- Displayed CSS ---
|
||||
const displayedCss = computed(() => {
|
||||
if (!selector.value) return '';
|
||||
const lines = [];
|
||||
|
||||
const widthVal = `${width.value}${width.unit}`;
|
||||
const defaultWidthVal = `${carteDefaults.width.value}${carteDefaults.width.unit}`;
|
||||
const wComment = (!widthEnabled.value && widthVal === defaultWidthVal) ? ' /* hérité de .block-carte */' : '';
|
||||
lines.push(` width: ${widthVal};${wComment}`);
|
||||
|
||||
const heightVal = heightAuto.value ? 'auto' : `${heightPx.value}${heightPx.unit}`;
|
||||
const defaultHeightVal = carteDefaults.height.auto ? 'auto' : `${carteDefaults.height.value}${carteDefaults.height.unit}`;
|
||||
const hComment = (!heightEnabled.value && heightVal === defaultHeightVal) ? ' /* hérité de .block-carte */' : '';
|
||||
lines.push(` height: ${heightVal};${hComment}`);
|
||||
|
||||
if (marginEnabled.value) {
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) lines.push(` margin-${side}: ${margin[side]}px;`);
|
||||
}
|
||||
if (positionEnabled.value) {
|
||||
lines.push(` position: relative;`);
|
||||
lines.push(` top: ${posTop.value}px;`);
|
||||
lines.push(` left: ${posLeft.value}px;`);
|
||||
}
|
||||
|
||||
return `${selector.value} {\n${lines.join('\n')}\n}`;
|
||||
});
|
||||
|
||||
const editableCss = computed(() => {
|
||||
return displayedCss.value.replace(/ \/\* hérité de \.block-carte \*\//g, '');
|
||||
});
|
||||
|
||||
// --- CSS input ---
|
||||
const handleCssInput = (newCss) => {
|
||||
isUpdatingFromStore = true;
|
||||
|
||||
const wm = newCss.match(/width\s*:\s*([\d.]+)(%|px)/i);
|
||||
if (wm) { width.value = parseFloat(wm[1]); width.unit = wm[2]; }
|
||||
|
||||
const hm = newCss.match(/height\s*:\s*([^;]+)/i);
|
||||
if (hm) {
|
||||
const hVal = hm[1].trim();
|
||||
if (hVal === 'auto') { heightAuto.value = true; }
|
||||
else { const m = hVal.match(/([\d.]+)px/i); if (m) { heightAuto.value = false; heightPx.value = parseFloat(m[1]); heightPx.unit = 'px'; } }
|
||||
}
|
||||
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) {
|
||||
const mm = newCss.match(new RegExp(`margin-${side}\\s*:\\s*([\\d.]+)px`, 'i'));
|
||||
if (mm) margin[side] = parseFloat(mm[1]);
|
||||
}
|
||||
|
||||
const posCss = newCss.match(/(?:^|\n)\s*position\s*:\s*([^;]+)/i);
|
||||
if (posCss) positionEnabled.value = posCss[1].trim() === 'relative';
|
||||
const tm = newCss.match(/(?:^|\n)\s*top\s*:\s*([-\d.]+)px/i);
|
||||
if (tm) posTop.value = parseFloat(tm[1]);
|
||||
const bm = newCss.match(/(?:^|\n)\s*left\s*:\s*([-\d.]+)px/i);
|
||||
if (bm) posLeft.value = parseFloat(bm[1]);
|
||||
|
||||
const lines = [` width: ${width.value}${width.unit};`, ` height: ${heightAuto.value ? 'auto' : `${heightPx.value}${heightPx.unit}`};`];
|
||||
if (marginEnabled.value) for (const s of ['top','right','bottom','left']) lines.push(` margin-${s}: ${margin[s]}px;`);
|
||||
if (positionEnabled.value) { lines.push(` position: relative;`); lines.push(` top: ${posTop.value}px;`); lines.push(` left: ${posLeft.value}px;`); }
|
||||
|
||||
const newBlock = `${selector.value} {\n${lines.join('\n')}\n}\n`;
|
||||
const oldBlock = stylesheetStore.extractBlock(selector.value) || '';
|
||||
if (oldBlock) { stylesheetStore.replaceInCustomCss(oldBlock, newBlock); }
|
||||
else { stylesheetStore.setCustomCss((stylesheetStore.customCss || '') + '\n' + newBlock); }
|
||||
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- State persistence ---
|
||||
const saveState = () => {
|
||||
if (!selector.value) return;
|
||||
elementStates.set(selector.value, {
|
||||
widthToggle: widthEnabled.value, widthCache: widthCache.value ? { ...widthCache.value } : null,
|
||||
widthValue: { value: width.value, unit: width.unit },
|
||||
heightToggle: heightEnabled.value, heightCache: heightCache.value ? { ...heightCache.value } : null,
|
||||
heightAuto: heightAuto.value, heightValue: { value: heightPx.value, unit: heightPx.unit },
|
||||
marginToggle: marginEnabled.value, marginCache: marginCache.value ? { ...marginCache.value } : null,
|
||||
marginValue: { ...margin },
|
||||
positionToggle: positionEnabled.value, positionCache: positionCache.value ? { ...positionCache.value } : null,
|
||||
posTop: posTop.value, posLeft: posLeft.value,
|
||||
});
|
||||
};
|
||||
|
||||
// --- Open ---
|
||||
const handleCarteClick = (figure, event) => {
|
||||
const uniqueClass = Array.from(figure.classList).find(cls => cls.startsWith('block-carte--'));
|
||||
const sel = uniqueClass ? `.block-carte.${uniqueClass}` : '.block-carte';
|
||||
|
||||
isUpdatingFromStore = true;
|
||||
selector.value = sel;
|
||||
currentFigure.value = figure;
|
||||
measuredHeight.value = null;
|
||||
|
||||
const stored = elementStates.get(sel);
|
||||
if (stored) {
|
||||
widthEnabled.value = stored.widthToggle;
|
||||
widthCache.value = stored.widthCache ? { ...stored.widthCache } : null;
|
||||
width.value = stored.widthToggle ? stored.widthValue.value : (stored.widthCache ? stored.widthCache.value : carteDefaults.width.value);
|
||||
width.unit = stored.widthToggle ? stored.widthValue.unit : (stored.widthCache ? stored.widthCache.unit : carteDefaults.width.unit);
|
||||
heightEnabled.value = stored.heightToggle;
|
||||
heightCache.value = stored.heightCache ? { ...stored.heightCache } : null;
|
||||
heightAuto.value = stored.heightAuto;
|
||||
heightPx.value = stored.heightToggle ? stored.heightValue.value : (stored.heightCache ? stored.heightCache.value : carteDefaults.height.value);
|
||||
heightPx.unit = stored.heightToggle ? stored.heightValue.unit : (stored.heightCache ? stored.heightCache.unit : carteDefaults.height.unit);
|
||||
marginEnabled.value = stored.marginToggle || false;
|
||||
marginCache.value = stored.marginCache ? { ...stored.marginCache } : null;
|
||||
Object.assign(margin, stored.marginToggle ? stored.marginValue : (stored.marginCache || { top: 0, right: 0, bottom: 0, left: 0 }));
|
||||
positionEnabled.value = stored.positionToggle || false;
|
||||
positionCache.value = stored.positionCache ? { ...stored.positionCache } : null;
|
||||
posTop.value = stored.positionToggle ? stored.posTop : (stored.positionCache ? stored.positionCache.top : 0);
|
||||
posLeft.value = stored.positionToggle ? stored.posLeft : (stored.positionCache ? stored.positionCache.left : 0);
|
||||
} else {
|
||||
widthEnabled.value = false; widthCache.value = null;
|
||||
const wCss = stylesheetStore.extractValue(sel, 'width');
|
||||
if (wCss && wCss.value !== undefined) {
|
||||
width.value = wCss.value; width.unit = wCss.unit;
|
||||
if (!(wCss.value === carteDefaults.width.value && wCss.unit === carteDefaults.width.unit)) widthEnabled.value = true;
|
||||
} else { width.value = carteDefaults.width.value; width.unit = carteDefaults.width.unit; }
|
||||
|
||||
heightEnabled.value = false; heightCache.value = null;
|
||||
const hCss = stylesheetStore.extractValue(sel, 'height');
|
||||
const hStr = typeof hCss === 'string' ? hCss : null;
|
||||
if (hStr === 'auto') { heightAuto.value = true; }
|
||||
else if (hStr) { const m = hStr.match(/([\d.]+)px/i); if (m) { heightAuto.value = false; heightPx.value = parseFloat(m[1]); heightPx.unit = 'px'; heightEnabled.value = true; } else { heightAuto.value = carteDefaults.height.auto; heightPx.value = carteDefaults.height.value; heightPx.unit = carteDefaults.height.unit; } }
|
||||
else if (hCss && hCss.value !== undefined) { heightAuto.value = false; heightPx.value = hCss.value; heightPx.unit = hCss.unit; heightEnabled.value = true; }
|
||||
else { heightAuto.value = carteDefaults.height.auto; heightPx.value = carteDefaults.height.value; heightPx.unit = carteDefaults.height.unit; }
|
||||
|
||||
marginEnabled.value = false; marginCache.value = null;
|
||||
margin.top = 0; margin.right = 0; margin.bottom = 0; margin.left = 0;
|
||||
let hasMargin = false;
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) {
|
||||
const mCss = stylesheetStore.extractValue(sel, `margin-${side}`);
|
||||
if (mCss) { const v = mCss.value !== undefined ? mCss.value : parseFloat(mCss); if (!isNaN(v) && v !== 0) { margin[side] = v; hasMargin = true; } }
|
||||
}
|
||||
if (hasMargin) marginEnabled.value = true;
|
||||
|
||||
positionEnabled.value = false; positionCache.value = null; posTop.value = 0; posLeft.value = 0;
|
||||
const posCss = stylesheetStore.extractValue(sel, 'position');
|
||||
const posStr = typeof posCss === 'string' ? posCss : posCss?.value;
|
||||
if (posStr === 'relative') {
|
||||
positionEnabled.value = true;
|
||||
const tCss = stylesheetStore.extractValue(sel, 'top');
|
||||
const bCss = stylesheetStore.extractValue(sel, 'left');
|
||||
posTop.value = tCss ? (tCss.value !== undefined ? tCss.value : parseFloat(tCss)) || 0 : 0;
|
||||
posLeft.value = bCss ? (bCss.value !== undefined ? bCss.value : parseFloat(bCss)) || 0 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
basePopup.value.open(event);
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- Close ---
|
||||
const handleClose = () => {
|
||||
saveState();
|
||||
selector.value = '';
|
||||
currentFigure.value = null;
|
||||
if (basePopup.value?.visible) basePopup.value.close();
|
||||
emit('close');
|
||||
};
|
||||
|
||||
defineExpose({ handleCarteClick, close: () => basePopup.value?.close(), visible });
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.carte-label {
|
||||
background: var(--color-600);
|
||||
color: white;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
<BasePopup
|
||||
ref="basePopup"
|
||||
id="element-popup"
|
||||
color-type="text"
|
||||
:display-css="displayedCss"
|
||||
:editable-css="editableFullCss"
|
||||
:popup-width="800"
|
||||
|
|
|
|||
|
|
@ -1,491 +0,0 @@
|
|||
<template>
|
||||
<BasePopup
|
||||
ref="basePopup"
|
||||
id="image-popup"
|
||||
color-type="image"
|
||||
:display-css="displayedCss"
|
||||
:editable-css="editableCss"
|
||||
:popup-width="440"
|
||||
:popup-height="550"
|
||||
:show-inheritance="false"
|
||||
@close="handleClose"
|
||||
@css-input="handleCssInput"
|
||||
>
|
||||
<template #header-left>
|
||||
<span class="image-label">{{ selector.replace('.block-image.', '.') || '' }}</span>
|
||||
</template>
|
||||
|
||||
<template #controls>
|
||||
|
||||
<!-- Largeur -->
|
||||
<div class="setting__section" data-setting="width" :class="{ 'setting-disabled': !widthEnabled }" @click="onWidthSectionClick">
|
||||
<div class="setting__header">
|
||||
<input type="checkbox" id="img-toggle-width" class="toggle-setting" :checked="widthEnabled" @change="onToggleWidth($event.target.checked)" /><label for="img-toggle-width" aria-label="Activer le réglage de largeur" @click.stop></label>
|
||||
<label class="label-with-tooltip" data-css="width">Largeur</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<InputWithUnit v-model="widthModel" :units="['%', 'px']" :min="1" :max="width.unit === 'px' ? 2000 : 200" showRange />
|
||||
</div>
|
||||
<p class="info-default">Valeur par défaut : {{ imageDefaults.width.value }}{{ imageDefaults.width.unit }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Hauteur -->
|
||||
<div class="setting__section" data-setting="height" :class="{ 'setting-disabled': !heightEnabled }" @click="onHeightSectionClick">
|
||||
<div class="setting__header">
|
||||
<input type="checkbox" id="img-toggle-height" class="toggle-setting" :checked="heightEnabled" @change="onToggleHeight($event.target.checked)" /><label for="img-toggle-height" aria-label="Activer le réglage de hauteur" @click.stop></label>
|
||||
<label class="label-with-tooltip" data-css="height">Hauteur</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<div class="field-checkbox" @click.stop>
|
||||
<input type="checkbox" id="img-height-auto" :checked="heightAuto" @change="onToggleHeightAuto(!heightAuto)" />
|
||||
<label for="img-height-auto">Auto</label>
|
||||
</div>
|
||||
<InputWithUnit v-if="!heightAuto" :model-value="{ value: heightPx.value, unit: heightPx.unit }" @update:model-value="onHeightValueChange" :units="['px']" :min="1" :max="800" showRange />
|
||||
</div>
|
||||
<p class="info-default">Valeur par défaut : {{ imageDefaults.height.auto ? 'auto' : imageDefaults.height.value + imageDefaults.height.unit }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Marges extérieures -->
|
||||
<div class="setting__section" data-setting="margin" :class="{ 'setting-disabled': !marginEnabled }" @click="onMarginSectionClick">
|
||||
<div class="setting__header">
|
||||
<input type="checkbox" id="img-toggle-margin" class="toggle-setting" :checked="marginEnabled" @change="onToggleMargin($event.target.checked)" /><label for="img-toggle-margin" aria-label="Activer les marges" @click.stop></label>
|
||||
<label class="label-with-tooltip" data-css="margin">Marges extérieures</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<div v-for="side in marginSides" :key="side.key" class="field field-margin">
|
||||
<label class="label-with-tooltip" :data-css="`margin-${side.key}`">{{ side.label }}</label>
|
||||
<div class="input-with-unit">
|
||||
<NumberInput :modelValue="margin[side.key]" :min="0" :max="500" :step="1" @update:modelValue="onMarginChange(side.key, $event)" />
|
||||
<div class="unit-toggle"><button type="button" class="active">px</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Position relative -->
|
||||
<div class="setting__section" data-setting="position" :class="{ 'setting-disabled': !positionEnabled }" @click="onPositionSectionClick">
|
||||
<div class="setting__header">
|
||||
<input type="checkbox" id="img-toggle-position" class="toggle-setting" :checked="positionEnabled" @change="onTogglePosition($event.target.checked)" /><label for="img-toggle-position" aria-label="Activer la position relative" @click.stop></label>
|
||||
<label class="label-with-tooltip" data-css="position">Position relative</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<div class="field field-margin">
|
||||
<label class="label-with-tooltip" data-css="top">Haut</label>
|
||||
<InputWithUnit v-model="posTopModel" :units="['px']" :min="-500" :max="500" showRange />
|
||||
</div>
|
||||
<div class="field field-margin">
|
||||
<label class="label-with-tooltip" data-css="left">Gauche</label>
|
||||
<InputWithUnit v-model="posLeftModel" :units="['px']" :min="-500" :max="500" showRange />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</BasePopup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, watch, nextTick } from 'vue';
|
||||
import InputWithUnit from './ui/InputWithUnit.vue';
|
||||
import NumberInput from './ui/NumberInput.vue';
|
||||
import BasePopup from './ui/BasePopup.vue';
|
||||
import { useStylesheetStore } from '../stores/stylesheet';
|
||||
import { useImageDefaults } from '../composables/useImageDefaults';
|
||||
import { IMAGE_DEFAULTS } from '../utils/defaults';
|
||||
import { useCssUpdater } from '../composables/useCssUpdater';
|
||||
import { useDebounce } from '../composables/useDebounce';
|
||||
|
||||
const emit = defineEmits(['close']);
|
||||
|
||||
const stylesheetStore = useStylesheetStore();
|
||||
const imageDefaults = useImageDefaults();
|
||||
const { updateStyle, removeProperty } = useCssUpdater();
|
||||
const { debouncedUpdate } = useDebounce(400);
|
||||
|
||||
const basePopup = ref(null);
|
||||
const visible = computed(() => basePopup.value?.visible ?? false);
|
||||
const currentFigure = ref(null);
|
||||
const selector = ref('');
|
||||
|
||||
// --- Width ---
|
||||
const width = reactive({ value: 100, unit: '%' });
|
||||
const widthEnabled = ref(false);
|
||||
const widthCache = ref(null);
|
||||
|
||||
// --- Height ---
|
||||
const heightAuto = ref(true);
|
||||
const heightPx = reactive({ value: IMAGE_DEFAULTS.height.value, unit: IMAGE_DEFAULTS.height.unit });
|
||||
const heightEnabled = ref(false);
|
||||
const heightCache = ref(null);
|
||||
const measuredHeight = ref(null);
|
||||
|
||||
// --- Margin ---
|
||||
const margin = reactive({ top: 0, right: 0, bottom: 0, left: 0 });
|
||||
const marginEnabled = ref(false);
|
||||
const marginCache = ref(null);
|
||||
const marginSides = [
|
||||
{ key: 'top', label: 'Haut' }, { key: 'right', label: 'Droite' },
|
||||
{ key: 'bottom', label: 'Bas' }, { key: 'left', label: 'Gauche' },
|
||||
];
|
||||
|
||||
// --- Position ---
|
||||
const posTop = ref(0);
|
||||
const posLeft = ref(0);
|
||||
const positionEnabled = ref(false);
|
||||
const positionCache = ref(null);
|
||||
|
||||
const elementStates = new Map();
|
||||
let isUpdatingFromStore = false;
|
||||
|
||||
// --- Models ---
|
||||
const widthModel = computed({
|
||||
get: () => ({ value: width.value, unit: width.unit }),
|
||||
set: (v) => { width.value = v.value; width.unit = v.unit; },
|
||||
});
|
||||
|
||||
// --- Watchers ---
|
||||
watch(() => [width.value, width.unit], () => {
|
||||
if (isUpdatingFromStore || !widthEnabled.value || !selector.value) return;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, 'width', width.value, width.unit); saveState(); });
|
||||
});
|
||||
|
||||
watch(() => imageDefaults.width, (val) => {
|
||||
if (!widthEnabled.value && widthCache.value === null) {
|
||||
isUpdatingFromStore = true; width.value = val.value; width.unit = val.unit;
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
watch(() => imageDefaults.height, (val) => {
|
||||
if (!heightEnabled.value && heightCache.value === null) {
|
||||
isUpdatingFromStore = true; heightAuto.value = val.auto; heightPx.value = val.value; heightPx.unit = val.unit;
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
// --- Height handlers ---
|
||||
const onHeightValueChange = (v) => {
|
||||
heightPx.value = v.value; heightPx.unit = v.unit;
|
||||
if (isUpdatingFromStore || !heightEnabled.value || heightAuto.value || !selector.value) return;
|
||||
measuredHeight.value = v.value;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, 'height', heightPx.value, heightPx.unit); saveState(); });
|
||||
};
|
||||
|
||||
const getActualImageHeight = () => {
|
||||
if (currentFigure.value) {
|
||||
const img = currentFigure.value.querySelector('img');
|
||||
if (img) { const h = Math.round(img.getBoundingClientRect().height); if (h > 0) return Math.min(h, 800); }
|
||||
const figH = Math.round(currentFigure.value.getBoundingClientRect().height);
|
||||
if (figH > 0) return Math.min(figH, 800);
|
||||
}
|
||||
return IMAGE_DEFAULTS.height.value;
|
||||
};
|
||||
|
||||
// --- Toggle Width ---
|
||||
const onWidthSectionClick = () => { if (!widthEnabled.value) onToggleWidth(true); };
|
||||
const onToggleWidth = (enabled) => {
|
||||
isUpdatingFromStore = true; widthEnabled.value = enabled;
|
||||
if (enabled) {
|
||||
if (widthCache.value) { width.value = widthCache.value.value; width.unit = widthCache.value.unit; widthCache.value = null; }
|
||||
stylesheetStore.updateProperty(selector.value, 'width', width.value, width.unit);
|
||||
} else {
|
||||
widthCache.value = { value: width.value, unit: width.unit };
|
||||
removeProp('width'); width.value = imageDefaults.width.value; width.unit = imageDefaults.width.unit;
|
||||
}
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- Toggle Height ---
|
||||
const onHeightSectionClick = () => { if (!heightEnabled.value) onToggleHeight(true); };
|
||||
const onToggleHeight = (enabled) => {
|
||||
isUpdatingFromStore = true; heightEnabled.value = enabled;
|
||||
if (enabled) {
|
||||
if (heightCache.value) { heightAuto.value = heightCache.value.auto; heightPx.value = heightCache.value.value; heightPx.unit = heightCache.value.unit; heightCache.value = null; }
|
||||
applyHeight();
|
||||
if (!heightAuto.value) updateStyle(`${selector.value} img`, 'height', '100%');
|
||||
} else {
|
||||
heightCache.value = { auto: heightAuto.value, value: heightPx.value, unit: heightPx.unit };
|
||||
removeProp('height'); removeProperty(`${selector.value} img`, 'height');
|
||||
heightAuto.value = imageDefaults.height.auto; heightPx.value = imageDefaults.height.value; heightPx.unit = imageDefaults.height.unit;
|
||||
}
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
const onToggleHeightAuto = (auto) => {
|
||||
if (!heightEnabled.value) return;
|
||||
isUpdatingFromStore = true;
|
||||
if (!auto && heightAuto.value) { if (measuredHeight.value === null) measuredHeight.value = getActualImageHeight(); heightPx.value = measuredHeight.value; heightPx.unit = 'px'; }
|
||||
heightAuto.value = auto; applyHeight();
|
||||
if (!auto) { updateStyle(`${selector.value} img`, 'height', '100%'); } else { removeProperty(`${selector.value} img`, 'height'); }
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- Toggle Margin ---
|
||||
const onMarginSectionClick = () => { if (!marginEnabled.value) onToggleMargin(true); };
|
||||
const onToggleMargin = (enabled) => {
|
||||
isUpdatingFromStore = true; marginEnabled.value = enabled;
|
||||
if (enabled) {
|
||||
if (marginCache.value) { Object.assign(margin, marginCache.value); marginCache.value = null; }
|
||||
applyMargin();
|
||||
} else {
|
||||
marginCache.value = { ...margin };
|
||||
removeMarginProps();
|
||||
margin.top = 0; margin.right = 0; margin.bottom = 0; margin.left = 0;
|
||||
}
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
const onMarginChange = (side, val) => {
|
||||
margin[side] = val;
|
||||
if (isUpdatingFromStore || !marginEnabled.value || !selector.value) return;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, `margin-${side}`, val, 'px'); saveState(); });
|
||||
};
|
||||
|
||||
// --- Position models ---
|
||||
const posTopModel = computed({
|
||||
get: () => ({ value: posTop.value, unit: 'px' }),
|
||||
set: (v) => { posTop.value = v.value; },
|
||||
});
|
||||
const posLeftModel = computed({
|
||||
get: () => ({ value: posLeft.value, unit: 'px' }),
|
||||
set: (v) => { posLeft.value = v.value; },
|
||||
});
|
||||
|
||||
watch(posTop, (val) => {
|
||||
if (isUpdatingFromStore || !positionEnabled.value || !selector.value) return;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, 'top', val, 'px'); saveState(); });
|
||||
});
|
||||
watch(posLeft, (val) => {
|
||||
if (isUpdatingFromStore || !positionEnabled.value || !selector.value) return;
|
||||
debouncedUpdate(() => { stylesheetStore.updateProperty(selector.value, 'left', val, 'px'); saveState(); });
|
||||
});
|
||||
|
||||
// --- Toggle Position ---
|
||||
const onPositionSectionClick = () => { if (!positionEnabled.value) onTogglePosition(true); };
|
||||
const onTogglePosition = (enabled) => {
|
||||
isUpdatingFromStore = true; positionEnabled.value = enabled;
|
||||
if (enabled) {
|
||||
if (positionCache.value) { posTop.value = positionCache.value.top; posLeft.value = positionCache.value.left; positionCache.value = null; }
|
||||
applyPosition();
|
||||
} else {
|
||||
positionCache.value = { top: posTop.value, left: posLeft.value };
|
||||
removeProp('position'); removeProp('top'); removeProp('left');
|
||||
posTop.value = 0; posLeft.value = 0;
|
||||
}
|
||||
saveState(); nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- CSS helpers ---
|
||||
const applyHeight = () => {
|
||||
if (!selector.value) return;
|
||||
if (heightAuto.value) { stylesheetStore.updateProperty(selector.value, 'height', 'auto'); }
|
||||
else { stylesheetStore.updateProperty(selector.value, 'height', heightPx.value, heightPx.unit); }
|
||||
};
|
||||
const applyMargin = () => {
|
||||
if (!selector.value) return;
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) {
|
||||
stylesheetStore.updateProperty(selector.value, `margin-${side}`, margin[side], 'px');
|
||||
}
|
||||
};
|
||||
const applyPosition = () => {
|
||||
if (!selector.value) return;
|
||||
stylesheetStore.updateProperty(selector.value, 'position', 'relative');
|
||||
stylesheetStore.updateProperty(selector.value, 'top', posTop.value, 'px');
|
||||
stylesheetStore.updateProperty(selector.value, 'left', posLeft.value, 'px');
|
||||
};
|
||||
const removeMarginProps = () => {
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) removeProp(`margin-${side}`);
|
||||
};
|
||||
const removeProp = (prop) => {
|
||||
if (!selector.value) return;
|
||||
const block = stylesheetStore.extractBlock(selector.value);
|
||||
if (!block || !stylesheetStore.customCss.includes(block)) return;
|
||||
const escaped = prop.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const newBlock = block.replace(new RegExp(`[ \\t]*${escaped}\\s*:[^;]*;[ \\t]*\\n?`, 'g'), '');
|
||||
const inner = newBlock.replace(/^[^{]*\{/, '').replace(/\}[^}]*$/, '');
|
||||
if (!inner.trim()) { stylesheetStore.replaceInCustomCss(block, ''); } else { stylesheetStore.replaceBlock(block, newBlock); }
|
||||
};
|
||||
|
||||
// --- Displayed CSS ---
|
||||
const displayedCss = computed(() => {
|
||||
if (!selector.value) return '';
|
||||
const lines = [];
|
||||
|
||||
const widthVal = `${width.value}${width.unit}`;
|
||||
const defaultWidthVal = `${imageDefaults.width.value}${imageDefaults.width.unit}`;
|
||||
const wComment = (!widthEnabled.value && widthVal === defaultWidthVal) ? ' /* hérité de .block-image */' : '';
|
||||
lines.push(` width: ${widthVal};${wComment}`);
|
||||
|
||||
const heightVal = heightAuto.value ? 'auto' : `${heightPx.value}${heightPx.unit}`;
|
||||
const defaultHeightVal = imageDefaults.height.auto ? 'auto' : `${imageDefaults.height.value}${imageDefaults.height.unit}`;
|
||||
const hComment = (!heightEnabled.value && heightVal === defaultHeightVal) ? ' /* hérité de .block-image */' : '';
|
||||
lines.push(` height: ${heightVal};${hComment}`);
|
||||
|
||||
if (marginEnabled.value) {
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) lines.push(` margin-${side}: ${margin[side]}px;`);
|
||||
}
|
||||
if (positionEnabled.value) {
|
||||
lines.push(` position: relative;`);
|
||||
lines.push(` top: ${posTop.value}px;`);
|
||||
lines.push(` left: ${posLeft.value}px;`);
|
||||
}
|
||||
|
||||
return `${selector.value} {\n${lines.join('\n')}\n}`;
|
||||
});
|
||||
|
||||
const editableCss = computed(() => {
|
||||
return displayedCss.value.replace(/ \/\* hérité de \.block-image \*\//g, '');
|
||||
});
|
||||
|
||||
// --- CSS input ---
|
||||
const handleCssInput = (newCss) => {
|
||||
isUpdatingFromStore = true;
|
||||
|
||||
const wm = newCss.match(/width\s*:\s*([\d.]+)(%|px)/i);
|
||||
if (wm) { width.value = parseFloat(wm[1]); width.unit = wm[2]; }
|
||||
|
||||
const hm = newCss.match(/height\s*:\s*([^;]+)/i);
|
||||
if (hm) {
|
||||
const hVal = hm[1].trim();
|
||||
if (hVal === 'auto') { heightAuto.value = true; }
|
||||
else { const m = hVal.match(/([\d.]+)px/i); if (m) { heightAuto.value = false; heightPx.value = parseFloat(m[1]); heightPx.unit = 'px'; } }
|
||||
}
|
||||
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) {
|
||||
const mm = newCss.match(new RegExp(`margin-${side}\\s*:\\s*([\\d.]+)px`, 'i'));
|
||||
if (mm) margin[side] = parseFloat(mm[1]);
|
||||
}
|
||||
|
||||
const posCss = newCss.match(/(?:^|\n)\s*position\s*:\s*([^;]+)/i);
|
||||
if (posCss) positionEnabled.value = posCss[1].trim() === 'relative';
|
||||
const tm = newCss.match(/(?:^|\n)\s*top\s*:\s*([-\d.]+)px/i);
|
||||
if (tm) posTop.value = parseFloat(tm[1]);
|
||||
const bm = newCss.match(/(?:^|\n)\s*left\s*:\s*([-\d.]+)px/i);
|
||||
if (bm) posLeft.value = parseFloat(bm[1]);
|
||||
|
||||
const lines = [` width: ${width.value}${width.unit};`, ` height: ${heightAuto.value ? 'auto' : `${heightPx.value}${heightPx.unit}`};`];
|
||||
if (marginEnabled.value) for (const s of ['top','right','bottom','left']) lines.push(` margin-${s}: ${margin[s]}px;`);
|
||||
if (positionEnabled.value) { lines.push(` position: relative;`); lines.push(` top: ${posTop.value}px;`); lines.push(` left: ${posLeft.value}px;`); }
|
||||
|
||||
const newBlock = `${selector.value} {\n${lines.join('\n')}\n}\n`;
|
||||
const oldBlock = stylesheetStore.extractBlock(selector.value) || '';
|
||||
if (oldBlock) { stylesheetStore.replaceInCustomCss(oldBlock, newBlock); }
|
||||
else { stylesheetStore.setCustomCss((stylesheetStore.customCss || '') + '\n' + newBlock); }
|
||||
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- State persistence ---
|
||||
const saveState = () => {
|
||||
if (!selector.value) return;
|
||||
elementStates.set(selector.value, {
|
||||
widthToggle: widthEnabled.value, widthCache: widthCache.value ? { ...widthCache.value } : null,
|
||||
widthValue: { value: width.value, unit: width.unit },
|
||||
heightToggle: heightEnabled.value, heightCache: heightCache.value ? { ...heightCache.value } : null,
|
||||
heightAuto: heightAuto.value, heightValue: { value: heightPx.value, unit: heightPx.unit },
|
||||
marginToggle: marginEnabled.value, marginCache: marginCache.value ? { ...marginCache.value } : null,
|
||||
marginValue: { ...margin },
|
||||
positionToggle: positionEnabled.value, positionCache: positionCache.value ? { ...positionCache.value } : null,
|
||||
posTop: posTop.value, posLeft: posLeft.value,
|
||||
});
|
||||
};
|
||||
|
||||
const restoreFromStored = (stored, defaults) => {
|
||||
widthEnabled.value = stored.widthToggle;
|
||||
widthCache.value = stored.widthCache ? { ...stored.widthCache } : null;
|
||||
width.value = stored.widthToggle ? stored.widthValue.value : (stored.widthCache ? stored.widthCache.value : defaults.width.value);
|
||||
width.unit = stored.widthToggle ? stored.widthValue.unit : (stored.widthCache ? stored.widthCache.unit : defaults.width.unit);
|
||||
|
||||
heightEnabled.value = stored.heightToggle;
|
||||
heightCache.value = stored.heightCache ? { ...stored.heightCache } : null;
|
||||
heightAuto.value = stored.heightAuto;
|
||||
heightPx.value = stored.heightToggle ? stored.heightValue.value : (stored.heightCache ? stored.heightCache.value : defaults.height.value);
|
||||
heightPx.unit = stored.heightToggle ? stored.heightValue.unit : (stored.heightCache ? stored.heightCache.unit : defaults.height.unit);
|
||||
|
||||
marginEnabled.value = stored.marginToggle || false;
|
||||
marginCache.value = stored.marginCache ? { ...stored.marginCache } : null;
|
||||
Object.assign(margin, stored.marginToggle ? stored.marginValue : (stored.marginCache || { top: 0, right: 0, bottom: 0, left: 0 }));
|
||||
|
||||
positionEnabled.value = stored.positionToggle || false;
|
||||
positionCache.value = stored.positionCache ? { ...stored.positionCache } : null;
|
||||
posTop.value = stored.positionToggle ? stored.posTop : (stored.positionCache ? stored.positionCache.top : 0);
|
||||
posLeft.value = stored.positionToggle ? stored.posLeft : (stored.positionCache ? stored.positionCache.left : 0);
|
||||
};
|
||||
|
||||
// --- Open ---
|
||||
const handleImageClick = (figure, event) => {
|
||||
const uniqueClass = Array.from(figure.classList).find(cls => cls.startsWith('block-image--'));
|
||||
const sel = uniqueClass
|
||||
? `.block-image.${uniqueClass}`
|
||||
: figure.classList.contains('geoformat-cover-image') ? '.geoformat-cover-image' : null;
|
||||
if (!sel) return;
|
||||
|
||||
isUpdatingFromStore = true;
|
||||
selector.value = sel;
|
||||
currentFigure.value = figure;
|
||||
measuredHeight.value = null;
|
||||
|
||||
const stored = elementStates.get(sel);
|
||||
if (stored) {
|
||||
restoreFromStored(stored, imageDefaults);
|
||||
} else {
|
||||
widthEnabled.value = false; widthCache.value = null;
|
||||
const wCss = stylesheetStore.extractValue(sel, 'width');
|
||||
if (wCss && wCss.value !== undefined) {
|
||||
width.value = wCss.value; width.unit = wCss.unit;
|
||||
if (!(wCss.value === imageDefaults.width.value && wCss.unit === imageDefaults.width.unit)) widthEnabled.value = true;
|
||||
} else { width.value = imageDefaults.width.value; width.unit = imageDefaults.width.unit; }
|
||||
|
||||
heightEnabled.value = false; heightCache.value = null;
|
||||
const hCss = stylesheetStore.extractValue(sel, 'height');
|
||||
const hStr = typeof hCss === 'string' ? hCss : null;
|
||||
if (hStr === 'auto') { heightAuto.value = true; }
|
||||
else if (hStr) { const m = hStr.match(/([\d.]+)px/i); if (m) { heightAuto.value = false; heightPx.value = parseFloat(m[1]); heightPx.unit = 'px'; heightEnabled.value = true; } else { heightAuto.value = imageDefaults.height.auto; heightPx.value = imageDefaults.height.value; heightPx.unit = imageDefaults.height.unit; } }
|
||||
else if (hCss && hCss.value !== undefined) { heightAuto.value = false; heightPx.value = hCss.value; heightPx.unit = hCss.unit; heightEnabled.value = true; }
|
||||
else { heightAuto.value = imageDefaults.height.auto; heightPx.value = imageDefaults.height.value; heightPx.unit = imageDefaults.height.unit; }
|
||||
|
||||
marginEnabled.value = false; marginCache.value = null;
|
||||
margin.top = 0; margin.right = 0; margin.bottom = 0; margin.left = 0;
|
||||
let hasMargin = false;
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) {
|
||||
const mCss = stylesheetStore.extractValue(sel, `margin-${side}`);
|
||||
if (mCss) { const v = mCss.value !== undefined ? mCss.value : parseFloat(mCss); if (!isNaN(v) && v !== 0) { margin[side] = v; hasMargin = true; } }
|
||||
}
|
||||
if (hasMargin) marginEnabled.value = true;
|
||||
|
||||
positionEnabled.value = false; positionCache.value = null; posTop.value = 0; posLeft.value = 0;
|
||||
const posCss = stylesheetStore.extractValue(sel, 'position');
|
||||
const posStr = typeof posCss === 'string' ? posCss : posCss?.value;
|
||||
if (posStr === 'relative') {
|
||||
positionEnabled.value = true;
|
||||
const tCss = stylesheetStore.extractValue(sel, 'top');
|
||||
const bCss = stylesheetStore.extractValue(sel, 'left');
|
||||
posTop.value = tCss ? (tCss.value !== undefined ? tCss.value : parseFloat(tCss)) || 0 : 0;
|
||||
posLeft.value = bCss ? (bCss.value !== undefined ? bCss.value : parseFloat(bCss)) || 0 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
basePopup.value.open(event);
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
// --- Close ---
|
||||
const handleClose = () => {
|
||||
saveState();
|
||||
selector.value = '';
|
||||
currentFigure.value = null;
|
||||
if (basePopup.value?.visible) basePopup.value.close();
|
||||
emit('close');
|
||||
};
|
||||
|
||||
defineExpose({ handleImageClick, close: () => basePopup.value?.close(), visible });
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.image-label {
|
||||
background: var(--color-600);
|
||||
color: white;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -33,9 +33,7 @@
|
|||
class="geoformat"
|
||||
:data-page-type="item.template"
|
||||
>
|
||||
<figure v-if="item.cover" class="geoformat-cover-image">
|
||||
<img :src="item.cover" alt="" />
|
||||
</figure>
|
||||
<img v-if="item.cover" :src="item.cover" class="cover-image" alt="" />
|
||||
<h2>{{ item.title }}</h2>
|
||||
<p v-if="item.subtitle" class="subtitle">{{ item.subtitle }}</p>
|
||||
<div v-if="item.tags && item.tags.length" class="tags">
|
||||
|
|
@ -57,7 +55,6 @@
|
|||
:key="block.id"
|
||||
:is="getBlockComponent(block.type)"
|
||||
:content="block.content"
|
||||
v-bind="block.type === 'image' ? { blockId: block.id } : {}"
|
||||
/>
|
||||
</template>
|
||||
</section>
|
||||
|
|
@ -69,9 +66,7 @@
|
|||
:data-page-type="item.template"
|
||||
>
|
||||
<h4>{{ item.title }}</h4>
|
||||
<figure v-if="item.image" :class="['block-carte', getCarteBlockId(item.id) ? `block-carte--${getCarteBlockId(item.id)}` : '']">
|
||||
<img :src="item.image" alt="" />
|
||||
</figure>
|
||||
<img v-if="item.image" :src="item.image" class="carte-image" alt="" />
|
||||
<div v-if="item.tags && item.tags.length" class="tags">
|
||||
<span v-for="tag in item.tags" :key="tag" class="tag">{{ tag }}</span>
|
||||
</div>
|
||||
|
|
@ -95,18 +90,13 @@
|
|||
{{ marker.title }}
|
||||
</h5>
|
||||
</div>
|
||||
<ImageBlock
|
||||
v-if="marker.cover"
|
||||
:content="{ url: marker.cover, alt: '' }"
|
||||
:block-id="`${(item.id || '').replace(/[^a-z0-9]/gi, '').slice(-6)}m${idx}`"
|
||||
/>
|
||||
<img v-if="marker.cover" :src="marker.cover" class="marker-cover" alt="" />
|
||||
<template v-if="marker.blocks">
|
||||
<component
|
||||
v-for="block in visibleBlocks(marker.blocks)"
|
||||
:key="block.id"
|
||||
:is="getBlockComponent(block.type)"
|
||||
:content="block.content"
|
||||
v-bind="block.type === 'image' ? { blockId: block.id } : {}"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
|
@ -133,10 +123,6 @@ import {
|
|||
const narrativeStore = useNarrativeStore();
|
||||
|
||||
const hasNarrativeData = computed(() => narrativeStore.data !== null);
|
||||
|
||||
const getCarteBlockId = (itemId) => {
|
||||
return (itemId || '').split('/').pop()?.replace(/[^a-z0-9]/gi, '').slice(0, 8) || '';
|
||||
};
|
||||
const flattenedContent = computed(() => narrativeStore.flattenedContent);
|
||||
|
||||
// Filter out hidden blocks
|
||||
|
|
@ -169,17 +155,11 @@ const getBlockComponent = (type) => {
|
|||
}
|
||||
|
||||
.narrative-cover .cover-image,
|
||||
.geoformat .geoformat-cover-image {
|
||||
.geoformat .cover-image {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.geoformat .geoformat-cover-image img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.narrative-cover h1 {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
|
@ -242,17 +222,11 @@ const getBlockComponent = (type) => {
|
|||
break-before: page;
|
||||
}
|
||||
|
||||
.block-carte {
|
||||
.carte-image {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.block-carte img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.marker {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
|
@ -269,4 +243,10 @@ const getBlockComponent = (type) => {
|
|||
flex-shrink: 0;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.marker-cover {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -204,11 +204,12 @@ watch(isCustomCssEditable, async (newValue, oldValue) => {
|
|||
flex-direction: column;
|
||||
background: #21252b;
|
||||
border-radius: 0.25rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.custom-section {
|
||||
flex: 1;
|
||||
max-height: 45.2rem;
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
|
|
@ -300,7 +301,6 @@ h3 {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.readonly {
|
||||
|
|
@ -321,6 +321,8 @@ h3 {
|
|||
textarea {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
min-height: 300px;
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
background: #1e1e1e;
|
||||
color: #abb2bf;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<figure
|
||||
:class="['block-image', blockId ? `block-image--${blockId.slice(0, 8)}` : '']"
|
||||
class="block-image"
|
||||
:style="figureStyle"
|
||||
>
|
||||
<img
|
||||
|
|
@ -19,16 +19,16 @@ const props = defineProps({
|
|||
content: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
blockId: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
});
|
||||
|
||||
const figureStyle = computed(() => {
|
||||
const styles = {};
|
||||
|
||||
if (props.content.width && props.content.width !== '100%') {
|
||||
styles.width = props.content.width;
|
||||
}
|
||||
|
||||
if (props.content.position === 'center') {
|
||||
styles.margin = '0 auto';
|
||||
} else if (props.content.position === 'right') {
|
||||
|
|
|
|||
|
|
@ -1,138 +0,0 @@
|
|||
<template>
|
||||
<section class="panel-settings__container" id="settings__container_carte" data-color-type="image">
|
||||
|
||||
<div class="settings__header">
|
||||
<div class="icon" v-html="carteIcon"></div>
|
||||
<h2 class="title">Réglage des cartes par défaut</h2>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<!-- Largeur -->
|
||||
<div class="setting__section" data-setting="width">
|
||||
<div class="setting__header">
|
||||
<label class="label-with-tooltip" data-css="width">Largeur</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<InputWithUnit
|
||||
v-model="width"
|
||||
:units="['%', 'px']"
|
||||
:min="1"
|
||||
:max="width.unit === 'px' ? 2000 : 200"
|
||||
showRange
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hauteur -->
|
||||
<div class="setting__section" data-setting="height">
|
||||
<div class="setting__header">
|
||||
<label class="label-with-tooltip" data-css="height">Hauteur</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<div class="field-checkbox">
|
||||
<input type="checkbox" id="carte-height-auto" :checked="heightAuto" @change="onHeightAutoChange(!heightAuto)" />
|
||||
<label for="carte-height-auto">Auto</label>
|
||||
</div>
|
||||
<InputWithUnit
|
||||
v-if="!heightAuto"
|
||||
v-model="height"
|
||||
:units="['px']"
|
||||
:min="1"
|
||||
:max="800"
|
||||
showRange
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, onMounted, nextTick } from 'vue';
|
||||
import carteIcon from '/assets/svg/carte.svg?raw';
|
||||
import { CARTE_DEFAULTS } from '../../utils/defaults';
|
||||
import InputWithUnit from '../ui/InputWithUnit.vue';
|
||||
import { useCssUpdater } from '../../composables/useCssUpdater';
|
||||
import { useCssSync } from '../../composables/useCssSync';
|
||||
import { useDebounce } from '../../composables/useDebounce';
|
||||
import { useCarteDefaults } from '../../composables/useCarteDefaults';
|
||||
|
||||
const { updateStyle, removeProperty } = useCssUpdater();
|
||||
const { extractNumericValue, extractValue } = useCssSync();
|
||||
const { debouncedUpdate } = useDebounce(500);
|
||||
const carteDefaults = useCarteDefaults();
|
||||
|
||||
const CARTE_SELECTOR = '.block-carte';
|
||||
|
||||
// Width
|
||||
const width = ref({ ...CARTE_DEFAULTS.width });
|
||||
|
||||
// Height
|
||||
const heightAuto = ref(CARTE_DEFAULTS.height.auto);
|
||||
const height = ref({ value: CARTE_DEFAULTS.height.value, unit: CARTE_DEFAULTS.height.unit });
|
||||
|
||||
let isUpdatingFromStore = true;
|
||||
|
||||
watch(width, (val) => {
|
||||
if (isUpdatingFromStore) return;
|
||||
carteDefaults.width = { value: val.value, unit: val.unit };
|
||||
debouncedUpdate(() => {
|
||||
updateStyle(CARTE_SELECTOR, 'width', `${val.value}${val.unit}`);
|
||||
});
|
||||
}, { deep: true, immediate: true });
|
||||
|
||||
const onHeightAutoChange = (auto) => {
|
||||
if (isUpdatingFromStore) return;
|
||||
heightAuto.value = auto;
|
||||
const cssVal = auto ? 'auto' : `${height.value.value}${height.value.unit}`;
|
||||
updateStyle(CARTE_SELECTOR, 'height', cssVal);
|
||||
if (auto) {
|
||||
removeProperty(`${CARTE_SELECTOR} img`, 'height');
|
||||
} else {
|
||||
updateStyle(`${CARTE_SELECTOR} img`, 'height', '100%');
|
||||
}
|
||||
carteDefaults.height = { auto, value: height.value.value, unit: height.value.unit };
|
||||
};
|
||||
|
||||
watch(height, (val) => {
|
||||
if (isUpdatingFromStore || heightAuto.value) return;
|
||||
carteDefaults.height = { auto: false, value: val.value, unit: val.unit };
|
||||
debouncedUpdate(() => {
|
||||
updateStyle(CARTE_SELECTOR, 'height', `${val.value}${val.unit}`);
|
||||
updateStyle(`${CARTE_SELECTOR} img`, 'height', '100%');
|
||||
});
|
||||
}, { deep: true });
|
||||
|
||||
const syncFromStore = () => {
|
||||
isUpdatingFromStore = true;
|
||||
|
||||
if (carteDefaults._initialized) {
|
||||
width.value = { value: carteDefaults.width.value, unit: carteDefaults.width.unit };
|
||||
heightAuto.value = carteDefaults.height.auto;
|
||||
height.value = { value: carteDefaults.height.value, unit: carteDefaults.height.unit };
|
||||
} else {
|
||||
const widthVal = extractNumericValue(CARTE_SELECTOR, 'width', ['%', 'px']);
|
||||
if (widthVal) width.value = widthVal;
|
||||
|
||||
const heightVal = extractValue(CARTE_SELECTOR, 'height');
|
||||
if (!heightVal || heightVal === 'auto') {
|
||||
heightAuto.value = true;
|
||||
} else {
|
||||
const m = heightVal.match(/([\d.]+)px/i);
|
||||
if (m) { heightAuto.value = false; height.value = { value: parseFloat(m[1]), unit: 'px' }; }
|
||||
}
|
||||
|
||||
carteDefaults.width = { value: width.value.value, unit: width.value.unit };
|
||||
carteDefaults.height = { auto: heightAuto.value, value: height.value.value, unit: height.value.unit };
|
||||
carteDefaults._initialized = true;
|
||||
}
|
||||
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
syncFromStore();
|
||||
});
|
||||
</script>
|
||||
|
|
@ -53,8 +53,6 @@
|
|||
<div v-if="activeTab === 'document'" class="tab-panel">
|
||||
<PageSettings />
|
||||
<TextSettings />
|
||||
<ImageSettings />
|
||||
<CarteSettings />
|
||||
</div>
|
||||
|
||||
<div v-else-if="activeTab === 'code'" class="tab-panel">
|
||||
|
|
@ -72,8 +70,6 @@
|
|||
import { inject } from 'vue';
|
||||
import PageSettings from './PageSettings.vue';
|
||||
import TextSettings from './TextSettings.vue';
|
||||
import ImageSettings from './ImageSettings.vue';
|
||||
import CarteSettings from './CarteSettings.vue';
|
||||
import StylesheetViewer from '../StylesheetViewer.vue';
|
||||
|
||||
const activeTab = inject('activeTab');
|
||||
|
|
|
|||
|
|
@ -1,148 +0,0 @@
|
|||
<template>
|
||||
<section class="panel-settings__container" id="settings__container_image" data-color-type="image">
|
||||
|
||||
<div class="settings__header">
|
||||
<div class="icon" v-html="imageIcon"></div>
|
||||
<h2 class="title">Réglage des images par défaut</h2>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<!-- Largeur -->
|
||||
<div class="setting__section" data-setting="width">
|
||||
<div class="setting__header">
|
||||
<label class="label-with-tooltip" data-css="width">Largeur</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<InputWithUnit
|
||||
v-model="width"
|
||||
:units="['%', 'px']"
|
||||
:min="1"
|
||||
:max="width.unit === 'px' ? 2000 : 200"
|
||||
showRange
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hauteur -->
|
||||
<div class="setting__section" data-setting="height">
|
||||
<div class="setting__header">
|
||||
<label class="label-with-tooltip" data-css="height">Hauteur</label>
|
||||
</div>
|
||||
<div class="setting__body">
|
||||
<div class="field-checkbox">
|
||||
<input type="checkbox" id="image-height-auto" :checked="heightAuto" @change="onHeightAutoChange(!heightAuto)" />
|
||||
<label for="image-height-auto">Auto</label>
|
||||
</div>
|
||||
<InputWithUnit
|
||||
v-if="!heightAuto"
|
||||
v-model="height"
|
||||
:units="['px']"
|
||||
:min="1"
|
||||
:max="800"
|
||||
showRange
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, onMounted, nextTick } from 'vue';
|
||||
import imageIcon from '/assets/svg/image.svg?raw';
|
||||
import { IMAGE_DEFAULTS } from '../../utils/defaults';
|
||||
import InputWithUnit from '../ui/InputWithUnit.vue';
|
||||
import { useCssUpdater } from '../../composables/useCssUpdater';
|
||||
import { useCssSync } from '../../composables/useCssSync';
|
||||
import { useDebounce } from '../../composables/useDebounce';
|
||||
import { useImageDefaults } from '../../composables/useImageDefaults';
|
||||
|
||||
const { updateStyle, removeProperty } = useCssUpdater();
|
||||
const { extractNumericValue, extractValue } = useCssSync();
|
||||
const { debouncedUpdate } = useDebounce(500);
|
||||
const imageDefaults = useImageDefaults();
|
||||
|
||||
const IMAGE_SELECTORS = ['.block-image', '.geoformat-cover-image'];
|
||||
|
||||
// Width
|
||||
const width = ref({ ...IMAGE_DEFAULTS.width });
|
||||
|
||||
// Height
|
||||
const heightAuto = ref(IMAGE_DEFAULTS.height.auto);
|
||||
const height = ref({ value: IMAGE_DEFAULTS.height.value, unit: IMAGE_DEFAULTS.height.unit });
|
||||
|
||||
let isUpdatingFromStore = true;
|
||||
|
||||
// Width watcher
|
||||
watch(width, (val) => {
|
||||
if (isUpdatingFromStore) return;
|
||||
imageDefaults.width = { value: val.value, unit: val.unit };
|
||||
debouncedUpdate(() => {
|
||||
IMAGE_SELECTORS.forEach(sel => updateStyle(sel, 'width', `${val.value}${val.unit}`));
|
||||
});
|
||||
}, { deep: true, immediate: true });
|
||||
|
||||
// Height auto toggle
|
||||
const onHeightAutoChange = (auto) => {
|
||||
if (isUpdatingFromStore) return;
|
||||
heightAuto.value = auto;
|
||||
const cssVal = auto ? 'auto' : `${height.value.value}${height.value.unit}`;
|
||||
IMAGE_SELECTORS.forEach(sel => {
|
||||
updateStyle(sel, 'height', cssVal);
|
||||
if (auto) {
|
||||
removeProperty(`${sel} img`, 'height');
|
||||
} else {
|
||||
updateStyle(`${sel} img`, 'height', '100%');
|
||||
}
|
||||
});
|
||||
imageDefaults.height = { auto, value: height.value.value, unit: height.value.unit };
|
||||
};
|
||||
|
||||
// Height value watcher (only when not auto)
|
||||
watch(height, (val) => {
|
||||
if (isUpdatingFromStore || heightAuto.value) return;
|
||||
imageDefaults.height = { auto: false, value: val.value, unit: val.unit };
|
||||
debouncedUpdate(() => {
|
||||
IMAGE_SELECTORS.forEach(sel => {
|
||||
updateStyle(sel, 'height', `${val.value}${val.unit}`);
|
||||
updateStyle(`${sel} img`, 'height', '100%');
|
||||
});
|
||||
});
|
||||
}, { deep: true });
|
||||
|
||||
const syncFromStore = () => {
|
||||
isUpdatingFromStore = true;
|
||||
|
||||
if (imageDefaults._initialized) {
|
||||
width.value = { value: imageDefaults.width.value, unit: imageDefaults.width.unit };
|
||||
heightAuto.value = imageDefaults.height.auto;
|
||||
height.value = { value: imageDefaults.height.value, unit: imageDefaults.height.unit };
|
||||
} else {
|
||||
const widthVal = extractNumericValue('.block-image', 'width', ['%', 'px']);
|
||||
if (widthVal) width.value = widthVal;
|
||||
|
||||
const heightVal = extractValue('.block-image', 'height');
|
||||
if (!heightVal || heightVal === 'auto') {
|
||||
heightAuto.value = true;
|
||||
} else {
|
||||
const m = heightVal.match(/([\d.]+)px/i);
|
||||
if (m) {
|
||||
heightAuto.value = false;
|
||||
height.value = { value: parseFloat(m[1]), unit: 'px' };
|
||||
}
|
||||
}
|
||||
|
||||
imageDefaults.width = { value: width.value.value, unit: width.value.unit };
|
||||
imageDefaults.height = { auto: heightAuto.value, value: height.value.value, unit: height.value.unit };
|
||||
imageDefaults._initialized = true;
|
||||
}
|
||||
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
syncFromStore();
|
||||
});
|
||||
</script>
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
v-if="visible"
|
||||
class="settings-popup"
|
||||
:style="{ top: position.y + 'px', left: position.x + 'px' }"
|
||||
:data-color-type="colorType || undefined"
|
||||
>
|
||||
<div class="popup-header" @mousedown="startDrag">
|
||||
<div class="header-left">
|
||||
|
|
@ -101,7 +100,6 @@ const props = defineProps({
|
|||
popupWidth: { type: Number, default: 800 },
|
||||
popupHeight: { type: Number, default: 600 },
|
||||
showInheritance: { type: Boolean, default: true },
|
||||
colorType: { type: String, default: '' },
|
||||
});
|
||||
|
||||
const emit = defineEmits(['close', 'css-input', 'toggle-inheritance']);
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
import { reactive } from 'vue';
|
||||
import { CARTE_DEFAULTS } from '../utils/defaults';
|
||||
|
||||
// Singleton reactive — CarteSettings writes here, CartePopup reads when toggle is disabled
|
||||
const defaults = reactive({
|
||||
width: { ...CARTE_DEFAULTS.width },
|
||||
height: { auto: CARTE_DEFAULTS.height.auto, value: CARTE_DEFAULTS.height.value, unit: CARTE_DEFAULTS.height.unit },
|
||||
_initialized: false,
|
||||
});
|
||||
|
||||
export function useCarteDefaults() {
|
||||
return defaults;
|
||||
}
|
||||
|
|
@ -236,30 +236,33 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
}
|
||||
};
|
||||
|
||||
// --- Reset refs to inherited/default values when toggle is turned off ---
|
||||
const resetRefsToDefaults = (group) => {
|
||||
if (group === 'font') {
|
||||
fontFamily.value = textDefaults.fontFamily;
|
||||
italic.value = ELEMENT_DEFAULTS.italic;
|
||||
bold.value = ELEMENT_DEFAULTS.bold;
|
||||
// Re-apply inline defaults if applicable
|
||||
const inlineDefaults = INLINE_DEFAULTS[currentTag.value];
|
||||
if (inlineDefaults) {
|
||||
if (inlineDefaults.fontStyle === 'italic') italic.value = true;
|
||||
if (inlineDefaults.fontWeight === 'bold') bold.value = true;
|
||||
}
|
||||
} else if (group === 'fontSize') {
|
||||
fontSize.value = textDefaults.fontSize.value;
|
||||
fontSize.unit = textDefaults.fontSize.unit;
|
||||
} else if (group === 'lineHeight') {
|
||||
lineHeight.value = textDefaults.lineHeight.value;
|
||||
lineHeight.unit = textDefaults.lineHeight.unit;
|
||||
} else if (group === 'color') {
|
||||
color.value = textDefaults.color;
|
||||
// Re-apply inline default color if applicable
|
||||
const inlineDefaults = INLINE_DEFAULTS[currentTag.value];
|
||||
if (inlineDefaults?.color) color.value = inlineDefaults.color;
|
||||
// --- Pre-toggle CSS snapshot ---
|
||||
// Saves the CSS values for a group before toggle ON, restores them on toggle OFF
|
||||
const preToggleSnapshots = new Map(); // key: `${selector}::${group}` → { cssProp: extractedValue }
|
||||
|
||||
const savePreToggleSnapshot = (group) => {
|
||||
const key = `${selector.value}::${group}`;
|
||||
const cssProps = settingGroups[group];
|
||||
const snapshot = {};
|
||||
for (const cssProp of cssProps) {
|
||||
const val = stylesheetStore.extractValue(selector.value, cssProp);
|
||||
if (val) snapshot[cssProp] = val;
|
||||
}
|
||||
preToggleSnapshots.set(key, snapshot);
|
||||
};
|
||||
|
||||
const restorePreToggleSnapshot = (group) => {
|
||||
const key = `${selector.value}::${group}`;
|
||||
const snapshot = preToggleSnapshots.get(key);
|
||||
if (!snapshot) return;
|
||||
for (const [cssProp, val] of Object.entries(snapshot)) {
|
||||
if (typeof val === 'object' && 'value' in val) {
|
||||
updateProp(cssProp, val.value, val.unit);
|
||||
} else {
|
||||
updateProp(cssProp, val);
|
||||
}
|
||||
}
|
||||
preToggleSnapshots.delete(key);
|
||||
};
|
||||
|
||||
// --- Toggle actions ---
|
||||
|
|
@ -272,6 +275,7 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
settingEnabled[group] = enabled;
|
||||
isUpdatingFromStore = true;
|
||||
if (enabled) {
|
||||
savePreToggleSnapshot(group);
|
||||
restoreFromCache(group);
|
||||
applyAllEnabledGroups();
|
||||
} else {
|
||||
|
|
@ -282,8 +286,7 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
} else {
|
||||
removeProps(settingGroups[group]);
|
||||
}
|
||||
// Reset refs to defaults so displayedCss shows inherited values
|
||||
resetRefsToDefaults(group);
|
||||
restorePreToggleSnapshot(group);
|
||||
}
|
||||
saveElementState();
|
||||
nextTick(() => { isUpdatingFromStore = false; });
|
||||
|
|
@ -350,10 +353,10 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
const INDEPENDENT_TAGS = new Set(['li', 'ul', 'ol', 'dt', 'dd', 'dl', 'table', 'tr', 'td', 'th', 'caption', 'figure', 'figcaption', 'pre', 'blockquote']);
|
||||
const isIndependentElement = computed(() => INDEPENDENT_TAGS.has(currentTag.value));
|
||||
|
||||
// Check if the current selector has a CSS property in the store (active CSS only, not commented)
|
||||
// Check if the current selector has a CSS property in the store
|
||||
const hasInCss = (cssProp) => {
|
||||
if (!selector.value) return false;
|
||||
return !!stylesheetStore.extractValue(selector.value, cssProp, false);
|
||||
return !!stylesheetStore.extractValue(selector.value, cssProp);
|
||||
};
|
||||
|
||||
const displayedCss = computed(() => {
|
||||
|
|
@ -361,10 +364,9 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
const lines = [];
|
||||
for (const entry of displayedCssOrder) {
|
||||
if (entry.skip && entry.skip()) continue;
|
||||
const groupEnabled = settingEnabled[entry.group];
|
||||
// For inline elements, skip special groups (TextSettings defaults) when toggle is OFF
|
||||
// Exception: keep if the current tag has an inline default for this CSS property
|
||||
if (entry.special && isInlineElement.value && !groupEnabled) {
|
||||
if (entry.special && isInlineElement.value && !settingEnabled[entry.group]) {
|
||||
const tagDefaults = INLINE_DEFAULTS[currentTag.value];
|
||||
const cssToDefaultKey = { 'color': 'color', 'font-family': 'fontFamily' };
|
||||
const defaultKey = cssToDefaultKey[entry.css];
|
||||
|
|
@ -372,26 +374,18 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
}
|
||||
const val = entry.getValue();
|
||||
if (val === null || val === undefined) continue;
|
||||
|
||||
// Determine inheritance comment for disabled groups
|
||||
let comment = '';
|
||||
if (!groupEnabled) {
|
||||
if (entry.special) {
|
||||
// Special groups: show "hérité de la page" when value matches page-level default
|
||||
const textDefaultValues = {
|
||||
'font-family': textDefaults.fontFamily === 'sans-serif' ? 'sans-serif' : `"${textDefaults.fontFamily}"`,
|
||||
'font-size': `${textDefaults.fontSize.value}${textDefaults.fontSize.unit}`,
|
||||
'line-height': `${textDefaults.lineHeight.value}${textDefaults.lineHeight.unit}`,
|
||||
'color': textDefaults.color,
|
||||
};
|
||||
if (val === textDefaultValues[entry.css]) {
|
||||
comment = ' /* hérité de la page */';
|
||||
}
|
||||
} else if (hasInCss(entry.css)) {
|
||||
// Non-special groups: show comment when CSS exists but toggle is off
|
||||
comment = ' /* hérité de la page */';
|
||||
}
|
||||
// Show "valeur par défaut" only if the value actually matches the TextSettings default
|
||||
let isTextDefault = false;
|
||||
if (entry.special && !settingEnabled[entry.group]) {
|
||||
const textDefaultValues = {
|
||||
'font-family': textDefaults.fontFamily === 'sans-serif' ? 'sans-serif' : `"${textDefaults.fontFamily}"`,
|
||||
'font-size': `${textDefaults.fontSize.value}${textDefaults.fontSize.unit}`,
|
||||
'line-height': `${textDefaults.lineHeight.value}${textDefaults.lineHeight.unit}`,
|
||||
'color': textDefaults.color,
|
||||
};
|
||||
isTextDefault = val === textDefaultValues[entry.css];
|
||||
}
|
||||
const comment = isTextDefault ? ' /* valeur par défaut */' : '';
|
||||
lines.push(` ${entry.css}: ${val};${comment}`);
|
||||
}
|
||||
for (const side of ['top', 'right', 'bottom', 'left']) {
|
||||
|
|
@ -408,7 +402,7 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
});
|
||||
|
||||
const editableFullCss = computed(() => {
|
||||
return displayedCss.value.replace(/ \/\* (?:valeur par défaut|hérité de la page) \*\//g, '');
|
||||
return displayedCss.value.replace(/ \/\* valeur par défaut \*\//g, '');
|
||||
});
|
||||
|
||||
// --- CSS parsing & sync ---
|
||||
|
|
|
|||
|
|
@ -4,16 +4,12 @@ import { ref } from 'vue';
|
|||
* Composable for managing interactions with pages and elements in the iframe
|
||||
* Handles hover effects, labels, and click events for both pages and content elements
|
||||
*/
|
||||
export function useIframeInteractions({ elementPopup, imagePopup, cartePopup /*, pagePopup // DISABLED: page template styling feature */ }) {
|
||||
export function useIframeInteractions({ elementPopup /*, pagePopup // DISABLED: page template styling feature */ }) {
|
||||
// DISABLED: page template styling feature
|
||||
// const hoveredPage = ref(null);
|
||||
// const selectedPages = ref([]); // Pages with active border (when popup is open)
|
||||
const hoveredElement = ref(null);
|
||||
const hoveredFigure = ref(null); // block-image or geoformat-cover-image
|
||||
const hoveredCarte = ref(null); // block-carte
|
||||
const selectedElement = ref(null);
|
||||
const selectedFigure = ref(null); // selected block-image
|
||||
const selectedCarte = ref(null); // selected block-carte
|
||||
const hoveredElement = ref(null); // Currently hovered content element
|
||||
const selectedElement = ref(null); // Selected element (when popup is open)
|
||||
// const EDGE_THRESHOLD = 30; // px from edge to trigger hover // DISABLED: page template styling feature
|
||||
|
||||
// Text elements that can trigger ElementPopup (excluding containers, images, etc.)
|
||||
|
|
@ -123,35 +119,6 @@ export function useIframeInteractions({ elementPopup, imagePopup, cartePopup /*,
|
|||
}
|
||||
};
|
||||
|
||||
// Create and position image label on hover
|
||||
const createImageLabel = (figure) => {
|
||||
const doc = figure.ownerDocument;
|
||||
const existing = doc.querySelector('.image-hover-label');
|
||||
if (existing) existing.remove();
|
||||
|
||||
const uniqueClass = Array.from(figure.classList).find(cls => cls.startsWith('block-image--'));
|
||||
const labelText = uniqueClass ? `.${uniqueClass}` : figure.classList.contains('geoformat-cover-image') ? '.geoformat-cover-image' : null;
|
||||
if (!labelText) return;
|
||||
|
||||
const rect = figure.getBoundingClientRect();
|
||||
const scrollTop = doc.documentElement.scrollTop || doc.body.scrollTop;
|
||||
const scrollLeft = doc.documentElement.scrollLeft || doc.body.scrollLeft;
|
||||
|
||||
const label = doc.createElement('div');
|
||||
label.className = 'image-hover-label';
|
||||
label.textContent = labelText;
|
||||
label.style.top = `${rect.top + scrollTop - 32}px`;
|
||||
label.style.left = `${rect.left + scrollLeft}px`;
|
||||
|
||||
doc.body.appendChild(label);
|
||||
};
|
||||
|
||||
// Remove image label
|
||||
const removeImageLabel = (doc) => {
|
||||
const label = doc.querySelector('.image-hover-label');
|
||||
if (label) label.remove();
|
||||
};
|
||||
|
||||
/* DISABLED: page template styling feature
|
||||
// Create and position page label on hover
|
||||
const createPageLabel = (page) => {
|
||||
|
|
@ -186,55 +153,6 @@ export function useIframeInteractions({ elementPopup, imagePopup, cartePopup /*,
|
|||
};
|
||||
*/
|
||||
|
||||
// Find closest image figure ancestor (block-image or geoformat-cover-image)
|
||||
const getImageFigure = (element) => {
|
||||
let current = element;
|
||||
while (current && current.tagName !== 'BODY') {
|
||||
if (current.tagName === 'FIGURE' &&
|
||||
(current.classList.contains('block-image') || current.classList.contains('geoformat-cover-image'))) {
|
||||
return current;
|
||||
}
|
||||
current = current.parentElement;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// Find closest block-carte figure ancestor
|
||||
const getCarteFigure = (element) => {
|
||||
let current = element;
|
||||
while (current && current.tagName !== 'BODY') {
|
||||
if (current.tagName === 'FIGURE' && current.classList.contains('block-carte')) return current;
|
||||
current = current.parentElement;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// Create and position carte label on hover
|
||||
const createCarteLabel = (figure) => {
|
||||
const doc = figure.ownerDocument;
|
||||
const existing = doc.querySelector('.carte-hover-label');
|
||||
if (existing) existing.remove();
|
||||
|
||||
const uniqueClass = Array.from(figure.classList).find(cls => cls.startsWith('block-carte--'));
|
||||
const labelText = uniqueClass ? `.${uniqueClass}` : '.block-carte';
|
||||
|
||||
const rect = figure.getBoundingClientRect();
|
||||
const scrollTop = doc.documentElement.scrollTop || doc.body.scrollTop;
|
||||
const scrollLeft = doc.documentElement.scrollLeft || doc.body.scrollLeft;
|
||||
|
||||
const label = doc.createElement('div');
|
||||
label.className = 'carte-hover-label';
|
||||
label.textContent = labelText;
|
||||
label.style.top = `${rect.top + scrollTop - 32}px`;
|
||||
label.style.left = `${rect.left + scrollLeft}px`;
|
||||
doc.body.appendChild(label);
|
||||
};
|
||||
|
||||
const removeCarteLabel = (doc) => {
|
||||
const label = doc.querySelector('.carte-hover-label');
|
||||
if (label) label.remove();
|
||||
};
|
||||
|
||||
// Check if element is a content element (or find closest content parent)
|
||||
const getContentElement = (element) => {
|
||||
let current = element;
|
||||
|
|
@ -308,37 +226,9 @@ export function useIframeInteractions({ elementPopup, imagePopup, cartePopup /*,
|
|||
}
|
||||
*/
|
||||
|
||||
// Check for block-image figure hover
|
||||
const imageFigure = getImageFigure(event.target);
|
||||
const doc = event.target.ownerDocument;
|
||||
if (imageFigure !== hoveredFigure.value) {
|
||||
if (hoveredFigure.value && hoveredFigure.value !== selectedFigure.value) {
|
||||
hoveredFigure.value.classList.remove('element-hovered');
|
||||
}
|
||||
removeImageLabel(doc);
|
||||
if (imageFigure && imageFigure !== selectedFigure.value) {
|
||||
imageFigure.classList.add('element-hovered');
|
||||
createImageLabel(imageFigure);
|
||||
}
|
||||
hoveredFigure.value = imageFigure;
|
||||
}
|
||||
|
||||
// Check for block-carte figure hover
|
||||
const carteFigure = (!imageFigure) ? getCarteFigure(event.target) : null;
|
||||
if (carteFigure !== hoveredCarte.value) {
|
||||
if (hoveredCarte.value && hoveredCarte.value !== selectedCarte.value) {
|
||||
hoveredCarte.value.classList.remove('element-hovered');
|
||||
}
|
||||
removeCarteLabel(doc);
|
||||
if (carteFigure && carteFigure !== selectedCarte.value) {
|
||||
carteFigure.classList.add('element-hovered');
|
||||
createCarteLabel(carteFigure);
|
||||
}
|
||||
hoveredCarte.value = carteFigure;
|
||||
}
|
||||
|
||||
// Check for content element hover
|
||||
const contentElement = (imageFigure || carteFigure) ? null : getContentElement(event.target);
|
||||
const contentElement = getContentElement(event.target);
|
||||
const doc = event.target.ownerDocument;
|
||||
|
||||
if (contentElement !== hoveredElement.value) {
|
||||
// Remove highlight from previous element (only if not selected)
|
||||
|
|
@ -397,69 +287,15 @@ export function useIframeInteractions({ elementPopup, imagePopup, cartePopup /*,
|
|||
const isInsidePage = element.closest('.pagedjs_page');
|
||||
if (!isInsidePage) {
|
||||
clearSelectedElement();
|
||||
if (elementPopup.value.visible) elementPopup.value.close();
|
||||
imagePopup.value?.close();
|
||||
cartePopup.value?.close();
|
||||
elementPopup.value.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if clicking a block-image figure
|
||||
const imageFigure = getImageFigure(element);
|
||||
if (imageFigure) {
|
||||
clearSelectedElement();
|
||||
if (elementPopup.value.visible) elementPopup.value.close();
|
||||
const doc = event.target.ownerDocument;
|
||||
removeElementLabel(doc);
|
||||
removeImageLabel(doc);
|
||||
if (imagePopup.value?.visible) {
|
||||
// Deselect current figure
|
||||
if (selectedFigure.value) {
|
||||
selectedFigure.value.classList.remove('element-selected');
|
||||
selectedFigure.value = null;
|
||||
}
|
||||
imagePopup.value.close();
|
||||
return;
|
||||
}
|
||||
// Select the figure
|
||||
imageFigure.classList.remove('element-hovered');
|
||||
imageFigure.classList.add('element-selected');
|
||||
hoveredFigure.value = null;
|
||||
selectedFigure.value = imageFigure;
|
||||
imagePopup.value?.handleImageClick(imageFigure, event);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if clicking a block-carte figure
|
||||
const carteFigure = getCarteFigure(element);
|
||||
if (carteFigure) {
|
||||
clearSelectedElement();
|
||||
if (elementPopup.value.visible) elementPopup.value.close();
|
||||
imagePopup.value?.close();
|
||||
const doc2 = event.target.ownerDocument;
|
||||
removeElementLabel(doc2);
|
||||
removeCarteLabel(doc2);
|
||||
if (cartePopup.value?.visible) {
|
||||
if (selectedCarte.value) { selectedCarte.value.classList.remove('element-selected'); selectedCarte.value = null; }
|
||||
cartePopup.value.close();
|
||||
return;
|
||||
}
|
||||
carteFigure.classList.remove('element-hovered');
|
||||
carteFigure.classList.add('element-selected');
|
||||
hoveredCarte.value = null;
|
||||
selectedCarte.value = carteFigure;
|
||||
cartePopup.value?.handleCarteClick(carteFigure, event);
|
||||
return;
|
||||
}
|
||||
|
||||
// Close image and carte popups when clicking a text element
|
||||
imagePopup.value?.close();
|
||||
cartePopup.value?.close();
|
||||
|
||||
// Only show ElementPopup for content elements, not divs
|
||||
const contentElement = getContentElement(element);
|
||||
if (!contentElement) {
|
||||
clearSelectedElement();
|
||||
if (elementPopup.value.visible) elementPopup.value.close();
|
||||
elementPopup.value.close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -506,20 +342,6 @@ export function useIframeInteractions({ elementPopup, imagePopup, cartePopup /*,
|
|||
clearSelectedElement();
|
||||
};
|
||||
|
||||
const handleImagePopupClose = () => {
|
||||
if (selectedFigure.value) {
|
||||
selectedFigure.value.classList.remove('element-selected');
|
||||
selectedFigure.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleCartePopupClose = () => {
|
||||
if (selectedCarte.value) {
|
||||
selectedCarte.value.classList.remove('element-selected');
|
||||
selectedCarte.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
// State
|
||||
// hoveredPage, // DISABLED: page template styling feature
|
||||
|
|
@ -531,8 +353,6 @@ export function useIframeInteractions({ elementPopup, imagePopup, cartePopup /*,
|
|||
handleIframeClick,
|
||||
// handlePagePopupClose, // DISABLED: page template styling feature
|
||||
handleElementPopupClose,
|
||||
handleImagePopupClose,
|
||||
handleCartePopupClose,
|
||||
// Utilities
|
||||
// clearSelectedPages, // DISABLED: page template styling feature
|
||||
clearSelectedElement,
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
import { reactive } from 'vue';
|
||||
import { IMAGE_DEFAULTS } from '../utils/defaults';
|
||||
|
||||
// Singleton reactive — ImageSettings writes here, ImagePopup reads when toggle is disabled
|
||||
const defaults = reactive({
|
||||
width: { ...IMAGE_DEFAULTS.width },
|
||||
height: { auto: IMAGE_DEFAULTS.height.auto, value: IMAGE_DEFAULTS.height.value, unit: IMAGE_DEFAULTS.height.unit },
|
||||
_initialized: false,
|
||||
});
|
||||
|
||||
export function useImageDefaults() {
|
||||
return defaults;
|
||||
}
|
||||
|
|
@ -39,11 +39,11 @@ export function usePopupPosition(popupWidth, popupHeight) {
|
|||
else {
|
||||
x = cursorX - OFFSET - popupWidth;
|
||||
y = cursorY - OFFSET - popupHeight;
|
||||
}
|
||||
|
||||
// Final clamp — ensure popup is always fully visible
|
||||
x = Math.max(10, Math.min(viewportWidth - popupWidth - 10, x));
|
||||
y = Math.max(10, Math.min(viewportHeight - popupHeight - 10, y));
|
||||
// Ensure it doesn't go off-screen
|
||||
x = Math.max(10, x);
|
||||
y = Math.max(10, y);
|
||||
}
|
||||
|
||||
return { x, y };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import * as cssComments from '../utils/css-comments';
|
|||
import prettier from 'prettier/standalone';
|
||||
import parserPostcss from 'prettier/plugins/postcss';
|
||||
import { getCsrfToken } from '../utils/kirby-auth';
|
||||
import { PAGE_DEFAULTS, TEXT_DEFAULTS, IMAGE_DEFAULTS, CARTE_DEFAULTS, HEADING_DEFAULTS, INLINE_DEFAULTS, PARAGRAPH_CLASS_DEFAULTS } from '../utils/defaults';
|
||||
import { PAGE_DEFAULTS, TEXT_DEFAULTS, HEADING_DEFAULTS, INLINE_DEFAULTS, PARAGRAPH_CLASS_DEFAULTS } from '../utils/defaults';
|
||||
|
||||
export const useStylesheetStore = defineStore('stylesheet', () => {
|
||||
// Base state
|
||||
|
|
@ -259,20 +259,6 @@ export const useStylesheetStore = defineStore('stylesheet', () => {
|
|||
}
|
||||
}
|
||||
|
||||
// Image defaults
|
||||
set('.block-image', 'width', IMAGE_DEFAULTS.width.value, IMAGE_DEFAULTS.width.unit);
|
||||
set('.block-image', 'height', 'auto');
|
||||
set('.block-image img', 'object-fit', 'cover');
|
||||
set('.block-image img', 'display', 'flex');
|
||||
set('.geoformat-cover-image', 'width', IMAGE_DEFAULTS.width.value, IMAGE_DEFAULTS.width.unit);
|
||||
set('.geoformat-cover-image', 'height', 'auto');
|
||||
set('.geoformat-cover-image img', 'object-fit', 'cover');
|
||||
set('.geoformat-cover-image img', 'display', 'flex');
|
||||
set('.block-carte', 'width', CARTE_DEFAULTS.width.value, CARTE_DEFAULTS.width.unit);
|
||||
set('.block-carte', 'height', 'auto');
|
||||
set('.block-carte img', 'object-fit', 'cover');
|
||||
set('.block-carte img', 'display', 'flex');
|
||||
|
||||
// Inline element defaults (em, i, strong, b, a)
|
||||
for (const [tag, props] of Object.entries(INLINE_DEFAULTS)) {
|
||||
if (props.fontStyle) set(tag, 'font-style', props.fontStyle);
|
||||
|
|
|
|||
|
|
@ -126,16 +126,6 @@ export const PARAGRAPH_CLASS_DEFAULTS = Object.freeze({
|
|||
}),
|
||||
});
|
||||
|
||||
export const IMAGE_DEFAULTS = Object.freeze({
|
||||
width: Object.freeze({ value: 100, unit: '%' }),
|
||||
height: Object.freeze({ auto: true, value: 400, unit: 'px' }),
|
||||
});
|
||||
|
||||
export const CARTE_DEFAULTS = Object.freeze({
|
||||
width: Object.freeze({ value: 100, unit: '%' }),
|
||||
height: Object.freeze({ auto: true, value: 400, unit: 'px' }),
|
||||
});
|
||||
|
||||
export const INLINE_DEFAULTS = Object.freeze({
|
||||
em: Object.freeze({ fontStyle: 'italic' }),
|
||||
i: Object.freeze({ fontStyle: 'italic' }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue