diff --git a/resources/js/components/SMEditor.vue b/resources/js/components/SMEditor.vue
index fad9d63..4a9f79c 100644
--- a/resources/js/components/SMEditor.vue
+++ b/resources/js/components/SMEditor.vue
@@ -74,6 +74,93 @@ const props = defineProps({
const useDarkMode = false; // window.matchMedia("(prefers-color-scheme: dark)").matches;
const tinyeditor = ref(null);
+tinymce.PluginManager.add("gallery", function (editor) {
+ // Register a command to open the dialog
+ editor.addCommand("image-gallery", function () {
+ var selected = [];
+ var node = editor.selection.getNode();
+
+ if (node) {
+ if (!editor.dom.hasClass(node, "tinymce-sm-gallery")) {
+ // Check if node is a descendant of a gallery node
+ var galleryNode = editor.dom.getParent(
+ node,
+ ".tinymce-sm-gallery"
+ );
+ if (!galleryNode) {
+ node = null;
+ } else {
+ node = galleryNode;
+ }
+ }
+ }
+
+ if (node) {
+ // Parse the gallery contents
+ const childEls = node.querySelectorAll("div");
+ const urls = Array.from(childEls).map((el) => {
+ const matches = (el as HTMLElement)
+ .getAttribute("style")
+ .match(/url\(['"]?(.*?)['"]?\)/);
+ return matches ? matches[1] : null;
+ });
+ selected = urls;
+ }
+ imageBrowser(
+ function (url) {
+ let galleryContent = "";
+ if (url.length > 0) {
+ url.forEach((item) => {
+ galleryContent += `
+ type: "htmlpanel",
+ html: `
`,
- },
- ],
},
],
},
+ ];
+
+ if (gallery == true) {
+ tabs.push({
+ name: "gallery",
+ title: "Gallery",
+ items: [
+ {
+ type: "htmlpanel",
+ html: `
`,
+ },
+ ],
+ });
+ }
+
+ // Add the container and file input to the dialog
+ const dialog = tinymce.activeEditor.windowManager.open({
+ title: "Image Library",
+ size: "large",
+ body: {
+ type: "tabpanel",
+ tabs: tabs,
+ },
initialData: {},
buttons: [
{
@@ -520,6 +734,8 @@ const imageBrowser = (callback, value, meta) => {
onTabChange: function (dialogApi, details) {
if (details.newTabName == "library") {
updateLibrary();
+ } else if (details.newTabName == "gallery") {
+ updateGallery();
}
},
});
@@ -591,7 +807,8 @@ const imageBrowser = (callback, value, meta) => {
}
}
-#image-library-content {
+#image-library-content,
+#image-gallery-content {
display: flex;
flex-wrap: wrap;
margin-top: 12px;
@@ -602,7 +819,9 @@ const imageBrowser = (callback, value, meta) => {
padding: 0.5rem;
height: 440px;
- .image-library-content-item {
+ .image-library-content-item,
+ .image-gallery-content-item {
+ position: relative;
width: 18vw;
height: 18vh;
min-width: 200px;
@@ -614,7 +833,6 @@ const imageBrowser = (callback, value, meta) => {
&:hover,
&.image-library-content-item-selected {
border: 3px solid #0060ce;
- position: relative;
cursor: pointer;
}
@@ -632,13 +850,91 @@ const imageBrowser = (callback, value, meta) => {
justify-content: center;
border-radius: 50%;
color: #fff;
- box-shadow: 0 0 2px 2px #fff;
+ box-shadow: 0 0 0 2px #fff;
background-repeat: no-repeat;
background-position: center;
background-color: #0060ce;
}
- .image-library-content-item-image {
+ .image-gallery-content-item-remove {
+ position: absolute;
+ top: -10px;
+ right: -10px;
+ width: 20px;
+ height: 20px;
+ font-size: 14px;
+ font-weight: bold;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ color: #fff;
+ box-shadow: 0 0 0 2px #fff;
+ background-repeat: no-repeat;
+ background-position: center;
+ background-size: 50%;
+ background-color: #ce0000;
+ background-image: url('data:image/svg+xml;utf8,
');
+ }
+
+ .image-gallery-content-item-left {
+ position: absolute;
+ top: -10px;
+ right: 40px;
+ width: 20px;
+ height: 20px;
+ font-size: 14px;
+ font-weight: bold;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ color: #fff;
+ box-shadow: 0 0 0 2px #fff;
+ background-repeat: no-repeat;
+ background-position: center;
+ background-size: 50%;
+ background-color: #0060ce;
+ background-image: url('data:image/svg+xml;utf8,
');
+ }
+
+ .image-gallery-content-item-right {
+ position: absolute;
+ top: -10px;
+ right: 15px;
+ width: 20px;
+ height: 20px;
+ font-size: 14px;
+ font-weight: bold;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ color: #fff;
+ box-shadow: 0 0 0 2px #fff;
+ background-repeat: no-repeat;
+ background-position: center;
+ background-size: 50%;
+ background-color: #0060ce;
+ background-image: url('data:image/svg+xml;utf8,
');
+ }
+
+ &:first-of-type .image-gallery-content-item-left {
+ display: none;
+ }
+
+ &:last-of-type {
+ .image-gallery-content-item-left {
+ right: 15px;
+ }
+
+ .image-gallery-content-item-right {
+ display: none;
+ }
+ }
+
+ .image-library-content-item-image,
+ .image-gallery-content-item-image {
width: 100%;
height: 14vh;
min-height: 113px;
@@ -648,7 +944,8 @@ const imageBrowser = (callback, value, meta) => {
background-clip: content-box;
}
- .image-library-content-item-title {
+ .image-library-content-item-title,
+ .image-gallery-content-item-title {
margin-top: 8px;
text-align: center;
font-size: 90%;
@@ -659,14 +956,16 @@ const imageBrowser = (callback, value, meta) => {
}
}
-#image-library-item-count {
+#image-library-item-count,
+#image-gallery-item-count {
font-size: 90%;
margin-top: 8px;
color: #999;
text-align: right;
}
-.image-library-content-loading {
+.image-library-content-loading,
+.image-gallery-content-loading {
position: relative;
&::after {
@@ -695,6 +994,10 @@ const imageBrowser = (callback, value, meta) => {
#image-library-content {
height: 408px;
}
+
+ #image-gallery-content {
+ height: 408px;
+ }
}
@media only screen and (max-width: 450px) {
@@ -717,5 +1020,9 @@ const imageBrowser = (callback, value, meta) => {
#image-library-content {
height: 380px;
}
+
+ #image-gallery-content {
+ height: 400px;
+ }
}