@saltcorn/builder 0.7.4-beta.2 → 0.7.4-beta.3
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/builder_bundle.js +1 -1
- package/package.json +1 -1
- package/src/components/elements/Link.js +222 -204
package/package.json
CHANGED
|
@@ -34,44 +34,43 @@ export /**
|
|
|
34
34
|
* @category saltcorn-builder
|
|
35
35
|
* @subcategory components
|
|
36
36
|
*/
|
|
37
|
-
const Link = ({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
? {
|
|
37
|
+
const Link = ({
|
|
38
|
+
text,
|
|
39
|
+
block,
|
|
40
|
+
isFormula,
|
|
41
|
+
textStyle,
|
|
42
|
+
link_style,
|
|
43
|
+
link_size,
|
|
44
|
+
link_icon,
|
|
45
|
+
link_bgcol,
|
|
46
|
+
link_bordercol,
|
|
47
|
+
link_textcol,
|
|
48
|
+
}) => {
|
|
49
|
+
const {
|
|
50
|
+
selected,
|
|
51
|
+
connectors: { connect, drag },
|
|
52
|
+
} = useNode((node) => ({ selected: node.events.selected }));
|
|
53
|
+
return (
|
|
54
|
+
<span
|
|
55
|
+
className={`${textStyle} is-builder-link ${selected ? "selected-node" : ""
|
|
56
|
+
} ${isFormula?.text ? "font-monospace" : ""} ${link_style} ${link_size}`}
|
|
57
|
+
{...blockProps(block)}
|
|
58
|
+
ref={(dom) => connect(drag(dom))}
|
|
59
|
+
style={
|
|
60
|
+
link_style === "btn btn-custom-color"
|
|
61
|
+
? {
|
|
63
62
|
backgroundColor: link_bgcol || "#000000",
|
|
64
63
|
borderColor: link_bordercol || "#000000",
|
|
65
64
|
color: link_textcol || "#000000",
|
|
66
65
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
66
|
+
: {}
|
|
67
|
+
}
|
|
68
|
+
>
|
|
69
|
+
<DynamicFontAwesomeIcon icon={link_icon} className="me-1" />
|
|
70
|
+
{isFormula?.text ? `=${text}` : text}
|
|
71
|
+
</span>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
75
74
|
|
|
76
75
|
export /**
|
|
77
76
|
* @returns {div}
|
|
@@ -79,205 +78,222 @@ export /**
|
|
|
79
78
|
* @category saltcorn-builder
|
|
80
79
|
* @subcategory components
|
|
81
80
|
*/
|
|
82
|
-
const LinkSettings = () => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
<label>Text to display</label>
|
|
123
|
-
</td>
|
|
124
|
-
<td>
|
|
125
|
-
<OrFormula nodekey="text" {...{ setProp, isFormula, node }}>
|
|
126
|
-
<input
|
|
127
|
-
type="text"
|
|
128
|
-
className="form-control text-to-display"
|
|
129
|
-
value={text}
|
|
130
|
-
onChange={setAProp("text")}
|
|
131
|
-
/>
|
|
132
|
-
</OrFormula>
|
|
133
|
-
</td>
|
|
134
|
-
</tr>
|
|
135
|
-
<tr>
|
|
136
|
-
<td>
|
|
137
|
-
<label>Link source</label>
|
|
138
|
-
</td>
|
|
139
|
-
<td>
|
|
140
|
-
<select
|
|
141
|
-
value={link_src}
|
|
142
|
-
className="form-control form-select"
|
|
143
|
-
onChange={(e) => {
|
|
144
|
-
if (!e.target) return;
|
|
145
|
-
const value = e.target.value;
|
|
146
|
-
setProp((prop) => {
|
|
147
|
-
prop.link_src = value;
|
|
148
|
-
if (e.target.value !== "URL") {
|
|
149
|
-
prop.isFormula.url = false;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}}
|
|
153
|
-
>
|
|
154
|
-
<option>URL</option>
|
|
155
|
-
{(options.pages || []).length > 0 && <option>Page</option>}
|
|
156
|
-
{(options.views || []).length > 0 &&
|
|
157
|
-
["page", "filter"].includes(options.mode) && (
|
|
158
|
-
<option>View</option>
|
|
159
|
-
)}
|
|
160
|
-
</select>
|
|
161
|
-
</td>
|
|
162
|
-
</tr>
|
|
163
|
-
{link_src === "URL" && (
|
|
81
|
+
const LinkSettings = () => {
|
|
82
|
+
const node = useNode((node) => ({
|
|
83
|
+
text: node.data.props.text,
|
|
84
|
+
url: node.data.props.url,
|
|
85
|
+
block: node.data.props.block,
|
|
86
|
+
isFormula: node.data.props.isFormula,
|
|
87
|
+
textStyle: node.data.props.textStyle,
|
|
88
|
+
nofollow: node.data.props.nofollow,
|
|
89
|
+
in_modal: node.data.props.in_modal,
|
|
90
|
+
view_state_fml: node.data.props.view_state_fml,
|
|
91
|
+
link_src: node.data.props.link_src,
|
|
92
|
+
target_blank: node.data.props.target_blank,
|
|
93
|
+
link_style: node.data.props.link_style,
|
|
94
|
+
link_size: node.data.props.link_size,
|
|
95
|
+
link_icon: node.data.props.link_icon,
|
|
96
|
+
link_bgcol: node.data.props.link_bgcol,
|
|
97
|
+
link_bordercol: node.data.props.link_bordercol,
|
|
98
|
+
link_textcol: node.data.props.link_textcol,
|
|
99
|
+
transfer_state: node.data.props.transfer_state,
|
|
100
|
+
}));
|
|
101
|
+
const {
|
|
102
|
+
actions: { setProp },
|
|
103
|
+
text,
|
|
104
|
+
url,
|
|
105
|
+
block,
|
|
106
|
+
isFormula,
|
|
107
|
+
textStyle,
|
|
108
|
+
nofollow,
|
|
109
|
+
target_blank,
|
|
110
|
+
link_src,
|
|
111
|
+
in_modal,
|
|
112
|
+
transfer_state,
|
|
113
|
+
view_state_fml
|
|
114
|
+
} = node;
|
|
115
|
+
const options = useContext(optionsCtx);
|
|
116
|
+
const setAProp = setAPropGen(setProp);
|
|
117
|
+
return (
|
|
118
|
+
<div>
|
|
119
|
+
<table className="w-100">
|
|
120
|
+
<tbody>
|
|
164
121
|
<tr>
|
|
165
122
|
<td>
|
|
166
|
-
<label>
|
|
123
|
+
<label>Text to display</label>
|
|
167
124
|
</td>
|
|
168
125
|
<td>
|
|
169
|
-
<OrFormula nodekey="
|
|
126
|
+
<OrFormula nodekey="text" {...{ setProp, isFormula, node }}>
|
|
170
127
|
<input
|
|
171
128
|
type="text"
|
|
172
|
-
className="form-control "
|
|
173
|
-
value={
|
|
174
|
-
onChange={setAProp("
|
|
129
|
+
className="form-control text-to-display"
|
|
130
|
+
value={text}
|
|
131
|
+
onChange={setAProp("text")}
|
|
175
132
|
/>
|
|
176
133
|
</OrFormula>
|
|
177
134
|
</td>
|
|
178
135
|
</tr>
|
|
179
|
-
)}
|
|
180
|
-
{link_src === "Page" && (
|
|
181
|
-
<tr>
|
|
182
|
-
<td>
|
|
183
|
-
<label>Page</label>
|
|
184
|
-
</td>
|
|
185
|
-
<td>
|
|
186
|
-
<select
|
|
187
|
-
value={url}
|
|
188
|
-
className="form-control form-select"
|
|
189
|
-
onChange={setAProp("url")}
|
|
190
|
-
>
|
|
191
|
-
<option></option>
|
|
192
|
-
{(options.pages || []).map((p, ix) => (
|
|
193
|
-
<option key={ix} value={`/page/${p.name}`}>
|
|
194
|
-
{p.name}
|
|
195
|
-
</option>
|
|
196
|
-
))}
|
|
197
|
-
</select>
|
|
198
|
-
</td>
|
|
199
|
-
</tr>
|
|
200
|
-
)}
|
|
201
|
-
{link_src === "View" && (
|
|
202
136
|
<tr>
|
|
203
137
|
<td>
|
|
204
|
-
<label>
|
|
138
|
+
<label>Link source</label>
|
|
205
139
|
</td>
|
|
206
140
|
<td>
|
|
207
141
|
<select
|
|
208
|
-
value={
|
|
142
|
+
value={link_src}
|
|
209
143
|
className="form-control form-select"
|
|
210
|
-
onChange={
|
|
144
|
+
onChange={(e) => {
|
|
145
|
+
if (!e.target) return;
|
|
146
|
+
const value = e.target.value;
|
|
147
|
+
setProp((prop) => {
|
|
148
|
+
prop.link_src = value;
|
|
149
|
+
if (value !== "URL" && prop.isFormula) {
|
|
150
|
+
prop.isFormula.url = false;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}}
|
|
211
154
|
>
|
|
212
|
-
<option
|
|
213
|
-
{(options.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
155
|
+
<option>URL</option>
|
|
156
|
+
{(options.pages || []).length > 0 && <option>Page</option>}
|
|
157
|
+
{(options.views || []).length > 0 &&
|
|
158
|
+
["page", "filter"].includes(options.mode) && (
|
|
159
|
+
<option>View</option>
|
|
160
|
+
)}
|
|
218
161
|
</select>
|
|
219
162
|
</td>
|
|
220
163
|
</tr>
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
164
|
+
{link_src === "URL" && (
|
|
165
|
+
<tr>
|
|
166
|
+
<td>
|
|
167
|
+
<label>URL</label>
|
|
168
|
+
</td>
|
|
169
|
+
<td>
|
|
170
|
+
<OrFormula nodekey="url" {...{ setProp, isFormula, node }}>
|
|
171
|
+
<input
|
|
172
|
+
type="text"
|
|
173
|
+
className="form-control "
|
|
174
|
+
value={url}
|
|
175
|
+
onChange={setAProp("url")}
|
|
176
|
+
/>
|
|
177
|
+
</OrFormula>
|
|
178
|
+
</td>
|
|
179
|
+
</tr>
|
|
180
|
+
)}
|
|
181
|
+
{link_src === "Page" && (
|
|
182
|
+
<tr>
|
|
183
|
+
<td>
|
|
184
|
+
<label>Page</label>
|
|
185
|
+
</td>
|
|
186
|
+
<td>
|
|
187
|
+
<select
|
|
188
|
+
value={url}
|
|
189
|
+
className="form-control form-select"
|
|
190
|
+
onChange={setAProp("url")}
|
|
191
|
+
>
|
|
192
|
+
<option></option>
|
|
193
|
+
{(options.pages || []).map((p, ix) => (
|
|
194
|
+
<option key={ix} value={`/page/${p.name}`}>
|
|
195
|
+
{p.name}
|
|
196
|
+
</option>
|
|
197
|
+
))}
|
|
198
|
+
</select>
|
|
199
|
+
</td>
|
|
200
|
+
</tr>
|
|
201
|
+
)}
|
|
202
|
+
{link_src === "View" && (
|
|
203
|
+
<tr>
|
|
204
|
+
<td>
|
|
205
|
+
<label>View</label>
|
|
206
|
+
</td>
|
|
207
|
+
<td>
|
|
208
|
+
<select
|
|
209
|
+
value={url}
|
|
210
|
+
className="form-control form-select"
|
|
211
|
+
onChange={setAProp("url")}
|
|
212
|
+
>
|
|
213
|
+
<option></option>
|
|
214
|
+
{(options.views || []).map((p, ix) => (
|
|
215
|
+
<option key={ix} value={`/view/${p.name}`}>
|
|
216
|
+
{p.name} [{p.viewtemplate}]
|
|
217
|
+
</option>
|
|
218
|
+
))}
|
|
219
|
+
</select>
|
|
220
|
+
</td>
|
|
221
|
+
</tr>
|
|
222
|
+
)}
|
|
223
|
+
{link_src === "View" && (
|
|
224
|
+
<tr>
|
|
225
|
+
<td>
|
|
226
|
+
<label>State Formula</label>
|
|
227
|
+
</td>
|
|
228
|
+
<td>
|
|
229
|
+
<input
|
|
230
|
+
type="text"
|
|
231
|
+
className="form-control"
|
|
232
|
+
value={view_state_fml}
|
|
233
|
+
onChange={setAProp("view_state_fml")}
|
|
234
|
+
/>
|
|
235
|
+
</td>
|
|
236
|
+
</tr>
|
|
237
|
+
)}
|
|
238
|
+
<ButtonOrLinkSettingsRows
|
|
239
|
+
setProp={setProp}
|
|
240
|
+
keyPrefix="link_"
|
|
241
|
+
btnClass="btn"
|
|
242
|
+
values={node}
|
|
243
|
+
linkFirst={true}
|
|
244
|
+
/>
|
|
245
|
+
</tbody>
|
|
246
|
+
</table>
|
|
262
247
|
|
|
263
|
-
{["filter", "page"].includes(options.mode) && (
|
|
264
248
|
<div className="form-check">
|
|
265
249
|
<input
|
|
266
250
|
className="form-check-input"
|
|
267
251
|
name="block"
|
|
268
252
|
type="checkbox"
|
|
269
|
-
checked={
|
|
270
|
-
onChange={setAProp("
|
|
253
|
+
checked={nofollow}
|
|
254
|
+
onChange={setAProp("nofollow", { checked: true })}
|
|
271
255
|
/>
|
|
272
|
-
<label className="form-check-label">
|
|
256
|
+
<label className="form-check-label">Nofollow</label>
|
|
257
|
+
</div>
|
|
258
|
+
<div className="form-check">
|
|
259
|
+
<input
|
|
260
|
+
className="form-check-input"
|
|
261
|
+
name="block"
|
|
262
|
+
type="checkbox"
|
|
263
|
+
checked={target_blank}
|
|
264
|
+
onChange={setAProp("target_blank", { checked: true })}
|
|
265
|
+
/>
|
|
266
|
+
<label className="form-check-label">Open in new tab</label>
|
|
267
|
+
</div>
|
|
268
|
+
<div className="form-check">
|
|
269
|
+
<input
|
|
270
|
+
className="form-check-input"
|
|
271
|
+
name="block"
|
|
272
|
+
type="checkbox"
|
|
273
|
+
checked={in_modal}
|
|
274
|
+
onChange={setAProp("in_modal", { checked: true })}
|
|
275
|
+
/>
|
|
276
|
+
<label className="form-check-label">Open in popup modal?</label>
|
|
273
277
|
</div>
|
|
274
|
-
)}
|
|
275
278
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
279
|
+
{["filter", "page"].includes(options.mode) && (
|
|
280
|
+
<div className="form-check">
|
|
281
|
+
<input
|
|
282
|
+
className="form-check-input"
|
|
283
|
+
name="block"
|
|
284
|
+
type="checkbox"
|
|
285
|
+
checked={transfer_state}
|
|
286
|
+
onChange={setAProp("transfer_state", { checked: true })}
|
|
287
|
+
/>
|
|
288
|
+
<label className="form-check-label">Transfer state</label>
|
|
289
|
+
</div>
|
|
290
|
+
)}
|
|
291
|
+
|
|
292
|
+
<BlockSetting block={block} setProp={setProp} />
|
|
293
|
+
<TextStyleSetting textStyle={textStyle} setProp={setProp} />
|
|
294
|
+
</div>
|
|
295
|
+
);
|
|
296
|
+
};
|
|
281
297
|
|
|
282
298
|
/**
|
|
283
299
|
* @type {object}
|
|
@@ -313,6 +329,8 @@ Link.craft = {
|
|
|
313
329
|
"link_textcol",
|
|
314
330
|
"in_modal",
|
|
315
331
|
"transfer_state",
|
|
332
|
+
"view_state_fml"
|
|
333
|
+
|
|
316
334
|
],
|
|
317
335
|
},
|
|
318
336
|
};
|