From d1e093cfc729dbfd9951032d91f838241984f790 Mon Sep 17 00:00:00 2001 From: Chris Millar Date: Tue, 6 Aug 2024 23:26:09 -0600 Subject: [PATCH] Library plugins (#192) --- blocks/edit/da-library/da-library.css | 23 +++++++++++- blocks/edit/da-library/da-library.js | 21 +++++++++-- blocks/edit/da-library/helpers/helpers.js | 45 ++++++++++++++++------- 3 files changed, 72 insertions(+), 17 deletions(-) diff --git a/blocks/edit/da-library/da-library.css b/blocks/edit/da-library/da-library.css index b3c04de4..52906b07 100644 --- a/blocks/edit/da-library/da-library.css +++ b/blocks/edit/da-library/da-library.css @@ -122,6 +122,10 @@ button span { background: url('/blocks/edit/img/library-back.svg') center center / 18px no-repeat; } +.da-library-item-list-main button { + background: #FFF; +} + .da-library-item-list-main button.blocks { background: url('/blocks/edit/img/Smock_Table_18_N.svg') 18px center / 18px no-repeat; } @@ -142,7 +146,8 @@ button span { background: url('/blocks/edit/img/Smock_Image_18_N.svg') 18px center / 18px no-repeat; } -.da-library-item-list-main button.plugins { +.da-library-item-list-main button.plugins, +.da-library-item-list-main button.is-plugin { background: url('/blocks/edit/img/Smock_Plug_18_N.svg') 18px center / 18px no-repeat; } @@ -408,3 +413,19 @@ ul { opacity: 1; z-index: 1; } + +/* Plugins */ +.da-library-type-plugin { + position: absolute; + top: 44px; + right: 0; + bottom: 0; + left: 0; +} + +.da-library-type-plugin iframe { + border: none; + display: block; + width: 100%; + height: 100%; +} diff --git a/blocks/edit/da-library/da-library.js b/blocks/edit/da-library/da-library.js index 3d77bdbc..f21114d5 100644 --- a/blocks/edit/da-library/da-library.js +++ b/blocks/edit/da-library/da-library.js @@ -1,5 +1,5 @@ import { DOMParser as proseDOMParser } from 'da-y-wrapper'; -import { LitElement, html, until } from '../../../deps/lit/lit-all.min.js'; +import { LitElement, html, until, nothing } from '../../../deps/lit/lit-all.min.js'; import { getBlocks, getBlockVariants } from './helpers/index.js'; import getSheet from '../../shared/sheet.js'; import inlinesvg from '../../shared/inlinesvg.js'; @@ -173,7 +173,22 @@ class DaLibrary extends LitElement { `; } - async renderLibrary({ name, sources, format }) { + renderPlugin(url) { + return html` +
+ +
`; + } + + async renderLibrary({ name, sources, url, format }) { + // Only plugins have a URL + if (url) { + return this.renderPlugin(url); + } + if (name === 'blocks') { const blocks = await getBlocks(sources); return this.renderGroups(blocks); @@ -203,7 +218,7 @@ class DaLibrary extends LitElement {