@dative-gpi/foundation-shared-components 0.0.211 → 0.0.212
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.
|
@@ -138,10 +138,10 @@
|
|
|
138
138
|
:elevation="true"
|
|
139
139
|
>
|
|
140
140
|
<FSAutoCompleteField
|
|
141
|
-
itemTitle="
|
|
141
|
+
itemTitle="label"
|
|
142
|
+
itemValue="code"
|
|
142
143
|
:placeholder="$tr('ui.rich-text-field.variable-placeholder', 'Choose a variable...')"
|
|
143
144
|
:items="$props.variableReferences"
|
|
144
|
-
:returnObject="true"
|
|
145
145
|
@update:modelValue="insertVariable($event)"
|
|
146
146
|
/>
|
|
147
147
|
</FSCard>
|
|
@@ -291,7 +291,7 @@ export default defineComponent({
|
|
|
291
291
|
default: () => []
|
|
292
292
|
},
|
|
293
293
|
variableValues: {
|
|
294
|
-
type: Object
|
|
294
|
+
type: Object as PropType<{ [key: string]: any }>,
|
|
295
295
|
required: false,
|
|
296
296
|
default: () => ({})
|
|
297
297
|
},
|
|
@@ -502,12 +502,16 @@ export default defineComponent({
|
|
|
502
502
|
});
|
|
503
503
|
};
|
|
504
504
|
|
|
505
|
-
const insertVariable = (
|
|
505
|
+
const insertVariable = (code: string) => {
|
|
506
|
+
const variable = props.variableReferences.find((v) => v.code === code);
|
|
507
|
+
if (!variable) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
506
510
|
menuVariable.value = false;
|
|
507
511
|
editor.update(() => {
|
|
508
512
|
const selection = $getSelection();
|
|
509
513
|
if ($isRangeSelection(selection)) {
|
|
510
|
-
const variableNode = $createVariableNode(
|
|
514
|
+
const variableNode = $createVariableNode(code, variable.defaultValue);
|
|
511
515
|
selection.insertNodes([variableNode]);
|
|
512
516
|
}
|
|
513
517
|
});
|
package/components/map/FSMap.vue
CHANGED
package/models/variableNode.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type LexicalNode, DecoratorNode, type SerializedLexicalNode, type Spread, type EditorConfig, type LexicalEditor } from "lexical";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { type RichTextVariable } from "./richTextVariable";
|
|
3
4
|
|
|
4
5
|
export type SerializedVariableNode = Spread<
|
|
5
6
|
{
|
|
6
7
|
type: "variable";
|
|
7
8
|
code: string;
|
|
8
9
|
defaultValue: string;
|
|
9
|
-
typeName: string;
|
|
10
10
|
},
|
|
11
11
|
SerializedLexicalNode
|
|
12
12
|
>;
|
|
@@ -14,7 +14,6 @@ export type SerializedVariableNode = Spread<
|
|
|
14
14
|
export class VariableNode extends DecoratorNode<Element> {
|
|
15
15
|
__code: string;
|
|
16
16
|
__defaultValue: string;
|
|
17
|
-
__typeName: string;
|
|
18
17
|
readonlyMode: boolean;
|
|
19
18
|
|
|
20
19
|
static getType() {
|
|
@@ -22,20 +21,21 @@ export class VariableNode extends DecoratorNode<Element> {
|
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
static clone(node: VariableNode) {
|
|
25
|
-
return new VariableNode(node.__code, node.__defaultValue, node.
|
|
24
|
+
return new VariableNode(node.__code, node.__defaultValue, node.__key);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
constructor(code: string, defaultValue: string,
|
|
27
|
+
constructor(code: string, defaultValue: string, key?: string) {
|
|
29
28
|
super(key);
|
|
30
29
|
this.__code = code;
|
|
31
30
|
this.__defaultValue = defaultValue;
|
|
32
|
-
this.__typeName = typeName;
|
|
33
31
|
this.readonlyMode = false;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
getValue(editorElement: HTMLElement): any {
|
|
37
35
|
const variableValues = editorElement.dataset.variableValues;
|
|
38
|
-
if (!variableValues) {
|
|
36
|
+
if (!variableValues) {
|
|
37
|
+
return this.__defaultValue;
|
|
38
|
+
}
|
|
39
39
|
const values = JSON.parse(variableValues);
|
|
40
40
|
return values[this.__code] ?? this.__defaultValue;
|
|
41
41
|
}
|
|
@@ -51,10 +51,12 @@ export class VariableNode extends DecoratorNode<Element> {
|
|
|
51
51
|
content.classList.add("fs-rich-text-field-node-variable-value");
|
|
52
52
|
if (_editor._rootElement) {
|
|
53
53
|
content.textContent = this.getValue(_editor._rootElement);
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
55
56
|
content.textContent = this.__defaultValue;
|
|
56
57
|
}
|
|
57
|
-
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
58
60
|
content.classList.add("fs-rich-text-field-node-variable-code");
|
|
59
61
|
content.textContent = `{${this.__code}}`
|
|
60
62
|
}
|
|
@@ -71,8 +73,7 @@ export class VariableNode extends DecoratorNode<Element> {
|
|
|
71
73
|
type: "variable",
|
|
72
74
|
version: 1,
|
|
73
75
|
code: this.__code,
|
|
74
|
-
defaultValue: this.__defaultValue
|
|
75
|
-
typeName: this.__typeName,
|
|
76
|
+
defaultValue: this.__defaultValue
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -83,20 +84,18 @@ export class VariableNode extends DecoratorNode<Element> {
|
|
|
83
84
|
static importJSON(serializedNode: SerializedVariableNode): VariableNode {
|
|
84
85
|
return new VariableNode(
|
|
85
86
|
serializedNode.code,
|
|
86
|
-
serializedNode.defaultValue
|
|
87
|
-
serializedNode.typeName
|
|
87
|
+
serializedNode.defaultValue
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
export function $createVariableNode(code: string, defaultValue: string
|
|
93
|
-
return new VariableNode(code, defaultValue
|
|
92
|
+
export function $createVariableNode(code: string, defaultValue: string): VariableNode {
|
|
93
|
+
return new VariableNode(code, defaultValue);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export function $modifyVariableNode(node: VariableNode, newValue: RichTextVariable): VariableNode {
|
|
97
97
|
node.__code = newValue.code;
|
|
98
98
|
node.__defaultValue = newValue.defaultValue;
|
|
99
|
-
node.__typeName = newValue.typeName;
|
|
100
99
|
return node;
|
|
101
100
|
}
|
|
102
101
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.212",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "0.0.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "0.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "0.0.212",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "0.0.212"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@dative-gpi/bones-ui": "^0.0.75",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sass": "1.71.1",
|
|
36
36
|
"sass-loader": "13.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "f91d3811c68a2c71bd08beacb5f0f7135ac0b8d2"
|
|
39
39
|
}
|