@conduction/nextcloud-vue 2.56.0-beta.69 → 2.56.0-beta.70
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/dist/esm/components/CnActionDialog/CnActionDialog.vue.js +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js +114 -11
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js +67 -17
- package/dist/esm/components/CnActionDialog/CnActionDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js +9 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js +352 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue2.js.map +1 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js +266 -0
- package/dist/esm/components/CnBlockListEditor/CnBlockListEditor.vue3.js.map +1 -0
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue.js +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js +257 -7
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js +113 -59
- package/dist/esm/components/CnChecklistRunWidget/CnChecklistRunWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue.js +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js +210 -5
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue2.js.map +1 -1
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js +134 -46
- package/dist/esm/components/CnChildRecordsField/CnChildRecordsField.vue3.js.map +1 -1
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js +9 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js +385 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue2.js.map +1 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js +277 -0
- package/dist/esm/components/CnChoiceMatrix/CnChoiceMatrix.vue3.js.map +1 -0
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue.js +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js +175 -20
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js +30 -8
- package/dist/esm/components/CnCountdownWidget/CnCountdownWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue.js +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js +72 -6
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js +48 -14
- package/dist/esm/components/CnCreateFormWidget/CnCreateFormWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue.js +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js +162 -9
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue2.js.map +1 -1
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js +63 -23
- package/dist/esm/components/CnDataMatrix/CnDataMatrix.vue3.js.map +1 -1
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js +9 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js +175 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue2.js.map +1 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js +114 -0
- package/dist/esm/components/CnDisplayScreen/CnDisplayScreen.vue3.js.map +1 -0
- package/dist/esm/components/CnDurationField/CnDurationField.vue.js +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js +218 -4
- package/dist/esm/components/CnDurationField/CnDurationField.vue2.js.map +1 -1
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js +133 -44
- package/dist/esm/components/CnDurationField/CnDurationField.vue3.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue.js +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue2.js.map +1 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js +5 -1
- package/dist/esm/components/CnFormDialog/CnFormDialog.vue3.js.map +1 -1
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js +9 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js +113 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue2.js.map +1 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js +43 -0
- package/dist/esm/components/CnGeoCaptureField/CnGeoCaptureField.vue3.js.map +1 -0
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue.js +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js +110 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue2.js.map +1 -1
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js +60 -18
- package/dist/esm/components/CnMarkdownEditor/CnMarkdownEditor.vue3.js.map +1 -1
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnMenuTreeNode/CnMenuTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js +2 -2
- package/dist/esm/components/CnObjectKanban/CnObjectKanban.vue2.js.map +1 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -2
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js +9 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js +241 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue2.js.map +1 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js +75 -0
- package/dist/esm/components/CnQrCode/CnQrCode.vue3.js.map +1 -0
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +34 -3
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -1
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +81 -19
- package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +11 -0
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js +112 -88
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js +9 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js +157 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue2.js.map +1 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js +116 -0
- package/dist/esm/components/CnRevealField/CnRevealField.vue3.js.map +1 -0
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js +43 -3
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js +19 -12
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js +9 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js +87 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue2.js.map +1 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js +126 -0
- package/dist/esm/components/CnTransferCard/CnTransferCard.vue3.js.map +1 -0
- package/dist/esm/components/CnTreeView/CnTreeNode.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js +66 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js +129 -29
- package/dist/esm/components/CnTreeView/CnTreeNode.vue3.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue.js +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js +158 -6
- package/dist/esm/components/CnTreeView/CnTreeView.vue2.js.map +1 -1
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js +100 -39
- package/dist/esm/components/CnTreeView/CnTreeView.vue3.js.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/l10n/en.json.js +63 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +63 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +1134 -499
- package/dist/esm/node_modules/vuedraggable/dist/vuedraggable.umd.js +2 -2
- package/dist/esm/utils/captureLocation.js +32 -0
- package/dist/esm/utils/captureLocation.js.map +1 -0
- package/dist/esm/utils/childRecordTotals.js +157 -0
- package/dist/esm/utils/childRecordTotals.js.map +1 -0
- package/dist/esm/utils/isoDuration.js +51 -1
- package/dist/esm/utils/isoDuration.js.map +1 -1
- package/dist/esm/utils/qr.js +649 -0
- package/dist/esm/utils/qr.js.map +1 -0
- package/dist/esm/utils/schema.js +3 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/templateVariables.js +54 -0
- package/dist/esm/utils/templateVariables.js.map +1 -0
- package/dist/nextcloud-vue.cjs.js +20307 -14544
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +1134 -499
- package/l10n/en.json +63 -1
- package/l10n/nl.json +63 -1
- package/package.json +1 -1
- package/src/components/CnActionDialog/CnActionDialog.vue +156 -9
- package/src/components/CnBlockListEditor/CnBlockListEditor.vue +615 -0
- package/src/components/CnBlockListEditor/index.js +9 -0
- package/src/components/CnChecklistRunWidget/CnChecklistRunWidget.vue +311 -10
- package/src/components/CnChildRecordsField/CnChildRecordsField.vue +306 -15
- package/src/components/CnChoiceMatrix/CnChoiceMatrix.vue +710 -0
- package/src/components/CnChoiceMatrix/index.js +9 -0
- package/src/components/CnCountdownWidget/CnCountdownWidget.vue +223 -28
- package/src/components/CnCreateFormWidget/CnCreateFormWidget.vue +97 -6
- package/src/components/CnDataMatrix/CnDataMatrix.vue +199 -13
- package/src/components/CnDisplayScreen/CnDisplayScreen.vue +308 -0
- package/src/components/CnDisplayScreen/index.js +9 -0
- package/src/components/CnDurationField/CnDurationField.vue +330 -5
- package/src/components/CnFormDialog/CnFormDialog.vue +4 -0
- package/src/components/CnGeoCaptureField/CnGeoCaptureField.vue +148 -0
- package/src/components/CnGeoCaptureField/index.js +9 -0
- package/src/components/CnMarkdownEditor/CnMarkdownEditor.vue +139 -1
- package/src/components/CnQrCode/CnQrCode.vue +321 -0
- package/src/components/CnQrCode/index.js +9 -0
- package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +80 -3
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +34 -1
- package/src/components/CnRevealField/CnRevealField.vue +273 -0
- package/src/components/CnRevealField/index.js +9 -0
- package/src/components/CnTextWidget/CnTextWidget.vue +62 -3
- package/src/components/CnTransferCard/CnTransferCard.vue +205 -0
- package/src/components/CnTransferCard/index.js +9 -0
- package/src/components/CnTreeView/CnTreeNode.vue +145 -2
- package/src/components/CnTreeView/CnTreeView.vue +210 -6
- package/src/components/index.js +7 -0
- package/src/index.js +8 -0
- package/src/utils/captureLocation.js +29 -0
- package/src/utils/childRecordTotals.js +153 -0
- package/src/utils/isoDuration.js +50 -0
- package/src/utils/qr.js +681 -0
- package/src/utils/schema.js +3 -0
- package/src/utils/templateVariables.js +51 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import script from './CnGeoCaptureField.vue2.js';
|
|
2
|
+
import { render } from './CnGeoCaptureField.vue3.js';
|
|
3
|
+
|
|
4
|
+
script.render = render;
|
|
5
|
+
script.__scopeId = "data-v-03b514ef";
|
|
6
|
+
const __sfc_main = script;
|
|
7
|
+
|
|
8
|
+
export { __sfc_main as default };
|
|
9
|
+
//# sourceMappingURL=CnGeoCaptureField.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnGeoCaptureField.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { translate } from '@nextcloud/l10n';
|
|
2
|
+
import { NcButton, NcTextField } from '@nextcloud/vue';
|
|
3
|
+
import { captureLocation } from '../../utils/captureLocation.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* CnGeoCaptureField: the place something was recorded, captured from the
|
|
7
|
+
* device (board DqInspectie: "51.9012, 4.4831 · ±12 m · 10:52"). A fix whose
|
|
8
|
+
* accuracy is worse than `goodAccuracy`, or no fix at all, says so, offers a
|
|
9
|
+
* retry and takes an address by hand. The user can always carry on, and the
|
|
10
|
+
* value says how good it was through `low`.
|
|
11
|
+
*
|
|
12
|
+
* The value is `{ lat, lng, accuracy, at, low, address? }`, or null.
|
|
13
|
+
*
|
|
14
|
+
* ```vue
|
|
15
|
+
* <CnGeoCaptureField v-model="place" auto />
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @event update:modelValue The new value.
|
|
19
|
+
* @spec openspec/changes/checklist-run-location/specs/checklist-run-location/spec.md#requirement-a-field-captures-where-something-was-recorded
|
|
20
|
+
*/
|
|
21
|
+
var script = {
|
|
22
|
+
name: 'CnGeoCaptureField',
|
|
23
|
+
|
|
24
|
+
components: { NcButton, NcTextField },
|
|
25
|
+
|
|
26
|
+
props: {
|
|
27
|
+
/** The captured place: `{ lat, lng, accuracy, at, low, address? }`, or null. */
|
|
28
|
+
modelValue: { type: Object, default: null },
|
|
29
|
+
/** Capture on mount when no value is held yet. */
|
|
30
|
+
auto: { type: Boolean, default: false },
|
|
31
|
+
/** A host is capturing; the field says it is looking. */
|
|
32
|
+
busy: { type: Boolean, default: false },
|
|
33
|
+
/** The accuracy in metres above which a fix counts as low. */
|
|
34
|
+
goodAccuracy: { type: Number, default: 50 },
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
emits: ['update:modelValue'],
|
|
38
|
+
|
|
39
|
+
data() {
|
|
40
|
+
return { capturing: false }
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
computed: {
|
|
44
|
+
/** @return {boolean} Whether a capture is under way. */
|
|
45
|
+
searching() {
|
|
46
|
+
return this.busy || this.capturing
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/** @return {boolean} Whether the value has coordinates. */
|
|
50
|
+
hasFix() {
|
|
51
|
+
return Number.isFinite(this.modelValue?.lat) && Number.isFinite(this.modelValue?.lng)
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
/** @return {boolean} Whether the fix is missing or too rough. */
|
|
55
|
+
needsAddress() {
|
|
56
|
+
return !this.hasFix || this.modelValue.low === true
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
/** @return {string} The state of the capture in words. */
|
|
60
|
+
lineText() {
|
|
61
|
+
if (this.searching) {
|
|
62
|
+
return translate('nextcloud-vue', 'Looking for your location…')
|
|
63
|
+
}
|
|
64
|
+
if (!this.hasFix) {
|
|
65
|
+
return translate('nextcloud-vue', 'No location found. You can carry on, or add the address by hand.')
|
|
66
|
+
}
|
|
67
|
+
const accuracy = Math.round(this.modelValue.accuracy);
|
|
68
|
+
if (this.modelValue.low === true) {
|
|
69
|
+
return translate('nextcloud-vue', 'Location is inaccurate (±{accuracy} m). Wait for a better signal or add the address by hand.', { accuracy })
|
|
70
|
+
}
|
|
71
|
+
const time = new Date(this.modelValue.at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
72
|
+
return `${this.modelValue.lat.toFixed(4)}, ${this.modelValue.lng.toFixed(4)} · ±${accuracy} m · ${time}`
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
mounted() {
|
|
77
|
+
if (this.auto && !this.modelValue) {
|
|
78
|
+
this.retry();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
methods: {
|
|
83
|
+
t: translate,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Ask the device again. A fix replaces what is held, keeping a typed
|
|
87
|
+
* address; no fix keeps it all.
|
|
88
|
+
*
|
|
89
|
+
* @return {Promise<void>}
|
|
90
|
+
*/
|
|
91
|
+
async retry() {
|
|
92
|
+
this.capturing = true;
|
|
93
|
+
const fix = await captureLocation();
|
|
94
|
+
this.capturing = false;
|
|
95
|
+
if (fix) {
|
|
96
|
+
this.$emit('update:modelValue', { ...this.modelValue, ...fix, low: fix.accuracy > this.goodAccuracy });
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Keep the address typed by hand beside whatever fix there is.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} address The address.
|
|
104
|
+
* @return {void}
|
|
105
|
+
*/
|
|
106
|
+
setAddress(address) {
|
|
107
|
+
this.$emit('update:modelValue', { low: true, ...this.modelValue, address });
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export { script as default };
|
|
113
|
+
//# sourceMappingURL=CnGeoCaptureField.vue2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnGeoCaptureField.vue2.js","sources":["../../../../src/components/CnGeoCaptureField/CnGeoCaptureField.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<div class=\"cn-geo-capture\" data-testid=\"cn-geo-capture\">\n\t\t<p class=\"cn-geo-capture__line\" role=\"status\" data-testid=\"cn-geo-capture-line\">\n\t\t\t{{ lineText }}\n\t\t</p>\n\t\t<template v-if=\"!searching && needsAddress\">\n\t\t\t<NcButton variant=\"tertiary\" data-testid=\"cn-geo-capture-retry\" @click=\"retry\">\n\t\t\t\t{{ t('nextcloud-vue', 'Try again') }}\n\t\t\t</NcButton>\n\t\t\t<NcTextField\n\t\t\t\t:modelValue=\"modelValue?.address || ''\"\n\t\t\t\t:label=\"t('nextcloud-vue', 'Address (by hand)')\"\n\t\t\t\tdata-testid=\"cn-geo-capture-address\"\n\t\t\t\t@update:modelValue=\"setAddress\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcTextField } from '@nextcloud/vue'\nimport { captureLocation } from '../../utils/captureLocation.js'\n\n/**\n * CnGeoCaptureField: the place something was recorded, captured from the\n * device (board DqInspectie: \"51.9012, 4.4831 · ±12 m · 10:52\"). A fix whose\n * accuracy is worse than `goodAccuracy`, or no fix at all, says so, offers a\n * retry and takes an address by hand. The user can always carry on, and the\n * value says how good it was through `low`.\n *\n * The value is `{ lat, lng, accuracy, at, low, address? }`, or null.\n *\n * ```vue\n * <CnGeoCaptureField v-model=\"place\" auto />\n * ```\n *\n * @event update:modelValue The new value.\n * @spec openspec/changes/checklist-run-location/specs/checklist-run-location/spec.md#requirement-a-field-captures-where-something-was-recorded\n */\nexport default {\n\tname: 'CnGeoCaptureField',\n\n\tcomponents: { NcButton, NcTextField },\n\n\tprops: {\n\t\t/** The captured place: `{ lat, lng, accuracy, at, low, address? }`, or null. */\n\t\tmodelValue: { type: Object, default: null },\n\t\t/** Capture on mount when no value is held yet. */\n\t\tauto: { type: Boolean, default: false },\n\t\t/** A host is capturing; the field says it is looking. */\n\t\tbusy: { type: Boolean, default: false },\n\t\t/** The accuracy in metres above which a fix counts as low. */\n\t\tgoodAccuracy: { type: Number, default: 50 },\n\t},\n\n\temits: ['update:modelValue'],\n\n\tdata() {\n\t\treturn { capturing: false }\n\t},\n\n\tcomputed: {\n\t\t/** @return {boolean} Whether a capture is under way. */\n\t\tsearching() {\n\t\t\treturn this.busy || this.capturing\n\t\t},\n\n\t\t/** @return {boolean} Whether the value has coordinates. */\n\t\thasFix() {\n\t\t\treturn Number.isFinite(this.modelValue?.lat) && Number.isFinite(this.modelValue?.lng)\n\t\t},\n\n\t\t/** @return {boolean} Whether the fix is missing or too rough. */\n\t\tneedsAddress() {\n\t\t\treturn !this.hasFix || this.modelValue.low === true\n\t\t},\n\n\t\t/** @return {string} The state of the capture in words. */\n\t\tlineText() {\n\t\t\tif (this.searching) {\n\t\t\t\treturn t('nextcloud-vue', 'Looking for your location…')\n\t\t\t}\n\t\t\tif (!this.hasFix) {\n\t\t\t\treturn t('nextcloud-vue', 'No location found. You can carry on, or add the address by hand.')\n\t\t\t}\n\t\t\tconst accuracy = Math.round(this.modelValue.accuracy)\n\t\t\tif (this.modelValue.low === true) {\n\t\t\t\treturn t('nextcloud-vue', 'Location is inaccurate (±{accuracy} m). Wait for a better signal or add the address by hand.', { accuracy })\n\t\t\t}\n\t\t\tconst time = new Date(this.modelValue.at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })\n\t\t\treturn `${this.modelValue.lat.toFixed(4)}, ${this.modelValue.lng.toFixed(4)} · ±${accuracy} m · ${time}`\n\t\t},\n\t},\n\n\tmounted() {\n\t\tif (this.auto && !this.modelValue) {\n\t\t\tthis.retry()\n\t\t}\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Ask the device again. A fix replaces what is held, keeping a typed\n\t\t * address; no fix keeps it all.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync retry() {\n\t\t\tthis.capturing = true\n\t\t\tconst fix = await captureLocation()\n\t\t\tthis.capturing = false\n\t\t\tif (fix) {\n\t\t\t\tthis.$emit('update:modelValue', { ...this.modelValue, ...fix, low: fix.accuracy > this.goodAccuracy })\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Keep the address typed by hand beside whatever fix there is.\n\t\t *\n\t\t * @param {string} address The address.\n\t\t * @return {void}\n\t\t */\n\t\tsetAddress(address) {\n\t\t\tthis.$emit('update:modelValue', { low: true, ...this.modelValue, address })\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-geo-capture {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n}\n\n.cn-geo-capture__line {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-variant-numeric: tabular-nums;\n\tmargin: 0;\n}\n</style>\n"],"names":["t"],"mappings":"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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolveComponent, openBlock, createElementBlock, createElementVNode, toDisplayString, Fragment, createVNode, withCtx, createTextVNode, createCommentVNode } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = {
|
|
4
|
+
class: "cn-geo-capture",
|
|
5
|
+
"data-testid": "cn-geo-capture"
|
|
6
|
+
};
|
|
7
|
+
const _hoisted_2 = {
|
|
8
|
+
class: "cn-geo-capture__line",
|
|
9
|
+
role: "status",
|
|
10
|
+
"data-testid": "cn-geo-capture-line"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
14
|
+
const _component_NcButton = resolveComponent("NcButton");
|
|
15
|
+
const _component_NcTextField = resolveComponent("NcTextField");
|
|
16
|
+
|
|
17
|
+
return (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
18
|
+
createElementVNode("p", _hoisted_2, toDisplayString($options.lineText), 1 /* TEXT */),
|
|
19
|
+
(!$options.searching && $options.needsAddress)
|
|
20
|
+
? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
21
|
+
createVNode(_component_NcButton, {
|
|
22
|
+
variant: "tertiary",
|
|
23
|
+
"data-testid": "cn-geo-capture-retry",
|
|
24
|
+
onClick: $options.retry
|
|
25
|
+
}, {
|
|
26
|
+
default: withCtx(() => [
|
|
27
|
+
createTextVNode(toDisplayString($options.t('nextcloud-vue', 'Try again')), 1 /* TEXT */)
|
|
28
|
+
]),
|
|
29
|
+
_: 1 /* STABLE */
|
|
30
|
+
}, 8 /* PROPS */, ["onClick"]),
|
|
31
|
+
createVNode(_component_NcTextField, {
|
|
32
|
+
modelValue: $props.modelValue?.address || '',
|
|
33
|
+
label: $options.t('nextcloud-vue', 'Address (by hand)'),
|
|
34
|
+
"data-testid": "cn-geo-capture-address",
|
|
35
|
+
"onUpdate:modelValue": $options.setAddress
|
|
36
|
+
}, null, 8 /* PROPS */, ["modelValue", "label", "onUpdate:modelValue"])
|
|
37
|
+
], 64 /* STABLE_FRAGMENT */))
|
|
38
|
+
: createCommentVNode("v-if", true)
|
|
39
|
+
]))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { render };
|
|
43
|
+
//# sourceMappingURL=CnGeoCaptureField.vue3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CnGeoCaptureField.vue3.js","sources":["../../../../src/components/CnGeoCaptureField/CnGeoCaptureField.vue?vue&type=template&id=03b514ef&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n<template>\n\t<div class=\"cn-geo-capture\" data-testid=\"cn-geo-capture\">\n\t\t<p class=\"cn-geo-capture__line\" role=\"status\" data-testid=\"cn-geo-capture-line\">\n\t\t\t{{ lineText }}\n\t\t</p>\n\t\t<template v-if=\"!searching && needsAddress\">\n\t\t\t<NcButton variant=\"tertiary\" data-testid=\"cn-geo-capture-retry\" @click=\"retry\">\n\t\t\t\t{{ t('nextcloud-vue', 'Try again') }}\n\t\t\t</NcButton>\n\t\t\t<NcTextField\n\t\t\t\t:modelValue=\"modelValue?.address || ''\"\n\t\t\t\t:label=\"t('nextcloud-vue', 'Address (by hand)')\"\n\t\t\t\tdata-testid=\"cn-geo-capture-address\"\n\t\t\t\t@update:modelValue=\"setAddress\" />\n\t\t</template>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcButton, NcTextField } from '@nextcloud/vue'\nimport { captureLocation } from '../../utils/captureLocation.js'\n\n/**\n * CnGeoCaptureField: the place something was recorded, captured from the\n * device (board DqInspectie: \"51.9012, 4.4831 · ±12 m · 10:52\"). A fix whose\n * accuracy is worse than `goodAccuracy`, or no fix at all, says so, offers a\n * retry and takes an address by hand. The user can always carry on, and the\n * value says how good it was through `low`.\n *\n * The value is `{ lat, lng, accuracy, at, low, address? }`, or null.\n *\n * ```vue\n * <CnGeoCaptureField v-model=\"place\" auto />\n * ```\n *\n * @event update:modelValue The new value.\n * @spec openspec/changes/checklist-run-location/specs/checklist-run-location/spec.md#requirement-a-field-captures-where-something-was-recorded\n */\nexport default {\n\tname: 'CnGeoCaptureField',\n\n\tcomponents: { NcButton, NcTextField },\n\n\tprops: {\n\t\t/** The captured place: `{ lat, lng, accuracy, at, low, address? }`, or null. */\n\t\tmodelValue: { type: Object, default: null },\n\t\t/** Capture on mount when no value is held yet. */\n\t\tauto: { type: Boolean, default: false },\n\t\t/** A host is capturing; the field says it is looking. */\n\t\tbusy: { type: Boolean, default: false },\n\t\t/** The accuracy in metres above which a fix counts as low. */\n\t\tgoodAccuracy: { type: Number, default: 50 },\n\t},\n\n\temits: ['update:modelValue'],\n\n\tdata() {\n\t\treturn { capturing: false }\n\t},\n\n\tcomputed: {\n\t\t/** @return {boolean} Whether a capture is under way. */\n\t\tsearching() {\n\t\t\treturn this.busy || this.capturing\n\t\t},\n\n\t\t/** @return {boolean} Whether the value has coordinates. */\n\t\thasFix() {\n\t\t\treturn Number.isFinite(this.modelValue?.lat) && Number.isFinite(this.modelValue?.lng)\n\t\t},\n\n\t\t/** @return {boolean} Whether the fix is missing or too rough. */\n\t\tneedsAddress() {\n\t\t\treturn !this.hasFix || this.modelValue.low === true\n\t\t},\n\n\t\t/** @return {string} The state of the capture in words. */\n\t\tlineText() {\n\t\t\tif (this.searching) {\n\t\t\t\treturn t('nextcloud-vue', 'Looking for your location…')\n\t\t\t}\n\t\t\tif (!this.hasFix) {\n\t\t\t\treturn t('nextcloud-vue', 'No location found. You can carry on, or add the address by hand.')\n\t\t\t}\n\t\t\tconst accuracy = Math.round(this.modelValue.accuracy)\n\t\t\tif (this.modelValue.low === true) {\n\t\t\t\treturn t('nextcloud-vue', 'Location is inaccurate (±{accuracy} m). Wait for a better signal or add the address by hand.', { accuracy })\n\t\t\t}\n\t\t\tconst time = new Date(this.modelValue.at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })\n\t\t\treturn `${this.modelValue.lat.toFixed(4)}, ${this.modelValue.lng.toFixed(4)} · ±${accuracy} m · ${time}`\n\t\t},\n\t},\n\n\tmounted() {\n\t\tif (this.auto && !this.modelValue) {\n\t\t\tthis.retry()\n\t\t}\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Ask the device again. A fix replaces what is held, keeping a typed\n\t\t * address; no fix keeps it all.\n\t\t *\n\t\t * @return {Promise<void>}\n\t\t */\n\t\tasync retry() {\n\t\t\tthis.capturing = true\n\t\t\tconst fix = await captureLocation()\n\t\t\tthis.capturing = false\n\t\t\tif (fix) {\n\t\t\t\tthis.$emit('update:modelValue', { ...this.modelValue, ...fix, low: fix.accuracy > this.goodAccuracy })\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Keep the address typed by hand beside whatever fix there is.\n\t\t *\n\t\t * @param {string} address The address.\n\t\t * @return {void}\n\t\t */\n\t\tsetAddress(address) {\n\t\t\tthis.$emit('update:modelValue', { low: true, ...this.modelValue, address })\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-geo-capture {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 6px;\n}\n\n.cn-geo-capture__line {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-variant-numeric: tabular-nums;\n\tmargin: 0;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode"],"mappings":";;;AASM,EAAA,KAAI,EAAE,gBAAe;AAAE,EAAA,aAAW,EAAC,gBAAI;;;AACxC,EAAA,KAAK,EAAC,sBAAsB;AAAC,EAAA,IAAI,EAAC,QAAQ;AAAC,EAAA,aAAW,EAAC,qBAAqB;;;;;;;AAD/E,EAAA,QAAAA,SAAA,EAAA,EAAAC,kBAAA,QAAA;IACCC,kBAEG,CAAA,GAAA,EAFH,UAEG,EAAAC,eAAA,CADC,QAAO,CAAA,QAAA,CAAA,EAAA,CAAA,YAAA;AAEA,IAAA,CAAA,CAAA,QAAA,CAAA,SAAA,IAAA,QAAA,CAAA,YAAA;;UACVC,WAEU,CAAA,mBAAA,EAAA;AAFD,YAAA,OAAO,EAAC,UAAU;AAAC,YAAA,aAAU,EAAA,sBAAA;AAAA,YAAA,OAAA,EAAA,QAAA,CAAA,KAAA;;6BACtC,MAAqC;8CAAlC,QAAC,CAAA,CAAA,CAAA,eAAA,EAAA,WAAA,CAAA,CAAA,EAAA,CAAA,YAAA;;;;UAEJA;YACC,UAAO,EAAA,MAAA,CAAA,UAAA,EAAA,OAAA,IAAA,EAAA;AACP,YAAA,KAAC,EAAA,QAAA,CAAA,CAAA,CAAA,eAAA,EAAA,mBAAA,CAAA;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import script from './CnMarkdownEditor.vue2.js';
|
|
|
2
2
|
import { render } from './CnMarkdownEditor.vue3.js';
|
|
3
3
|
|
|
4
4
|
script.render = render;
|
|
5
|
-
script.__scopeId = "data-v-
|
|
5
|
+
script.__scopeId = "data-v-8f860382";
|
|
6
6
|
const __sfc_main = script;
|
|
7
7
|
|
|
8
8
|
export { __sfc_main as default };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { translate } from '@nextcloud/l10n';
|
|
2
|
+
import { NcActionButton, NcActions } from '@nextcloud/vue';
|
|
2
3
|
import { cnRenderMarkdown } from '../../composables/cnRenderMarkdown.js';
|
|
4
|
+
import { unknownTemplateVariables } from '../../utils/templateVariables.js';
|
|
3
5
|
import { guardedToastUiEditorClass } from '../../utils/toastUiRawHtmlGuard.js';
|
|
4
6
|
import { toastUiSanitizer } from '../../utils/toastUiSanitizer.js';
|
|
5
7
|
|
|
@@ -98,6 +100,10 @@ const DEFAULT_WYSIWYG_TOOLBAR = Object.freeze([
|
|
|
98
100
|
* textarea modes carry no editor dependency. The `v-model` contract
|
|
99
101
|
* is identical across all modes (`value` in, `input` out).
|
|
100
102
|
*
|
|
103
|
+
* With `variables`, a menu inserts `{name}` at the caret and the editor
|
|
104
|
+
* names every `{…}` in the text that is not allowed, under the editor and
|
|
105
|
+
* through the `unknown-variables` event, so a host can refuse to save.
|
|
106
|
+
*
|
|
101
107
|
* ```vue
|
|
102
108
|
* <CnMarkdownEditor v-model="article" placeholder="Write your article …" />
|
|
103
109
|
* <CnMarkdownEditor v-model="article" mode="wysiwyg" />
|
|
@@ -110,6 +116,8 @@ const DEFAULT_WYSIWYG_TOOLBAR = Object.freeze([
|
|
|
110
116
|
*/
|
|
111
117
|
var script = {
|
|
112
118
|
name: 'CnMarkdownEditor',
|
|
119
|
+
|
|
120
|
+
components: { NcActionButton, NcActions },
|
|
113
121
|
props: {
|
|
114
122
|
/**
|
|
115
123
|
* Markdown source (v-model).
|
|
@@ -171,6 +179,20 @@ var script = {
|
|
|
171
179
|
toolbar: { type: Array, default: () => DEFAULT_TOOLBAR.slice() },
|
|
172
180
|
/** Optional helper text rendered under the editor. */
|
|
173
181
|
hint: { type: String, default: '' },
|
|
182
|
+
/**
|
|
183
|
+
* Variables the text may use, written as `{name}`: names, or
|
|
184
|
+
* `{ name, label?, description? }`. Given, the editor offers an insert
|
|
185
|
+
* menu and names every `{…}` in the text that is not one of them. A
|
|
186
|
+
* dotted variable (`case.number`) is allowed under a listed `case`.
|
|
187
|
+
*/
|
|
188
|
+
variables: { type: Array, default: () => [] },
|
|
189
|
+
/**
|
|
190
|
+
* The message for unknown variables; `{names}` becomes the list.
|
|
191
|
+
* Defaults to "Unknown variable: {names}.".
|
|
192
|
+
*/
|
|
193
|
+
unknownVariableText: { type: String, default: '' },
|
|
194
|
+
/** The name of the insert menu. Defaults to "Insert variable". */
|
|
195
|
+
insertVariableText: { type: String, default: '' },
|
|
174
196
|
/**
|
|
175
197
|
* WYSIWYG mode only: Toast UI toolbar layout (array of button groups).
|
|
176
198
|
* Ignored in the textarea modes.
|
|
@@ -188,7 +210,7 @@ var script = {
|
|
|
188
210
|
// the component as its own `input` — after the component's own
|
|
189
211
|
// `$emit('input', value)` — and listeners receive the raw InputEvent
|
|
190
212
|
// instead of the string.
|
|
191
|
-
emits: ['input', 'update:modelValue', 'update:mode'],
|
|
213
|
+
emits: ['input', 'update:modelValue', 'update:mode', 'unknown-variables'],
|
|
192
214
|
data() {
|
|
193
215
|
return {
|
|
194
216
|
localValue: (this.modelValue !== undefined ? this.modelValue : this.value),
|
|
@@ -199,6 +221,59 @@ var script = {
|
|
|
199
221
|
},
|
|
200
222
|
|
|
201
223
|
computed: {
|
|
224
|
+
/**
|
|
225
|
+
* The allowed variables as `{ name, label, description }`.
|
|
226
|
+
*
|
|
227
|
+
* @return {Array<{name: string, label: string, description: string}>} The variables.
|
|
228
|
+
* @spec openspec/changes/markdown-editor-variables/tasks.md#task-1
|
|
229
|
+
*/
|
|
230
|
+
variableList() {
|
|
231
|
+
const list = Array.isArray(this.variables) ? this.variables : [];
|
|
232
|
+
return list
|
|
233
|
+
.map((v) => (typeof v === 'string' ? { name: v } : v))
|
|
234
|
+
.filter((v) => v && typeof v.name === 'string' && v.name !== '')
|
|
235
|
+
.map((v) => ({ name: v.name, label: v.label || v.name, description: v.description || '' }))
|
|
236
|
+
},
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* The variables in the text that are not allowed, each once, in order.
|
|
240
|
+
* Empty when no `variables` are given, so the check is off.
|
|
241
|
+
*
|
|
242
|
+
* @return {string[]} The unknown variable names.
|
|
243
|
+
* @spec openspec/changes/markdown-editor-variables/tasks.md#task-2
|
|
244
|
+
*/
|
|
245
|
+
unknownVariables() {
|
|
246
|
+
if (this.variableList.length === 0) {
|
|
247
|
+
return []
|
|
248
|
+
}
|
|
249
|
+
return unknownTemplateVariables(this.localValue, this.variableList.map((v) => v.name))
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The message under the editor for the unknown variables.
|
|
254
|
+
*
|
|
255
|
+
* @return {string} The message.
|
|
256
|
+
* @spec openspec/changes/markdown-editor-variables/tasks.md#task-2
|
|
257
|
+
*/
|
|
258
|
+
unknownVariableMessage() {
|
|
259
|
+
const names = this.unknownVariables.map((name) => `{${name}}`).join(', ');
|
|
260
|
+
if (this.unknownVariableText) {
|
|
261
|
+
return this.unknownVariableText.split('{names}').join(names)
|
|
262
|
+
}
|
|
263
|
+
return this.unknownVariables.length === 1
|
|
264
|
+
? translate('nextcloud-vue', 'Unknown variable: {names}.', { names }, undefined, { escape: false })
|
|
265
|
+
: translate('nextcloud-vue', 'Unknown variables: {names}.', { names }, undefined, { escape: false })
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* The name of the insert menu.
|
|
270
|
+
*
|
|
271
|
+
* @return {string} The name.
|
|
272
|
+
*/
|
|
273
|
+
insertVariableLabel() {
|
|
274
|
+
return this.insertVariableText || translate('nextcloud-vue', 'Insert variable')
|
|
275
|
+
},
|
|
276
|
+
|
|
202
277
|
/**
|
|
203
278
|
* BEM modifier for the current layout mode.
|
|
204
279
|
*
|
|
@@ -274,6 +349,24 @@ var script = {
|
|
|
274
349
|
},
|
|
275
350
|
|
|
276
351
|
watch: {
|
|
352
|
+
unknownVariables: {
|
|
353
|
+
immediate: true,
|
|
354
|
+
handler(next, previous) {
|
|
355
|
+
if (previous === undefined && next.length === 0) {
|
|
356
|
+
return
|
|
357
|
+
}
|
|
358
|
+
if (previous && previous.join('\n') === next.join('\n')) {
|
|
359
|
+
return
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* @event unknown-variables The unknown variables in the text changed;
|
|
363
|
+
* empty when every variable is known again.
|
|
364
|
+
* @type {string[]}
|
|
365
|
+
*/
|
|
366
|
+
this.$emit('unknown-variables', next);
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
|
|
277
370
|
// Both spellings watched, because either may be the one the consumer
|
|
278
371
|
// bound. `boundValue` collapses them so the body is written once.
|
|
279
372
|
modelValue() {
|
|
@@ -718,6 +811,22 @@ var script = {
|
|
|
718
811
|
});
|
|
719
812
|
},
|
|
720
813
|
|
|
814
|
+
/**
|
|
815
|
+
* Insert `{name}` at the caret.
|
|
816
|
+
*
|
|
817
|
+
* @param {string} name The variable name.
|
|
818
|
+
* @return {void}
|
|
819
|
+
* @spec openspec/changes/markdown-editor-variables/tasks.md#task-1
|
|
820
|
+
*/
|
|
821
|
+
insertVariable(name) {
|
|
822
|
+
const token = `{${name}}`;
|
|
823
|
+
if (this.mode === 'wysiwyg' && this.toastEditor) {
|
|
824
|
+
this.toastEditor.insertText(token);
|
|
825
|
+
return
|
|
826
|
+
}
|
|
827
|
+
this.insertAtCaret(token);
|
|
828
|
+
},
|
|
829
|
+
|
|
721
830
|
/**
|
|
722
831
|
* Programmatic insert helper — exposed publicly so parents
|
|
723
832
|
* can drop content at the caret (e.g. from a file-picker
|