domma-cms 1.75.3 → 1.76.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 +7 -0
- package/admin/js/lib/shortcode-registry.js +1 -1
- package/admin/js/templates/docs/usage-shortcodes-content.html +13 -3
- package/docs/DommaFeatures.md +2 -0
- package/docs/markdown-shortcodes.md +16 -1
- package/package.json +1 -1
- package/server/routes/map-frame.js +26 -0
- package/server/server.js +3 -0
- package/server/services/mapPins.js +121 -0
- package/server/services/markdown.js +53 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.76.0] - 2026-11-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **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.
|
|
8
|
+
- **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.
|
|
9
|
+
|
|
3
10
|
## [1.75.3] - 2026-11-19
|
|
4
11
|
|
|
5
12
|
### 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: latitude,longitude then a label, one pin after another split by | (51.5034,-0.1276 Office | 51.5007,-0.1246 Shop). Shown on OpenStreetMap; addresses are not looked up."},{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}];
|
|
@@ -388,10 +388,12 @@
|
|
|
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" /]
|
|
395
397
|
</code></pre>
|
|
396
398
|
<table class="table table-sm">
|
|
397
399
|
<thead>
|
|
@@ -413,6 +415,10 @@
|
|
|
413
415
|
<td>The place, as <code>latitude,longitude</code></td>
|
|
414
416
|
</tr>
|
|
415
417
|
<tr>
|
|
418
|
+
<td><code>pins</code></td>
|
|
419
|
+
<td>Several places: <code>latitude,longitude</code> then a label, each split by <code>|</code>. Up to 50. Shown on OpenStreetMap with every pin in view; click a pin for its label</td>
|
|
420
|
+
</tr>
|
|
421
|
+
<tr>
|
|
416
422
|
<td><code>lat</code>, <code>lon</code> (or <code>lng</code>)</td>
|
|
417
423
|
<td>The place, as two separate numbers</td>
|
|
418
424
|
</tr>
|
|
@@ -436,8 +442,12 @@
|
|
|
436
442
|
<td><code>caption</code> (or <code>title</code>)</td>
|
|
437
443
|
<td>Words under the map</td>
|
|
438
444
|
</tr>
|
|
445
|
+
<tr>
|
|
446
|
+
<td><code>directions</code></td>
|
|
447
|
+
<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>
|
|
448
|
+
</tr>
|
|
439
449
|
</tbody></table>
|
|
440
|
-
<p>Give one of <code>postcode</code>, <code>address</code>, <code>pin</code>, or <code>lat</code> with <code>lon</code
|
|
450
|
+
<p>Give one of <code>postcode</code>, <code>address</code>, <code>pin</code>, or <code>lat</code> with <code>lon</code>. Pins take coordinates only: addresses and postcodes are not looked up.</p>
|
|
441
451
|
<h3 id="sc-demo"><code>demo</code> - a demo page in a frame</h3>
|
|
442
452
|
<p>Shows a demo page kept on this site inside a frame.</p>
|
|
443
453
|
<pre><code>[demo src="elements/accordion" /]
|
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 | ..."]`** - several pins (up to 50) on OpenStreetMap via Leaflet, every pin in view, labels and per-pin directions in popups. 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`), 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,25 @@ 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, each `latitude,longitude` then an optional label, split by `|`:
|
|
1033
|
+
|
|
1034
|
+
```text
|
|
1035
|
+
[map pins="51.5034,-0.1276 Downing Street | 51.5007,-0.1246 Big Ben" directions="true" caption="Find us" /]
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
Up to 50 pins, labels up to 80 characters. The map is OpenStreetMap, drawn on this site's own `/_map` page (framed by
|
|
1039
|
+
this site only, with its own Content-Security-Policy for the tile host). Every pin is in view unless `zoom` is given;
|
|
1040
|
+
each pin's label shows when it is clicked, with the directions link to that pin when `directions` is set. Addresses
|
|
1041
|
+
and postcodes are not looked up for pins - give coordinates. `ratio`, `width`, `align`, `title` and `caption` work as
|
|
1042
|
+
above. Malformed coordinates show a notice instead of a map. Google's
|
|
1028
1043
|
embed host is always allowed to frame, so no `config/embeds.json` entry is needed.
|
|
1029
1044
|
### `[form]`
|
|
1030
1045
|
|
package/package.json
CHANGED
|
@@ -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');
|
|
@@ -0,0 +1,121 @@
|
|
|
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 only - no address look-ups (that would send the
|
|
11
|
+
* site's visitors, or the server, to a geocoding service):
|
|
12
|
+
* pins="51.5034,-0.1276 Downing Street | 51.5007,-0.1246 Big Ben"
|
|
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
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Read a pins attribute: `lat,lon Label | lat,lon Label`.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} value
|
|
30
|
+
* @returns {{pins: {lat: number, lon: number, label: string}[], error?: string}}
|
|
31
|
+
*/
|
|
32
|
+
export function parsePins(value) {
|
|
33
|
+
const parts = String(value ?? '').split('|').map(s => s.trim()).filter(Boolean);
|
|
34
|
+
if (!parts.length) return {pins: [], error: 'Add at least one pin: latitude,longitude then an optional label.'};
|
|
35
|
+
if (parts.length > MAX_PINS) return {pins: [], error: `A map takes up to ${MAX_PINS} pins.`};
|
|
36
|
+
const pins = [];
|
|
37
|
+
for (const part of parts) {
|
|
38
|
+
const m = PIN_RE.exec(part);
|
|
39
|
+
if (!m) return {pins: [], error: `Pins are latitude,longitude then an optional label - "${part.slice(0, 40)}" is not.`};
|
|
40
|
+
const lat = Number(m[1]);
|
|
41
|
+
const lon = Number(m[2]);
|
|
42
|
+
if (Math.abs(lat) > 90 || Math.abs(lon) > 180) return {pins: [], error: 'Map pin coordinates are outside the valid range.'};
|
|
43
|
+
const label = String(m[3] ?? '').replace(/[\u0000-\u001f\u007f]/g, '').trim().slice(0, MAX_LABEL);
|
|
44
|
+
pins.push({lat, lon, label});
|
|
45
|
+
}
|
|
46
|
+
return {pins};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The pins back as an attribute value (what /_map is given). */
|
|
50
|
+
export const pinsToString = (pins) => pins.map(p => `${p.lat},${p.lon}${p.label ? ' ' + p.label : ''}`).join(' | ');
|
|
51
|
+
|
|
52
|
+
/** The framed page's own policy: Leaflet from the CDN, OSM tiles, framed by this site only. */
|
|
53
|
+
export const MAP_FRAME_CSP = [
|
|
54
|
+
"default-src 'none'",
|
|
55
|
+
`script-src 'unsafe-inline' ${LEAFLET}/leaflet.js`,
|
|
56
|
+
`style-src 'unsafe-inline' ${LEAFLET}/leaflet.css`,
|
|
57
|
+
`img-src ${TILES} data:`,
|
|
58
|
+
"base-uri 'none'",
|
|
59
|
+
"form-action 'none'",
|
|
60
|
+
"frame-ancestors 'self'"
|
|
61
|
+
].join('; ');
|
|
62
|
+
|
|
63
|
+
/** JSON safe inside a <script>: no `</script>`, no `<!--`. */
|
|
64
|
+
const scriptJson = (v) => JSON.stringify(v).replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026')
|
|
65
|
+
.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The /_map page.
|
|
69
|
+
*
|
|
70
|
+
* @param {{pins: object[], zoom?: number|null, directions?: string, title?: string}} opts
|
|
71
|
+
* zoom: null fits every pin in view; directions: the link text in each pin's popup ('' = none)
|
|
72
|
+
* @returns {string} HTML
|
|
73
|
+
*/
|
|
74
|
+
export function mapFrameHtml({pins, zoom = null, directions = '', title = 'Map'}) {
|
|
75
|
+
const data = scriptJson({pins, zoom, directions});
|
|
76
|
+
const esc = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
77
|
+
return `<!doctype html>
|
|
78
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
79
|
+
<meta name="referrer" content="strict-origin-when-cross-origin">
|
|
80
|
+
<title>${esc(title)}</title>
|
|
81
|
+
<link rel="stylesheet" href="${LEAFLET}/leaflet.css" integrity="${LEAFLET_CSS_SRI}" crossorigin="anonymous">
|
|
82
|
+
<style>
|
|
83
|
+
html,body,#m{height:100%;margin:0}
|
|
84
|
+
.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)}
|
|
85
|
+
.dm-pin::after{content:"";position:absolute;width:8px;height:8px;left:5px;top:5px;border-radius:50%;background:#fff}
|
|
86
|
+
.dm-pop{font:14px/1.4 system-ui,-apple-system,Segoe UI,Roboto,sans-serif}
|
|
87
|
+
.dm-pop a{display:inline-block;margin-top:.25rem}
|
|
88
|
+
</style></head>
|
|
89
|
+
<body><div id="m" role="region" aria-label="${esc(title)}"></div>
|
|
90
|
+
<script src="${LEAFLET}/leaflet.js" integrity="${LEAFLET_JS_SRI}" crossorigin="anonymous"></script>
|
|
91
|
+
<script>
|
|
92
|
+
(function () {
|
|
93
|
+
var d = ${data};
|
|
94
|
+
var map = L.map('m', {scrollWheelZoom: false});
|
|
95
|
+
L.tileLayer('${TILES}/{z}/{x}/{y}.png', {maxZoom: 19,
|
|
96
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors'}).addTo(map);
|
|
97
|
+
var icon = L.divIcon({className: '', html: '<div class="dm-pin"></div>', iconSize: [26, 30], iconAnchor: [13, 30], popupAnchor: [0, -28]});
|
|
98
|
+
var points = [];
|
|
99
|
+
d.pins.forEach(function (p) {
|
|
100
|
+
var at = [p.lat, p.lon];
|
|
101
|
+
points.push(at);
|
|
102
|
+
var marker = L.marker(at, {icon: icon, title: p.label || '', alt: p.label || 'Pin'}).addTo(map);
|
|
103
|
+
if (!p.label && !d.directions) return;
|
|
104
|
+
var box = document.createElement('div');
|
|
105
|
+
box.className = 'dm-pop';
|
|
106
|
+
if (p.label) { var b = document.createElement('strong'); b.textContent = p.label; box.appendChild(b); }
|
|
107
|
+
if (d.directions) {
|
|
108
|
+
var a = document.createElement('a');
|
|
109
|
+
a.href = 'https://www.google.com/maps/dir/?api=1&destination=' + p.lat + ',' + p.lon;
|
|
110
|
+
a.target = '_blank'; a.rel = 'noopener noreferrer'; a.textContent = d.directions;
|
|
111
|
+
if (p.label) box.appendChild(document.createElement('br'));
|
|
112
|
+
box.appendChild(a);
|
|
113
|
+
}
|
|
114
|
+
marker.bindPopup(box);
|
|
115
|
+
});
|
|
116
|
+
if (points.length === 1) map.setView(points[0], d.zoom || 14);
|
|
117
|
+
else if (d.zoom) map.setView(L.latLngBounds(points).getCenter(), d.zoom);
|
|
118
|
+
else map.fitBounds(points, {padding: [30, 30], maxZoom: 16});
|
|
119
|
+
})();
|
|
120
|
+
</script></body></html>`;
|
|
121
|
+
}
|
|
@@ -3,6 +3,7 @@ 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';
|
|
6
7
|
import {normaliseBackground, backgroundStyle} from '../../public/js/background-style.mjs';
|
|
7
8
|
import {cssClasses} from '../../public/js/css-classes.mjs';
|
|
8
9
|
import matter from 'gray-matter';
|
|
@@ -4937,8 +4938,52 @@ function processEmbedBlocks(markdown) {
|
|
|
4937
4938
|
|
|
4938
4939
|
// ─── [map] - responsive Google Maps location embed ─────────────────────────
|
|
4939
4940
|
|
|
4941
|
+
/** The directions link text a [map] asks for: '' for none, "Get directions" for true, else its own words. */
|
|
4942
|
+
function mapDirectionsLabel(value) {
|
|
4943
|
+
const raw = value === true ? 'true' : typeof value === 'string' ? value.trim() : '';
|
|
4944
|
+
if (raw === '' || /^(false|no|off|0)$/i.test(raw)) return '';
|
|
4945
|
+
return /^(true|yes|on|1)$/i.test(raw) ? 'Get directions' : raw.slice(0, 100);
|
|
4946
|
+
}
|
|
4947
|
+
|
|
4948
|
+
/** The figure around a map's frame: width, alignment, ratio and a caption, shared by both kinds of map. */
|
|
4949
|
+
function mapFigure(attrs, src, titleText, below) {
|
|
4950
|
+
const styles = ['margin:1.5rem 0'];
|
|
4951
|
+
if (attrs.width) {
|
|
4952
|
+
const w = /^\d+%$/.test(attrs.width) ? attrs.width : `${parseInt(attrs.width, 10) || 0}px`;
|
|
4953
|
+
if (w !== '0px') styles.push(`max-width:${w}`);
|
|
4954
|
+
}
|
|
4955
|
+
const align = String(attrs.align || '').toLowerCase();
|
|
4956
|
+
if (align === 'center') styles.push('margin-left:auto', 'margin-right:auto');
|
|
4957
|
+
else if (align === 'right') styles.push('margin-left:auto');
|
|
4958
|
+
return `<figure class="dm-map" style="${styles.join(';')}"><div class="dm-map-frame" style="position:relative;width:100%;aspect-ratio:${_embedRatio(attrs.ratio)}">`
|
|
4959
|
+
+ `<iframe src="${escapeAttr(src)}" title="${escapeAttr(titleText)}" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"`
|
|
4960
|
+
+ ` style="position:absolute;inset:0;width:100%;height:100%;border:0" allowfullscreen></iframe></div>`
|
|
4961
|
+
+ (below ? `<figcaption class="dm-embed-caption">${below}</figcaption>` : '')
|
|
4962
|
+
+ '</figure>';
|
|
4963
|
+
}
|
|
4964
|
+
|
|
4965
|
+
/**
|
|
4966
|
+
* [map pins="lat,lon Label | lat,lon Label"] - several pins, on this site's own /_map page
|
|
4967
|
+
* (OpenStreetMap; services/mapPins.js). Every pin is in view unless a zoom is given; with
|
|
4968
|
+
* directions, each pin's popup links to Google's route planner.
|
|
4969
|
+
*/
|
|
4970
|
+
function renderPinsMap(attrs) {
|
|
4971
|
+
const {pins, error} = parsePins(attrs.pins);
|
|
4972
|
+
if (error) return _embedBlocked(error);
|
|
4973
|
+
const params = new URLSearchParams({pins: pinsToString(pins)});
|
|
4974
|
+
const parsedZoom = Number.parseInt(attrs.zoom, 10);
|
|
4975
|
+
if (Number.isFinite(parsedZoom)) params.set('zoom', String(Math.max(1, Math.min(19, parsedZoom))));
|
|
4976
|
+
const directions = mapDirectionsLabel(attrs.directions);
|
|
4977
|
+
if (directions) params.set('directions', directions);
|
|
4978
|
+
const titleText = String(attrs.title || 'Map');
|
|
4979
|
+
params.set('title', titleText.slice(0, 200));
|
|
4980
|
+
const caption = attrs.caption || attrs.title;
|
|
4981
|
+
return mapFigure(attrs, `/_map?${params}`, titleText, caption ? escapeAttr(caption) : '');
|
|
4982
|
+
}
|
|
4983
|
+
|
|
4940
4984
|
/** Build a safe map iframe from a location, postcode, or coordinate pin. */
|
|
4941
4985
|
export function renderMap(attrs = {}) {
|
|
4986
|
+
if (typeof attrs.pins === 'string' && attrs.pins.trim()) return renderPinsMap(attrs);
|
|
4942
4987
|
const pin = typeof attrs.pin === 'string' ? attrs.pin.trim() : '';
|
|
4943
4988
|
const lat = typeof attrs.lat === 'string' ? attrs.lat.trim() : '';
|
|
4944
4989
|
const lonRaw = attrs.lon ?? attrs.lng;
|
|
@@ -4965,23 +5010,16 @@ export function renderMap(attrs = {}) {
|
|
|
4965
5010
|
// Google marks that redirect SAMEORIGIN, which browsers can block in iframes.
|
|
4966
5011
|
const encodedQuery = encodeURIComponent(query).replace(/%20/g, '+');
|
|
4967
5012
|
const src = `https://www.google.com/maps/embed?origin=mfe&pb=!1m3!2m1!1s${encodedQuery}!6i${zoom}`;
|
|
4968
|
-
const ratio = _embedRatio(attrs.ratio);
|
|
4969
5013
|
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
5014
|
const caption = attrs.caption || attrs.title;
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
5015
|
+
// directions="true" (or any label text) adds a link to Google's route planner, ending at this place.
|
|
5016
|
+
const dirLabel = mapDirectionsLabel(attrs.directions);
|
|
5017
|
+
const dirHref = `https://www.google.com/maps/dir/?api=1&destination=${encodedQuery}`;
|
|
5018
|
+
const directions = dirLabel
|
|
5019
|
+
? `<a class="dm-map-directions" href="${escapeAttr(dirHref)}" target="_blank" rel="noopener noreferrer">${escapeAttr(dirLabel)}</a>`
|
|
5020
|
+
: '';
|
|
5021
|
+
const below = [caption ? escapeAttr(caption) : '', directions].filter(Boolean).join(' · ');
|
|
5022
|
+
return mapFigure(attrs, src, titleText, below);
|
|
4985
5023
|
}
|
|
4986
5024
|
|
|
4987
5025
|
function processMapBlocks(markdown) {
|