aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
-rw-r--r--src/client/views/nodes/formattedText/RichTextRules.ts8
-rw-r--r--src/fields/Doc.ts5
3 files changed, 11 insertions, 4 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 9368560e9..bd046d6ff 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1502,7 +1502,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
({ code, first }) => {
if (!code.includes('dashDiv')) {
const script = CompileScript(code, { params: { docView: 'any' }, typecheck: false, editable: true });
- if (script.compiled) script.run({ this: this.Document, docView: this.DocumentView?.() });
+ if (script.compiled) script.run({ this: this.DocumentView?.() });
} else code && !first && eval(code);
},
{ fireImmediately: true }
diff --git a/src/client/views/nodes/formattedText/RichTextRules.ts b/src/client/views/nodes/formattedText/RichTextRules.ts
index ce2c33fb4..2fdd6374a 100644
--- a/src/client/views/nodes/formattedText/RichTextRules.ts
+++ b/src/client/views/nodes/formattedText/RichTextRules.ts
@@ -289,7 +289,7 @@ export class RichTextRules {
// [[fieldKey=value]] => show field and also set its value
// [[fieldKey:docTitle]] => show field of doc
new InputRule(
- new RegExp(/\[\[([a-zA-Z_\? \-0-9]*)(=[a-zA-Z_@\? /\-0-9]*)?(:[a-zA-Z_@:\.\? \-0-9]+)?\]\]$/),
+ new RegExp(/\[\[([a-zA-Z_\? \-0-9]*)(=[a-z,A-Z_@\? /\-0-9]*)?(:[a-zA-Z_@:\.\? \-0-9]+)?\]\]$/),
(state, match, start, end) => {
const fieldKey = match[1];
const docTitle = match[3]?.replace(':', '');
@@ -325,7 +325,11 @@ export class RichTextRules {
}
return state.tr;
}
- if (value !== '' && value !== undefined) {
+ if (value?.includes(',')) {
+ const values = value.split(',');
+ const strs = values.some(v => !v.match(/^[-]?[0-9.]$/));
+ this.Document[DocData][fieldKey] = strs ? new List<string>(values) : new List<number>(values.map(v => Number(v)));
+ } else if (value !== '' && value !== undefined) {
const num = value.match(/^[0-9.]$/);
this.Document[DocData][fieldKey] = value === 'true' ? true : value === 'false' ? false : num ? Number(value) : value;
}
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index f3fc51671..ab6d0390b 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -67,7 +67,10 @@ export namespace Field {
// as a kind of macro to include the content of those documents
Doc.MyPublishedDocs.forEach(doc => {
const regex = new RegExp(`^\\^${doc.title}\\s`, 'm');
- script = script.replace(regex, Cast(doc.text, RichTextField, null)?.Text ?? '');
+ const sections = (Cast(doc.text, RichTextField, null)?.Text ?? '').split('--DOCDATA--');
+ if (script.match(regex)) {
+ script = script.replace(regex, sections[0]) + (sections.length > 1 ? sections[1] : '');
+ }
});
return script;
}