@dative-gpi/foundation-shared-components 0.1.120 → 1.0.1
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/assets/images/map/imagery.png +0 -0
- package/assets/images/map/map.png +0 -0
- package/components/FSAccordion.vue +2 -1
- package/components/FSAccordionPanel.vue +20 -1
- package/components/FSBadge.vue +7 -3
- package/components/FSBreadcrumbs.vue +4 -2
- package/components/FSButton.vue +15 -8
- package/components/FSCalendar.vue +5 -2
- package/components/FSCalendarTwin.vue +6 -3
- package/components/FSCard.vue +4 -2
- package/components/FSCardPlaceholder.vue +80 -0
- package/components/FSCheckbox.vue +10 -7
- package/components/FSChip.vue +4 -2
- package/components/FSClickable.vue +5 -3
- package/components/FSClock.vue +18 -4
- package/components/FSCol.vue +12 -5
- package/components/FSColor.vue +4 -2
- package/components/FSColorIcon.vue +5 -3
- package/components/FSDialog.vue +28 -87
- package/components/FSDialogContent.vue +133 -0
- package/components/FSDialogForm.vue +25 -236
- package/components/FSDialogFormBody.vue +273 -0
- package/components/FSDialogMenu.vue +5 -2
- package/components/FSDialogMultiForm.vue +21 -197
- package/components/FSDialogMultiFormBody.vue +231 -0
- package/components/FSDialogSubmit.vue +4 -2
- package/components/FSDivider.vue +6 -4
- package/components/FSEditImage.vue +16 -9
- package/components/FSErrorToast.vue +2 -1
- package/components/FSFadeOut.vue +1 -1
- package/components/FSForm.vue +7 -7
- package/components/FSGrid.vue +4 -2
- package/components/FSGridMosaic.vue +3 -2
- package/components/FSIcon.vue +3 -2
- package/components/FSIconCard.vue +10 -3
- package/components/FSIconCheck.vue +2 -1
- package/components/FSIconFlag.vue +2 -1
- package/components/FSImage.vue +2 -1
- package/components/FSImageCard.vue +72 -0
- package/components/FSLabel.vue +4 -2
- package/components/FSLink.vue +5 -3
- package/components/FSLoader.vue +2 -1
- package/components/FSOptionGroup.vue +28 -20
- package/components/FSOptionItem.vue +8 -18
- package/components/FSPagination.vue +4 -2
- package/components/FSRadio.vue +23 -11
- package/components/FSRadioGroup.vue +23 -10
- package/components/FSRow.vue +8 -1
- package/components/FSSlideGroup.vue +27 -6
- package/components/FSSlider.vue +4 -2
- package/components/FSSpan.vue +2 -1
- package/components/FSSwitch.vue +13 -10
- package/components/FSTab.vue +4 -2
- package/components/FSTabs.vue +5 -14
- package/components/FSTag.vue +11 -4
- package/components/FSTagGroup.vue +4 -2
- package/components/FSText.vue +4 -2
- package/components/FSToggleSet.vue +30 -17
- package/components/FSTooltip.vue +15 -4
- package/components/FSWindow.vue +2 -2
- package/components/FSWrapGroup.vue +2 -1
- package/components/autocompletes/FSAutoCompleteAddress.vue +104 -0
- package/components/autocompletes/FSAutocompleteLanguage.vue +18 -26
- package/components/autocompletes/FSAutocompleteTag.vue +138 -0
- package/components/autocompletes/FSAutocompleteTimeZone.vue +19 -30
- package/components/buttons/FSButtonAdd.vue +28 -0
- package/components/buttons/FSButtonAddIcon.vue +28 -0
- package/components/buttons/FSButtonAddLabel.vue +27 -0
- package/components/buttons/FSButtonAddMini.vue +27 -0
- package/components/buttons/FSButtonFile.vue +4 -4
- package/components/buttons/FSButtonFileIcon.vue +4 -4
- package/components/buttons/FSButtonFileLabel.vue +4 -4
- package/components/buttons/FSButtonFileMini.vue +4 -4
- package/components/deviceOrganisations/FSConnectivity.vue +3 -2
- package/components/deviceOrganisations/FSConnectivityCard.vue +3 -2
- package/components/deviceOrganisations/FSStatus.vue +3 -2
- package/components/deviceOrganisations/FSStatusCard.vue +3 -2
- package/components/deviceOrganisations/FSStatusesCarousel.vue +3 -2
- package/components/deviceOrganisations/FSStatusesRow.vue +3 -2
- package/components/deviceOrganisations/FSWorstAlert.vue +5 -4
- package/components/deviceOrganisations/FSWorstAlertCard.vue +4 -2
- package/components/fields/FSAutocompleteField.vue +219 -97
- package/components/fields/FSBaseField.vue +2 -1
- package/components/fields/FSColorField.vue +65 -94
- package/components/fields/FSDateField.vue +12 -25
- package/components/fields/FSDateRangeField.vue +15 -27
- package/components/fields/FSDateTimeField.vue +22 -32
- package/components/fields/FSDateTimeRangeField.vue +43 -51
- package/components/fields/FSGradientField.vue +143 -0
- package/components/fields/FSIconField.vue +9 -6
- package/components/fields/FSMagicConfigField.vue +154 -0
- package/components/fields/FSMagicField.vue +185 -0
- package/components/fields/FSNumberField.vue +3 -1
- package/components/fields/FSPasswordField.vue +10 -10
- package/components/fields/FSRichTextField.vue +136 -50
- package/components/fields/FSSearchField.vue +41 -62
- package/components/fields/FSSelectField.vue +148 -53
- package/components/fields/FSTagField.vue +19 -16
- package/components/fields/FSTermField.vue +192 -186
- package/components/fields/FSTextArea.vue +4 -4
- package/components/fields/FSTextField.vue +29 -6
- package/components/fields/FSTimeField.vue +55 -20
- package/components/fields/FSTimeSlotField.vue +6 -5
- package/components/fields/FSTranslateField.vue +234 -0
- package/components/fields/FSTranslateRichTextField.vue +185 -0
- package/components/fields/FSTreeViewField.vue +520 -0
- package/components/lists/FSDataIteratorItem.vue +18 -3
- package/components/lists/FSDataTableUI.vue +138 -51
- package/components/lists/FSFilterButton.vue +4 -2
- package/components/lists/FSHiddenButton.vue +4 -2
- package/components/map/FSMap.vue +598 -0
- package/components/map/FSMapEditPointAddressOverlay.vue +164 -0
- package/components/map/FSMapLayerButton.vue +77 -0
- package/components/map/FSMapOverlay.vue +150 -0
- package/components/selects/FSSelectAutoRefresh.vue +62 -0
- package/components/selects/FSSelectDashboardVariableType.vue +47 -0
- package/components/selects/FSSelectDateSetting.vue +39 -37
- package/components/selects/FSSelectDays.vue +62 -0
- package/components/tiles/FSDashboardOrganisationTileUI.vue +8 -8
- package/components/tiles/FSDashboardOrganisationTypeTileUI.vue +8 -8
- package/components/tiles/FSDashboardShallowTileUI.vue +8 -8
- package/components/tiles/FSDeviceOrganisationTileUI.vue +20 -15
- package/components/tiles/FSFolderTileUI.vue +7 -7
- package/components/tiles/FSGroupTileUI.vue +34 -27
- package/components/tiles/FSServiceAccountOrganisationTileUI.vue +142 -0
- package/components/tiles/{FSSimpleIconTileUI.vue → FSSimpleTileUI.vue} +48 -25
- package/components/tiles/FSTile.vue +51 -13
- package/components/tiles/FSUserOrganisationTileUI.vue +25 -34
- package/components/toggleSets/FSToggleSetPosition.vue +61 -0
- package/composables/index.ts +5 -1
- package/composables/useAddress.ts +158 -0
- package/composables/useAutocomplete.ts +4 -3
- package/composables/useColors.ts +8 -25
- package/composables/useDebounce.ts +2 -1
- package/composables/useMagicFieldProvider.ts +22 -0
- package/composables/useRules.ts +4 -12
- package/composables/useSlots.ts +65 -27
- package/composables/useTables.ts +29 -0
- package/composables/useTreeView.ts +48 -0
- package/elements/FSFormElement.ts +2 -1
- package/icons/flags/France.vue +21 -5
- package/icons/flags/Germany.vue +16 -4
- package/icons/flags/GreatBritain.vue +25 -6
- package/icons/flags/Italy.vue +21 -5
- package/icons/flags/Portugal.vue +225 -51
- package/icons/flags/Spain.vue +2781 -543
- package/icons/flags/UnitedStates.vue +31 -7
- package/icons/widgetTemplates/DevicesWidget.vue +189 -189
- package/icons/widgetTemplates/ProfileWidget.vue +9 -9
- package/icons/widgetTemplates/TextWidget.vue +6 -6
- package/models/breadcrumbs.ts +1 -1
- package/models/deviceAlerts.ts +1 -1
- package/models/deviceConnectivities.ts +1 -1
- package/models/index.ts +2 -0
- package/models/magicFields.ts +9 -0
- package/models/map.ts +18 -0
- package/models/richTextVariable.ts +5 -0
- package/models/rules.ts +11 -2
- package/models/tables.ts +30 -21
- package/models/variableNode.ts +104 -0
- package/package.json +21 -18
- package/plugins/colorPlugin.ts +2 -2
- package/plugins/index.ts +2 -1
- package/plugins/mapsPlugin.ts +37 -0
- package/shims-plugin.d.ts +2 -2
- package/shims-window.d.ts +3 -0
- package/styles/components/fs_button.scss +5 -0
- package/styles/components/fs_card.scss +0 -1
- package/styles/components/fs_col.scss +1 -0
- package/styles/components/fs_color_field.scss +12 -2
- package/styles/components/fs_data_iterator_item.scss +19 -6
- package/styles/components/fs_dialog.scss +12 -22
- package/styles/components/fs_gradient_field.scss +16 -0
- package/styles/components/fs_image_card.scss +18 -0
- package/styles/components/fs_magic_config_field.scss +13 -0
- package/styles/components/fs_map.scss +129 -0
- package/styles/components/fs_map_overlay.scss +38 -0
- package/styles/components/fs_meta_field.scss +6 -0
- package/styles/components/fs_option_group.scss +1 -0
- package/styles/components/fs_radio.scss +1 -1
- package/styles/components/fs_rich_text_field.scss +17 -5
- package/styles/components/fs_row.scss +1 -1
- package/styles/components/fs_select_field.scss +9 -14
- package/styles/components/fs_text.scss +1 -1
- package/styles/components/fs_time_field.scss +0 -4
- package/styles/components/fs_translate_field.scss +3 -0
- package/styles/components/fs_tree_view_field.scss +53 -0
- package/styles/components/index.scss +8 -1
- package/styles/globals/overrides.scss +54 -8
- package/styles/globals/scrollbars.scss +2 -2
- package/themes/default.ts +1 -1
- package/utils/gradient.ts +1601 -0
- package/utils/index.ts +3 -1
- package/utils/leafletMarkers.ts +23 -0
- package/utils/lexical.ts +3 -1
- package/components/selects/FSSelectTimeZone.vue +0 -67
- package/styles/components/fs_date_field.scss +0 -8
|
@@ -115,6 +115,37 @@
|
|
|
115
115
|
>
|
|
116
116
|
mdi-link
|
|
117
117
|
</FSIcon>
|
|
118
|
+
<v-menu
|
|
119
|
+
v-if="$props.variableReferences && $props.variableReferences.length > 0"
|
|
120
|
+
:closeOnContentClick="false"
|
|
121
|
+
v-model="menuVariable"
|
|
122
|
+
>
|
|
123
|
+
<template
|
|
124
|
+
v-slot:activator="{ props }"
|
|
125
|
+
>
|
|
126
|
+
<FSIcon
|
|
127
|
+
v-bind="props"
|
|
128
|
+
class="fs-rich-text-field-icon"
|
|
129
|
+
:color="toolbarColors.variable"
|
|
130
|
+
:style="style"
|
|
131
|
+
>
|
|
132
|
+
mdi-variable
|
|
133
|
+
</FSIcon>
|
|
134
|
+
</template>
|
|
135
|
+
<FSCard
|
|
136
|
+
padding="12"
|
|
137
|
+
width="300px"
|
|
138
|
+
:elevation="true"
|
|
139
|
+
>
|
|
140
|
+
<FSAutoCompleteField
|
|
141
|
+
itemTitle="label"
|
|
142
|
+
itemValue="code"
|
|
143
|
+
:placeholder="$tr('ui.rich-text-field.variable-placeholder', 'Choose a variable...')"
|
|
144
|
+
:items="$props.variableReferences"
|
|
145
|
+
@update:modelValue="insertVariable($event)"
|
|
146
|
+
/>
|
|
147
|
+
</FSCard>
|
|
148
|
+
</v-menu>
|
|
118
149
|
<v-divider
|
|
119
150
|
vertical
|
|
120
151
|
/>
|
|
@@ -150,10 +181,21 @@
|
|
|
150
181
|
</FSRow>
|
|
151
182
|
<div
|
|
152
183
|
class="fs-rich-text-field"
|
|
153
|
-
:id="id"
|
|
154
184
|
:style="style"
|
|
155
|
-
|
|
156
|
-
|
|
185
|
+
>
|
|
186
|
+
<div
|
|
187
|
+
class="fs-rich-text-field-content"
|
|
188
|
+
:data-variable-values="JSON.stringify($props.variableValues)"
|
|
189
|
+
:contenteditable="!readonly && $props.editable"
|
|
190
|
+
:data-readonly="$props.variant === 'readonly'"
|
|
191
|
+
:id="id"
|
|
192
|
+
/>
|
|
193
|
+
<slot
|
|
194
|
+
name="append-inner"
|
|
195
|
+
v-bind="{ props: $props }"
|
|
196
|
+
/>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
157
199
|
<FSTextField
|
|
158
200
|
v-if="isLink && !readonly && $props.editable"
|
|
159
201
|
:hideHeader="true"
|
|
@@ -176,27 +218,35 @@
|
|
|
176
218
|
</template>
|
|
177
219
|
|
|
178
220
|
<script lang="ts">
|
|
179
|
-
import {
|
|
180
|
-
|
|
221
|
+
import { computed, defineComponent, onMounted, type PropType, ref, watch } from "vue";
|
|
222
|
+
|
|
223
|
+
import { $createParagraphNode, $getSelection, $isElementNode, $isRangeSelection, $isNodeSelection, $setSelection, CAN_UNDO_COMMAND, createEditor, type ElementNode, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, ParagraphNode, UNDO_COMMAND } from "lexical";
|
|
224
|
+
import { $createHeadingNode, HeadingNode, type HeadingTagType, registerRichText } from "@lexical/rich-text";
|
|
181
225
|
import { createEmptyHistoryState, registerHistory } from "@lexical/history";
|
|
182
|
-
import { computed, defineComponent, onMounted, PropType, ref, watch } from "vue";
|
|
183
226
|
import { $createLinkNode, $isLinkNode, LinkNode } from "@lexical/link";
|
|
184
227
|
import { $wrapNodes } from "@lexical/selection";
|
|
185
228
|
|
|
229
|
+
import { emptyLexicalState, getAncestor, getSelectedNode } from "@dative-gpi/foundation-shared-components/utils";
|
|
186
230
|
import { useBreakpoints, useColors } from "@dative-gpi/foundation-shared-components/composables";
|
|
187
|
-
import {
|
|
188
|
-
|
|
231
|
+
import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
232
|
+
|
|
233
|
+
import { $createVariableNode, $isVariableNode, VariableNode } from "../../models/variableNode";
|
|
234
|
+
import { type RichTextVariable } from "../../models/richTextVariable";
|
|
189
235
|
|
|
236
|
+
import FSAutoCompleteField from "./FSAutocompleteField.vue";
|
|
190
237
|
import FSTextField from "./FSTextField.vue";
|
|
191
238
|
import FSIcon from "../FSIcon.vue";
|
|
239
|
+
import FSCard from "../FSCard.vue";
|
|
192
240
|
import FSCol from "../FSCol.vue";
|
|
193
241
|
import FSRow from "../FSRow.vue";
|
|
194
242
|
|
|
195
243
|
export default defineComponent({
|
|
196
244
|
name: "FSRichTextField",
|
|
197
245
|
components: {
|
|
246
|
+
FSAutoCompleteField,
|
|
198
247
|
FSTextField,
|
|
199
248
|
FSIcon,
|
|
249
|
+
FSCard,
|
|
200
250
|
FSCol,
|
|
201
251
|
FSRow
|
|
202
252
|
},
|
|
@@ -236,6 +286,15 @@ export default defineComponent({
|
|
|
236
286
|
required: false,
|
|
237
287
|
default: "standard"
|
|
238
288
|
},
|
|
289
|
+
variableReferences: {
|
|
290
|
+
type: Array as PropType<Array<RichTextVariable>>,
|
|
291
|
+
default: () => []
|
|
292
|
+
},
|
|
293
|
+
variableValues: {
|
|
294
|
+
type: Object as PropType<{ [key: string]: any }>,
|
|
295
|
+
required: false,
|
|
296
|
+
default: () => ({})
|
|
297
|
+
},
|
|
239
298
|
editable: {
|
|
240
299
|
type: Boolean,
|
|
241
300
|
required: false,
|
|
@@ -247,7 +306,7 @@ export default defineComponent({
|
|
|
247
306
|
const { isMobileSized } = useBreakpoints();
|
|
248
307
|
const { getColors } = useColors();
|
|
249
308
|
|
|
250
|
-
const linkColors = computed(()=> getColors(props.linkColor));
|
|
309
|
+
const linkColors = computed(() => getColors(props.linkColor));
|
|
251
310
|
const lights = getColors(ColorEnum.Light);
|
|
252
311
|
const darks = getColors(ColorEnum.Dark);
|
|
253
312
|
|
|
@@ -257,13 +316,13 @@ export default defineComponent({
|
|
|
257
316
|
const isItalic = ref(false);
|
|
258
317
|
const isUnderline = ref(false);
|
|
259
318
|
const isStrikethrough = ref(false);
|
|
319
|
+
const isVariable = ref(false);
|
|
320
|
+
const menuVariable = ref(false);
|
|
260
321
|
|
|
261
322
|
const id = `${Math.random()}-editor`;
|
|
262
|
-
const emptyState = "{\"root\":{\"children\":[{\"children\":[],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"paragraph\",\"version\":1}],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}";
|
|
263
|
-
|
|
264
323
|
|
|
265
324
|
const linkUrl = ref("https://");
|
|
266
|
-
|
|
325
|
+
|
|
267
326
|
const config = {
|
|
268
327
|
namespace: "MyEditor",
|
|
269
328
|
theme: {
|
|
@@ -285,7 +344,8 @@ export default defineComponent({
|
|
|
285
344
|
nodes: [
|
|
286
345
|
HeadingNode,
|
|
287
346
|
LinkNode,
|
|
288
|
-
ParagraphNode
|
|
347
|
+
ParagraphNode,
|
|
348
|
+
VariableNode
|
|
289
349
|
],
|
|
290
350
|
onError: console.error
|
|
291
351
|
}
|
|
@@ -305,7 +365,7 @@ export default defineComponent({
|
|
|
305
365
|
}
|
|
306
366
|
else {
|
|
307
367
|
editor.update((): void => {
|
|
308
|
-
editor.setEditorState(editor.parseEditorState(
|
|
368
|
+
editor.setEditorState(editor.parseEditorState(emptyLexicalState));
|
|
309
369
|
});
|
|
310
370
|
}
|
|
311
371
|
});
|
|
@@ -314,7 +374,7 @@ export default defineComponent({
|
|
|
314
374
|
return ["readonly"].includes(props.variant);
|
|
315
375
|
});
|
|
316
376
|
|
|
317
|
-
const style = computed((): { [key: string]
|
|
377
|
+
const style = computed((): { [key: string]: string | null | undefined } => {
|
|
318
378
|
let minHeight: string | undefined = "auto";
|
|
319
379
|
if (!readonly.value) {
|
|
320
380
|
const base = isMobileSized.value ? 30 : 42;
|
|
@@ -331,38 +391,40 @@ export default defineComponent({
|
|
|
331
391
|
case "standard": {
|
|
332
392
|
if (!props.editable) {
|
|
333
393
|
return {
|
|
334
|
-
"--fs-rich-text-field-undo-cursor"
|
|
335
|
-
"--fs-rich-text-field-icon-cursor"
|
|
336
|
-
"--fs-rich-text-field-border-color"
|
|
337
|
-
"--fs-rich-text-field-color"
|
|
394
|
+
"--fs-rich-text-field-undo-cursor": "default",
|
|
395
|
+
"--fs-rich-text-field-icon-cursor": "default",
|
|
396
|
+
"--fs-rich-text-field-border-color": lights.base,
|
|
397
|
+
"--fs-rich-text-field-color": lights.dark,
|
|
338
398
|
"--fs-rich-text-field-active-border-color": lights.base,
|
|
339
|
-
"--fs-rich-text-field-link-color"
|
|
340
|
-
"--fs-rich-text-field-min-height"
|
|
399
|
+
"--fs-rich-text-field-link-color": linkColors.value.light,
|
|
400
|
+
"--fs-rich-text-field-min-height": minHeight
|
|
341
401
|
};
|
|
342
402
|
}
|
|
343
403
|
else {
|
|
344
404
|
return {
|
|
345
|
-
"--fs-rich-text-field-undo-cursor"
|
|
346
|
-
"--fs-rich-text-field-icon-cursor"
|
|
347
|
-
"--fs-rich-text-field-border-color"
|
|
348
|
-
"--fs-rich-text-field-color"
|
|
405
|
+
"--fs-rich-text-field-undo-cursor": canUndo.value ? "pointer" : "default",
|
|
406
|
+
"--fs-rich-text-field-icon-cursor": "pointer",
|
|
407
|
+
"--fs-rich-text-field-border-color": lights.dark,
|
|
408
|
+
"--fs-rich-text-field-color": darks.base,
|
|
349
409
|
"--fs-rich-text-field-active-border-color": darks.dark,
|
|
350
|
-
"--fs-rich-text-field-link-color"
|
|
351
|
-
"--fs-rich-text-field-min-height"
|
|
410
|
+
"--fs-rich-text-field-link-color": linkColors.value.dark,
|
|
411
|
+
"--fs-rich-text-field-min-height": minHeight,
|
|
412
|
+
"--fs-rich-text-field-variable-backgroundcolor": getColors(ColorEnum.Primary).light,
|
|
413
|
+
"--fs-rich-text-field-variable-color": getColors(ColorEnum.Primary).lightContrast
|
|
352
414
|
};
|
|
353
415
|
}
|
|
354
416
|
}
|
|
355
417
|
case "readonly": return {
|
|
356
|
-
"--fs-rich-text-field-border-color"
|
|
357
|
-
"--fs-rich-text-field-color"
|
|
418
|
+
"--fs-rich-text-field-border-color": "transparent",
|
|
419
|
+
"--fs-rich-text-field-color": darks.base,
|
|
358
420
|
"--fs-rich-text-field-active-border-color": "transparent",
|
|
359
|
-
"--fs-rich-text-field-link-color"
|
|
360
|
-
"--fs-rich-text-field-min-height"
|
|
421
|
+
"--fs-rich-text-field-link-color": linkColors.value.dark,
|
|
422
|
+
"--fs-rich-text-field-min-height": minHeight
|
|
361
423
|
}
|
|
362
424
|
}
|
|
363
425
|
});
|
|
364
426
|
|
|
365
|
-
const toolbarColors = computed((): {[code: string]: string} => {
|
|
427
|
+
const toolbarColors = computed((): { [code: string]: string } => {
|
|
366
428
|
if (props.editable) {
|
|
367
429
|
return {
|
|
368
430
|
undo: canUndo.value ? darks.base : lights.base,
|
|
@@ -370,7 +432,8 @@ export default defineComponent({
|
|
|
370
432
|
italic: isItalic.value ? darks.base : lights.base,
|
|
371
433
|
underline: isUnderline.value ? darks.base : lights.base,
|
|
372
434
|
strikethrough: isStrikethrough.value ? darks.base : lights.base,
|
|
373
|
-
link: isLink.value ? darks.base : lights.base
|
|
435
|
+
link: isLink.value ? darks.base : lights.base,
|
|
436
|
+
variable: isVariable.value ? darks.base : lights.base
|
|
374
437
|
};
|
|
375
438
|
}
|
|
376
439
|
else {
|
|
@@ -387,6 +450,7 @@ export default defineComponent({
|
|
|
387
450
|
|
|
388
451
|
const updateToolbar = (): void => {
|
|
389
452
|
const selection = $getSelection();
|
|
453
|
+
isVariable.value = false;
|
|
390
454
|
if ($isRangeSelection(selection)) {
|
|
391
455
|
isBold.value = selection.hasFormat("bold");
|
|
392
456
|
isItalic.value = selection.hasFormat("italic");
|
|
@@ -394,12 +458,17 @@ export default defineComponent({
|
|
|
394
458
|
isStrikethrough.value = selection.hasFormat("strikethrough");
|
|
395
459
|
isLink.value = $isLinkNode(getSelectedNode(selection)) || $isLinkNode(getSelectedNode(selection).getParent());
|
|
396
460
|
}
|
|
461
|
+
else if($isNodeSelection(selection)){
|
|
462
|
+
if($isVariableNode(selection?.getNodes()[0])){
|
|
463
|
+
isVariable.value = true;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
397
466
|
};
|
|
398
467
|
|
|
399
468
|
editor.registerUpdateListener(({ editorState }) => {
|
|
400
469
|
editorState.read(() => {
|
|
401
470
|
updateToolbar();
|
|
402
|
-
if (JSON.stringify(editorState.toJSON()) !==
|
|
471
|
+
if (JSON.stringify(editorState.toJSON()) !== emptyLexicalState) {
|
|
403
472
|
emit("update:modelValue", JSON.stringify(editorState.toJSON()));
|
|
404
473
|
}
|
|
405
474
|
else {
|
|
@@ -433,6 +502,21 @@ export default defineComponent({
|
|
|
433
502
|
});
|
|
434
503
|
};
|
|
435
504
|
|
|
505
|
+
const insertVariable = (code: string) => {
|
|
506
|
+
const variable = props.variableReferences.find((v) => v.code === code);
|
|
507
|
+
if (!variable) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
menuVariable.value = false;
|
|
511
|
+
editor.update(() => {
|
|
512
|
+
const selection = $getSelection();
|
|
513
|
+
if ($isRangeSelection(selection)) {
|
|
514
|
+
const variableNode = $createVariableNode(code, variable.defaultValue);
|
|
515
|
+
selection.insertNodes([variableNode]);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
};
|
|
519
|
+
|
|
436
520
|
const openLink = (): void => {
|
|
437
521
|
if (!isLink.value) {
|
|
438
522
|
isLink.value = true;
|
|
@@ -444,7 +528,7 @@ export default defineComponent({
|
|
|
444
528
|
if ($isRangeSelection(selection)) {
|
|
445
529
|
toggleLink();
|
|
446
530
|
}
|
|
447
|
-
});
|
|
531
|
+
});
|
|
448
532
|
}
|
|
449
533
|
};
|
|
450
534
|
|
|
@@ -494,7 +578,7 @@ export default defineComponent({
|
|
|
494
578
|
let linkNode: LinkNode | null = null;
|
|
495
579
|
nodes.forEach((node) => {
|
|
496
580
|
const parent = node.getParent();
|
|
497
|
-
if (
|
|
581
|
+
if (parent === linkNode || parent === null || ($isElementNode(node) && !node.isInline())) {
|
|
498
582
|
return;
|
|
499
583
|
}
|
|
500
584
|
if ($isLinkNode(parent)) {
|
|
@@ -513,7 +597,7 @@ export default defineComponent({
|
|
|
513
597
|
}
|
|
514
598
|
if (!parent.is(prevParent)) {
|
|
515
599
|
prevParent = parent;
|
|
516
|
-
linkNode = $createLinkNode(linkUrl.value, {rel, target, title});
|
|
600
|
+
linkNode = $createLinkNode(linkUrl.value, { rel, target, title });
|
|
517
601
|
|
|
518
602
|
if ($isLinkNode(parent)) {
|
|
519
603
|
if (node.getPreviousSibling() === null) {
|
|
@@ -558,30 +642,32 @@ export default defineComponent({
|
|
|
558
642
|
editor.setEditorState(editor.parseEditorState(props.modelValue!));
|
|
559
643
|
});
|
|
560
644
|
}
|
|
561
|
-
else if (JSON.stringify(editor.getEditorState().toJSON()) !==
|
|
645
|
+
else if (JSON.stringify(editor.getEditorState().toJSON()) !== emptyLexicalState) {
|
|
562
646
|
editor.update(() => {
|
|
563
|
-
editor.setEditorState(editor.parseEditorState(
|
|
647
|
+
editor.setEditorState(editor.parseEditorState(emptyLexicalState));
|
|
564
648
|
});
|
|
565
649
|
}
|
|
566
650
|
}
|
|
567
651
|
});
|
|
568
652
|
|
|
569
653
|
return {
|
|
654
|
+
FORMAT_ELEMENT_COMMAND,
|
|
655
|
+
FORMAT_TEXT_COMMAND,
|
|
656
|
+
toolbarColors,
|
|
657
|
+
menuVariable,
|
|
658
|
+
UNDO_COMMAND,
|
|
570
659
|
readonly,
|
|
571
|
-
|
|
572
|
-
id,
|
|
660
|
+
linkUrl,
|
|
573
661
|
editor,
|
|
574
662
|
isLink,
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
openLink,
|
|
578
|
-
toggleLink,
|
|
579
|
-
formatText,
|
|
663
|
+
style,
|
|
664
|
+
id,
|
|
580
665
|
formatParagraph,
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
666
|
+
insertVariable,
|
|
667
|
+
formatText,
|
|
668
|
+
toggleLink,
|
|
669
|
+
openLink
|
|
670
|
+
};
|
|
585
671
|
}
|
|
586
672
|
});
|
|
587
673
|
</script>
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<FSTextField
|
|
3
|
-
:label="$props.label"
|
|
4
|
-
:description="$props.description"
|
|
5
|
-
:color="$props.color"
|
|
6
|
-
:hideHeader="$props.hideHeader"
|
|
7
|
-
:required="$props.required"
|
|
8
3
|
:editable="$props.editable"
|
|
9
4
|
:placeholder="placeholder"
|
|
10
5
|
@keydown.enter="onSearch"
|
|
@@ -12,56 +7,60 @@
|
|
|
12
7
|
v-bind="$attrs"
|
|
13
8
|
>
|
|
14
9
|
<template
|
|
15
|
-
v-
|
|
16
|
-
|
|
10
|
+
v-for="(_, name) in slots"
|
|
11
|
+
v-slot:[name]="slotData"
|
|
17
12
|
>
|
|
18
13
|
<slot
|
|
19
|
-
name="
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
variant="icon"
|
|
23
|
-
:icon="$props.prependInnerIcon"
|
|
24
|
-
:editable="$props.editable"
|
|
25
|
-
:color="ColorEnum.Dark"
|
|
26
|
-
@click="onSearch"
|
|
27
|
-
/>
|
|
28
|
-
</slot>
|
|
14
|
+
:name="name"
|
|
15
|
+
v-bind="slotData"
|
|
16
|
+
/>
|
|
29
17
|
</template>
|
|
30
18
|
<template
|
|
31
|
-
v-if="
|
|
32
|
-
#
|
|
19
|
+
v-if="$props.prependInnerIcon || $slots['prepend-inner']"
|
|
20
|
+
#prepend-inner
|
|
33
21
|
>
|
|
22
|
+
<FSButton
|
|
23
|
+
v-if="$props.prependInnerIcon"
|
|
24
|
+
variant="icon"
|
|
25
|
+
:icon="$props.prependInnerIcon"
|
|
26
|
+
:editable="$props.editable"
|
|
27
|
+
:color="ColorEnum.Dark"
|
|
28
|
+
@click="onSearch"
|
|
29
|
+
/>
|
|
34
30
|
<slot
|
|
35
|
-
name="
|
|
36
|
-
|
|
37
|
-
<FSButton
|
|
38
|
-
:prependIcon="$props.buttonPrependIcon"
|
|
39
|
-
:label="buttonLabel"
|
|
40
|
-
:appendIcon="$props.buttonAppendIcon"
|
|
41
|
-
:variant="$props.buttonVariant"
|
|
42
|
-
:color="$props.buttonColor"
|
|
43
|
-
:editable="$props.editable"
|
|
44
|
-
@click="onSearch"
|
|
45
|
-
/>
|
|
46
|
-
</slot>
|
|
31
|
+
name="prepend-inner"
|
|
32
|
+
/>
|
|
47
33
|
</template>
|
|
48
34
|
<template
|
|
49
|
-
v-
|
|
50
|
-
|
|
35
|
+
v-if="$props.variant !== 'instant' || $slots.append"
|
|
36
|
+
#append
|
|
51
37
|
>
|
|
38
|
+
<FSButton
|
|
39
|
+
v-if="$props.variant !== 'instant'"
|
|
40
|
+
:prependIcon="$props.buttonPrependIcon"
|
|
41
|
+
:label="buttonLabel"
|
|
42
|
+
:appendIcon="$props.buttonAppendIcon"
|
|
43
|
+
:variant="$props.buttonVariant"
|
|
44
|
+
:color="$props.buttonColor"
|
|
45
|
+
:editable="$props.editable"
|
|
46
|
+
@click="onSearch"
|
|
47
|
+
/>
|
|
52
48
|
<slot
|
|
53
|
-
|
|
54
|
-
v-bind="slotData"
|
|
49
|
+
name="append"
|
|
55
50
|
/>
|
|
56
51
|
</template>
|
|
57
52
|
</FSTextField>
|
|
58
53
|
</template>
|
|
59
54
|
|
|
60
55
|
<script lang="ts">
|
|
61
|
-
import {
|
|
56
|
+
import type { PropType} from "vue";
|
|
57
|
+
import { computed, defineComponent, ref, watch } from "vue";
|
|
62
58
|
|
|
63
59
|
import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
|
|
64
|
-
import { ColorBase
|
|
60
|
+
import type { ColorBase} from "@dative-gpi/foundation-shared-components/models";
|
|
61
|
+
import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
62
|
+
|
|
63
|
+
import { useSlots } from "../../composables";
|
|
65
64
|
|
|
66
65
|
import FSTextField from "./FSTextField.vue";
|
|
67
66
|
import FSButton from "../FSButton.vue";
|
|
@@ -73,16 +72,6 @@ export default defineComponent({
|
|
|
73
72
|
FSButton
|
|
74
73
|
},
|
|
75
74
|
props: {
|
|
76
|
-
label: {
|
|
77
|
-
type: String as PropType<string | null>,
|
|
78
|
-
required: false,
|
|
79
|
-
default: null
|
|
80
|
-
},
|
|
81
|
-
description: {
|
|
82
|
-
type: String as PropType<string | null>,
|
|
83
|
-
required: false,
|
|
84
|
-
default: null
|
|
85
|
-
},
|
|
86
75
|
placeholder: {
|
|
87
76
|
type: String as PropType<string | null>,
|
|
88
77
|
required: false,
|
|
@@ -123,26 +112,11 @@ export default defineComponent({
|
|
|
123
112
|
required: false,
|
|
124
113
|
default: null
|
|
125
114
|
},
|
|
126
|
-
color: {
|
|
127
|
-
type: String as PropType<ColorBase>,
|
|
128
|
-
required: false,
|
|
129
|
-
default: ColorEnum.Dark
|
|
130
|
-
},
|
|
131
115
|
buttonColor: {
|
|
132
116
|
type: String as PropType<ColorBase>,
|
|
133
117
|
required: false,
|
|
134
118
|
default: ColorEnum.Primary
|
|
135
119
|
},
|
|
136
|
-
hideHeader: {
|
|
137
|
-
type: Boolean,
|
|
138
|
-
required: false,
|
|
139
|
-
default: true
|
|
140
|
-
},
|
|
141
|
-
required: {
|
|
142
|
-
type: Boolean,
|
|
143
|
-
required: false,
|
|
144
|
-
default: false
|
|
145
|
-
},
|
|
146
120
|
editable: {
|
|
147
121
|
type: Boolean,
|
|
148
122
|
required: false,
|
|
@@ -152,6 +126,10 @@ export default defineComponent({
|
|
|
152
126
|
emits: ["update:modelValue"],
|
|
153
127
|
setup(props, { emit }) {
|
|
154
128
|
const { $tr } = useTranslationsProvider();
|
|
129
|
+
const { slots } = useSlots();
|
|
130
|
+
|
|
131
|
+
delete slots["prepend-inner"];
|
|
132
|
+
delete slots.append;
|
|
155
133
|
|
|
156
134
|
const innerValue = ref(props.modelValue);
|
|
157
135
|
|
|
@@ -180,6 +158,7 @@ export default defineComponent({
|
|
|
180
158
|
buttonLabel,
|
|
181
159
|
innerValue,
|
|
182
160
|
ColorEnum,
|
|
161
|
+
slots,
|
|
183
162
|
onSearch
|
|
184
163
|
};
|
|
185
164
|
}
|