@mapomodule/uikit 1.0.0-alpha.9 → 1.0.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.
Files changed (230) hide show
  1. package/CHANGELOG.md +853 -0
  2. package/components/ConfirmDialog.vue +58 -37
  3. package/components/Detail/Detail.vue +415 -285
  4. package/components/Detail/DetailLangSwitch.vue +8 -1
  5. package/components/DropArea.vue +62 -55
  6. package/components/Form/Form.vue +218 -0
  7. package/components/Form/FormField.vue +216 -0
  8. package/components/Form/FormGroup.vue +146 -0
  9. package/components/Form/FormTabs.vue +188 -0
  10. package/components/Form/defaults.js +98 -0
  11. package/components/Form/fields/ColorField.vue +79 -0
  12. package/components/{fields → Form/fields}/DateField.vue +12 -9
  13. package/components/Form/fields/DateTimeField.vue +271 -0
  14. package/components/Form/fields/EnhancedMediaField.vue +224 -0
  15. package/components/Form/fields/FileField.vue +125 -0
  16. package/components/Form/fields/FksField.vue +115 -0
  17. package/components/Form/fields/MediaField.vue +159 -0
  18. package/components/Form/fields/MediaM2mField.vue +149 -0
  19. package/components/Form/fields/Repeater.vue +618 -0
  20. package/components/{fields → Form/fields}/SeoPreview.vue +10 -10
  21. package/components/Form/fields/TimeField.vue +154 -0
  22. package/components/Form/fields/mapField/leaflet.injector.js +39 -0
  23. package/components/Form/fields/mapField/mapField.vue +350 -0
  24. package/components/Form/fields/wygEditor/defaults.js +25 -0
  25. package/components/{fields → Form/fields}/wygEditor/utils/mapomedia.plugin.js +7 -6
  26. package/components/{fields → Form/fields}/wygEditor/wygEditor.vue +114 -25
  27. package/components/Form/fields/wygEditorCKE/defaults.js +103 -0
  28. package/components/Form/fields/wygEditorCKE/utils/ckeditor.injector.js +29 -0
  29. package/components/Form/fields/wygEditorCKE/wygEditorCKE.vue +270 -0
  30. package/components/LangSwitcher.vue +44 -0
  31. package/components/List/List.vue +34 -17
  32. package/components/List/ListActions.vue +5 -5
  33. package/components/List/ListFilters.vue +48 -10
  34. package/components/List/ListHead.vue +1 -1
  35. package/components/List/ListQuickEdit.vue +28 -102
  36. package/components/List/ListTable.vue +89 -11
  37. package/components/Login.vue +5 -4
  38. package/components/LogoutButton.vue +43 -28
  39. package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
  40. package/components/MediaManager/MediaEditor.vue +226 -195
  41. package/components/MediaManager/MediaFileChanger.vue +78 -0
  42. package/components/MediaManager/MediaFolders.vue +207 -183
  43. package/components/MediaManager/MediaGallery.vue +212 -137
  44. package/components/MediaManager/MediaManager.vue +97 -171
  45. package/components/MediaManager/MediaManagerDialog.vue +28 -20
  46. package/components/MediaManager/MediaPreview.vue +89 -11
  47. package/components/MediaManager/MediaUploader.vue +75 -77
  48. package/components/MenuManager/MenuManager.vue +332 -0
  49. package/components/MenuManager/MenuNodeEditor.vue +270 -0
  50. package/components/MenuManager/MenuTreeview.vue +237 -0
  51. package/components/MenuManager/MenuTreeviewNode.vue +208 -0
  52. package/components/PagePreview.vue +58 -0
  53. package/components/SnackBar.vue +2 -3
  54. package/components/ThemeToggle.vue +13 -0
  55. package/components/layout/Sidebar/Sidebar.vue +48 -39
  56. package/components/layout/Sidebar/SidebarList.vue +10 -5
  57. package/components/layout/Sidebar/SidebarListItem.vue +56 -15
  58. package/components/layout/Sidebar/SidebarProfile.vue +42 -0
  59. package/components/layout/Sidebar/SidebarTitle.vue +45 -0
  60. package/components/layout/Topbar/Topbar.vue +11 -9
  61. package/components/layout/routebuilder.js +2 -2
  62. package/defaults/i18n.js +37 -0
  63. package/defaults/vuetify.js +34 -0
  64. package/layouts/default.vue +33 -7
  65. package/layouts/empty.vue +10 -0
  66. package/module.js +7 -5
  67. package/package.json +6 -4
  68. package/pages/index.vue +19 -17
  69. package/static/mapo/ckeditor/plugins/image2/dev/assets/image1.jpg +0 -0
  70. package/static/mapo/ckeditor/plugins/image2/dev/assets/image2.jpg +0 -0
  71. package/static/mapo/ckeditor/plugins/image2/dev/contents.css +35 -0
  72. package/static/mapo/ckeditor/plugins/image2/dev/image2.html +338 -0
  73. package/static/mapo/ckeditor/plugins/image2/dialogs/image2.js +557 -0
  74. package/static/mapo/ckeditor/plugins/image2/icons/hidpi/image.png +0 -0
  75. package/static/mapo/ckeditor/plugins/image2/icons/image.png +0 -0
  76. package/static/mapo/ckeditor/plugins/image2/lang/af.js +21 -0
  77. package/static/mapo/ckeditor/plugins/image2/lang/ar.js +21 -0
  78. package/static/mapo/ckeditor/plugins/image2/lang/az.js +21 -0
  79. package/static/mapo/ckeditor/plugins/image2/lang/bg.js +21 -0
  80. package/static/mapo/ckeditor/plugins/image2/lang/bn.js +21 -0
  81. package/static/mapo/ckeditor/plugins/image2/lang/bs.js +21 -0
  82. package/static/mapo/ckeditor/plugins/image2/lang/ca.js +21 -0
  83. package/static/mapo/ckeditor/plugins/image2/lang/cs.js +21 -0
  84. package/static/mapo/ckeditor/plugins/image2/lang/cy.js +21 -0
  85. package/static/mapo/ckeditor/plugins/image2/lang/da.js +21 -0
  86. package/static/mapo/ckeditor/plugins/image2/lang/de-ch.js +21 -0
  87. package/static/mapo/ckeditor/plugins/image2/lang/de.js +21 -0
  88. package/static/mapo/ckeditor/plugins/image2/lang/el.js +21 -0
  89. package/static/mapo/ckeditor/plugins/image2/lang/en-au.js +21 -0
  90. package/static/mapo/ckeditor/plugins/image2/lang/en-ca.js +21 -0
  91. package/static/mapo/ckeditor/plugins/image2/lang/en-gb.js +21 -0
  92. package/static/mapo/ckeditor/plugins/image2/lang/en.js +21 -0
  93. package/static/mapo/ckeditor/plugins/image2/lang/eo.js +21 -0
  94. package/static/mapo/ckeditor/plugins/image2/lang/es-mx.js +21 -0
  95. package/static/mapo/ckeditor/plugins/image2/lang/es.js +21 -0
  96. package/static/mapo/ckeditor/plugins/image2/lang/et.js +21 -0
  97. package/static/mapo/ckeditor/plugins/image2/lang/eu.js +21 -0
  98. package/static/mapo/ckeditor/plugins/image2/lang/fa.js +21 -0
  99. package/static/mapo/ckeditor/plugins/image2/lang/fi.js +21 -0
  100. package/static/mapo/ckeditor/plugins/image2/lang/fo.js +21 -0
  101. package/static/mapo/ckeditor/plugins/image2/lang/fr-ca.js +21 -0
  102. package/static/mapo/ckeditor/plugins/image2/lang/fr.js +21 -0
  103. package/static/mapo/ckeditor/plugins/image2/lang/gl.js +21 -0
  104. package/static/mapo/ckeditor/plugins/image2/lang/gu.js +21 -0
  105. package/static/mapo/ckeditor/plugins/image2/lang/he.js +21 -0
  106. package/static/mapo/ckeditor/plugins/image2/lang/hi.js +21 -0
  107. package/static/mapo/ckeditor/plugins/image2/lang/hr.js +21 -0
  108. package/static/mapo/ckeditor/plugins/image2/lang/hu.js +21 -0
  109. package/static/mapo/ckeditor/plugins/image2/lang/id.js +21 -0
  110. package/static/mapo/ckeditor/plugins/image2/lang/is.js +21 -0
  111. package/static/mapo/ckeditor/plugins/image2/lang/it.js +21 -0
  112. package/static/mapo/ckeditor/plugins/image2/lang/ja.js +21 -0
  113. package/static/mapo/ckeditor/plugins/image2/lang/ka.js +21 -0
  114. package/static/mapo/ckeditor/plugins/image2/lang/km.js +21 -0
  115. package/static/mapo/ckeditor/plugins/image2/lang/ko.js +21 -0
  116. package/static/mapo/ckeditor/plugins/image2/lang/ku.js +21 -0
  117. package/static/mapo/ckeditor/plugins/image2/lang/lt.js +21 -0
  118. package/static/mapo/ckeditor/plugins/image2/lang/lv.js +21 -0
  119. package/static/mapo/ckeditor/plugins/image2/lang/mk.js +21 -0
  120. package/static/mapo/ckeditor/plugins/image2/lang/mn.js +21 -0
  121. package/static/mapo/ckeditor/plugins/image2/lang/ms.js +21 -0
  122. package/static/mapo/ckeditor/plugins/image2/lang/nb.js +21 -0
  123. package/static/mapo/ckeditor/plugins/image2/lang/nl.js +21 -0
  124. package/static/mapo/ckeditor/plugins/image2/lang/no.js +21 -0
  125. package/static/mapo/ckeditor/plugins/image2/lang/oc.js +21 -0
  126. package/static/mapo/ckeditor/plugins/image2/lang/pl.js +21 -0
  127. package/static/mapo/ckeditor/plugins/image2/lang/pt-br.js +21 -0
  128. package/static/mapo/ckeditor/plugins/image2/lang/pt.js +21 -0
  129. package/static/mapo/ckeditor/plugins/image2/lang/ro.js +21 -0
  130. package/static/mapo/ckeditor/plugins/image2/lang/ru.js +21 -0
  131. package/static/mapo/ckeditor/plugins/image2/lang/si.js +21 -0
  132. package/static/mapo/ckeditor/plugins/image2/lang/sk.js +21 -0
  133. package/static/mapo/ckeditor/plugins/image2/lang/sl.js +21 -0
  134. package/static/mapo/ckeditor/plugins/image2/lang/sq.js +21 -0
  135. package/static/mapo/ckeditor/plugins/image2/lang/sr-latn.js +21 -0
  136. package/static/mapo/ckeditor/plugins/image2/lang/sr.js +21 -0
  137. package/static/mapo/ckeditor/plugins/image2/lang/sv.js +21 -0
  138. package/static/mapo/ckeditor/plugins/image2/lang/th.js +21 -0
  139. package/static/mapo/ckeditor/plugins/image2/lang/tr.js +21 -0
  140. package/static/mapo/ckeditor/plugins/image2/lang/tt.js +21 -0
  141. package/static/mapo/ckeditor/plugins/image2/lang/ug.js +21 -0
  142. package/static/mapo/ckeditor/plugins/image2/lang/uk.js +21 -0
  143. package/static/mapo/ckeditor/plugins/image2/lang/vi.js +21 -0
  144. package/static/mapo/ckeditor/plugins/image2/lang/zh-cn.js +21 -0
  145. package/static/mapo/ckeditor/plugins/image2/lang/zh.js +21 -0
  146. package/static/mapo/ckeditor/plugins/image2/plugin.js +1798 -0
  147. package/static/mapo/ckeditor/plugins/image2/samples/assets/image1.jpg +0 -0
  148. package/static/mapo/ckeditor/plugins/image2/samples/assets/image2.jpg +0 -0
  149. package/static/mapo/ckeditor/plugins/image2/samples/image2.html +68 -0
  150. package/static/mapo/ckeditor/skins/moono/dev/icons16.png +0 -0
  151. package/static/mapo/ckeditor/skins/moono/dev/icons16.svg +2374 -0
  152. package/static/mapo/ckeditor/skins/moono/dev/icons32.png +0 -0
  153. package/static/mapo/ckeditor/skins/moono/dev/icons32.svg +2722 -0
  154. package/static/mapo/ckeditor/skins/moono/dev/locations.json +144 -0
  155. package/static/mapo/ckeditor/skins/moono/dialog.css +5 -0
  156. package/static/mapo/ckeditor/skins/moono/dialog_ie.css +5 -0
  157. package/static/mapo/ckeditor/skins/moono/dialog_ie7.css +5 -0
  158. package/static/mapo/ckeditor/skins/moono/dialog_ie8.css +5 -0
  159. package/static/mapo/ckeditor/skins/moono/dialog_iequirks.css +5 -0
  160. package/static/mapo/ckeditor/skins/moono/editor.css +5 -0
  161. package/static/mapo/ckeditor/skins/moono/editor_gecko.css +5 -0
  162. package/static/mapo/ckeditor/skins/moono/editor_ie.css +5 -0
  163. package/static/mapo/ckeditor/skins/moono/editor_ie7.css +5 -0
  164. package/static/mapo/ckeditor/skins/moono/editor_ie8.css +5 -0
  165. package/static/mapo/ckeditor/skins/moono/editor_iequirks.css +5 -0
  166. package/static/mapo/ckeditor/skins/moono/icons.png +0 -0
  167. package/static/mapo/ckeditor/skins/moono/icons_hidpi.png +0 -0
  168. package/static/mapo/ckeditor/skins/moono/images/anchor.png +0 -0
  169. package/static/mapo/ckeditor/skins/moono/images/arrow.png +0 -0
  170. package/static/mapo/ckeditor/skins/moono/images/close.png +0 -0
  171. package/static/mapo/ckeditor/skins/moono/images/hidpi/anchor.png +0 -0
  172. package/static/mapo/ckeditor/skins/moono/images/hidpi/close.png +0 -0
  173. package/static/mapo/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
  174. package/static/mapo/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
  175. package/static/mapo/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
  176. package/static/mapo/ckeditor/skins/moono/images/lock-open.png +0 -0
  177. package/static/mapo/ckeditor/skins/moono/images/lock.png +0 -0
  178. package/static/mapo/ckeditor/skins/moono/images/refresh.png +0 -0
  179. package/static/mapo/ckeditor/skins/moono/images/spinner.gif +0 -0
  180. package/static/mapo/ckeditor/skins/moono/readme.md +49 -0
  181. package/static/mapo/ckeditor/skins/moono/skin.js +10 -0
  182. package/static/mapo/ckeditor/skins/moono-dark/dialog.css +5 -0
  183. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie.css +5 -0
  184. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie7.css +5 -0
  185. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie8.css +5 -0
  186. package/static/mapo/ckeditor/skins/moono-dark/dialog_iequirks.css +5 -0
  187. package/static/mapo/ckeditor/skins/moono-dark/editor.css +5 -0
  188. package/static/mapo/ckeditor/skins/moono-dark/editor_gecko.css +5 -0
  189. package/static/mapo/ckeditor/skins/moono-dark/editor_ie.css +5 -0
  190. package/static/mapo/ckeditor/skins/moono-dark/editor_ie7.css +5 -0
  191. package/static/mapo/ckeditor/skins/moono-dark/editor_ie8.css +5 -0
  192. package/static/mapo/ckeditor/skins/moono-dark/editor_iequirks.css +5 -0
  193. package/static/mapo/ckeditor/skins/moono-dark/icons.png +0 -0
  194. package/static/mapo/ckeditor/skins/moono-dark/icons_hidpi.png +0 -0
  195. package/static/mapo/ckeditor/skins/moono-dark/images/arrow.png +0 -0
  196. package/static/mapo/ckeditor/skins/moono-dark/images/close.png +0 -0
  197. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/close.png +0 -0
  198. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock-open.png +0 -0
  199. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock.png +0 -0
  200. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/refresh.png +0 -0
  201. package/static/mapo/ckeditor/skins/moono-dark/images/lock-open.png +0 -0
  202. package/static/mapo/ckeditor/skins/moono-dark/images/lock.png +0 -0
  203. package/static/mapo/ckeditor/skins/moono-dark/images/refresh.png +0 -0
  204. package/static/mapo/ckeditor/skins/moono-dark/readme.md +51 -0
  205. package/static/mapo/ckeditor/skins/moono-dark/skin.js +5 -0
  206. package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
  207. package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
  208. package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
  209. package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
  210. package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
  211. package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
  212. package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
  213. package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
  214. package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
  215. package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
  216. package/translations/en-US.js +177 -0
  217. package/translations/it-IT.js +180 -0
  218. package/LICENSE.md +0 -20
  219. package/components/Detail/DetailField.vue +0 -142
  220. package/components/Detail/defaults.js +0 -57
  221. package/components/fields/FksField.vue +0 -60
  222. package/components/fields/MediaField.vue +0 -213
  223. package/components/fields/MediaM2mField.vue +0 -243
  224. package/components/fields/wygEditor/defaults.js +0 -55
  225. package/components/layout/Sidebar/SidebarFooter.vue +0 -71
  226. package/defaults.js +0 -29
  227. package/layouts/error.vue +0 -45
  228. /package/components/{fields → Form/fields}/wygEditor/utils/events.js +0 -0
  229. /package/components/{fields/wygEditor/utils/script.injector.js → Form/fields/wygEditor/utils/tinymce.injector.js} +0 -0
  230. /package/static/{favicon.ico → mapo/favicon.ico} +0 -0
