domma-cms 1.75.3 → 1.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/admin/js/lib/shortcode-registry.js +1 -1
- package/admin/js/lib/site-settings-arrange.js +2 -2
- package/admin/js/templates/docs/usage-shortcodes-content.html +14 -3
- package/admin/js/templates/settings.html +7 -0
- package/docs/DommaFeatures.md +2 -0
- package/docs/markdown-shortcodes.md +31 -1
- package/package.json +1 -1
- package/server/routes/api/settings.js +17 -1
- package/server/routes/map-frame.js +26 -0
- package/server/server.js +3 -0
- package/server/services/content.js +5 -0
- package/server/services/geocode.js +158 -0
- package/server/services/mapPins.js +155 -0
- package/server/services/markdown.js +62 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.77.0] - 2026-11-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Map pins by address.** `[map pins="Office = SW1A 2AA | Warehouse = 1 Dock Road, Hull" /]` - a pin can be an address or postcode as well as coordinates. Addresses are found when you save the page, so visitors never wait for them. Switch on **Address look-ups** in Site Settings > General > Maps first: it is off by default, because it sends the addresses (and the site's address) to OpenStreetMap's Nominatim service. Switching it on finds the addresses already in your pages.
|
|
8
|
+
|
|
9
|
+
## [1.76.0] - 2026-11-19
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **Directions from a map.** `[map ... directions="true" /]` puts a "Get directions" link under the map, opening Google's route planner to that place. Give your own wording instead of `true` (`directions="Find us"`). There is a Directions link tick box in the shortcode panel too.
|
|
14
|
+
- **Maps with several pins.** `[map pins="51.5034,-0.1276 Office | 51.5007,-0.1246 Shop" /]` shows every place on one map (OpenStreetMap), zoomed to fit them all. Click a pin for its label and, with `directions`, a directions link to it. Up to 50 pins, given as coordinates.
|
|
15
|
+
|
|
3
16
|
## [1.75.3] - 2026-11-19
|
|
4
17
|
|
|
5
18
|
### Fixed
|
|
@@ -46,4 +46,4 @@ Optional body content.
|
|
|
46
46
|
[/table]`,attrs:[{name:"striped",type:"checkbox",label:"Striped"},{name:"bordered",type:"checkbox",label:"Bordered"},{name:"compact",type:"checkbox",label:"Compact"},{name:"caption",type:"text",label:"Caption"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"badge",label:"Badge",icon:"badge",category:"Content",selfClosing:!1,container:!1,wrappable:!1,template:'[badge variant="success"]New[/badge]',inline:!0,attrs:[{name:"variant",type:"select",label:"Variant",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"],["light","Light"],["dark","Dark"]]},{name:"pill",type:"checkbox",label:"Pill"},{name:"outline",type:"checkbox",label:"Outline"},{name:"size",type:"select",label:"Size",options:[["","Default"],["small","Small"],["large","Large"]]}]},{name:"text",label:"Text",icon:"text-style",preview:"text",category:"Content",selfClosing:!1,container:!0,wrappable:!0,template:"[text]Styled text[/text]",inline:!0,actions:[{label:"Highlight - gradient with a shine",icon:"star",set:{gradient:"sunset",shine:"hover"}},{label:"Highlight that sweeps by itself",icon:"star",set:{gradient:"sunset",shine:"sweep"}},{label:"Light up as you read",icon:"eye",set:{"light-up":"true"}},{label:"Rise in word by word",icon:"arrow-up",set:{words:"true"}},{label:"Plain - no highlight or motion",icon:"minimize",set:{gradient:null,shine:null,"light-up":null,words:null}}],quickAttrs:["gradient","shine","align","size","bold","color"],attrs:[{name:"size",type:"select",label:"Size",options:[["xs","XS"],["sm","Small"],["base","Base"],["lg","Large"],["xl","XL"],["2xl","2XL"],["3xl","3XL"],["4xl","4XL"]]},{name:"weight",type:"select",label:"Weight",options:[["thin","Thin"],["light","Light"],["normal","Normal"],["medium","Medium"],["semibold","Semibold"],["bold","Bold"],["extrabold","Extra bold"],["black","Black"]]},{name:"point-size",type:"number",label:"Point size"},{name:"bold",type:"checkbox",label:"Bold"},{name:"italic",type:"checkbox",label:"Italic"},{name:"color",type:"colour",label:"Colour"},{name:"font",type:"select",label:"Font",options:Object.keys(n).map(e=>[e,o(e)?`${e} (licensed)`:e])},{name:"transform",type:"select",label:"Transform",options:[["upper","Uppercase"],["lower","Lowercase"],["capitalize","Capitalise"],["none","None"]]},{name:"decoration",type:"select",label:"Decoration",options:[["underline","Underline"],["line-through","Line through"],["none","None"]]},{name:"spacing",type:"select",label:"Letter spacing",options:[["tight","Tight"],["normal","Normal"],["wide","Wide"],["wider","Wider"]]},{name:"align",type:"select",label:"Align",options:[["","None"],["left","Left"],["center","Centre"],["right","Right"],["justify","Justify"]]},{name:"gradient",type:"select",label:"Gradient",options:[["","None"],["brand","Theme"],["sunset","Sunset"],["ocean","Ocean"],["forest","Forest"],["fire","Fire"],["candy","Candy"],["newspaper","Newspaper"],["grey-fire","Grey-fire"],["ice","Ice"],["summer","Summer"],["autumn","Autumn"],["spring","Spring"],["winter","Winter"],["aurora","Aurora"],["twilight","Twilight"],["rose-gold","Rose-gold"],["copper","Copper"],["amethyst","Amethyst"],["lagoon","Lagoon"],["cherry","Cherry"],["lavender","Lavender"],["midnight","Midnight"]]},{name:"shine",type:"select",label:"Shine (gradient)",options:[["","None"],["hover","Follows the pointer"],["sweep","Sweeps across"]]},{name:"light-up",type:"checkbox",label:"Words light up as you scroll"},{name:"words",type:"checkbox",label:"Rise in word by word"},{name:"style",type:"text",label:"Inline CSS"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"button",label:"Button",icon:"btn-insert",category:"Content",selfClosing:!0,container:!1,wrappable:!1,template:'[button href="/contact" variant="primary" label="Get in touch" /]',attrs:[{name:"href",type:"url",label:"Link"},{name:"label",type:"text",label:"Label"},{name:"variant",type:"select",label:"Variant",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"],["outline","Outline"],["ghost","Ghost"],["link","Link"],["outline-success","Outline success"],["outline-danger","Outline danger"],["outline-warning","Outline warning"],["outline-info","Outline info"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"icon",type:"icon",label:"Icon (before)"},{name:"icon-after",type:"icon",label:"Icon (after)"},{name:"target",type:"text",label:"Target"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"link",label:"Link",icon:"link-shortcode",category:"Content",selfClosing:!0,container:!1,wrappable:!1,template:'[link href="/about" label="About us" /]',formats:[{value:"markdown",label:"Markdown link",emit:e=>Object.keys(e).some(t=>t!=="href"&&t!=="label"&&e[t])||!e.href?null:`[${e.label||e.href}](${e.href})`},{value:"shortcode",label:"Link shortcode"}],attrs:[{name:"href",type:"url",label:"Link"},{name:"label",type:"text",label:"Label"},{name:"target",type:"text",label:"Target"},{name:"class",type:"text",label:"CSS class"},{name:"icon",type:"icon",label:"Icon (before)"},{name:"icon-after",type:"icon",label:"Icon (after)"},{name:"id",type:"text",label:"ID"}]},{name:"listgroup",label:"List group",icon:"list",category:"Content",selfClosing:!1,container:!0,wrappable:!1,template:`[listgroup]
|
|
47
47
|
[item]First item[/item]
|
|
48
48
|
[item]Second item[/item]
|
|
49
|
-
[/listgroup]`,children:{name:"item",min:1,max:20},attrs:[{name:"variant",type:"select",label:"Variant",options:[["","Default"],["flush","Flush"],["numbered","Numbered"],["horizontal","Horizontal"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"itemvariant",type:"select",label:"Item variant",options:[["","Default"],["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"action",type:"checkbox",label:"Actionable items"}]},{name:"collection",label:"Collection",icon:"database",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[collection slug="enquiries" display="table" /]',attrs:[{name:"slug",type:"lookup",source:"collections",label:"Collection"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"limit",type:"number",label:"Limit"},{name:"sort",type:"lookup",source:"collection-fields",label:"Sort field"},{name:"order",type:"select",label:"Order",options:[["desc","Descending"],["asc","Ascending"]]},{name:"title-field",type:"lookup",source:"collection-fields",label:"Title field"},{name:"image-field",type:"lookup",source:"collection-fields",label:"Image field"},{name:"body-field",type:"lookup",source:"collection-fields",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"search",type:"checkbox",label:"Search (table)",default:!0},{name:"sortable",type:"checkbox",label:"Sortable (table)",default:!0},{name:"exportable",type:"checkbox",label:"CSV export"},{name:"page-size",type:"number",label:"Page size"},{name:"empty",type:"text",label:"Empty message"},{name:"scope",type:"select",label:"Scope",options:[["","All"],["mine","Current user"]]},{name:"cta",type:"lookup",source:"actions",label:"CTA action"},{name:"cta-label",type:"text",label:"CTA label"},{name:"cta-icon",type:"icon",label:"CTA icon"},{name:"cta-style",type:"select",label:"CTA style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"cta-confirm",type:"text",label:"CTA confirm text"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"view",label:"View",icon:"eye",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[view slug="products" display="table" limit="50" /]',attrs:[{name:"slug",type:"lookup",source:"views",label:"View"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"limit",type:"number",label:"Limit"},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"title-field",type:"text",label:"Title field"},{name:"image-field",type:"text",label:"Image field"},{name:"body-field",type:"text",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"empty",type:"text",label:"Empty message"}]},{name:"block",label:"Block",icon:"layout",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[block template="post-card" title="My Post" /]',attrs:[{name:"template",type:"lookup",source:"blocks",label:"Template"}]},{name:"form",label:"Form",icon:"file-text",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[form name="contact" /]',attrs:[{name:"name",type:"lookup",source:"forms",label:"Form"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"cta",label:"CTA",icon:"mouse-pointer",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[cta action="send-welcome" entry="abc123" style="primary" label="Send" /]',attrs:[{name:"action",type:"lookup",source:"actions",label:"Action"},{name:"entry",type:"text",label:"Entry ID"},{name:"style",type:"select",label:"Style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"icon",type:"icon",label:"Icon"},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"confirm",type:"text",label:"Confirm text"},{name:"label",type:"text",label:"Label"}]},{name:"menu",label:"Menu",icon:"menu",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[menu slug="legal" /]',attrs:[{name:"slug",type:"lookup",source:"menus",label:"Menu"},{name:"location",type:"lookup",source:"menu-locations",label:"Location slot"},{name:"variant",type:"text",label:"Variant"},{name:"class",type:"text",label:"CSS class"},{name:"depth",type:"number",label:"Max depth"},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"float",type:"select",label:"Floating",options:[["","Menu default"],["no","Render inline here"]]}]},{name:"contents",label:"Page contents (this page)",icon:"list",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[contents numbered="true" /]',actions:[{label:"Number the contents",icon:"hash",set:{numbered:"true"}},{label:"List H2 and H3 headings",icon:"list",set:{headings:"h2h3"}},{label:"Contents on the right",icon:"sidebar-right",set:{side:"right"}},{label:"Collapse the contents to a button",icon:"minimize",set:{collapsible:"true",collapsed:"true"}},{label:"Float the contents",icon:"move",set:{floating:"true","float-anchor":"TR",movable:"true"}},{label:"No contents on this page",icon:"eye-off",set:{hidden:"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["side","headings","numbered","title","collapsible","floating","hidden"],attrs:[{name:"side",type:"select",label:"Side",options:[["","Layout default"],["left","Left"],["right","Right"]]},{name:"width",type:"number",label:"Width (px, 160-480)"},{name:"headings",type:"select",label:"Headings",options:[["","Layout default"],["auto","Sections (H2s, else H3s)"],["h2","H2 only"],["h3","H3 only"],["h2h3","H2 and H3"]]},{name:"numbered",type:"select",label:"Numbered",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"title",type:"text",label:"Title above the list"},{name:"exclude",type:"text",label:"Leave out (headings, comma separated)"},{name:"sticky",type:"select",label:"Stays in view",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"scroll-spy",type:"select",label:"Marks the section being read",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsible",type:"select",label:"Collapsible to a button",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off its edge",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"floating",type:"select",label:"Floating panel",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Layout default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"movable",type:"select",label:"Visitors can move it",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hidden",type:"select",label:"No contents on this page",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Accent"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"}]},{name:"navbar",label:"Navbar settings (this page)",icon:"sliders",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[navbar collapsed="true" /]',actions:[{label:"Collapse the rail on this page",icon:"chevrons-right",set:{collapsible:"true",collapsed:"true",autohide:"false"}},{label:"Autohide the rail on this page",icon:"eye-off",set:{autohide:"true",collapsed:null}},{label:"Keep the rail open on this page",icon:"eye",set:{autohide:"false",collapsed:"false"}},{label:"Hide the bar on scroll on this page",icon:"arrow-up",set:{"hide-on-scroll":"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["position","width","collapsible","collapsed","autohide","hide-on-scroll"],attrs:[{name:"position",type:"select",label:"Position",options:[["","Menu default"],["sticky","Sticky"],["fixed","Fixed"],["static","Static"],["floating","Floating"]]},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"side",type:"select",label:"Rail side",options:[["","Menu default"],["left","Left"],["right","Right"]]},{name:"align",type:"select",label:"Alignment",options:[["","Menu default"],["left","Left"],["centre","Centre"],["right","Right"],["spread","Spread"]]},{name:"width",type:"number",label:"Rail width (px, 160-480)"},{name:"collapsible",type:"select",label:"Collapsible to icons",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off-screen",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hide-on-scroll",type:"select",label:"Hide on scroll (bar)",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover-open",type:"select",label:"Open dropdowns on hover",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"bar",type:"select",label:"Bar shape",options:[["","Menu default"],["pill","Pill"],["segmented","Segmented"],["underline","Underline glide"],["dock","Dock"],["neon","Neon"],["tabs","Tabs"],["tiles","Tiles"],["bubbles","Bubbles"],["brutalist","Brutalist"],["gradient","Gradient band"]]},{name:"shrink",type:"select",label:"Shrink on scroll",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"icons",type:"select",label:"Bar icons",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Accent"]]},{name:"brand",type:"select",label:"Branding shape",options:[["","Menu default"],["pill","Pill"]]},{name:"strip",type:"select",label:"Bar background",options:[["","Menu default"],["none","None - floating pills"],["band","Strip - keep the band"]]},{name:"dropdown",type:"select",label:"Dropdown style",options:[["","Menu default"],["cards","Cards"]]},{name:"tiles",type:"select",label:"Icon tiles (cards)",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Theme colour"],["neutral","Neutral"],["none","No tiles"]]},{name:"morph",type:"select",label:"Slide between cards",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Highlight colour"},{name:"variant",type:"text",label:"Variant"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"},{name:"letter-spacing",type:"text",label:"Letter spacing"},{name:"icon-size",type:"text",label:"Icon size"},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Menu default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"float-x",type:"number",label:"Float offset X (px)"},{name:"float-y",type:"number",label:"Float offset Y (px)"},{name:"float-width",type:"number",label:"Float width (px)"},{name:"float-collapsible",type:"select",label:"Float: collapsible",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"float-movable",type:"select",label:"Float: movable",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"class",type:"text",label:"CSS classes"}]},{name:"theme-switcher",label:"Theme switcher",icon:"palette",category:"Components",selfClosing:!0,container:!1,wrappable:!1,template:"[theme-switcher /]",attrs:[{name:"position",type:"select",label:"Position",options:[["","Inline - where the tag is"],["top-left","Top left"],["top-right","Top right"],["left-center","Left, centred"],["right-center","Right, centred"],["bottom-left","Bottom left"],["bottom-right","Bottom right"]]},{name:"offset-x",type:"number",label:"Offset from the side (px, pinned only)"},{name:"offset-y",type:"number",label:"Offset from the top/bottom (px, pinned only)"},{name:"themes",type:"text",label:"Themes (comma list - blank for the site's)"}]},{name:"icon",label:"Icon",icon:"icon-pick",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[icon name="arrow-right" /]',attrs:[{name:"name",type:"icon",label:"Icon name"},{name:"size",type:"number",label:"Size (px)"},{name:"color",type:"colour",label:"Colour"},{name:"class",type:"text",label:"CSS class"}]},{name:"image",label:"Image",icon:"image-add",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[image src="/media/photo.jpg" alt="" /]',custom:"image",quickAttrs:["zoom","align","width","shadow"],attrs:[{name:"src",type:"image",label:"Image",help:"The picture: choose it from Media, or type a /media/\u2026 path or an https:// address."},{name:"alt",type:"text",label:"Description (alt)",help:"What the picture shows, in a few words. Screen readers and search engines read it. Leave empty only for decoration."},{name:"caption",type:"text",label:"Caption",help:"Shown under the picture, and in the zoom view."},{name:"zoom",type:"checkbox",label:"Click to zoom",help:"Visitors click the picture to see it full size in a viewer: fitted first, then actual size with drag to pan. Best for screenshots with small text. Ignored when the picture has a link."},{name:"width",type:"text",label:"Width (480, 60%, 30rem)",help:"How wide the picture shows. A bare number is pixels. Empty: its own size, never wider than the column."},{name:"align",type:"select",label:"Alignment",options:[["","Default (left)"],["center","Centre"],["right","Right"],["float-left","Float left (text wraps)"],["float-right","Float right (text wraps)"]],help:"Floats let the text run beside the picture; on phones they stack."},{name:"group",type:"text",label:"Zoom group",help:"Give zoomable pictures the same group name and the viewer steps between them with arrows - a gallery or a tour."},{name:"zoom-src",type:"image",label:"Full-size file (zoom)",help:"Optional: a larger file for the zoom view, when the page shows a smaller copy."},{name:"title",type:"text",label:"Hover text (title)"},{name:"max-width",type:"text",label:"Max width (800, 50%)"},{name:"height",type:"text",label:"Height (240, 20rem)",help:"A set height crops the picture to fill the box (see Fit)."},{name:"fit",type:"select",label:"Fit (with a height)",options:[["","Fill and crop (default)"],["contain","Show it all"],["fill","Stretch"],["none","Actual size"],["scale-down","Shrink only"]]},{name:"radius",type:"select",label:"Corners",options:[["","Square"],["sm","Slightly rounded"],["md","Rounded"],["lg","Very rounded"],["full","Circle / pill"]]},{name:"border",type:"checkbox",label:"Border"},{name:"shadow",type:"select",label:"Shadow",options:[["","None"],["sm","Small"],["md","Medium"],["lg","Large"]]},{name:"link",type:"url",label:"Link to",help:"Clicking the picture goes here instead of zooming."},{name:"target",type:"select",label:"Open link in",options:[["","Same tab"],["_blank","New tab"]]},{name:"loading",type:"select",label:"Loading",options:[["","When scrolled near (lazy)"],["eager","Straight away (top of page)"]]},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"map",label:"Map",icon:"map-pin",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[map address="10 Downing Street, London" zoom="15" /]',attrs:[{name:"pin",type:"text",label:"Pin (latitude, longitude)"},{name:"lat",type:"number",label:"Latitude"},{name:"lon",type:"number",label:"Longitude"},{name:"address",type:"text",label:"Address"},{name:"postcode",type:"text",label:"Postcode"},{name:"zoom",type:"number",label:"Zoom (1-20)"},{name:"title",type:"text",label:"Title"},{name:"caption",type:"text",label:"Caption"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"]]},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]}]},{name:"embed",label:"Embed",icon:"video",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[embed url="https://youtu.be/dQw4w9WgXcQ" /]',custom:"embed",attrs:[{name:"url",type:"url",label:"URL"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"],["9:16","9:16"],["3:4","3:4"]]},{name:"title",type:"text",label:"Title / caption"},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]},{name:"autoplay",type:"checkbox",label:"Autoplay"},{name:"loop",type:"checkbox",label:"Loop"},{name:"muted",type:"checkbox",label:"Muted"}]}];for(const e of SHORTCODES){e.attrs||(e.attrs=[]);for(const a of i)e.attrs.some(t=>t.name===a.name)||e.attrs.push(a)}export const EDITOR_TOOLS=[{name:"colourpick",label:"Colour picker",icon:"colour-picker",category:"Media",custom:"colourpick"},{name:"component",label:"Component",icon:"component",category:"Components",custom:"component"},{name:"scribe",label:"Scribe",icon:"scribe-insert",category:"Content",custom:"scribe"},{name:"highlight-text",label:"Highlight text",icon:"star",category:"Content",custom:"highlighttext",wrappable:!0}];
|
|
49
|
+
[/listgroup]`,children:{name:"item",min:1,max:20},attrs:[{name:"variant",type:"select",label:"Variant",options:[["","Default"],["flush","Flush"],["numbered","Numbered"],["horizontal","Horizontal"]]},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"itemvariant",type:"select",label:"Item variant",options:[["","Default"],["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"action",type:"checkbox",label:"Actionable items"}]},{name:"collection",label:"Collection",icon:"database",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[collection slug="enquiries" display="table" /]',attrs:[{name:"slug",type:"lookup",source:"collections",label:"Collection"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"limit",type:"number",label:"Limit"},{name:"sort",type:"lookup",source:"collection-fields",label:"Sort field"},{name:"order",type:"select",label:"Order",options:[["desc","Descending"],["asc","Ascending"]]},{name:"title-field",type:"lookup",source:"collection-fields",label:"Title field"},{name:"image-field",type:"lookup",source:"collection-fields",label:"Image field"},{name:"body-field",type:"lookup",source:"collection-fields",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"search",type:"checkbox",label:"Search (table)",default:!0},{name:"sortable",type:"checkbox",label:"Sortable (table)",default:!0},{name:"exportable",type:"checkbox",label:"CSV export"},{name:"page-size",type:"number",label:"Page size"},{name:"empty",type:"text",label:"Empty message"},{name:"scope",type:"select",label:"Scope",options:[["","All"],["mine","Current user"]]},{name:"cta",type:"lookup",source:"actions",label:"CTA action"},{name:"cta-label",type:"text",label:"CTA label"},{name:"cta-icon",type:"icon",label:"CTA icon"},{name:"cta-style",type:"select",label:"CTA style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"cta-confirm",type:"text",label:"CTA confirm text"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"view",label:"View",icon:"eye",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[view slug="products" display="table" limit="50" /]',attrs:[{name:"slug",type:"lookup",source:"views",label:"View"},{name:"display",type:"select",label:"Display",options:[["table","Table"],["cards","Cards"],["list","List"],["accordion","Accordion"],["timeline","Timeline"],["carousel","Carousel"],["block","Block"]]},{name:"limit",type:"number",label:"Limit"},{name:"fields",type:"text",label:"Fields (comma-separated)"},{name:"title-field",type:"text",label:"Title field"},{name:"image-field",type:"text",label:"Image field"},{name:"body-field",type:"text",label:"Body field"},{name:"mobile-popup",type:"checkbox",label:"Open carousel cards in a popup on mobile"},{name:"arrow-position",type:"select",label:"Arrow position",options:[["middle","Middle"],["top","Top"],["bottom","Bottom"]]},{name:"background",type:"colour",label:"Carousel background"},{name:"arrow-background",type:"colour",label:"Arrow background"},{name:"arrow-color",type:"colour",label:"Arrow colour"},{name:"autoplay",type:"checkbox",label:"Autoplay",domma:"carousel.autoplay"},{name:"interval",type:"number",label:"Interval (ms)",domma:"carousel.interval"},{name:"loop",type:"checkbox",label:"Loop",default:!0,domma:"carousel.loop"},{name:"animation",type:"select",label:"Animation",options:[["slide","Slide"],["fade","Fade"],["crossfade","Crossfade"]],domma:"carousel.animation"},{name:"animation-duration",type:"number",label:"Animation duration (ms)",domma:"carousel.animationDuration"},{name:"animation-easing",type:"text",label:"Animation easing",domma:"carousel.animationEasing"},{name:"height-mode",type:"select",label:"Image height",options:[["crop","Top-aligned crop (shortest image)"],["average","Average of shortest and tallest images"]],domma:"carousel.heightMode"},{name:"height",type:"number",label:"Fixed height (px, optional)",domma:"carousel.height"},{name:"columns",type:"number",label:"Card columns"},{name:"empty",type:"text",label:"Empty message"}]},{name:"block",label:"Block",icon:"layout",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[block template="post-card" title="My Post" /]',attrs:[{name:"template",type:"lookup",source:"blocks",label:"Template"}]},{name:"form",label:"Form",icon:"file-text",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[form name="contact" /]',attrs:[{name:"name",type:"lookup",source:"forms",label:"Form"},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"cta",label:"CTA",icon:"mouse-pointer",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[cta action="send-welcome" entry="abc123" style="primary" label="Send" /]',attrs:[{name:"action",type:"lookup",source:"actions",label:"Action"},{name:"entry",type:"text",label:"Entry ID"},{name:"style",type:"select",label:"Style",options:[["primary","Primary"],["secondary","Secondary"],["success","Success"],["danger","Danger"],["warning","Warning"],["info","Info"]]},{name:"icon",type:"icon",label:"Icon"},{name:"size",type:"select",label:"Size",options:[["","Default"],["sm","Small"],["lg","Large"]]},{name:"confirm",type:"text",label:"Confirm text"},{name:"label",type:"text",label:"Label"}]},{name:"menu",label:"Menu",icon:"menu",category:"Data",selfClosing:!0,container:!1,wrappable:!1,template:'[menu slug="legal" /]',attrs:[{name:"slug",type:"lookup",source:"menus",label:"Menu"},{name:"location",type:"lookup",source:"menu-locations",label:"Location slot"},{name:"variant",type:"text",label:"Variant"},{name:"class",type:"text",label:"CSS class"},{name:"depth",type:"number",label:"Max depth"},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"float",type:"select",label:"Floating",options:[["","Menu default"],["no","Render inline here"]]}]},{name:"contents",label:"Page contents (this page)",icon:"list",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[contents numbered="true" /]',actions:[{label:"Number the contents",icon:"hash",set:{numbered:"true"}},{label:"List H2 and H3 headings",icon:"list",set:{headings:"h2h3"}},{label:"Contents on the right",icon:"sidebar-right",set:{side:"right"}},{label:"Collapse the contents to a button",icon:"minimize",set:{collapsible:"true",collapsed:"true"}},{label:"Float the contents",icon:"move",set:{floating:"true","float-anchor":"TR",movable:"true"}},{label:"No contents on this page",icon:"eye-off",set:{hidden:"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["side","headings","numbered","title","collapsible","floating","hidden"],attrs:[{name:"side",type:"select",label:"Side",options:[["","Layout default"],["left","Left"],["right","Right"]]},{name:"width",type:"number",label:"Width (px, 160-480)"},{name:"headings",type:"select",label:"Headings",options:[["","Layout default"],["auto","Sections (H2s, else H3s)"],["h2","H2 only"],["h3","H3 only"],["h2h3","H2 and H3"]]},{name:"numbered",type:"select",label:"Numbered",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"title",type:"text",label:"Title above the list"},{name:"exclude",type:"text",label:"Leave out (headings, comma separated)"},{name:"sticky",type:"select",label:"Stays in view",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"scroll-spy",type:"select",label:"Marks the section being read",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsible",type:"select",label:"Collapsible to a button",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off its edge",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"floating",type:"select",label:"Floating panel",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Layout default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"movable",type:"select",label:"Visitors can move it",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hidden",type:"select",label:"No contents on this page",options:[["","Layout default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Accent"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"}]},{name:"navbar",label:"Navbar settings (this page)",icon:"sliders",category:"Layout",selfClosing:!0,container:!1,wrappable:!1,template:'[navbar collapsed="true" /]',actions:[{label:"Collapse the rail on this page",icon:"chevrons-right",set:{collapsible:"true",collapsed:"true",autohide:"false"}},{label:"Autohide the rail on this page",icon:"eye-off",set:{autohide:"true",collapsed:null}},{label:"Keep the rail open on this page",icon:"eye",set:{autohide:"false",collapsed:"false"}},{label:"Hide the bar on scroll on this page",icon:"arrow-up",set:{"hide-on-scroll":"true"}},{label:"Remove this override",icon:"trash",remove:!0}],quickAttrs:["position","width","collapsible","collapsed","autohide","hide-on-scroll"],attrs:[{name:"position",type:"select",label:"Position",options:[["","Menu default"],["sticky","Sticky"],["fixed","Fixed"],["static","Static"],["floating","Floating"]]},{name:"orientation",type:"select",label:"Orientation",options:[["","Menu default"],["horizontal","Horizontal"],["vertical","Vertical"]]},{name:"side",type:"select",label:"Rail side",options:[["","Menu default"],["left","Left"],["right","Right"]]},{name:"align",type:"select",label:"Alignment",options:[["","Menu default"],["left","Left"],["centre","Centre"],["right","Right"],["spread","Spread"]]},{name:"width",type:"number",label:"Rail width (px, 160-480)"},{name:"collapsible",type:"select",label:"Collapsible to icons",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"collapsed",type:"select",label:"Start collapsed",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"autohide",type:"select",label:"Autohide off-screen",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hide-on-scroll",type:"select",label:"Hide on scroll (bar)",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover-open",type:"select",label:"Open dropdowns on hover",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"bar",type:"select",label:"Bar shape",options:[["","Menu default"],["pill","Pill"],["segmented","Segmented"],["underline","Underline glide"],["dock","Dock"],["neon","Neon"],["tabs","Tabs"],["tiles","Tiles"],["bubbles","Bubbles"],["brutalist","Brutalist"],["gradient","Gradient band"]]},{name:"shrink",type:"select",label:"Shrink on scroll",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"icons",type:"select",label:"Bar icons",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Accent"]]},{name:"brand",type:"select",label:"Branding shape",options:[["","Menu default"],["pill","Pill"]]},{name:"strip",type:"select",label:"Bar background",options:[["","Menu default"],["none","None - floating pills"],["band","Strip - keep the band"]]},{name:"dropdown",type:"select",label:"Dropdown style",options:[["","Menu default"],["cards","Cards"]]},{name:"tiles",type:"select",label:"Icon tiles (cards)",options:[["","Menu default"],["rainbow","Rainbow"],["accent","Theme colour"],["neutral","Neutral"],["none","No tiles"]]},{name:"morph",type:"select",label:"Slide between cards",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"hover",type:"text",label:"Hover effect"},{name:"selected",type:"text",label:"When selected"},{name:"accent",type:"colour",label:"Highlight colour"},{name:"variant",type:"text",label:"Variant"},{name:"font",type:"text",label:"Font family"},{name:"font-size",type:"text",label:"Font size"},{name:"font-weight",type:"text",label:"Font weight"},{name:"letter-spacing",type:"text",label:"Letter spacing"},{name:"icon-size",type:"text",label:"Icon size"},{name:"float-anchor",type:"select",label:"Float anchor",options:[["","Menu default"],["TL","Top left"],["TR","Top right"],["BL","Bottom left"],["BR","Bottom right"],["L","Left"],["R","Right"]]},{name:"float-x",type:"number",label:"Float offset X (px)"},{name:"float-y",type:"number",label:"Float offset Y (px)"},{name:"float-width",type:"number",label:"Float width (px)"},{name:"float-collapsible",type:"select",label:"Float: collapsible",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"float-movable",type:"select",label:"Float: movable",options:[["","Menu default"],["true","On"],["false","Off"]]},{name:"class",type:"text",label:"CSS classes"}]},{name:"theme-switcher",label:"Theme switcher",icon:"palette",category:"Components",selfClosing:!0,container:!1,wrappable:!1,template:"[theme-switcher /]",attrs:[{name:"position",type:"select",label:"Position",options:[["","Inline - where the tag is"],["top-left","Top left"],["top-right","Top right"],["left-center","Left, centred"],["right-center","Right, centred"],["bottom-left","Bottom left"],["bottom-right","Bottom right"]]},{name:"offset-x",type:"number",label:"Offset from the side (px, pinned only)"},{name:"offset-y",type:"number",label:"Offset from the top/bottom (px, pinned only)"},{name:"themes",type:"text",label:"Themes (comma list - blank for the site's)"}]},{name:"icon",label:"Icon",icon:"icon-pick",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[icon name="arrow-right" /]',attrs:[{name:"name",type:"icon",label:"Icon name"},{name:"size",type:"number",label:"Size (px)"},{name:"color",type:"colour",label:"Colour"},{name:"class",type:"text",label:"CSS class"}]},{name:"image",label:"Image",icon:"image-add",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[image src="/media/photo.jpg" alt="" /]',custom:"image",quickAttrs:["zoom","align","width","shadow"],attrs:[{name:"src",type:"image",label:"Image",help:"The picture: choose it from Media, or type a /media/\u2026 path or an https:// address."},{name:"alt",type:"text",label:"Description (alt)",help:"What the picture shows, in a few words. Screen readers and search engines read it. Leave empty only for decoration."},{name:"caption",type:"text",label:"Caption",help:"Shown under the picture, and in the zoom view."},{name:"zoom",type:"checkbox",label:"Click to zoom",help:"Visitors click the picture to see it full size in a viewer: fitted first, then actual size with drag to pan. Best for screenshots with small text. Ignored when the picture has a link."},{name:"width",type:"text",label:"Width (480, 60%, 30rem)",help:"How wide the picture shows. A bare number is pixels. Empty: its own size, never wider than the column."},{name:"align",type:"select",label:"Alignment",options:[["","Default (left)"],["center","Centre"],["right","Right"],["float-left","Float left (text wraps)"],["float-right","Float right (text wraps)"]],help:"Floats let the text run beside the picture; on phones they stack."},{name:"group",type:"text",label:"Zoom group",help:"Give zoomable pictures the same group name and the viewer steps between them with arrows - a gallery or a tour."},{name:"zoom-src",type:"image",label:"Full-size file (zoom)",help:"Optional: a larger file for the zoom view, when the page shows a smaller copy."},{name:"title",type:"text",label:"Hover text (title)"},{name:"max-width",type:"text",label:"Max width (800, 50%)"},{name:"height",type:"text",label:"Height (240, 20rem)",help:"A set height crops the picture to fill the box (see Fit)."},{name:"fit",type:"select",label:"Fit (with a height)",options:[["","Fill and crop (default)"],["contain","Show it all"],["fill","Stretch"],["none","Actual size"],["scale-down","Shrink only"]]},{name:"radius",type:"select",label:"Corners",options:[["","Square"],["sm","Slightly rounded"],["md","Rounded"],["lg","Very rounded"],["full","Circle / pill"]]},{name:"border",type:"checkbox",label:"Border"},{name:"shadow",type:"select",label:"Shadow",options:[["","None"],["sm","Small"],["md","Medium"],["lg","Large"]]},{name:"link",type:"url",label:"Link to",help:"Clicking the picture goes here instead of zooming."},{name:"target",type:"select",label:"Open link in",options:[["","Same tab"],["_blank","New tab"]]},{name:"loading",type:"select",label:"Loading",options:[["","When scrolled near (lazy)"],["eager","Straight away (top of page)"]]},{name:"class",type:"text",label:"CSS class"},{name:"id",type:"text",label:"ID"}]},{name:"map",label:"Map",icon:"map-pin",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[map address="10 Downing Street, London" zoom="15" /]',attrs:[{name:"pin",type:"text",label:"Pin (latitude, longitude)"},{name:"pins",type:"text",label:"Several pins",help:"For a map of several places, split by |. Each is latitude,longitude then a label, or Label = an address (Office = SW1A 2AA | 51.5007,-0.1246 Big Ben). Addresses are found when the page is saved, once Address look-ups is on in Site Settings. Shown on OpenStreetMap."},{name:"lat",type:"number",label:"Latitude"},{name:"lon",type:"number",label:"Longitude"},{name:"address",type:"text",label:"Address"},{name:"postcode",type:"text",label:"Postcode"},{name:"zoom",type:"number",label:"Zoom (1-20)"},{name:"title",type:"text",label:"Title"},{name:"caption",type:"text",label:"Caption"},{name:"directions",type:"checkbox",label:"Directions link"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"]]},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]}]},{name:"embed",label:"Embed",icon:"video",category:"Media",selfClosing:!0,container:!1,wrappable:!1,template:'[embed url="https://youtu.be/dQw4w9WgXcQ" /]',custom:"embed",attrs:[{name:"url",type:"url",label:"URL"},{name:"ratio",type:"select",label:"Aspect ratio",options:[["16:9","16:9"],["4:3","4:3"],["1:1","1:1"],["21:9","21:9"],["9:16","9:16"],["3:4","3:4"]]},{name:"title",type:"text",label:"Title / caption"},{name:"width",type:"text",label:"Width"},{name:"align",type:"select",label:"Alignment",options:[["left","Left"],["center","Centre"],["right","Right"]]},{name:"autoplay",type:"checkbox",label:"Autoplay"},{name:"loop",type:"checkbox",label:"Loop"},{name:"muted",type:"checkbox",label:"Muted"}]}];for(const e of SHORTCODES){e.attrs||(e.attrs=[]);for(const a of i)e.attrs.some(t=>t.name===a.name)||e.attrs.push(a)}export const EDITOR_TOOLS=[{name:"colourpick",label:"Colour picker",icon:"colour-picker",category:"Media",custom:"colourpick"},{name:"component",label:"Component",icon:"component",category:"Components",custom:"component"},{name:"scribe",label:"Scribe",icon:"scribe-insert",category:"Content",custom:"scribe"},{name:"highlight-text",label:"Highlight text",icon:"star",category:"Content",custom:"highlighttext",wrappable:!0}];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass","charactersEnabled","charactersAnimated","charactersLaunchers","charactersChats","charactersBuilders","charactersDot","charactersDaisy"],branding:["brandEnabled","brandText","brandLogo","brandIcon","brandUrl","adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"],favicon:["favicon"],footer:["footerCopyright","footerLayout","footerBlurb","footerBlocks","footerClass","footerSocialClass","footerLook","footerCtaText","footerCtaHighlight","footerCtaUrl","footerCtaSub","footerWatermark","footerStatus","footerFacts","footerTagline","footerEmail","footerAddress","footerGradFrom","footerGradTo","socialTwitter","socialFacebook","socialInstagram","socialLinkedin","socialGithub","socialYoutube"],email:["smtpHost","smtpPort","smtpUser","smtpPass","smtpSecure","smtpInsecureTLS","smtpFromAddress","smtpFromName"],pageNavigation:["bttEnabled","bttSmooth","bttLabel","bttThreshold","bttPosition","bttOffset","bttBottomOffset","gtbEnabled","gtbSmooth","gtbLabel","gtbThreshold","gtbPosition","gtbOffset","gtbBottomOffset"],cookies:["ccEnabled","ccMessage","ccAcceptAll","ccRejectAll","ccCustomize","ccSavePrefs","ccPrivacyText","ccPrivacyUrl","ccCookieText","ccCookieUrl","ccPosition","ccLayout","ccTheme","ccShowFunctional","ccShowAnalytics","ccShowMarketing","ccVersion","ccSettingsLink","ccSettingsLinkText"],breadcrumbs:["bcEnabled","bcHomeLabel","bcPosition","bcOffsetX","bcOffsetY"],motion:["mtEnabled","mtLabel","mtDefault","mtControl","mtPlacement","mtTriggerStyle","mtPosition","mtOffsetX","mtOffsetY","mtIconSize","mtIconRadius","mtClass"]},SECRET_FIELDS=["smtpPass"],BREADCRUMB_POSITIONS=["TL","TR","BL","BR"],MOTION_PLACEMENTS=["footer","floating","navbar"],MOTION_LABEL="Reduce motion";const b=["system","off","on"],i=(t,r,a,o)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?Math.min(o,Math.max(a,n)):r};export function motionFromSettings(t={}){const r=t.motion&&typeof t.motion=="object"?t.motion:{},a=t.footer||{},o=m=>r[m]!==void 0&&r[m]!==null,n=o("default")?r.default:a.motionDefault,s=o("control")?r.control:a.motionControl,l=i(r.iconSize,52,32,96);return{mtEnabled:(o("enabled")?r.enabled:a.showMotionToggle)!==!1,mtLabel:typeof r.label=="string"&&r.label.trim()?r.label.trim():MOTION_LABEL,mtDefault:b.includes(n)?n:"system",mtControl:s==="checkbox"?"checkbox":"switch",mtPlacement:MOTION_PLACEMENTS.includes(r.placement)?r.placement:"footer",mtTriggerStyle:r.triggerStyle==="icon-text"?"icon-text":"icon",mtPosition:BREADCRUMB_POSITIONS.includes(r.position)?r.position:"BL",mtOffsetX:e(i(r.offsetX,32,0,500)),mtOffsetY:e(i(r.offsetY,32,0,500)),mtIconSize:e(l),mtIconRadius:e(i(r.iconRadius,26,0,Math.floor(l/2))),mtClass:e(r.class)}}export function motionFromForm(t){const r=i(t.mtIconSize,52,32,96);return{enabled:t.mtEnabled===!0,default:b.includes(t.mtDefault)?t.mtDefault:"system",placement:MOTION_PLACEMENTS.includes(t.mtPlacement)?t.mtPlacement:"footer",control:t.mtControl==="checkbox"?"checkbox":"switch",triggerStyle:t.mtTriggerStyle==="icon-text"?"icon-text":"icon",label:e(t.mtLabel).trim().replace(/\s+/g," ").slice(0,40)||MOTION_LABEL,position:BREADCRUMB_POSITIONS.includes(t.mtPosition)?t.mtPosition:"BL",offsetX:i(t.mtOffsetX,32,0,500),offsetY:i(t.mtOffsetY,32,0,500),iconSize:r,iconRadius:i(t.mtIconRadius,26,0,Math.floor(r/2)),class:e(t.mtClass).trim()}}export function footerBlockNames(t){return[...new Set(String(t??"").split(/[\s,]+/).map(r=>r.trim().toLowerCase()).filter(Boolean))]}export function gaIdError(t){const r=e(t).trim();return!r||/^G-[A-Z0-9]{4,20}$/i.test(r)?"":"A measurement ID looks like G-XXXXXXXXXX (Google Analytics > Admin > Data streams)."}export const FOOTER_LAYOUTS=["auto","columns","row"],FOOTER_LOOKS=["","showcase"],FOOTER_FACTS_MAX=4;const
|
|
2
|
-
`):"",footerTagline:e(t.footer?.tagline),footerEmail:e(t.footer?.email),footerAddress:e(t.footer?.address),footerGradFrom:e(t.footer?.gradient?.from),footerGradTo:e(t.footer?.gradient?.to),socialTwitter:e(t.social?.twitter),socialFacebook:e(t.social?.facebook),socialInstagram:e(t.social?.instagram),socialLinkedin:e(t.social?.linkedin),socialGithub:e(t.social?.github),socialYoutube:e(t.social?.youtube),smtpHost:e(t.smtp?.host),smtpPort:e(t.smtp?.port||587),smtpUser:e(t.smtp?.user),smtpPass:"",smtpSecure:t.smtp?.secure===!0,smtpInsecureTLS:t.smtp?.allowInsecureTLS===!0,smtpFromAddress:e(t.smtp?.fromAddress),smtpFromName:e(t.smtp?.fromName),bttEnabled:r.enabled!==!1,bttSmooth:r.smooth!==!1,bttLabel:e(r.label),bttThreshold:e(r.scrollThreshold??300),bttPosition:e(r.position,"bottom-right"),bttOffset:e(r.offset??32),bttBottomOffset:e(r.bottomOffset??r.offset??32),gtbEnabled:a.enabled===!0,gtbSmooth:a.smooth!==!1,gtbLabel:e(a.label),gtbThreshold:e(a.scrollThreshold??300),gtbPosition:e(a.position,"bottom-right"),gtbOffset:e(a.offset??32),gtbBottomOffset:e(a.bottomOffset??a.offset??32),ccEnabled:o.enabled!==!1,ccMessage:e(o.message),ccAcceptAll:e(o.acceptAllText,"Accept All"),ccRejectAll:e(o.rejectAllText,"Reject All"),ccCustomize:e(o.customizeText,"Customize"),ccSavePrefs:e(o.savePreferencesText,"Save Preferences"),ccPrivacyText:e(o.privacyPolicyText,"Privacy Policy"),ccPrivacyUrl:e(o.privacyPolicyUrl),ccCookieText:e(o.cookiePolicyText,"Cookie Policy"),ccCookieUrl:e(o.cookiePolicyUrl),ccPosition:e(o.position,"bottom"),ccLayout:e(o.layout,"bar"),ccTheme:e(o.theme,"dark"),ccShowFunctional:o.showFunctional!==!1,ccShowAnalytics:o.showAnalytics!==!1,ccShowMarketing:o.showMarketing!==!1,ccVersion:e(o.consentVersion,"1.0"),ccSettingsLink:o.showSettingsLink!==!1,ccSettingsLinkText:e(o.settingsLinkText,"Cookie settings"),bcEnabled:n.enabled===!0,bcHomeLabel:e(n.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(n.position)?n.position:"TL",bcOffsetX:e(n.offsetX??8),bcOffsetY:e(n.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,r={},{adminHomeReady:a=!0}={}){const o=s=>e(s).trim(),n=motionFromForm(t);return{title:o(t.title),tagline:o(t.tagline),baseUrl:o(t.siteUrl).replace(/\/+$/,""),...a&&{adminHome:o(t.adminHome)||"/"},layoutOptions:{spacerSize:c(t.spacerSize,40)||40},bodyClass:o(t.bodyClass),characters:{enabled:t.charactersEnabled!==!1,animated:t.charactersAnimated!==!1,launchers:t.charactersLaunchers!==!1,chats:t.charactersChats!==!1,builders:t.charactersBuilders!==!1,dot:t.charactersDot!==!1,daisy:t.charactersDaisy!==!1},brand:{...r.brand,enabled:t.brandEnabled!==!1,text:o(t.brandText),logo:o(t.brandLogo),icon:o(t.brandIcon),url:o(t.brandUrl)||"/"},favicon:o(t.favicon),adminBrand:{...r.adminBrand,enabled:t.adminBrandEnabled!==!1,title:o(t.adminBrandTitle),logo:o(t.adminBrandLogo),logoDark:o(t.adminBrandLogoDark),icon:o(t.adminBrandIcon)},footer:{copyright:o(t.footerCopyright),layout:FOOTER_LAYOUTS.includes(t.footerLayout)?t.footerLayout:"auto",blurb:o(t.footerBlurb),blocks:footerBlockNames(t.footerBlocks),links:r.footer?.links||[],showMotionToggle:n.enabled,motionDefault:n.default,motionControl:n.control,class:o(t.footerClass),socialClass:o(t.footerSocialClass),look:FOOTER_LOOKS.includes(t.footerLook)?t.footerLook:"",cta:{text:o(t.footerCtaText),highlight:o(t.footerCtaHighlight),url:o(t.footerCtaUrl),sub:o(t.footerCtaSub)},watermark:o(t.footerWatermark),status:o(t.footerStatus),facts:String(t.footerFacts??"").split(`
|
|
1
|
+
export const TAB_FIELDS={general:["title","tagline","siteUrl","adminHome","spacerSize","bodyClass","charactersEnabled","charactersAnimated","charactersLaunchers","charactersChats","charactersBuilders","charactersDot","charactersDaisy","mapLookups"],branding:["brandEnabled","brandText","brandLogo","brandIcon","brandUrl","adminBrandEnabled","adminBrandTitle","adminBrandLogo","adminBrandLogoDark","adminBrandIcon"],favicon:["favicon"],footer:["footerCopyright","footerLayout","footerBlurb","footerBlocks","footerClass","footerSocialClass","footerLook","footerCtaText","footerCtaHighlight","footerCtaUrl","footerCtaSub","footerWatermark","footerStatus","footerFacts","footerTagline","footerEmail","footerAddress","footerGradFrom","footerGradTo","socialTwitter","socialFacebook","socialInstagram","socialLinkedin","socialGithub","socialYoutube"],email:["smtpHost","smtpPort","smtpUser","smtpPass","smtpSecure","smtpInsecureTLS","smtpFromAddress","smtpFromName"],pageNavigation:["bttEnabled","bttSmooth","bttLabel","bttThreshold","bttPosition","bttOffset","bttBottomOffset","gtbEnabled","gtbSmooth","gtbLabel","gtbThreshold","gtbPosition","gtbOffset","gtbBottomOffset"],cookies:["ccEnabled","ccMessage","ccAcceptAll","ccRejectAll","ccCustomize","ccSavePrefs","ccPrivacyText","ccPrivacyUrl","ccCookieText","ccCookieUrl","ccPosition","ccLayout","ccTheme","ccShowFunctional","ccShowAnalytics","ccShowMarketing","ccVersion","ccSettingsLink","ccSettingsLinkText"],breadcrumbs:["bcEnabled","bcHomeLabel","bcPosition","bcOffsetX","bcOffsetY"],motion:["mtEnabled","mtLabel","mtDefault","mtControl","mtPlacement","mtTriggerStyle","mtPosition","mtOffsetX","mtOffsetY","mtIconSize","mtIconRadius","mtClass"]},SECRET_FIELDS=["smtpPass"],BREADCRUMB_POSITIONS=["TL","TR","BL","BR"],MOTION_PLACEMENTS=["footer","floating","navbar"],MOTION_LABEL="Reduce motion";const b=["system","off","on"],i=(t,r,a,o)=>{const n=Number.parseInt(t,10);return Number.isFinite(n)?Math.min(o,Math.max(a,n)):r};export function motionFromSettings(t={}){const r=t.motion&&typeof t.motion=="object"?t.motion:{},a=t.footer||{},o=m=>r[m]!==void 0&&r[m]!==null,n=o("default")?r.default:a.motionDefault,s=o("control")?r.control:a.motionControl,l=i(r.iconSize,52,32,96);return{mtEnabled:(o("enabled")?r.enabled:a.showMotionToggle)!==!1,mtLabel:typeof r.label=="string"&&r.label.trim()?r.label.trim():MOTION_LABEL,mtDefault:b.includes(n)?n:"system",mtControl:s==="checkbox"?"checkbox":"switch",mtPlacement:MOTION_PLACEMENTS.includes(r.placement)?r.placement:"footer",mtTriggerStyle:r.triggerStyle==="icon-text"?"icon-text":"icon",mtPosition:BREADCRUMB_POSITIONS.includes(r.position)?r.position:"BL",mtOffsetX:e(i(r.offsetX,32,0,500)),mtOffsetY:e(i(r.offsetY,32,0,500)),mtIconSize:e(l),mtIconRadius:e(i(r.iconRadius,26,0,Math.floor(l/2))),mtClass:e(r.class)}}export function motionFromForm(t){const r=i(t.mtIconSize,52,32,96);return{enabled:t.mtEnabled===!0,default:b.includes(t.mtDefault)?t.mtDefault:"system",placement:MOTION_PLACEMENTS.includes(t.mtPlacement)?t.mtPlacement:"footer",control:t.mtControl==="checkbox"?"checkbox":"switch",triggerStyle:t.mtTriggerStyle==="icon-text"?"icon-text":"icon",label:e(t.mtLabel).trim().replace(/\s+/g," ").slice(0,40)||MOTION_LABEL,position:BREADCRUMB_POSITIONS.includes(t.mtPosition)?t.mtPosition:"BL",offsetX:i(t.mtOffsetX,32,0,500),offsetY:i(t.mtOffsetY,32,0,500),iconSize:r,iconRadius:i(t.mtIconRadius,26,0,Math.floor(r/2)),class:e(t.mtClass).trim()}}export function footerBlockNames(t){return[...new Set(String(t??"").split(/[\s,]+/).map(r=>r.trim().toLowerCase()).filter(Boolean))]}export function gaIdError(t){const r=e(t).trim();return!r||/^G-[A-Z0-9]{4,20}$/i.test(r)?"":"A measurement ID looks like G-XXXXXXXXXX (Google Analytics > Admin > Data streams)."}export const FOOTER_LAYOUTS=["auto","columns","row"],FOOTER_LOOKS=["","showcase"],FOOTER_FACTS_MAX=4;const p=/^(\/|#|https?:\/\/|mailto:)/,h=/^#[0-9a-f]{6}$/i;export function footerShowcaseErrors(t){const r=[],a=e(t.footerCtaUrl).trim();a&&!p.test(a)&&r.push("The footer call to action link must start with /, #, https:// or mailto: (Footer tool).");for(const[o,n]of[["from",t.footerGradFrom],["to",t.footerGradTo]]){const s=e(n).trim();s&&!h.test(s)&&r.push(`The footer gradient "${o}" colour must look like #f26b3a (Footer tool).`)}return r}const e=(t,r="")=>t==null?r:String(t),c=(t,r)=>{const a=Number.parseInt(t,10);return Number.isFinite(a)?a:r};export function homeValue(t){return/^\/[A-Za-z0-9\-_/]*$/.test(t||"")&&String(t).replace(/\/+$/,"")||"/"}export function formFromSettings(t={}){const r=t.backToTop||{},a=t.goToBottom||{},o=t.cookieConsent||{},n=t.breadcrumbs||{};return{title:e(t.title),tagline:e(t.tagline),siteUrl:e(t.baseUrl),adminHome:homeValue(t.adminHome),spacerSize:e(t.layoutOptions?.spacerSize??40),bodyClass:e(t.bodyClass),charactersEnabled:t.characters?.enabled!==!1,charactersAnimated:t.characters?.animated!==!1,charactersLaunchers:t.characters?.launchers!==!1,charactersChats:t.characters?.chats!==!1,charactersBuilders:t.characters?.builders!==!1,charactersDot:t.characters?.dot!==!1,charactersDaisy:t.characters?.daisy!==!1,mapLookups:t.maps?.lookupAddresses===!0,brandEnabled:t.brand?.enabled!==!1,brandText:e(t.brand?.text),brandLogo:e(t.brand?.logo),brandIcon:e(t.brand?.icon),brandUrl:e(t.brand?.url,"/"),favicon:e(t.favicon),adminBrandEnabled:t.adminBrand?.enabled!==!1,adminBrandTitle:e(t.adminBrand?.title),adminBrandLogo:e(t.adminBrand?.logo),adminBrandLogoDark:e(t.adminBrand?.logoDark),adminBrandIcon:e(t.adminBrand?.icon),footerCopyright:e(t.footer?.copyright),footerLayout:FOOTER_LAYOUTS.includes(t.footer?.layout)?t.footer.layout:"auto",footerBlurb:e(t.footer?.blurb),footerBlocks:Array.isArray(t.footer?.blocks)?t.footer.blocks.filter(s=>typeof s=="string").join(", "):"",footerClass:e(t.footer?.class),footerSocialClass:e(t.footer?.socialClass),footerLook:FOOTER_LOOKS.includes(t.footer?.look)?t.footer.look:"",footerCtaText:e(t.footer?.cta?.text),footerCtaHighlight:e(t.footer?.cta?.highlight),footerCtaUrl:e(t.footer?.cta?.url),footerCtaSub:e(t.footer?.cta?.sub),footerWatermark:e(t.footer?.watermark),footerStatus:e(t.footer?.status),footerFacts:Array.isArray(t.footer?.facts)?t.footer.facts.filter(s=>typeof s=="string").join(`
|
|
2
|
+
`):"",footerTagline:e(t.footer?.tagline),footerEmail:e(t.footer?.email),footerAddress:e(t.footer?.address),footerGradFrom:e(t.footer?.gradient?.from),footerGradTo:e(t.footer?.gradient?.to),socialTwitter:e(t.social?.twitter),socialFacebook:e(t.social?.facebook),socialInstagram:e(t.social?.instagram),socialLinkedin:e(t.social?.linkedin),socialGithub:e(t.social?.github),socialYoutube:e(t.social?.youtube),smtpHost:e(t.smtp?.host),smtpPort:e(t.smtp?.port||587),smtpUser:e(t.smtp?.user),smtpPass:"",smtpSecure:t.smtp?.secure===!0,smtpInsecureTLS:t.smtp?.allowInsecureTLS===!0,smtpFromAddress:e(t.smtp?.fromAddress),smtpFromName:e(t.smtp?.fromName),bttEnabled:r.enabled!==!1,bttSmooth:r.smooth!==!1,bttLabel:e(r.label),bttThreshold:e(r.scrollThreshold??300),bttPosition:e(r.position,"bottom-right"),bttOffset:e(r.offset??32),bttBottomOffset:e(r.bottomOffset??r.offset??32),gtbEnabled:a.enabled===!0,gtbSmooth:a.smooth!==!1,gtbLabel:e(a.label),gtbThreshold:e(a.scrollThreshold??300),gtbPosition:e(a.position,"bottom-right"),gtbOffset:e(a.offset??32),gtbBottomOffset:e(a.bottomOffset??a.offset??32),ccEnabled:o.enabled!==!1,ccMessage:e(o.message),ccAcceptAll:e(o.acceptAllText,"Accept All"),ccRejectAll:e(o.rejectAllText,"Reject All"),ccCustomize:e(o.customizeText,"Customize"),ccSavePrefs:e(o.savePreferencesText,"Save Preferences"),ccPrivacyText:e(o.privacyPolicyText,"Privacy Policy"),ccPrivacyUrl:e(o.privacyPolicyUrl),ccCookieText:e(o.cookiePolicyText,"Cookie Policy"),ccCookieUrl:e(o.cookiePolicyUrl),ccPosition:e(o.position,"bottom"),ccLayout:e(o.layout,"bar"),ccTheme:e(o.theme,"dark"),ccShowFunctional:o.showFunctional!==!1,ccShowAnalytics:o.showAnalytics!==!1,ccShowMarketing:o.showMarketing!==!1,ccVersion:e(o.consentVersion,"1.0"),ccSettingsLink:o.showSettingsLink!==!1,ccSettingsLinkText:e(o.settingsLinkText,"Cookie settings"),bcEnabled:n.enabled===!0,bcHomeLabel:e(n.homeLabel,"Home"),bcPosition:BREADCRUMB_POSITIONS.includes(n.position)?n.position:"TL",bcOffsetX:e(n.offsetX??8),bcOffsetY:e(n.offsetY??8),...motionFromSettings(t)}}export function payloadFromForm(t,r={},{adminHomeReady:a=!0}={}){const o=s=>e(s).trim(),n=motionFromForm(t);return{title:o(t.title),tagline:o(t.tagline),baseUrl:o(t.siteUrl).replace(/\/+$/,""),...a&&{adminHome:o(t.adminHome)||"/"},layoutOptions:{spacerSize:c(t.spacerSize,40)||40},bodyClass:o(t.bodyClass),characters:{enabled:t.charactersEnabled!==!1,animated:t.charactersAnimated!==!1,launchers:t.charactersLaunchers!==!1,chats:t.charactersChats!==!1,builders:t.charactersBuilders!==!1,dot:t.charactersDot!==!1,daisy:t.charactersDaisy!==!1},maps:{lookupAddresses:t.mapLookups===!0},brand:{...r.brand,enabled:t.brandEnabled!==!1,text:o(t.brandText),logo:o(t.brandLogo),icon:o(t.brandIcon),url:o(t.brandUrl)||"/"},favicon:o(t.favicon),adminBrand:{...r.adminBrand,enabled:t.adminBrandEnabled!==!1,title:o(t.adminBrandTitle),logo:o(t.adminBrandLogo),logoDark:o(t.adminBrandLogoDark),icon:o(t.adminBrandIcon)},footer:{copyright:o(t.footerCopyright),layout:FOOTER_LAYOUTS.includes(t.footerLayout)?t.footerLayout:"auto",blurb:o(t.footerBlurb),blocks:footerBlockNames(t.footerBlocks),links:r.footer?.links||[],showMotionToggle:n.enabled,motionDefault:n.default,motionControl:n.control,class:o(t.footerClass),socialClass:o(t.footerSocialClass),look:FOOTER_LOOKS.includes(t.footerLook)?t.footerLook:"",cta:{text:o(t.footerCtaText),highlight:o(t.footerCtaHighlight),url:o(t.footerCtaUrl),sub:o(t.footerCtaSub)},watermark:o(t.footerWatermark),status:o(t.footerStatus),facts:String(t.footerFacts??"").split(`
|
|
3
3
|
`).map(s=>s.trim()).filter(Boolean).slice(0,FOOTER_FACTS_MAX),tagline:o(t.footerTagline),email:o(t.footerEmail),address:o(t.footerAddress),gradient:{from:o(t.footerGradFrom),to:o(t.footerGradTo)}},social:{twitter:o(t.socialTwitter),facebook:o(t.socialFacebook),instagram:o(t.socialInstagram),linkedin:o(t.socialLinkedin),github:o(t.socialGithub),youtube:o(t.socialYoutube)},smtp:{host:o(t.smtpHost),port:c(t.smtpPort,587)||587,user:o(t.smtpUser),pass:e(t.smtpPass),secure:t.smtpSecure===!0,allowInsecureTLS:t.smtpInsecureTLS===!0,fromAddress:o(t.smtpFromAddress),fromName:o(t.smtpFromName)},backToTop:{enabled:t.bttEnabled===!0,scrollThreshold:c(t.bttThreshold,300),position:e(t.bttPosition)||"bottom-right",offset:c(t.bttOffset,32),bottomOffset:c(t.bttBottomOffset,32),label:o(t.bttLabel),smooth:t.bttSmooth===!0},goToBottom:{enabled:t.gtbEnabled===!0,scrollThreshold:c(t.gtbThreshold,300),position:e(t.gtbPosition)||"bottom-right",offset:c(t.gtbOffset,32),bottomOffset:c(t.gtbBottomOffset,32),label:o(t.gtbLabel),smooth:t.gtbSmooth===!0},cookieConsent:{enabled:t.ccEnabled===!0,message:o(t.ccMessage),acceptAllText:o(t.ccAcceptAll),rejectAllText:o(t.ccRejectAll),customizeText:o(t.ccCustomize),savePreferencesText:o(t.ccSavePrefs),privacyPolicyText:o(t.ccPrivacyText),privacyPolicyUrl:o(t.ccPrivacyUrl),cookiePolicyText:o(t.ccCookieText),cookiePolicyUrl:o(t.ccCookieUrl),position:e(t.ccPosition)||"bottom",layout:e(t.ccLayout)||"bar",theme:e(t.ccTheme)||"dark",showFunctional:t.ccShowFunctional===!0,showAnalytics:t.ccShowAnalytics===!0,showMarketing:t.ccShowMarketing===!0,consentVersion:o(t.ccVersion)||"1.0",showSettingsLink:t.ccSettingsLink===!0,settingsLinkText:o(t.ccSettingsLinkText)||"Cookie settings"},breadcrumbs:{enabled:t.bcEnabled===!0,homeLabel:o(t.bcHomeLabel)||"Home",position:BREADCRUMB_POSITIONS.includes(t.bcPosition)?t.bcPosition:"TL",offsetX:c(t.bcOffsetX,8),offsetY:c(t.bcOffsetY,8)},motion:n}}export function siteUrlError(t){const r=e(t).trim().replace(/\/+$/,"");return r?/^https?:\/\//i.test(r)?/^https?:\/\/([a-z0-9.\-]+|\[[0-9a-f:.]+\])(:\d{1,5})?$/i.test(r)?"":"Just the address, like https://example.com - no page path after it.":"Start with https:// (or http://).":""}const d=t=>typeof t=="boolean"?t:e(t);export function snapshot(t){return JSON.stringify(Object.keys(t).sort().map(r=>[r,d(t[r])]))}export function changedTabs(t,r){const a=[];for(const[o,n]of Object.entries(TAB_FIELDS))n.some(s=>d(t[s])!==d(r[s]))&&a.push(o);return a}export function draftOf(t){return Object.fromEntries(Object.entries(t).filter(([r])=>!SECRET_FIELDS.includes(r)))}const g={footerMotionToggle:"mtEnabled",footerMotionDefault:"mtDefault",footerMotionControl:"mtControl"};export function formFromDraft(t,r={}){const a={...r};for(const[n,s]of Object.entries(g))n in a&&!(s in a)&&(a[s]=a[n]),delete a[n];const o={...t};for(const[n,s]of Object.entries(a))n in o&&!SECRET_FIELDS.includes(n)&&(o[n]=s);return o}export function settingsProblems(t,r={}){const a=[];return e(t.smtpHost).trim()?e(t.smtpFromAddress).trim()||a.push({tone:"warn",tab:"email",text:"No From address - mail has no sender and many servers refuse it."}):a.push({tone:"danger",tab:"email",text:"No SMTP host - mail goes to a throwaway test inbox and reaches no one (password resets, form notifications)."}),(t.ccEnabled===!0||e(r.googleAnalytics?.measurementId).trim())&&!e(t.ccPrivacyUrl).trim()&&a.push({tone:"warn",tab:"cookies",text:"The cookie banner is on but links to no privacy policy."}),a}export function describeCacheKey(t){const r=/^page:(.*?):m\d+:role([^:]*):/.exec(String(t||""));return r?{path:r[1]||"/",role:r[2]||"anon",page:!0}:{path:String(t||""),role:"",page:!1}}export function expiresIn(t,r=Date.now()){if(t==null)return"no expiry";const a=t-r;return a<=0?"expired":a<6e4?`${Math.round(a/1e3)}s`:a<36e5?`${Math.round(a/6e4)}m`:`${Math.round(a/36e5)}h`}export function footerForm(t={}){const r=formFromSettings(t);return Object.fromEntries(TAB_FIELDS.footer.map(a=>[a,r[a]]))}export function footerPayload(t){const{footer:r,social:a}=payloadFromForm(t);return delete r.links,delete r.showMotionToggle,delete r.motionDefault,delete r.motionControl,{footer:r,social:a}}export function siteSettingsForm(t={}){return Object.fromEntries(Object.entries(formFromSettings(t)).filter(([r])=>!TAB_FIELDS.footer.includes(r)&&!u.includes(r)))}export function siteSettingsPayload(...t){const{footer:r,social:a,favicon:o,backToTop:n,goToBottom:s,breadcrumbs:l,motion:m,...f}=payloadFromForm(...t);return f}export const APPEARANCE_TABS=["favicon","pageNavigation","breadcrumbs","motion","search"];const u=APPEARANCE_TABS.flatMap(t=>TAB_FIELDS[t]||[]);export function appearanceForm(t={}){const r=formFromSettings(t);return Object.fromEntries(u.map(a=>[a,r[a]]))}export function appearancePayload(t){const{favicon:r,backToTop:a,goToBottom:o,breadcrumbs:n,motion:s}=payloadFromForm(t);return{favicon:r,backToTop:a,goToBottom:o,breadcrumbs:n,motion:s}}
|
|
@@ -388,10 +388,13 @@
|
|
|
388
388
|
<li>Any other website has to be on the site's list of allowed hosts first; until it is, the page shows a "not allowed" notice in place of the frame. On a self-hosted site the list is <code>config/embeds.json</code>.</li>
|
|
389
389
|
<li>In the editor, <strong>Insert > Embed</strong> has a field for the address and a picker for videos in Media.</li>
|
|
390
390
|
</ul>
|
|
391
|
-
<h3 id="sc-map"><code>map</code> - a map of
|
|
392
|
-
<p>A Google Map of one place.</p>
|
|
391
|
+
<h3 id="sc-map"><code>map</code> - a map of a place, or of several</h3>
|
|
392
|
+
<p>A Google Map of one place, or an OpenStreetMap with several pins.</p>
|
|
393
393
|
<pre><code>[map postcode="SW1A 2AA" zoom="15" caption="Visit us" /]
|
|
394
394
|
[map pin="51.5034,-0.1276" zoom="14" ratio="4:3" width="640" align="center" /]
|
|
395
|
+
[map address="10 Downing Street, London" directions="true" /]
|
|
396
|
+
[map pins="51.5034,-0.1276 Downing Street | 51.5007,-0.1246 Big Ben" directions="true" /]
|
|
397
|
+
[map pins="Office = SW1A 2AA | Warehouse = 1 Dock Road, Hull" /]
|
|
395
398
|
</code></pre>
|
|
396
399
|
<table class="table table-sm">
|
|
397
400
|
<thead>
|
|
@@ -413,6 +416,10 @@
|
|
|
413
416
|
<td>The place, as <code>latitude,longitude</code></td>
|
|
414
417
|
</tr>
|
|
415
418
|
<tr>
|
|
419
|
+
<td><code>pins</code></td>
|
|
420
|
+
<td>Several places, split by <code>|</code>: <code>latitude,longitude Label</code>, or <code>Label = an address</code> (or just the address). Up to 50. Shown on OpenStreetMap with every pin in view; click a pin for its label</td>
|
|
421
|
+
</tr>
|
|
422
|
+
<tr>
|
|
416
423
|
<td><code>lat</code>, <code>lon</code> (or <code>lng</code>)</td>
|
|
417
424
|
<td>The place, as two separate numbers</td>
|
|
418
425
|
</tr>
|
|
@@ -436,8 +443,12 @@
|
|
|
436
443
|
<td><code>caption</code> (or <code>title</code>)</td>
|
|
437
444
|
<td>Words under the map</td>
|
|
438
445
|
</tr>
|
|
446
|
+
<tr>
|
|
447
|
+
<td><code>directions</code></td>
|
|
448
|
+
<td><code>true</code> adds a "Get directions" link under the map (with <code>pins</code>, in each pin's label), opening Google's route planner to the place in a new tab. Give your own words instead of <code>true</code> for the link (<code>directions="Find us"</code>)</td>
|
|
449
|
+
</tr>
|
|
439
450
|
</tbody></table>
|
|
440
|
-
<p>Give one of <code>postcode</code>, <code>address</code>, <code>pin</code>, or <code>lat</code> with <code>lon</code
|
|
451
|
+
<p>Give one of <code>postcode</code>, <code>address</code>, <code>pin</code>, or <code>lat</code> with <code>lon</code>. Addresses in <code>pins</code> need <strong>Address look-ups</strong> switched on in Site Settings > General > Maps (off at first). They are then found when you save the page, which can take a few seconds for many; until then those pins are left off. Pins in blocks or collection entries need coordinates.</p>
|
|
441
452
|
<h3 id="sc-demo"><code>demo</code> - a demo page in a frame</h3>
|
|
442
453
|
<p>Shows a demo page kept on this site inside a frame.</p>
|
|
443
454
|
<pre><code>[demo src="elements/accordion" /]
|
|
@@ -96,6 +96,13 @@
|
|
|
96
96
|
</div>
|
|
97
97
|
<small class="text-muted">Reduced-motion preferences always take priority. Changes apply when the page is next opened or refreshed.</small>
|
|
98
98
|
</div>
|
|
99
|
+
<div class="stx-card dm-settings-section">
|
|
100
|
+
<div class="stx-card-title dm-settings-section-title"><span data-icon="map-pin" data-icon-size="16" aria-hidden="true"></span>Maps</div>
|
|
101
|
+
<p class="text-muted">Let map pins use addresses, as in <code>[map pins="Office = SW1A 2AA"]</code>. When you save a page, the site looks its map addresses up with OpenStreetMap's Nominatim service, sending it the address text and this site's address. Visitors are never sent there. Off: pins need latitude,longitude.</p>
|
|
102
|
+
<div class="stx-grid">
|
|
103
|
+
<div class="stx-setting"><label class="form-label" for="stx-map-lookups">Address look-ups</label><input id="stx-map-lookups" type="checkbox" class="form-switch" data-model="mapLookups.value"></div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
99
106
|
<div class="stx-card stx-moved dm-settings-section">
|
|
100
107
|
<span data-icon="droplet"></span>
|
|
101
108
|
<div class="stx-moved-text">
|
package/docs/DommaFeatures.md
CHANGED
|
@@ -279,6 +279,8 @@ Where: `server/services/markdown.js`; reference `docs/markdown-shortcodes.md`; a
|
|
|
279
279
|
- Where: `server/services/markdown.js` (`renderImage`, `processImageBlocks`, also in `processInlineShortcodes`), `public/js/image-zoom.mjs` + `public/css/image-zoom.css` (loaded by `renderer.js` `imageZoomModule()` only when a page has a `data-dm-zoom` picture), `.dm-image*` in `public/css/site.css`, registry entry in `admin/js/lib/shortcode-registry.js` (attrs carry `help`, shown by shortcode-form.js)
|
|
280
280
|
- **`[embed url ratio title width align autoplay loop muted /]`** - YouTube/Vimeo (privacy-friendly `youtube-nocookie`), self-hosted `.mp4`/`.webm`/`.ogg` as a native player, or any other URL as an iframe only if its host is on the allow-list. Since 0.36.0.
|
|
281
281
|
- Where: `config/embeds.json` `allowedHosts`
|
|
282
|
+
- **`[map pin|lat lon|address|postcode zoom title caption ratio width align directions /]`** - a Google Map of one place (keyless embed); `directions` adds a link to Google's route planner. **`[map pins="lat,lon Label | Label = address | ..."]`** - several pins (up to 50) on OpenStreetMap via Leaflet, every pin in view, labels and per-pin directions in popups. Addresses (only with Site Settings > General > Maps `maps.lookupAddresses: true`, off by default; switching on sweeps every page) are geocoded on page save (Nominatim, 1/s, background via safeFetch) into `content/map-places.json`; rendering only reads that store. Unreleased (after 1.75.3).
|
|
283
|
+
- Where: `server/services/markdown.js` (`renderMap`, `renderPinsMap`, `mapFigure`), `server/services/mapPins.js` (`parsePins`, the `/_map` page and its own CSP), `server/routes/map-frame.js` (`GET /_map`), `server/services/geocode.js` (`queueMapAddresses` from content.js create/updatePage, `placeFor`), registry entry in `admin/js/lib/shortcode-registry.js`
|
|
282
284
|
- **`[demo src height title base /]`** - embeds a same-origin demo page (default under `/public/demos`) in a captioned frame. Built in since 0.67.0 (was the `demo-viewer` plugin).
|
|
283
285
|
|
|
284
286
|
#### Data, forms and reuse
|
|
@@ -1021,10 +1021,40 @@ A responsive Google Map of one place. Give `pin` (latitude, longitude), `lat` +
|
|
|
1021
1021
|
```text
|
|
1022
1022
|
[map postcode="SW1A 2AA" zoom="15" caption="Visit us" /]
|
|
1023
1023
|
[map pin="51.5034,-0.1276" zoom="14" title="Office" ratio="4:3" width="640" align="center" /]
|
|
1024
|
+
[map address="10 Downing Street, London" directions="true" /]
|
|
1024
1025
|
```
|
|
1025
1026
|
|
|
1026
1027
|
`zoom` is 1-20 (default 14); `ratio` is 16:9 (default), 4:3, 1:1 or 21:9; `width` in px or %; `align` left, center or
|
|
1027
|
-
right; `caption` (or `title`) is shown under the map.
|
|
1028
|
+
right; `caption` (or `title`) is shown under the map. `directions="true"` adds a "Get directions" link under the map
|
|
1029
|
+
that opens Google's route planner to the place in a new tab; give text instead of `true` for your own label
|
|
1030
|
+
(`directions="Find us"`).
|
|
1031
|
+
|
|
1032
|
+
**Several pins.** `pins` takes several places split by `|`. Each is coordinates or an address:
|
|
1033
|
+
|
|
1034
|
+
```text
|
|
1035
|
+
[map pins="51.5034,-0.1276 Downing Street | 51.5007,-0.1246 Big Ben" directions="true" caption="Find us" /]
|
|
1036
|
+
[map pins="Office = SW1A 2AA | Warehouse = 1 Dock Road, Hull | 51.5007,-0.1246 Big Ben" /]
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
| Pin | Means |
|
|
1040
|
+
|-----|-------|
|
|
1041
|
+
| `51.5,-0.12 Label` | coordinates, then an optional label |
|
|
1042
|
+
| `Label = 51.5,-0.12` | the same, label first |
|
|
1043
|
+
| `Label = an address` | an address or postcode, with a label |
|
|
1044
|
+
| `an address` | an address, which is also its label |
|
|
1045
|
+
|
|
1046
|
+
Addresses need **Address look-ups** switched on in Site Settings > General > Maps (off by default: it sends the
|
|
1047
|
+
address text and the site's address to a third party). With it on, addresses are looked up when the page is **saved** (OpenStreetMap's Nominatim, one a second, in the background) and
|
|
1048
|
+
kept in `content/map-places.json`, so a page never waits on a lookup and visitors' browsers never reach the lookup
|
|
1049
|
+
service. Until an address is found its pin is left off (a map with none found yet shows a notice); one that is not
|
|
1050
|
+
found is tried again on a save a day later. Switching it on looks up the addresses already in every page. With it
|
|
1051
|
+
off, address pins are left off and coordinates still work. Pins in blocks or collection entries are not looked up - use coordinates
|
|
1052
|
+
there.
|
|
1053
|
+
|
|
1054
|
+
Up to 50 pins, labels up to 80 characters. The map is OpenStreetMap, drawn on this site's own `/_map` page (framed by
|
|
1055
|
+
this site only, with its own Content-Security-Policy for the tile host). Every pin is in view unless `zoom` is given;
|
|
1056
|
+
each pin's label shows when it is clicked, with the directions link to that pin when `directions` is set. `ratio`, `width`, `align`, `title` and `caption` work as
|
|
1057
|
+
above. Malformed coordinates show a notice instead of a map. Google's
|
|
1028
1058
|
embed host is always allowed to frame, so no `config/embeds.json` entry is needed.
|
|
1029
1059
|
### `[form]`
|
|
1030
1060
|
|
package/package.json
CHANGED
|
@@ -26,6 +26,8 @@ import {invalidateMeasurementId, measurementIdOf, normaliseMeasurementId} from '
|
|
|
26
26
|
import {assistantProblem, normaliseAssistant} from '../../services/assistant.js';
|
|
27
27
|
import {adminAssistantProblem, normaliseAdminAssistant} from '../../services/adminAssistant.js';
|
|
28
28
|
import {normaliseCharacterSettings} from '../../../public/js/characters.mjs';
|
|
29
|
+
import {queueAllPages} from '../../services/geocode.js';
|
|
30
|
+
import {listPages} from '../../services/content.js';
|
|
29
31
|
|
|
30
32
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
31
33
|
const CUSTOM_CSS_FILE = path.resolve(__dirname, '../../../content/custom.css');
|
|
@@ -151,7 +153,9 @@ export async function settingsRoutes(fastify) {
|
|
|
151
153
|
// The "Reduce motion" control (Site Settings > Reduce motion) - services/motionSettings.js.
|
|
152
154
|
'motion',
|
|
153
155
|
// What every AI answer knows about the site and the rules it keeps (services/assistant.js).
|
|
154
|
-
'assistant', 'characters', 'adminAssistant'
|
|
156
|
+
'assistant', 'characters', 'adminAssistant',
|
|
157
|
+
// [map pins] addresses looked up on save (Site Settings > General > Maps) - services/geocode.js.
|
|
158
|
+
'maps'
|
|
155
159
|
]);
|
|
156
160
|
const unknownKeys = Object.keys(data).filter(k => !ALLOWED_KEYS.has(k));
|
|
157
161
|
if (unknownKeys.length > 0) {
|
|
@@ -194,6 +198,14 @@ export async function settingsRoutes(fastify) {
|
|
|
194
198
|
if ('characters' in data && (!data.characters || typeof data.characters !== 'object' || Array.isArray(data.characters))) {
|
|
195
199
|
return reply.status(400).send({error: 'Builders and Bots: send an object.'});
|
|
196
200
|
}
|
|
201
|
+
let mapLookupsTurnedOn = false;
|
|
202
|
+
if ('maps' in data) {
|
|
203
|
+
if (!data.maps || typeof data.maps !== 'object' || Array.isArray(data.maps)) {
|
|
204
|
+
return reply.status(400).send({error: 'Maps: send {lookupAddresses}.'});
|
|
205
|
+
}
|
|
206
|
+
data.maps = {lookupAddresses: data.maps.lookupAddresses === true};
|
|
207
|
+
mapLookupsTurnedOn = data.maps.lookupAddresses && getConfig('site')?.maps?.lookupAddresses !== true;
|
|
208
|
+
}
|
|
197
209
|
if ('adminAssistant' in data) {
|
|
198
210
|
const problem = adminAssistantProblem(data.adminAssistant);
|
|
199
211
|
if (problem) return reply.status(400).send({error: `Admin assistant: ${problem}`});
|
|
@@ -263,6 +275,10 @@ export async function settingsRoutes(fastify) {
|
|
|
263
275
|
saveConfig('site', merged);
|
|
264
276
|
invalidateMeasurementId();
|
|
265
277
|
await cache.invalidateTags(['site']);
|
|
278
|
+
// Switched on: pages saved while it was off get their address pins now, in the background.
|
|
279
|
+
if (mapLookupsTurnedOn) {
|
|
280
|
+
listPages({render: false}).then(pages => queueAllPages(pages, {log: request.log})).catch(() => {});
|
|
281
|
+
}
|
|
266
282
|
return { success: true };
|
|
267
283
|
});
|
|
268
284
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GET /_map - the framed page behind [map pins="..."] (services/mapPins.js).
|
|
3
|
+
*
|
|
4
|
+
* Everything it shows comes from its query, read again here (never trusted from
|
|
5
|
+
* the page that framed it): pins, zoom, the directions link text, a title. It
|
|
6
|
+
* answers with its own Content-Security-Policy - the only page allowed the
|
|
7
|
+
* OpenStreetMap tile host - and may be framed by this site only.
|
|
8
|
+
*/
|
|
9
|
+
import {MAP_FRAME_CSP, mapFrameHtml, parsePins} from '../services/mapPins.js';
|
|
10
|
+
|
|
11
|
+
const text = (v, max) => String(typeof v === 'string' ? v : '').replace(/[\u0000-\u001f\u007f]/g, '').trim().slice(0, max);
|
|
12
|
+
|
|
13
|
+
export async function mapFrameRoutes(fastify) {
|
|
14
|
+
fastify.get('/_map', async (request, reply) => {
|
|
15
|
+
const q = request.query ?? {};
|
|
16
|
+
const {pins, error} = parsePins(text(q.pins, 8000));
|
|
17
|
+
if (error) return reply.code(400).type('text/plain; charset=utf-8').send(error);
|
|
18
|
+
const z = Number.parseInt(q.zoom, 10);
|
|
19
|
+
const zoom = Number.isFinite(z) ? Math.max(1, Math.min(19, z)) : null;
|
|
20
|
+
reply.header('Content-Security-Policy', MAP_FRAME_CSP);
|
|
21
|
+
reply.header('X-Frame-Options', 'SAMEORIGIN');
|
|
22
|
+
reply.header('Cache-Control', 'public, max-age=3600');
|
|
23
|
+
return reply.type('text/html; charset=utf-8')
|
|
24
|
+
.send(mapFrameHtml({pins, zoom, directions: text(q.directions, 100), title: text(q.title, 200) || 'Map'}));
|
|
25
|
+
});
|
|
26
|
+
}
|
package/server/server.js
CHANGED
|
@@ -860,6 +860,9 @@ await app.register(outreachPublicRoutes);
|
|
|
860
860
|
const { faviconRoutes } = await import('./routes/favicon.js');
|
|
861
861
|
await app.register(faviconRoutes);
|
|
862
862
|
// Before the catch-all: /_launcher/<id> is what a launcher's panel frames.
|
|
863
|
+
// [map pins="..."]'s framed page, with its own CSP (services/mapPins.js).
|
|
864
|
+
const {mapFrameRoutes} = await import('./routes/map-frame.js');
|
|
865
|
+
await app.register(mapFrameRoutes);
|
|
863
866
|
const {launcherPublicRoutes} = await import('./routes/launcher-public.js');
|
|
864
867
|
await app.register(launcherPublicRoutes);
|
|
865
868
|
const { publicRoutes } = await import('./routes/public.js');
|
|
@@ -12,6 +12,7 @@ import {config} from '../config.js';
|
|
|
12
12
|
import {hooks} from './hooks.js';
|
|
13
13
|
import {createVersion, deleteAllVersions, renameVersionDir} from './versions.js';
|
|
14
14
|
import * as cache from './cache/index.js';
|
|
15
|
+
import {queueMapAddresses} from './geocode.js';
|
|
15
16
|
|
|
16
17
|
const CONTENT_DIR = config.content.contentDir;
|
|
17
18
|
const PAGES_DIR = path.join(CONTENT_DIR, 'pages');
|
|
@@ -334,6 +335,8 @@ export async function createPage(urlPath, frontmatter, body, {exclusive = false}
|
|
|
334
335
|
const page = await readPageFile(filePath);
|
|
335
336
|
await cache.invalidateTags([`page:${urlPath}`, 'sitemap', 'pages:list']);
|
|
336
337
|
hooks.emit('content:pageCreated', {page, urlPath});
|
|
338
|
+
// [map pins] addresses: looked up in the background, never holding up the save.
|
|
339
|
+
queueMapAddresses(page.content, urlPath).catch(() => {});
|
|
337
340
|
return page;
|
|
338
341
|
}
|
|
339
342
|
|
|
@@ -392,6 +395,8 @@ export async function updatePage(urlPath, frontmatter, body, {author} = {}) {
|
|
|
392
395
|
const page = await readPageFile(filePath);
|
|
393
396
|
await cache.invalidateTags([`page:${urlPath}`, 'sitemap', 'pages:list']);
|
|
394
397
|
hooks.emit('content:pageUpdated', {page, urlPath});
|
|
398
|
+
// [map pins] addresses: looked up in the background, never holding up the save.
|
|
399
|
+
queueMapAddresses(page.content, urlPath).catch(() => {});
|
|
395
400
|
return page;
|
|
396
401
|
}
|
|
397
402
|
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Addresses for [map pins] - looked up when a page is SAVED, never while one renders.
|
|
3
|
+
*
|
|
4
|
+
* A save hands its body to `queueMapAddresses()`: every address in a [map pins] tag that
|
|
5
|
+
* is not already known is looked up with OpenStreetMap's Nominatim, one a second (its
|
|
6
|
+
* usage policy), in the background, and kept in content/map-places.json. When the
|
|
7
|
+
* lookups finish, the page's cache entry is dropped so the next visitor gets the pins.
|
|
8
|
+
* Rendering reads only what is kept (`placeFor()`, synchronous), so a page never waits
|
|
9
|
+
* on a lookup and a visitor's request never reaches Nominatim.
|
|
10
|
+
*
|
|
11
|
+
* Only the server talks to Nominatim, through safeFetch, and only with the address text.
|
|
12
|
+
* OFF unless the site switches it on (Site Settings > General > Maps; site.json
|
|
13
|
+
* `maps.lookupAddresses: true`) - it is a call to a third party.
|
|
14
|
+
*/
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import {config, getConfig} from '../config.js';
|
|
18
|
+
import {safeFetch} from './outbound.js';
|
|
19
|
+
import * as cache from './cache/index.js';
|
|
20
|
+
import {mapAddresses} from './mapPins.js';
|
|
21
|
+
|
|
22
|
+
const STORE_PATH = path.join(config.content.contentDir, 'map-places.json');
|
|
23
|
+
const NOMINATIM = 'https://nominatim.openstreetmap.org/search';
|
|
24
|
+
/** Nominatim's policy: at most one request a second. */
|
|
25
|
+
const GAP_MS = 1100;
|
|
26
|
+
/** An address that was not found is tried again on a save this long after. */
|
|
27
|
+
const MISS_RETRY_MS = 24 * 60 * 60 * 1000;
|
|
28
|
+
/** The most addresses one store keeps; the oldest go first. */
|
|
29
|
+
const MAX_PLACES = 5000;
|
|
30
|
+
|
|
31
|
+
/** The key an address is kept under: case and spacing do not matter. */
|
|
32
|
+
export const addressKey = (a) => String(a ?? '').toLowerCase().replace(/\s+/g, ' ').trim();
|
|
33
|
+
|
|
34
|
+
let places = null;
|
|
35
|
+
let storePath = STORE_PATH;
|
|
36
|
+
let fetcher = (url, opts) => safeFetch(url, opts);
|
|
37
|
+
let gapMs = GAP_MS;
|
|
38
|
+
let enabledOverride = null;
|
|
39
|
+
|
|
40
|
+
/** Whether this site looks addresses up (Site Settings; off unless switched on). */
|
|
41
|
+
export function addressLookupsOn() {
|
|
42
|
+
if (enabledOverride !== null) return enabledOverride;
|
|
43
|
+
try { return getConfig('site')?.maps?.lookupAddresses === true; } catch { return false; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function load() {
|
|
47
|
+
if (places) return places;
|
|
48
|
+
try {
|
|
49
|
+
const raw = JSON.parse(fs.readFileSync(storePath, 'utf8'));
|
|
50
|
+
places = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
|
|
51
|
+
} catch {
|
|
52
|
+
places = {};
|
|
53
|
+
}
|
|
54
|
+
return places;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function save() {
|
|
58
|
+
const all = Object.entries(load());
|
|
59
|
+
const kept = all.length > MAX_PLACES
|
|
60
|
+
? Object.fromEntries(all.sort((a, b) => String(b[1].at).localeCompare(String(a[1].at))).slice(0, MAX_PLACES))
|
|
61
|
+
: places;
|
|
62
|
+
places = kept;
|
|
63
|
+
const tmp = `${storePath}.${process.pid}.tmp`;
|
|
64
|
+
await fs.promises.writeFile(tmp, JSON.stringify(kept, null, 2), 'utf8');
|
|
65
|
+
await fs.promises.rename(tmp, storePath);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Where an address is, from what is kept: `{lat, lon}`, or null (not looked up yet, or not found).
|
|
70
|
+
*
|
|
71
|
+
* @param {string} address
|
|
72
|
+
*/
|
|
73
|
+
export function placeFor(address) {
|
|
74
|
+
const p = load()[addressKey(address)];
|
|
75
|
+
return p && Number.isFinite(p.lat) && Number.isFinite(p.lon) ? {lat: p.lat, lon: p.lon} : null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Whether an address still needs looking up: never tried, or not found long enough ago. */
|
|
79
|
+
function needsLookup(address, now = Date.now()) {
|
|
80
|
+
const p = load()[addressKey(address)];
|
|
81
|
+
if (!p) return true;
|
|
82
|
+
if (Number.isFinite(p.lat)) return false;
|
|
83
|
+
return now - Date.parse(p.at || 0) > MISS_RETRY_MS;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** How this site introduces itself to Nominatim (its policy asks for an identifying User-Agent). */
|
|
87
|
+
function userAgent() {
|
|
88
|
+
let base = '';
|
|
89
|
+
try { base = String(getConfig('site')?.baseUrl || '').trim(); } catch { /* no site config */ }
|
|
90
|
+
return /^https?:\/\/[^\s]+$/i.test(base) ? `DommaCMS/1 (+${base})` : 'DommaCMS/1';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** One lookup: {lat, lon} or null. Throws when Nominatim cannot be reached. */
|
|
94
|
+
async function lookup(address) {
|
|
95
|
+
const url = `${NOMINATIM}?${new URLSearchParams({q: address, format: 'jsonv2', limit: '1'})}`;
|
|
96
|
+
const res = await fetcher(url, {headers: {'user-agent': userAgent(), accept: 'application/json'}, timeoutMs: 10000, maxBytes: 200000});
|
|
97
|
+
if (!res.ok) throw new Error(`Nominatim answered ${res.status}`);
|
|
98
|
+
const hit = (res.json() || [])[0];
|
|
99
|
+
const lat = Number(hit?.lat);
|
|
100
|
+
const lon = Number(hit?.lon);
|
|
101
|
+
return Number.isFinite(lat) && Number.isFinite(lon) && Math.abs(lat) <= 90 && Math.abs(lon) <= 180 ? {lat, lon} : null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let queue = Promise.resolve();
|
|
105
|
+
const wait = (ms) => new Promise(r => setTimeout(r, ms));
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Look up, in the background, the addresses a page body's [map pins] tags name that are
|
|
109
|
+
* not known yet. Returns the queued run's promise (tests await it; saves do not).
|
|
110
|
+
*
|
|
111
|
+
* @param {string} body - the page's Markdown
|
|
112
|
+
* @param {string} [urlPath] - the page, whose cache entry is dropped when its pins are ready
|
|
113
|
+
* @param {{log?: object}} [opts]
|
|
114
|
+
*/
|
|
115
|
+
export function queueMapAddresses(body, urlPath, {log} = {}) {
|
|
116
|
+
if (!addressLookupsOn()) return Promise.resolve({looked: 0, off: true});
|
|
117
|
+
const wanted = [...new Set(mapAddresses(body).filter(a => needsLookup(a)))];
|
|
118
|
+
if (!wanted.length) return Promise.resolve({looked: 0});
|
|
119
|
+
const run = queue.then(async () => {
|
|
120
|
+
let looked = 0;
|
|
121
|
+
for (const address of wanted) {
|
|
122
|
+
if (!needsLookup(address)) continue;
|
|
123
|
+
if (looked) await wait(gapMs);
|
|
124
|
+
try {
|
|
125
|
+
const hit = await lookup(address);
|
|
126
|
+
load()[addressKey(address)] = hit ? {...hit, at: new Date().toISOString()} : {miss: true, at: new Date().toISOString()};
|
|
127
|
+
if (!hit) log?.warn?.({address}, '[map] address not found');
|
|
128
|
+
} catch (err) {
|
|
129
|
+
log?.warn?.({address, err: err?.message}, '[map] address lookup failed');
|
|
130
|
+
}
|
|
131
|
+
looked++;
|
|
132
|
+
}
|
|
133
|
+
await save();
|
|
134
|
+
if (urlPath) await cache.invalidateTags([`page:${urlPath}`]).catch(() => {});
|
|
135
|
+
return {looked};
|
|
136
|
+
});
|
|
137
|
+
queue = run.catch(() => {});
|
|
138
|
+
return run;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Look up every page's [map pins] addresses - when the switch is turned on, so pages saved
|
|
143
|
+
* while it was off get their pins without being saved again. One queue, so still one a second.
|
|
144
|
+
*
|
|
145
|
+
* @param {{urlPath: string, content: string}[]} pages
|
|
146
|
+
*/
|
|
147
|
+
export function queueAllPages(pages, opts = {}) {
|
|
148
|
+
return Promise.all((pages || []).map(p => queueMapAddresses(p.content, p.urlPath, opts)));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Tests: a store file, a fetch, a gap and the switch of their own; nothing resets. */
|
|
152
|
+
export function _setGeocodeForTests({store, fetch, gap, enabled} = {}) {
|
|
153
|
+
enabledOverride = enabled ?? null;
|
|
154
|
+
places = null;
|
|
155
|
+
storePath = store ?? STORE_PATH;
|
|
156
|
+
fetcher = fetch ?? ((url, opts) => safeFetch(url, opts));
|
|
157
|
+
gapMs = gap ?? GAP_MS;
|
|
158
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [map pins="..."] - a map with several pins.
|
|
3
|
+
*
|
|
4
|
+
* Google's keyless embed shows one place, so a map of several is our own
|
|
5
|
+
* small page, /_map, framed by the [map] figure: OpenStreetMap tiles drawn by
|
|
6
|
+
* Leaflet (pinned, with SRI, from the CDN the site already loads from). That
|
|
7
|
+
* page carries its own Content-Security-Policy, so the tile host is allowed
|
|
8
|
+
* there and nowhere else on the site.
|
|
9
|
+
*
|
|
10
|
+
* Pins are coordinates or addresses. Addresses are looked up when the page is
|
|
11
|
+
* saved (services/geocode.js), never while it renders or by a visitor's browser:
|
|
12
|
+
* pins="51.5034,-0.1276 Downing Street | Office = SW1A 2AA | 1 Main St, York"
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The most pins one map takes, and the longest label. */
|
|
16
|
+
export const MAX_PINS = 50;
|
|
17
|
+
export const MAX_LABEL = 80;
|
|
18
|
+
|
|
19
|
+
const LEAFLET = 'https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist';
|
|
20
|
+
const LEAFLET_JS_SRI = 'sha384-cxOPjt7s7Iz04uaHJceBmS+qpjv2JkIHNVcuOrM+YHwZOmJGBXI00mdUXEq65HTH';
|
|
21
|
+
const LEAFLET_CSS_SRI = 'sha384-sHL9NAb7lN7rfvG5lfHpm643Xkcjzp4jFvuavGOndn6pjVqS6ny56CAt3nsEVT4H';
|
|
22
|
+
const TILES = 'https://tile.openstreetmap.org';
|
|
23
|
+
|
|
24
|
+
const PIN_RE = /^([-+]?\d{1,3}(?:\.\d+)?)\s*,\s*([-+]?\d{1,3}(?:\.\d+)?)(?:\s+(.*))?$/;
|
|
25
|
+
const COORDS_RE = /^([-+]?\d{1,3}(?:\.\d+)?)\s*,\s*([-+]?\d{1,3}(?:\.\d+)?)$/;
|
|
26
|
+
/** The longest address a pin takes. */
|
|
27
|
+
export const MAX_ADDRESS = 200;
|
|
28
|
+
|
|
29
|
+
const clean = (v, max) => String(v ?? '').replace(/[\u0000-\u001f\u007f]/g, '').replace(/\s+/g, ' ').trim().slice(0, max);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Read a pins attribute. Each pin, split by `|`, is one of:
|
|
33
|
+
* `lat,lon Label` - coordinates, then an optional label
|
|
34
|
+
* `Label = lat,lon` - the same, label first
|
|
35
|
+
* `Label = an address` - an address (looked up when the page is saved; services/geocode.js)
|
|
36
|
+
* `an address` - an address, which is also its label
|
|
37
|
+
* Addresses only when `addresses` is set - /_map takes coordinates alone.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} value
|
|
40
|
+
* @param {{addresses?: boolean}} [opts]
|
|
41
|
+
* @returns {{pins: ({lat: number, lon: number, label: string}|{address: string, label: string})[], error?: string}}
|
|
42
|
+
*/
|
|
43
|
+
export function parsePins(value, {addresses = false} = {}) {
|
|
44
|
+
const parts = String(value ?? '').split('|').map(s => s.trim()).filter(Boolean);
|
|
45
|
+
const how = addresses ? 'latitude,longitude or an address' : 'latitude,longitude';
|
|
46
|
+
if (!parts.length) return {pins: [], error: `Add at least one pin: ${how}, with an optional label.`};
|
|
47
|
+
if (parts.length > MAX_PINS) return {pins: [], error: `A map takes up to ${MAX_PINS} pins.`};
|
|
48
|
+
const pins = [];
|
|
49
|
+
for (const part of parts) {
|
|
50
|
+
let lat; let lon; let label = ''; let address = '';
|
|
51
|
+
const m = PIN_RE.exec(part);
|
|
52
|
+
if (m) {
|
|
53
|
+
[lat, lon, label] = [Number(m[1]), Number(m[2]), m[3]];
|
|
54
|
+
} else {
|
|
55
|
+
const eq = part.indexOf('=');
|
|
56
|
+
const place = (eq >= 0 ? part.slice(eq + 1) : part).trim();
|
|
57
|
+
label = eq >= 0 ? part.slice(0, eq) : '';
|
|
58
|
+
const c = COORDS_RE.exec(place);
|
|
59
|
+
if (c) [lat, lon] = [Number(c[1]), Number(c[2])];
|
|
60
|
+
else if (addresses && place) address = clean(place, MAX_ADDRESS);
|
|
61
|
+
else return {pins: [], error: `Each pin is ${how}, with an optional label.`};
|
|
62
|
+
if (address && !label.trim()) label = address;
|
|
63
|
+
}
|
|
64
|
+
label = clean(label, MAX_LABEL);
|
|
65
|
+
if (address) { pins.push({address, label}); continue; }
|
|
66
|
+
if (Math.abs(lat) > 90 || Math.abs(lon) > 180) return {pins: [], error: 'Map pin coordinates are outside the valid range.'};
|
|
67
|
+
pins.push({lat, lon, label});
|
|
68
|
+
}
|
|
69
|
+
return {pins};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Every address the [map pins] tags in a page body name (what a save looks up). */
|
|
73
|
+
export function mapAddresses(body) {
|
|
74
|
+
const out = [];
|
|
75
|
+
const re = /\[map(?=[\s/\]])[^\]]*?\bpins\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
|
|
76
|
+
for (const m of String(body ?? '').matchAll(re)) {
|
|
77
|
+
const {pins} = parsePins(m[1] ?? m[2], {addresses: true});
|
|
78
|
+
for (const p of pins) if (p.address) out.push(p.address);
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The pins back as an attribute value (what /_map is given). */
|
|
84
|
+
export const pinsToString = (pins) => pins.map(p => `${p.lat},${p.lon}${p.label ? ' ' + p.label : ''}`).join(' | ');
|
|
85
|
+
|
|
86
|
+
/** The framed page's own policy: Leaflet from the CDN, OSM tiles, framed by this site only. */
|
|
87
|
+
export const MAP_FRAME_CSP = [
|
|
88
|
+
"default-src 'none'",
|
|
89
|
+
`script-src 'unsafe-inline' ${LEAFLET}/leaflet.js`,
|
|
90
|
+
`style-src 'unsafe-inline' ${LEAFLET}/leaflet.css`,
|
|
91
|
+
`img-src ${TILES} data:`,
|
|
92
|
+
"base-uri 'none'",
|
|
93
|
+
"form-action 'none'",
|
|
94
|
+
"frame-ancestors 'self'"
|
|
95
|
+
].join('; ');
|
|
96
|
+
|
|
97
|
+
/** JSON safe inside a <script>: no `</script>`, no `<!--`. */
|
|
98
|
+
const scriptJson = (v) => JSON.stringify(v).replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026')
|
|
99
|
+
.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The /_map page.
|
|
103
|
+
*
|
|
104
|
+
* @param {{pins: object[], zoom?: number|null, directions?: string, title?: string}} opts
|
|
105
|
+
* zoom: null fits every pin in view; directions: the link text in each pin's popup ('' = none)
|
|
106
|
+
* @returns {string} HTML
|
|
107
|
+
*/
|
|
108
|
+
export function mapFrameHtml({pins, zoom = null, directions = '', title = 'Map'}) {
|
|
109
|
+
const data = scriptJson({pins, zoom, directions});
|
|
110
|
+
const esc = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
111
|
+
return `<!doctype html>
|
|
112
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
113
|
+
<meta name="referrer" content="strict-origin-when-cross-origin">
|
|
114
|
+
<title>${esc(title)}</title>
|
|
115
|
+
<link rel="stylesheet" href="${LEAFLET}/leaflet.css" integrity="${LEAFLET_CSS_SRI}" crossorigin="anonymous">
|
|
116
|
+
<style>
|
|
117
|
+
html,body,#m{height:100%;margin:0}
|
|
118
|
+
.dm-pin{position:relative;width:22px;height:22px;margin:0 2px;border-radius:50% 50% 50% 0;background:#d93025;transform:rotate(-45deg);border:2px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.4)}
|
|
119
|
+
.dm-pin::after{content:"";position:absolute;width:8px;height:8px;left:5px;top:5px;border-radius:50%;background:#fff}
|
|
120
|
+
.dm-pop{font:14px/1.4 system-ui,-apple-system,Segoe UI,Roboto,sans-serif}
|
|
121
|
+
.dm-pop a{display:inline-block;margin-top:.25rem}
|
|
122
|
+
</style></head>
|
|
123
|
+
<body><div id="m" role="region" aria-label="${esc(title)}"></div>
|
|
124
|
+
<script src="${LEAFLET}/leaflet.js" integrity="${LEAFLET_JS_SRI}" crossorigin="anonymous"></script>
|
|
125
|
+
<script>
|
|
126
|
+
(function () {
|
|
127
|
+
var d = ${data};
|
|
128
|
+
var map = L.map('m', {scrollWheelZoom: false});
|
|
129
|
+
L.tileLayer('${TILES}/{z}/{x}/{y}.png', {maxZoom: 19,
|
|
130
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors'}).addTo(map);
|
|
131
|
+
var icon = L.divIcon({className: '', html: '<div class="dm-pin"></div>', iconSize: [26, 30], iconAnchor: [13, 30], popupAnchor: [0, -28]});
|
|
132
|
+
var points = [];
|
|
133
|
+
d.pins.forEach(function (p) {
|
|
134
|
+
var at = [p.lat, p.lon];
|
|
135
|
+
points.push(at);
|
|
136
|
+
var marker = L.marker(at, {icon: icon, title: p.label || '', alt: p.label || 'Pin'}).addTo(map);
|
|
137
|
+
if (!p.label && !d.directions) return;
|
|
138
|
+
var box = document.createElement('div');
|
|
139
|
+
box.className = 'dm-pop';
|
|
140
|
+
if (p.label) { var b = document.createElement('strong'); b.textContent = p.label; box.appendChild(b); }
|
|
141
|
+
if (d.directions) {
|
|
142
|
+
var a = document.createElement('a');
|
|
143
|
+
a.href = 'https://www.google.com/maps/dir/?api=1&destination=' + p.lat + ',' + p.lon;
|
|
144
|
+
a.target = '_blank'; a.rel = 'noopener noreferrer'; a.textContent = d.directions;
|
|
145
|
+
if (p.label) box.appendChild(document.createElement('br'));
|
|
146
|
+
box.appendChild(a);
|
|
147
|
+
}
|
|
148
|
+
marker.bindPopup(box);
|
|
149
|
+
});
|
|
150
|
+
if (points.length === 1) map.setView(points[0], d.zoom || 14);
|
|
151
|
+
else if (d.zoom) map.setView(L.latLngBounds(points).getCenter(), d.zoom);
|
|
152
|
+
else map.fitBounds(points, {padding: [30, 30], maxZoom: 16});
|
|
153
|
+
})();
|
|
154
|
+
</script></body></html>`;
|
|
155
|
+
}
|
|
@@ -3,6 +3,8 @@ import {decodeMessageAttribute} from '../../public/js/celebrations/message-attrs
|
|
|
3
3
|
* Markdown Service
|
|
4
4
|
* Parses frontmatter with gray-matter and renders Markdown to HTML with marked.
|
|
5
5
|
*/
|
|
6
|
+
import {parsePins, pinsToString} from './mapPins.js';
|
|
7
|
+
import {addressLookupsOn, placeFor} from './geocode.js';
|
|
6
8
|
import {normaliseBackground, backgroundStyle} from '../../public/js/background-style.mjs';
|
|
7
9
|
import {cssClasses} from '../../public/js/css-classes.mjs';
|
|
8
10
|
import matter from 'gray-matter';
|
|
@@ -4937,8 +4939,60 @@ function processEmbedBlocks(markdown) {
|
|
|
4937
4939
|
|
|
4938
4940
|
// ─── [map] - responsive Google Maps location embed ─────────────────────────
|
|
4939
4941
|
|
|
4942
|
+
/** The directions link text a [map] asks for: '' for none, "Get directions" for true, else its own words. */
|
|
4943
|
+
function mapDirectionsLabel(value) {
|
|
4944
|
+
const raw = value === true ? 'true' : typeof value === 'string' ? value.trim() : '';
|
|
4945
|
+
if (raw === '' || /^(false|no|off|0)$/i.test(raw)) return '';
|
|
4946
|
+
return /^(true|yes|on|1)$/i.test(raw) ? 'Get directions' : raw.slice(0, 100);
|
|
4947
|
+
}
|
|
4948
|
+
|
|
4949
|
+
/** The figure around a map's frame: width, alignment, ratio and a caption, shared by both kinds of map. */
|
|
4950
|
+
function mapFigure(attrs, src, titleText, below) {
|
|
4951
|
+
const styles = ['margin:1.5rem 0'];
|
|
4952
|
+
if (attrs.width) {
|
|
4953
|
+
const w = /^\d+%$/.test(attrs.width) ? attrs.width : `${parseInt(attrs.width, 10) || 0}px`;
|
|
4954
|
+
if (w !== '0px') styles.push(`max-width:${w}`);
|
|
4955
|
+
}
|
|
4956
|
+
const align = String(attrs.align || '').toLowerCase();
|
|
4957
|
+
if (align === 'center') styles.push('margin-left:auto', 'margin-right:auto');
|
|
4958
|
+
else if (align === 'right') styles.push('margin-left:auto');
|
|
4959
|
+
return `<figure class="dm-map" style="${styles.join(';')}"><div class="dm-map-frame" style="position:relative;width:100%;aspect-ratio:${_embedRatio(attrs.ratio)}">`
|
|
4960
|
+
+ `<iframe src="${escapeAttr(src)}" title="${escapeAttr(titleText)}" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"`
|
|
4961
|
+
+ ` style="position:absolute;inset:0;width:100%;height:100%;border:0" allowfullscreen></iframe></div>`
|
|
4962
|
+
+ (below ? `<figcaption class="dm-embed-caption">${below}</figcaption>` : '')
|
|
4963
|
+
+ '</figure>';
|
|
4964
|
+
}
|
|
4965
|
+
|
|
4966
|
+
/**
|
|
4967
|
+
* [map pins="lat,lon Label | Label = address | ..."] - several pins, on this site's own /_map page
|
|
4968
|
+
* (OpenStreetMap; services/mapPins.js). Addresses are read from services/geocode.js's store, filled when the
|
|
4969
|
+
* page is saved; a renderer never looks one up. Every pin is in view unless a zoom is given; with
|
|
4970
|
+
* directions, each pin's popup links to Google's route planner.
|
|
4971
|
+
*/
|
|
4972
|
+
function renderPinsMap(attrs) {
|
|
4973
|
+
const {pins: asked, error} = parsePins(attrs.pins, {addresses: true});
|
|
4974
|
+
if (error) return _embedBlocked(escapeAttr(error));
|
|
4975
|
+
// Addresses come from what the page's save looked up (services/geocode.js); one not found yet is left off.
|
|
4976
|
+
const pins = asked.map(p => (p.address ? (placeFor(p.address) ? {...placeFor(p.address), label: p.label} : null) : p)).filter(Boolean);
|
|
4977
|
+
if (!pins.length) {
|
|
4978
|
+
return _embedBlocked(addressLookupsOn()
|
|
4979
|
+
? 'This map's addresses have not been found yet. They are looked up when the page is saved - give it a minute, or check the addresses.'
|
|
4980
|
+
: 'Map pins by address need Address look-ups switched on in Site Settings > General. Or give each pin latitude,longitude.');
|
|
4981
|
+
}
|
|
4982
|
+
const params = new URLSearchParams({pins: pinsToString(pins)});
|
|
4983
|
+
const parsedZoom = Number.parseInt(attrs.zoom, 10);
|
|
4984
|
+
if (Number.isFinite(parsedZoom)) params.set('zoom', String(Math.max(1, Math.min(19, parsedZoom))));
|
|
4985
|
+
const directions = mapDirectionsLabel(attrs.directions);
|
|
4986
|
+
if (directions) params.set('directions', directions);
|
|
4987
|
+
const titleText = String(attrs.title || 'Map');
|
|
4988
|
+
params.set('title', titleText.slice(0, 200));
|
|
4989
|
+
const caption = attrs.caption || attrs.title;
|
|
4990
|
+
return mapFigure(attrs, `/_map?${params}`, titleText, caption ? escapeAttr(caption) : '');
|
|
4991
|
+
}
|
|
4992
|
+
|
|
4940
4993
|
/** Build a safe map iframe from a location, postcode, or coordinate pin. */
|
|
4941
4994
|
export function renderMap(attrs = {}) {
|
|
4995
|
+
if (typeof attrs.pins === 'string' && attrs.pins.trim()) return renderPinsMap(attrs);
|
|
4942
4996
|
const pin = typeof attrs.pin === 'string' ? attrs.pin.trim() : '';
|
|
4943
4997
|
const lat = typeof attrs.lat === 'string' ? attrs.lat.trim() : '';
|
|
4944
4998
|
const lonRaw = attrs.lon ?? attrs.lng;
|
|
@@ -4965,23 +5019,16 @@ export function renderMap(attrs = {}) {
|
|
|
4965
5019
|
// Google marks that redirect SAMEORIGIN, which browsers can block in iframes.
|
|
4966
5020
|
const encodedQuery = encodeURIComponent(query).replace(/%20/g, '+');
|
|
4967
5021
|
const src = `https://www.google.com/maps/embed?origin=mfe&pb=!1m3!2m1!1s${encodedQuery}!6i${zoom}`;
|
|
4968
|
-
const ratio = _embedRatio(attrs.ratio);
|
|
4969
5022
|
const titleText = String(attrs.title || address || postcode || 'Map');
|
|
4970
|
-
const title = escapeAttr(titleText);
|
|
4971
|
-
const styles = ['margin:1.5rem 0'];
|
|
4972
|
-
if (attrs.width) {
|
|
4973
|
-
const w = /^\d+%$/.test(attrs.width) ? attrs.width : `${parseInt(attrs.width, 10) || 0}px`;
|
|
4974
|
-
if (w !== '0px') styles.push(`max-width:${w}`);
|
|
4975
|
-
}
|
|
4976
|
-
const align = String(attrs.align || '').toLowerCase();
|
|
4977
|
-
if (align === 'center') styles.push('margin-left:auto', 'margin-right:auto');
|
|
4978
|
-
else if (align === 'right') styles.push('margin-left:auto');
|
|
4979
5023
|
const caption = attrs.caption || attrs.title;
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
5024
|
+
// directions="true" (or any label text) adds a link to Google's route planner, ending at this place.
|
|
5025
|
+
const dirLabel = mapDirectionsLabel(attrs.directions);
|
|
5026
|
+
const dirHref = `https://www.google.com/maps/dir/?api=1&destination=${encodedQuery}`;
|
|
5027
|
+
const directions = dirLabel
|
|
5028
|
+
? `<a class="dm-map-directions" href="${escapeAttr(dirHref)}" target="_blank" rel="noopener noreferrer">${escapeAttr(dirLabel)}</a>`
|
|
5029
|
+
: '';
|
|
5030
|
+
const below = [caption ? escapeAttr(caption) : '', directions].filter(Boolean).join(' · ');
|
|
5031
|
+
return mapFigure(attrs, src, titleText, below);
|
|
4985
5032
|
}
|
|
4986
5033
|
|
|
4987
5034
|
function processMapBlocks(markdown) {
|