diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2020-01-30 01:42:50 -0500 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2020-01-30 01:42:50 -0500 |
commit | 03c97e178c7c768cd37f24043d1804816fab6253 (patch) | |
tree | f64a1a2f63e7e3408c27186ea24aee3623330c56 /src/client/util/RichTextRules.ts | |
parent | bbaf25c10a3e1fcb36c75d8dedc825a955eab369 (diff) |
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
Diffstat (limited to 'src/client/util/RichTextRules.ts')
-rw-r--r-- | src/client/util/RichTextRules.ts | 5 |
1 files changed, 4 insertions, 1 deletions
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; |