@@ -0,0 +1,154 @@
1
+ <template>
2
+ <div>
3
+ <v-menu
4
+ ref="menu"
5
+ v-model="menu"
6
+ :close-on-content-click="false"
7
+ transition="scale-transition"
8
+ offset-y
9
+ min-width="auto"
10
+ >
11
+ <template v-slot:activator="{ on, attrs }">
12
+ <v-text-field
13
+ v-model="localModel"
14
+ prepend-inner-icon="mdi-clock"
15
+ v-bind="{ ...$attrs, ...attrs }"
16
+ v-on="readonly ? undefined : on"
17
+ readonly
18
+ :clearable="!readonly"
19
+ class="rounded-inherit"
20
+ ></v-text-field>
21
+ </template>
22
+ <v-time-picker v-model="localModel" no-title v-bind="$attrs" ref="timePicker">
23
+ <div class="raw-input-container">
24
+ <input
25
+ :value="localModel"
26
+ type="time"
27
+ class="primary--text text-h6"
28
+ ref="rawInput"
29
+ @input="setModel"
30
+ autofocus
31
+ v-bind="$attrs"
32
+ />
33
+ </div>
34
+ <v-btn text @click="menu = false">{{ $t('mapo.ok') }}</v-btn>
35
+ </v-time-picker>
36
+ </v-menu>
37
+ </div>
38
+ </template>
39
+
40
+ <style scoped>
41
+ .rounded-inherit {
42
+ border-radius: inherit;
43
+ }
44
+ .raw-input-container {
45
+ width: 100%;
46
+ }
47
+ .raw-input-container input {
48
+ width: 100%;
49
+ text-align: center;
50
+ outline: none;
51
+ }
52
+ </style>
53
+
54
+ <script>
55
+ import {
56
+ formatLocalTime,
57
+ cleanDateStr,
58
+ formatUTCTime,
59
+ mergeTime,
60
+ } from "@mapomodule/utils/helpers/datetime";
61
+
62
+ /**
63
+ * This component is used to edit a time in iso format. It is a combination of "v-text-field" and "v-time-picker".
64
+ * Can get time from a full ISO date (as string in UTC timezone) or from string in a HH:MM:ss format.
65
+ */
66
+ export default {
67
+ name: "TimeField",
68
+ data() {
69
+ return {
70
+ model: { model: null, returnDate: false },
71
+ menu: null,
72
+ isUpdating: false, // Add a flag to track updates
73
+ };
74
+ },
75
+ props: {
76
+ // V-model property. Is the time to be modified.
77
+ value: {
78
+ // `String`
79
+ type: String, // TODO: make it work also with arrays for ranges
80
+ },
81
+ // This set the component status to readonly, stopping the user interaction.
82
+ readonly: {
83
+ type: Boolean,
84
+ default: false,
85
+ },
86
+ },
87
+ watch: {
88
+ value(val) {
89
+ if (!this.isUpdating) { // Check if an update is already in progress
90
+ const model = this.setupModel(val);
91
+ if (JSON.stringify(model) !== JSON.stringify(this.model)) {
92
+ this.isUpdating = true; // Set the flag to indicate an update is in progress
93
+ this.model = model;
94
+ }
95
+ }
96
+ },
97
+ model: {
98
+ handler: function (val) {
99
+ // Fired when the v-model changes
100
+ //@arg Emits the time edited.
101
+ if (val.returnDate) this.$emit("input", val.model.toISOString());
102
+ else this.$emit("input", formatUTCTime(val.model));
103
+ },
104
+ deep: true,
105
+ },
106
+ menu(val) {
107
+ if (val)
108
+ setTimeout(() => {
109
+ this.$refs.rawInput.focus();
110
+ });
111
+ },
112
+ },
113
+ computed: {
114
+ localModel: {
115
+ get() {
116
+ return this.model?.model && formatLocalTime(this.model?.model);
117
+ },
118
+ set(value) {
119
+ this.model.model = mergeTime(this?.model?.model || new Date(), value);
120
+ },
121
+ },
122
+ },
123
+ methods: {
124
+ setModel(evt) {
125
+ const model = evt.target.value;
126
+ const currentValue = this.localModel?.split(":") || [];
127
+ const nextValue = model?.split(":") || [];
128
+ for (
129
+ let index = 0;
130
+ index < Math.min(currentValue.length, nextValue.length);
131
+ index++
132
+ ) {
133
+ if (currentValue[index] != nextValue[index]) {
134
+ this.$refs.timePicker.selecting = index + 1;
135
+ break;
136
+ }
137
+ }
138
+ this.localModel = model;
139
+ },
140
+ setupModel(val) {
141
+ const d = new Date(cleanDateStr(val));
142
+ const returnDate = !isNaN(d);
143
+ const model = !isNaN(d) ? d : mergeTime(new Date(), cleanDateStr(val));
144
+ return { returnDate, model };
145
+ },
146
+ },
147
+ mounted() {
148
+ this.model = this.setupModel(this.value); // Initialize the model on mount
149
+ },
150
+ updated() {
151
+ this.isUpdating = false; // Reset the flag after the component updates
152
+ },
153
+ };
154
+ </script>
@@ -0,0 +1,39 @@
1
+ export default async function () {
2
+ return new Promise((resolve, reject) => {
3
+ if (typeof window.L !== 'undefined'){
4
+ resolve()
5
+ }
6
+ let scriptTag = document.getElementById("leaflet-script") || null
7
+ let styleTag = document.getElementById("leaflet-style") || null
8
+ const handler = () => {
9
+ scriptTag.removeEventListener('load', handler);
10
+ resolve()
11
+ };
12
+ if (!scriptTag) {
13
+ try {
14
+ scriptTag = document.createElement('script');
15
+ scriptTag.src = "https://unpkg.com/leaflet@1.7.1/dist/leaflet.js",
16
+ scriptTag.crossorigin = "anonymous",
17
+ scriptTag.async = true,
18
+ scriptTag.referrerPolicy = 'origin';
19
+ scriptTag.type = 'application/javascript';
20
+ scriptTag.id = 'leaflet-script';
21
+ scriptTag.addEventListener('load', handler);
22
+ document.head.appendChild(scriptTag);
23
+ styleTag = document.createElement('link');
24
+
25
+ styleTag.rel = "stylesheet",
26
+ styleTag.href = "https://unpkg.com/leaflet@1.7.1/dist/leaflet.css",
27
+ styleTag.crossorigin = "anonymous",
28
+ styleTag.id = 'leaflet-style';
29
+ document.head.appendChild(styleTag);
30
+
31
+
32
+ } catch (error) {
33
+ reject(error)
34
+ }
35
+ } else {
36
+ scriptTag.addEventListener('load', handler);
37
+ }
38
+ })
39
+ }
@@ -0,0 +1,350 @@
1
+ <template>
2
+ <div>
3
+ <span v-if="label" class="v-label" :class="{'error--text': hasErrors, 'text--secondary': !hasErrors}">{{ label }}:</span>
4
+ <div ref="map" class="map"></div>
5
+ <div class="map-fields">
6
+ <div class="row search-row">
7
+ <div class="col-sm-12" style="padding: 0px">
8
+ <v-text-field
9
+ v-model="searchQuery"
10
+ :label="$t('mapo.searchLocation')"
11
+ @input="debouncedSearchLocation()"
12
+ v-bind="{ ...$attrs }"
13
+ class="col"
14
+ />
15
+ </div>
16
+ </div>
17
+ <div class="row input-gap" style="margin-top: 1rem;" v-for="(point, index) in model" :key="index">
18
+ <div class="col-sm-12"><v-divider></v-divider></div>
19
+ <div class="col-sm-6">
20
+ <div class="row">
21
+ <v-text-field
22
+ v-model="point.pointName"
23
+ :label="$t('mapo.pointName')"
24
+ v-bind="{ ...$attrs }"
25
+ ref="pointName"
26
+ />
27
+ </div>
28
+ </div>
29
+ <div class="col">
30
+ <div class="row">
31
+ <v-text-field
32
+ v-model="point.lat"
33
+ :label="$t('mapo.latitude')"
34
+ v-bind="{ ...$attrs }"
35
+ readonly
36
+ class="col-5"
37
+ />
38
+ <v-text-field
39
+ v-model="point.lon"
40
+ :label="$t('mapo.longitude')"
41
+ v-bind="{ ...$attrs }"
42
+ readonly
43
+ class="col-5"
44
+ />
45
+ <v-btn
46
+ v-if="!readonly"
47
+ @click="removePointFromModel(index)"
48
+ class="col"
49
+ icon
50
+ ><v-icon>mdi-close</v-icon></v-btn
51
+ >
52
+ </div>
53
+ </div>
54
+ <div class="col-sm-12">
55
+ <div class="row">
56
+ <Form
57
+ v-model="point.extra_fields"
58
+ :fields="getFields(model.extra_fields)"
59
+ :errors="getErrors(index)"
60
+ :readonly="readonly"
61
+ immediate
62
+ >
63
+ <template
64
+ v-for="(slot, name) in templateSlots(model, $slots)"
65
+ :slot="slot"
66
+ >
67
+ <slot :name="name"></slot>
68
+ </template>
69
+ <template
70
+ v-for="(slot, name) in templateSlots(model, $scopedSlots)"
71
+ v-slot:[slot]="props"
72
+ >
73
+ <slot :name="name" v-bind="props" />
74
+ </template>
75
+ </Form>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </template>
82
+
83
+ <style>
84
+ .map {
85
+ height: 400px;
86
+ width: 100%;
87
+ }
88
+ .map-fields {
89
+ margin-top: 10px;
90
+ max-width: 100%;
91
+ padding: 12px;
92
+ }
93
+ .input-gap {
94
+ gap: 8px;
95
+ }
96
+ .search-row {
97
+ margin-bottom: 10px;
98
+ & > div {
99
+ padding: 0 !important;
100
+ }
101
+ }
102
+ </style>
103
+
104
+ <script>
105
+ /**
106
+ * This component is made to get coordinates from a map.
107
+ */
108
+ import { debounce } from "@mapomodule/utils/helpers/debounce";
109
+ import injectScript from "./leaflet.injector.js";
110
+ import { nameSpacedSlots } from "@mapomodule/utils/helpers/slots";
111
+
112
+ export default {
113
+ name: "MapField",
114
+ components: {
115
+ // For recursive dynamic components is better to resolve dependencies at runtime to avoid circular deps
116
+ Form: () => import("@mapomodule/uikit/components/Form/Form.vue"),
117
+ },
118
+ props: {
119
+ // V-model property.
120
+ value: {
121
+ type: Array,
122
+ default: () => [],
123
+ },
124
+ // This label will be shown at the top of the editor.
125
+ label: String,
126
+ // This set the component status to readonly, stopping the user interaction.
127
+ readonly: {
128
+ type: Boolean,
129
+ default: false,
130
+ },
131
+ // This set the component status to multiple, allowing the user to add multiple points. Pass it into attrs
132
+ multiple: {
133
+ type: Boolean,
134
+ default: false,
135
+ },
136
+ fields: {
137
+ // [`Array<FieldConfiguration>`](/components/Detail/Detail/#fieldconfiguration)
138
+ type: Array | Object,
139
+ default: () => [],
140
+ },
141
+ // Puts the input in an error state and passes through custom error messages.
142
+ errorMessages: {
143
+ type: Array,
144
+ default: () => [],
145
+ },
146
+ },
147
+ data() {
148
+ return {
149
+ model: this.value || [],
150
+ map: null,
151
+ searchQuery: "",
152
+ markers: [],
153
+ };
154
+ },
155
+ watch: {
156
+ value(val) {
157
+ this.model = val || [];
158
+ },
159
+ model(val) {
160
+ this.$emit("input", val);
161
+ },
162
+ },
163
+ mounted() {
164
+ injectScript().then(this.initMap);
165
+ },
166
+ methods: {
167
+ initMap() {
168
+ const coordinates = this.model || [];
169
+ if (coordinates.length > 0) {
170
+ const { lat, lon } = coordinates[coordinates.length - 1];
171
+ this.map = L.map(this.$refs.map).setView([lat, lon], 12);
172
+ coordinates.forEach((point, index) => {
173
+ const marker = L.marker([point.lat, point.lon]).addTo(this.map);
174
+ this.markers[index] = marker;
175
+ });
176
+ this.map.fitBounds(coordinates.map((point) => [point.lat, point.lon]));
177
+ } else {
178
+ this.map = L.map(this.$refs.map).setView([0, 0], 2);
179
+ }
180
+ L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
181
+ attribution: "© OpenStreetMap contributors",
182
+ }).addTo(this.map);
183
+ this.handleClickOnMap();
184
+ },
185
+ handleClickOnMap() {
186
+ this.map.on("click", async (event) => {
187
+ const coordinates = event.latlng;
188
+
189
+ if (!this.multiple) {
190
+ this.removeAllMarkers();
191
+ this.model = [];
192
+ }
193
+
194
+ this.model.push({
195
+ lat: coordinates.lat,
196
+ lon: coordinates.lng,
197
+ pointName: "",
198
+ extra_fields: {},
199
+ });
200
+
201
+ const marker = L.marker([coordinates.lat, coordinates.lng]).addTo(
202
+ this.map
203
+ );
204
+ this.markers.push(marker);
205
+ await this.reverseGeoCoding(coordinates.lat, coordinates.lng);
206
+ });
207
+ },
208
+ removeAllMarkers() {
209
+ this.markers.forEach((marker) => this.map.removeLayer(marker));
210
+ this.markers = [];
211
+ },
212
+ async reverseGeoCoding(lat, lon) {
213
+ const reverseGeocodingResponse = await this.$axios.get(
214
+ "https://nominatim.openstreetmap.org/reverse",
215
+ {
216
+ params: {
217
+ lat,
218
+ lon,
219
+ format: "json",
220
+ addressdetails: 1,
221
+ "accept-language": this.$attrs.currentLang || "en",
222
+ },
223
+ }
224
+ );
225
+
226
+ if (
227
+ reverseGeocodingResponse.data &&
228
+ reverseGeocodingResponse.data.display_name
229
+ ) {
230
+ this.model[this.currentIndex].pointName =
231
+ reverseGeocodingResponse.data.display_name;
232
+ } else {
233
+ this.model[this.currentIndex].pointName = this.searchQuery;
234
+ }
235
+ },
236
+ removePointFromModel(index) {
237
+ this.map.removeLayer(this.markers[index]);
238
+ this.markers.splice(index, 1);
239
+ this.model.splice(index, 1);
240
+
241
+ if (this.model.length > 0) {
242
+ this.map.fitBounds(this.model.map((point) => [point.lat, point.lon]));
243
+ } else {
244
+ this.map.setView([0, 0], 2);
245
+ }
246
+ },
247
+ async searchLocation() {
248
+ try {
249
+ const response = await this.$axios.get(
250
+ "https://nominatim.openstreetmap.org/search",
251
+ {
252
+ params: {
253
+ q: this.searchQuery,
254
+ format: "json",
255
+ limit: 1,
256
+ },
257
+ }
258
+ );
259
+
260
+ if (response.data.length > 0) {
261
+ if (!this.multiple) {
262
+ this.removeAllMarkers();
263
+ this.model = [];
264
+ }
265
+ const { lat, lon } = response.data[0];
266
+ this.map.setView([lat, lon], 12);
267
+
268
+ const marker = L.marker([lat, lon]).addTo(this.map);
269
+ this.markers.push(marker);
270
+
271
+ this.model.push({
272
+ lat,
273
+ lon,
274
+ pointName: this.searchQuery,
275
+ extra_fields: {},
276
+ });
277
+
278
+ await this.reverseGeoCoding(lat, lon);
279
+ this.map.fitBounds(this.model.map((point) => [point.lat, point.lon]));
280
+ }
281
+ } catch (error) {
282
+ console.error(`${this.$t("mapo.error.searchError")}: `, error);
283
+ }
284
+ },
285
+ debouncedSearchLocation: debounce(function () {
286
+ this.searchLocation();
287
+ }, 500),
288
+ getErrors(index) {
289
+ return (this.errorMessages[index]) || {};
290
+ },
291
+ getFields(model) {
292
+ if (this.hasTemplates) {
293
+ const template = this.templates.find(
294
+ (t) => model[t.tCodeField] == t.tCode
295
+ );
296
+ return template ? template.fields : [];
297
+ }
298
+ return this.fields;
299
+ },
300
+ templateSlots(model, slots) {
301
+ if (this.hasTemplates) {
302
+ const template = this.templates.find(
303
+ (t) => model[t.tCodeField] == t.tCode
304
+ );
305
+ return nameSpacedSlots(slots, `template.${template.tCode}.`).reduce(
306
+ (acc, v) => ({ [`template.${template.tCode}.${v}`]: v, ...acc }),
307
+ {}
308
+ );
309
+ }
310
+ return Object.keys(slots).reduce((acc, v) => ({ [v]: v, ...acc }), {});
311
+ },
312
+ },
313
+ computed: {
314
+ lat() {
315
+ return this.model?.lat || "";
316
+ },
317
+ lon() {
318
+ return this.model?.lon || "";
319
+ },
320
+ pointName() {
321
+ return this.model?.pointName || "";
322
+ },
323
+ currentIndex() {
324
+ return this.model.length > 0 ? this.model.length - 1 : 0;
325
+ },
326
+ hasTemplates() {
327
+ return typeof this.fields == "object" && !Array.isArray(this.fields);
328
+ },
329
+ hasErrors () { return this.errorMessages && this.errorMessages.length },
330
+ templates() {
331
+ const templates = {};
332
+ if (this.hasTemplates) {
333
+ Object.keys(this.fields).forEach((tKey) => {
334
+ const tValue = this.fields[tKey];
335
+ const { preview, description } = tValue;
336
+ templates[tKey] = {
337
+ fields: tValue.fields || tValue,
338
+ name: tValue.name || titleCase(tKey.replace(/_/, " ")),
339
+ tCode: tValue.tCode || tKey,
340
+ tCodeField: tValue.tCodeField || "tCode",
341
+ preview,
342
+ description,
343
+ };
344
+ });
345
+ }
346
+ return Object.values(templates);
347
+ },
348
+ },
349
+ };
350
+ </script>
@@ -0,0 +1,25 @@
1
+ export default ({ isDark, base }) => ({
2
+ plugins: "mapomedia preview paste importcss searchreplace autolink directionality code visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount textpattern noneditable help charmap quickbars emoticons",
3
+ menubar: "file edit view insert format tools table help",
4
+ menu: {
5
+ insert: {
6
+ title: "Insert",
7
+ items: "link mapomedia media template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor | insertdatetime",
8
+ },
9
+ },
10
+ toolbar: "undo redo | bold italic underline strikethrough | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview | mapomedia media template link anchor codesample | ltr rtl",
11
+ toolbar_sticky: true,
12
+ image_advtab: true,
13
+ importcss_append: true,
14
+ template_cdate_format: "[Date Created (CDATE): %m/%d/%Y : %H:%M:%S]",
15
+ template_mdate_format: "[Date Modified (MDATE): %m/%d/%Y : %H:%M:%S]",
16
+ height: 400,
17
+ image_caption: true,
18
+ quickbars_insert_toolbar: "mapomedia quicktable",
19
+ quickbars_selection_toolbar: "bold italic | quicklink h2 h3 blockquote mapomedia quicktable",
20
+ noneditable_noneditable_class: "mceNonEditable",
21
+ toolbar_mode: "sliding",
22
+ contextmenu: "link mapomedia table",
23
+ skin_url: isDark ? `${base}mapo/tinymce-skins/mapo-dark` : `${base}mapo/tinymce-skins/mapo-light`,
24
+ content_style: "body { font-family:Helvetica,Arial,sans-serif; font-size:14px }",
25
+ });
@@ -1,24 +1,25 @@
1
1
  export default function (callback) {
2
2
  const pluginmanager = window.tinymce.util.Tools.resolve('tinymce.PluginManager');
3
- pluginmanager.add('mapomedia', function (editor, url) {
4
- const conf = ['mapomedia', {
3
+ const pluginname = "mapomedia"
4
+ pluginmanager.add(pluginname, function (editor, url) {
5
+ const conf = {
5
6
  icon: 'image',
6
- text: 'Mapo Media',
7
+ tooltip: 'Insert image/video/audio/docs',
7
8
  onAction: () => callback().then(html => {
8
9
  editor.focus();
9
10
  editor.undoManager.transact(() => editor.selection.setContent(html))
10
11
  editor.selection.setCursorLocation();
11
12
  editor.nodeChanged();
12
13
  }).catch(() => null)
13
- }]
14
+ }
14
15
  editor.addCommand('mceMapoMedia', () => callback().then(html => {
15
16
  editor.focus();
16
17
  editor.undoManager.transact(() => editor.selection.setContent(html))
17
18
  editor.selection.setCursorLocation();
18
19
  editor.nodeChanged();
19
20
  }).catch(() => null))
20
- editor.ui.registry.addButton(...conf);
21
- editor.ui.registry.addMenuItem(...conf);
21
+ editor.ui.registry.addButton(pluginname, conf);
22
+ editor.ui.registry.addMenuItem(pluginname, { text: "Mapo Media...", ...conf });
22
23
  return {
23
24
  getMetadata: function () {
24
25
  return {