aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/RichTextRules.ts
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2020-01-28 19:58:26 -0500
committerBob Zeleznik <zzzman@gmail.com>2020-01-28 19:58:26 -0500
commit2c9b61d0166d825e062f7c16f9344fd5f23aa3ed (patch)
treef7c875f7ceb28daf2114d8865fe948d49a418ee9 /src/client/util/RichTextRules.ts
parent7f27720aa9b3dd691b95635ea8b345a5a14a417f (diff)
minor cleanup so that layout strings are all stored in layout_<name> fields
Diffstat (limited to 'src/client/util/RichTextRules.ts')
-rw-r--r--src/client/util/RichTextRules.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts
index 1de8e7175..d56a6a5fe 100644
--- a/src/client/util/RichTextRules.ts
+++ b/src/client/util/RichTextRules.ts
@@ -203,22 +203,22 @@ export const inpRules = {
const textDoc = Doc.GetProto(Cast((schema as any).Document[DataSym], Doc, null)!);
const numInlines = NumCast(textDoc.inlineTextCount);
textDoc.inlineTextCount = numInlines + 1;
- const inlineFieldKey = "inline" + numInlines;
- const textDocInline = Docs.Create.TextDocument("", { _width: 75, _height: 35, backgroundColor: "yellow", annotationOn: textDoc, _autoHeight: true, fontSize: 9, title: "inline comment" });
- textDocInline.layoutKey = "layout_" + inlineFieldKey;
- textDocInline.customTitle = true;
- textDocInline.isTemplateForField = inlineFieldKey;
- textDocInline.title = inlineFieldKey;
- textDocInline.proto = textDoc;
- textDoc[textDocInline.layoutKey] = FormattedTextBox.LayoutString(inlineFieldKey);
- textDoc[inlineFieldKey] = "";
+ const inlineFieldKey = "inline" + numInlines; // which field on the text document this annotation will write to
+ const inlineLayoutKey = "layout_" + inlineFieldKey; // the field holding the layout string that will render the inline annotation
+ const textDocInline = Docs.Create.TextDocument("", { layoutKey: inlineLayoutKey, _width: 75, _height: 35, annotationOn: textDoc, _autoHeight: true, fontSize: 9, title: "inline comment" });
+ textDocInline.title = inlineFieldKey; // give the annotation its own title
+ 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]]
+ 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;
const newNode = schema.nodes.dashComment.create({ docid: textDocInline[Id] });
const dashDoc = schema.nodes.dashDoc.create({ width: 75, height: 35, title: "dashDoc", docid: textDocInline[Id], float: "right" });
const sm = state.storedMarks || undefined;
const replaced = node ? state.tr.insert(start, newNode).replaceRangeWith(start + 1, end + 1, dashDoc).insertText(" ", start + 2).setStoredMarks([...node.marks, ...(sm ? sm : [])]) :
state.tr;
- return replaced;//.setSelection(new NodeSelection(replaced.doc.resolve(end)));
+ return replaced;
}),
new InputRule(
new RegExp(/%\(/),