From 0142f4e14cc8e291ee5acbae3cc4b81c95c4634a Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 23 Jan 2020 00:40:55 -0500
Subject: got rid of rule provider stuff.  fixed panning in freeform view with
 pivot layouts

---
 src/client/views/collections/CollectionSchemaCells.tsx | 1 -
 1 file changed, 1 deletion(-)

(limited to 'src/client/views/collections/CollectionSchemaCells.tsx')

diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 79a34bc00..7e990ab4d 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -145,7 +145,6 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
             DataDoc: this.props.rowProps.original,
             LibraryPath: [],
             fieldKey: this.props.rowProps.column.id as string,
-            ruleProvider: undefined,
             ContainingCollectionView: this.props.CollectionView,
             ContainingCollectionDoc: this.props.CollectionView && this.props.CollectionView.props.Document,
             isSelected: returnFalse,
-- 
cgit v1.2.3-70-g09d2


From 03c97e178c7c768cd37f24043d1804816fab6253 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 30 Jan 2020 01:42:50 -0500
Subject: fixed adding inline docs in active templates.  added image templates.
  made schema scripts editable & no type check

this.data.map((d,i) => d.proto.caption = copyField(this.captions[i]?.data)).length
---
 src/client/util/DropConverter.ts                       | 5 +++--
 src/client/util/RichTextRules.ts                       | 5 ++++-
 src/client/views/collections/CollectionSchemaCells.tsx | 4 ++--
 src/new_fields/ObjectField.ts                          | 2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

(limited to 'src/client/views/collections/CollectionSchemaCells.tsx')

diff --git a/src/client/util/DropConverter.ts b/src/client/util/DropConverter.ts
index 03d8ac953..669ac5336 100644
--- a/src/client/util/DropConverter.ts
+++ b/src/client/util/DropConverter.ts
@@ -6,6 +6,7 @@ import { StrCast } from "../../new_fields/Types";
 import { Docs } from "../documents/Documents";
 import { ScriptField, ComputedField } from "../../new_fields/ScriptField";
 import { RichTextField } from "../../new_fields/RichTextField";
+import { ImageField } from "../../new_fields/URLField";
 
 export function makeTemplate(doc: Doc): boolean {
     const layoutDoc = doc.layout instanceof Doc && doc.layout.isTemplateForField ? doc.layout : doc;
@@ -20,7 +21,7 @@ export function makeTemplate(doc: Doc): boolean {
             any = makeTemplate(d) || any;
         }
     });
-    if (layoutDoc[fieldKey] instanceof RichTextField) {
+    if (layoutDoc[fieldKey] instanceof RichTextField || layoutDoc[fieldKey] instanceof ImageField) {
         if (!StrCast(layoutDoc.title).startsWith("-")) {
             any = Doc.MakeMetadataFieldTemplate(layoutDoc, Doc.GetProto(layoutDoc));
         }
@@ -33,7 +34,7 @@ export function convertDropDataToButtons(data: DragManager.DocumentDragData) {
         // bcz: isButtonBar is intended to allow a collection of linear buttons to be dropped and nested into another collection of buttons... it's not being used yet, and isn't very elegant
         if (!doc.onDragStart && !doc.onClick && !doc.isButtonBar) {
             const layoutDoc = doc.layout instanceof Doc && doc.layout.isTemplateForField ? doc.layout : doc;
-            if (layoutDoc.type === DocumentType.COL || layoutDoc.type === DocumentType.TEXT) {
+            if (layoutDoc.type === DocumentType.COL || layoutDoc.type === DocumentType.TEXT || layoutDoc.type === DocumentType.IMG) {
                 layoutDoc.isTemplateDoc = makeTemplate(layoutDoc);
             } else {
                 layoutDoc.isTemplateDoc = (layoutDoc.layout instanceof Doc) && !data.userDropAction;
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts
index d00921626..38cd5ca5c 100644
--- a/src/client/util/RichTextRules.ts
+++ b/src/client/util/RichTextRules.ts
@@ -11,6 +11,7 @@ import { DocServer } from "../DocServer";
 import { returnFalse, Utils } from "../../Utils";
 import RichTextMenu from "./RichTextMenu";
 import { RichTextField } from "../../new_fields/RichTextField";
+import { ComputedField } from "../../new_fields/ScriptField";
 
 export const inpRules = {
     rules: [
@@ -206,7 +207,8 @@ export const inpRules = {
         new InputRule(
             new RegExp(/##$/),
             (state, match, start, end) => {
-                const textDoc = Doc.GetProto(Cast((schema as any).Document[DataSym], Doc, null)!);
+                const schemaDoc = Doc.GetDataDoc((schema as any).Document);
+                const textDoc = Doc.GetProto(Cast(schemaDoc[DataSym], Doc, null)!);
                 const numInlines = NumCast(textDoc.inlineTextCount);
                 textDoc.inlineTextCount = numInlines + 1;
                 const inlineFieldKey = "inline" + numInlines; // which field on the text document this annotation will write to
@@ -216,6 +218,7 @@ export const inpRules = {
                 textDocInline.customTitle = true; // And make sure that it's 'custom' so that editing text doesn't change the title of the containing doc
                 textDocInline.isTemplateForField = inlineFieldKey; // this is needed in case the containing text doc is converted to a template at some point
                 textDocInline.proto = textDoc;  // make the annotation inherit from the outer text doc so that it can resolve any nested field references, e.g., [[field]]
+                textDocInline._textContext = ComputedField.MakeFunction(`copyField(this.${inlineFieldKey})`, { this: Doc.name });
                 textDoc[inlineLayoutKey] = FormattedTextBox.LayoutString(inlineFieldKey); // create a layout string for the layout key that will render the annotation text
                 textDoc[inlineFieldKey] = ""; // set a default value for the annotation
                 const node = (state.doc.resolve(start) as any).nodeAfter;
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 7e990ab4d..caffa7eb1 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -225,14 +225,14 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                                 if (value.startsWith(":=")) {
                                     return this.props.setComputed(value.substring(2), props.Document, this.props.rowProps.column.id!, this.props.row, this.props.col);
                                 }
-                                const script = CompileScript(value, { requiredType: type, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } });
+                                const script = CompileScript(value, { requiredType: type, typecheck: false, editable: true, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } });
                                 if (!script.compiled) {
                                     return false;
                                 }
                                 return this.applyToDoc(props.Document, this.props.row, this.props.col, script.run);
                             }}
                             OnFillDown={async (value: string) => {
-                                const script = CompileScript(value, { requiredType: type, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } });
+                                const script = CompileScript(value, { requiredType: type, typecheck: false, editable: true, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } });
                                 if (script.compiled) {
                                     DocListCast(this.props.Document[this.props.fieldKey]).
                                         forEach((doc, i) => this.applyToDoc(doc, i, this.props.col, script.run));
diff --git a/src/new_fields/ObjectField.ts b/src/new_fields/ObjectField.ts
index b693c8c98..566104b40 100644
--- a/src/new_fields/ObjectField.ts
+++ b/src/new_fields/ObjectField.ts
@@ -14,7 +14,7 @@ export abstract class ObjectField {
 
 export namespace ObjectField {
     export function MakeCopy<T extends ObjectField>(field: T) {
-        return field[Copy]();
+        return field?.[Copy]();
     }
 }
 
-- 
cgit v1.2.3-70-g09d2

