aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/animationtimeline/Keyframe.tsx4
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeView.tsx2
-rw-r--r--src/client/views/nodes/DocumentBox.tsx27
-rw-r--r--src/client/views/nodes/formattedText/DashDocView.tsx2
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx5
-rw-r--r--src/client/views/nodes/formattedText/RichTextSchema.tsx181
-rw-r--r--src/server/authentication/models/current_user_utils.ts14
7 files changed, 28 insertions, 207 deletions
diff --git a/src/client/views/animationtimeline/Keyframe.tsx b/src/client/views/animationtimeline/Keyframe.tsx
index a3407f653..bbd7b2676 100644
--- a/src/client/views/animationtimeline/Keyframe.tsx
+++ b/src/client/views/animationtimeline/Keyframe.tsx
@@ -225,7 +225,7 @@ export class Keyframe extends React.Component<IProps> {
this._mouseToggled = true;
}
const left = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.left, this.regiondata, this.regions)!;
- const right = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.right, this.regiondata, this.regions!);
+ const right = KeyframeFunc.findAdjacentRegion(KeyframeFunc.Direction.right, this.regiondata, this.regions)!;
const prevX = this.regiondata.position;
const futureX = this.regiondata.position + KeyframeFunc.convertPixelTime(e.movementX, "mili", "time", this.props.tickSpacing, this.props.tickIncrement);
if (futureX <= 0) {
@@ -495,7 +495,7 @@ export class Keyframe extends React.Component<IProps> {
} else {
return <div className="keyframe" style={{ left: `${KeyframeFunc.convertPixelTime(NumCast(kf.time), "mili", "pixel", this.props.tickSpacing, this.props.tickIncrement) - this.pixelPosition}px` }}>
<div className="divider" />
- </div>
+ </div>;
}
});
}
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 2d3bb6f3c..c70301b2f 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -113,7 +113,7 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
if (template instanceof Doc) {
tbox._width = NumCast(template._width);
tbox.layoutKey = "layout_" + StrCast(template.title);
- tbox[StrCast(tbox.layoutKey)] = template;
+ Doc.GetProto(tbox)[StrCast(tbox.layoutKey)] = template;
}
this.props.addLiveTextDocument(tbox);
}
diff --git a/src/client/views/nodes/DocumentBox.tsx b/src/client/views/nodes/DocumentBox.tsx
index 0d18baaed..d4d997120 100644
--- a/src/client/views/nodes/DocumentBox.tsx
+++ b/src/client/views/nodes/DocumentBox.tsx
@@ -15,7 +15,6 @@ import "./DocumentBox.scss";
import { FieldView, FieldViewProps } from "./FieldView";
import React = require("react");
import { TraceMobx } from "../../../new_fields/util";
-import { DocumentView } from "./DocumentView";
import { Docs } from "../../documents/Documents";
type DocHolderBoxSchema = makeInterface<[typeof documentSchema]>;
@@ -28,7 +27,7 @@ export class DocHolderBox extends ViewBoxAnnotatableComponent<FieldViewProps, Do
_selections: Doc[] = [];
_curSelection = -1;
componentDidMount() {
- this._prevSelectionDisposer = reaction(() => this.contentDoc[this.props.fieldKey], (data) => {
+ this._prevSelectionDisposer = reaction(() => this.layoutDoc[this.props.fieldKey], (data) => {
if (data instanceof Doc && !this.isSelectionLocked()) {
this._selections.indexOf(data) !== -1 && this._selections.splice(this._selections.indexOf(data), 1);
this._selections.push(data);
@@ -42,22 +41,20 @@ export class DocHolderBox extends ViewBoxAnnotatableComponent<FieldViewProps, Do
specificContextMenu = (e: React.MouseEvent): void => {
const funcs: ContextMenuProps[] = [];
funcs.push({ description: (this.isSelectionLocked() ? "Show" : "Lock") + " Selection", event: () => this.toggleLockSelection, icon: "expand-arrows-alt" });
- funcs.push({ description: (this.props.Document.excludeCollections ? "Include" : "Exclude") + " Collections", event: () => Doc.GetProto(this.props.Document).excludeCollections = !this.props.Document.excludeCollections, icon: "expand-arrows-alt" });
- funcs.push({ description: `${this.props.Document.forceActive ? "Select" : "Force"} Contents Active`, event: () => this.props.Document.forceActive = !this.props.Document.forceActive, icon: "project-diagram" });
+ funcs.push({ description: (this.layoutDoc.excludeCollections ? "Include" : "Exclude") + " Collections", event: () => this.layoutDoc.excludeCollections = !this.layoutDoc.excludeCollections, icon: "expand-arrows-alt" });
+ funcs.push({ description: `${this.layoutDoc.forceActive ? "Select" : "Force"} Contents Active`, event: () => this.layoutDoc.forceActive = !this.layoutDoc.forceActive, icon: "project-diagram" });
+ funcs.push({ description: `Show ${this.layoutDoc.childTemplateName !== "keyValue" ? "key values" : "contents"}`, event: () => this.layoutDoc.childTemplateName = this.layoutDoc.childTemplateName ? undefined : "keyValue", icon: "project-diagram" });
ContextMenu.Instance.addItem({ description: "Options...", subitems: funcs, icon: "asterisk" });
}
- @computed get contentDoc() {
- return (this.props.Document.isTemplateDoc || this.props.Document.isTemplateForField ? this.props.Document : Doc.GetProto(this.props.Document));
- }
lockSelection = () => {
- this.contentDoc[this.props.fieldKey] = this.props.Document[this.props.fieldKey];
+ this.layoutDoc[this.props.fieldKey] = this.layoutDoc[this.props.fieldKey];
}
showSelection = () => {
- this.contentDoc[this.props.fieldKey] = ComputedField.MakeFunction(`selectedDocs(self,this.excludeCollections,[_last_])?.[0]`);
+ this.layoutDoc[this.props.fieldKey] = ComputedField.MakeFunction(`selectedDocs(self,this.excludeCollections,[_last_])?.[0]`);
}
isSelectionLocked = () => {
- const kvpstring = Field.toKeyValueString(this.contentDoc, this.props.fieldKey);
+ const kvpstring = Field.toKeyValueString(this.layoutDoc, this.props.fieldKey);
return !kvpstring || kvpstring.includes("DOC");
}
toggleLockSelection = () => {
@@ -67,13 +64,13 @@ export class DocHolderBox extends ViewBoxAnnotatableComponent<FieldViewProps, Do
prevSelection = () => {
this.lockSelection();
if (this._curSelection > 0) {
- this.contentDoc[this.props.fieldKey] = this._selections[--this._curSelection];
+ this.layoutDoc[this.props.fieldKey] = this._selections[--this._curSelection];
return true;
}
}
nextSelection = () => {
if (this._curSelection < this._selections.length - 1 && this._selections.length) {
- this.contentDoc[this.props.fieldKey] = this._selections[++this._curSelection];
+ this.layoutDoc[this.props.fieldKey] = this._selections[++this._curSelection];
return true;
}
}
@@ -107,8 +104,8 @@ export class DocHolderBox extends ViewBoxAnnotatableComponent<FieldViewProps, Do
pheight = () => this.props.PanelHeight() - 2 * this.yPad;
getTransform = () => this.props.ScreenToLocalTransform().translate(-this.xPad, -this.yPad);
get renderContents() {
- const containedDoc = Cast(this.contentDoc[this.props.fieldKey], Doc, null);
- const childTemplateName = StrCast(this.props.Document.childTemplateName);
+ const containedDoc = Cast(this.dataDoc[this.props.fieldKey], Doc, null);
+ const childTemplateName = StrCast(this.layoutDoc.childTemplateName);
if (containedDoc && childTemplateName && !containedDoc["layout_" + childTemplateName]) {
setTimeout(() => {
Doc.createCustomView(containedDoc, Docs.Create.StackingDocument, childTemplateName);
@@ -145,7 +142,7 @@ export class DocHolderBox extends ViewBoxAnnotatableComponent<FieldViewProps, Do
onContextMenu={this.specificContextMenu}
onPointerDown={this.onPointerDown} onClick={this.onClick}
style={{
- background: StrCast(this.props.Document.backgroundColor),
+ background: StrCast(this.layoutDoc.backgroundColor),
border: `#00000021 solid ${this.xPad}px`,
borderTop: `#0000005e solid ${this.yPad}px`,
borderBottom: `#0000005e solid ${this.yPad}px`,
diff --git a/src/client/views/nodes/formattedText/DashDocView.tsx b/src/client/views/nodes/formattedText/DashDocView.tsx
index 9fe8fa320..7130fee2b 100644
--- a/src/client/views/nodes/formattedText/DashDocView.tsx
+++ b/src/client/views/nodes/formattedText/DashDocView.tsx
@@ -48,7 +48,7 @@ export class DashDocView extends React.Component<IDashDocView> {
if (dashDocBase instanceof Doc) {
const aliasedDoc = Doc.MakeAlias(dashDocBase, docid + alias);
aliasedDoc.layoutKey = "layout";
- node.attrs.fieldKey && DocumentView.makeCustomViewClicked(aliasedDoc, Docs.Create.StackingDocument, node.attrs.fieldKey, undefined);
+ node.attrs.fieldKey && Doc.makeCustomViewClicked(aliasedDoc, Docs.Create.StackingDocument, node.attrs.fieldKey, undefined);
this._dashDoc = aliasedDoc;
// self.doRender(aliasedDoc, removeDoc, node, view, getPos);
}
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index c4e387e5a..782a91547 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -418,9 +418,10 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
const cm = ContextMenu.Instance;
const funcs: ContextMenuProps[] = [];
- this.props.Document.isTemplateDoc && funcs.push({ description: "Make Default Layout", event: async () => Doc.UserDoc().defaultTextLayout = new PrefetchProxy(this.props.Document), icon: "eye" });
+ this.rootDoc.isTemplateDoc && funcs.push({ description: "Make Default Layout", event: async () => Doc.UserDoc().defaultTextLayout = new PrefetchProxy(this.props.Document), icon: "eye" });
+ !this.rootDoc.isTemplateDoc && funcs.push({ description: "Show Template", event: async () => this.props.addDocTab(Doc.GetProto(this.layoutDoc), "onRight"), icon: "eye" });
funcs.push({ description: "Reset Default Layout", event: () => Doc.UserDoc().defaultTextLayout = undefined, icon: "eye" });
- !this.props.Document.rootDocument && funcs.push({
+ !this.rootDoc.isTemplateDoc && funcs.push({
description: "Make Template", event: () => {
this.props.Document.isTemplateDoc = makeTemplate(this.props.Document);
Doc.AddDocToList(Cast(Doc.UserDoc()["template-notes"], Doc, null), "data", this.props.Document);
diff --git a/src/client/views/nodes/formattedText/RichTextSchema.tsx b/src/client/views/nodes/formattedText/RichTextSchema.tsx
index 33caf5751..cdb7374f8 100644
--- a/src/client/views/nodes/formattedText/RichTextSchema.tsx
+++ b/src/client/views/nodes/formattedText/RichTextSchema.tsx
@@ -342,187 +342,6 @@ export class DashDocView {
}
}
-export class DashFieldView {
- _fieldWrapper: HTMLDivElement; // container for label and value
- _labelSpan: HTMLSpanElement; // field label
- _fieldSpan: HTMLSpanElement; // field value
- _fieldCheck: HTMLInputElement;
- _enumerables: HTMLDivElement; // field value
- _reactionDisposer: IReactionDisposer | undefined;
- _textBoxDoc: Doc;
- @observable _dashDoc: Doc | undefined;
- _fieldKey: string;
- _options: Doc[] = [];
-
- constructor(node: any, view: any, getPos: any, tbox: FormattedTextBox) {
- this._fieldKey = node.attrs.fieldKey;
- this._textBoxDoc = tbox.props.Document;
- this._fieldWrapper = document.createElement("p");
- this._fieldWrapper.style.width = node.attrs.width;
- this._fieldWrapper.style.height = node.attrs.height;
- this._fieldWrapper.style.fontWeight = "bold";
- this._fieldWrapper.style.position = "relative";
- this._fieldWrapper.style.display = "inline-block";
-
- const self = this;
-
- this._enumerables = document.createElement("div");
- this._enumerables.style.width = "10px";
- this._enumerables.style.height = "10px";
- this._enumerables.style.position = "relative";
- this._enumerables.style.display = "none";
-
- //Moved
- this._enumerables.onpointerdown = async (e) => {
- e.stopPropagation();
- const collview = await Doc.addFieldEnumerations(self._textBoxDoc, self._fieldKey, [{ title: self._fieldSpan.innerText }]);
- collview instanceof Doc && tbox.props.addDocTab(collview, "onRight");
- };
- //Moved
- const updateText = (forceMatch: boolean) => {
- self._enumerables.style.display = "none";
- const newText = self._fieldSpan.innerText.startsWith(":=") || self._fieldSpan.innerText.startsWith("=:=") ? ":=-computed-" : self._fieldSpan.innerText;
-
- // look for a document whose id === the fieldKey being displayed. If there's a match, then that document
- // holds the different enumerated values for the field in the titles of its collected documents.
- // if there's a partial match from the start of the input text, complete the text --- TODO: make this an auto suggest box and select from a drop down.
- DocServer.GetRefField(self._fieldKey).then(options => {
- let modText = "";
- (options instanceof Doc) && DocListCast(options.data).forEach(opt => (forceMatch ? StrCast(opt.title).startsWith(newText) : StrCast(opt.title) === newText) && (modText = StrCast(opt.title)));
- if (modText) {
- self._fieldSpan.innerHTML = self._dashDoc![self._fieldKey] = modText;
- Doc.addFieldEnumerations(self._textBoxDoc, self._fieldKey, []);
- } // if the text starts with a ':=' then treat it as an expression by making a computed field from its value storing it in the key
- else if (self._fieldSpan.innerText.startsWith(":=")) {
- self._dashDoc![self._fieldKey] = ComputedField.MakeFunction(self._fieldSpan.innerText.substring(2));
- } else if (self._fieldSpan.innerText.startsWith("=:=")) {
- Doc.Layout(tbox.props.Document)[self._fieldKey] = ComputedField.MakeFunction(self._fieldSpan.innerText.substring(3));
- } else {
- self._dashDoc![self._fieldKey] = newText;
- }
- });
- };
-
- //Moved
- this._fieldCheck = document.createElement("input");
- this._fieldCheck.id = Utils.GenerateGuid();
- this._fieldCheck.type = "checkbox";
- this._fieldCheck.style.position = "relative";
- this._fieldCheck.style.display = "none";
- this._fieldCheck.style.minWidth = "12px";
- this._fieldCheck.style.backgroundColor = "rgba(155, 155, 155, 0.24)";
- this._fieldCheck.onchange = function (e: any) {
- self._dashDoc![self._fieldKey] = e.target.checked;
- };
-
- this._fieldSpan = document.createElement("span");
- this._fieldSpan.id = Utils.GenerateGuid();
- this._fieldSpan.contentEditable = "true";
- this._fieldSpan.style.position = "relative";
- this._fieldSpan.style.display = "none";
- this._fieldSpan.style.minWidth = "12px";
- this._fieldSpan.style.fontSize = "large";
- this._fieldSpan.onkeypress = function (e: any) { e.stopPropagation(); };
- this._fieldSpan.onkeyup = function (e: any) { e.stopPropagation(); };
- this._fieldSpan.onmousedown = function (e: any) { e.stopPropagation(); self._enumerables.style.display = "inline-block"; };
- this._fieldSpan.onblur = function (e: any) { updateText(false); };
-
- // MOVED
- const setDashDoc = (doc: Doc) => {
- self._dashDoc = doc;
- if (self._options?.length && !self._dashDoc[self._fieldKey]) {
- self._dashDoc[self._fieldKey] = StrCast(self._options[0].title);
- }
- this._labelSpan.innerHTML = `${self._fieldKey}: `;
- const fieldVal = Cast(this._dashDoc?.[self._fieldKey], "boolean", null);
- this._fieldCheck.style.display = (fieldVal === true || fieldVal === false) ? "inline-block" : "none";
- this._fieldSpan.style.display = !(fieldVal === true || fieldVal === false) ? StrCast(this._dashDoc?.[self._fieldKey]) ? "" : "inline-block" : "none";
- };
-
- //Moved
- this._fieldSpan.onkeydown = function (e: any) {
- e.stopPropagation();
- if ((e.key === "a" && e.ctrlKey) || (e.key === "a" && e.metaKey)) {
- if (window.getSelection) {
- const range = document.createRange();
- range.selectNodeContents(self._fieldSpan);
- window.getSelection()!.removeAllRanges();
- window.getSelection()!.addRange(range);
- }
- e.preventDefault();
- }
- if (e.key === "Enter") {
- e.preventDefault();
- e.ctrlKey && Doc.addFieldEnumerations(self._textBoxDoc, self._fieldKey, [{ title: self._fieldSpan.innerText }]);
- updateText(true);
- }
- };
-
- this._labelSpan = document.createElement("span");
- this._labelSpan.style.position = "relative";
- this._labelSpan.style.fontSize = "small";
- this._labelSpan.title = "click to see related tags";
- this._labelSpan.style.fontSize = "x-small";
- this._labelSpan.onpointerdown = function (e: any) {
- e.stopPropagation();
- let container = tbox.props.ContainingCollectionView;
- while (container?.props.Document.isTemplateForField || container?.props.Document.isTemplateDoc) {
- container = container.props.ContainingCollectionView;
- }
- if (container) {
- const alias = Doc.MakeAlias(container.props.Document);
- alias.viewType = CollectionViewType.Time;
- let list = Cast(alias.schemaColumns, listSpec(SchemaHeaderField));
- if (!list) {
- alias.schemaColumns = list = new List<SchemaHeaderField>();
- }
- list.map(c => c.heading).indexOf(self._fieldKey) === -1 && list.push(new SchemaHeaderField(self._fieldKey, "#f1efeb"));
- list.map(c => c.heading).indexOf("text") === -1 && list.push(new SchemaHeaderField("text", "#f1efeb"));
- alias._pivotField = self._fieldKey;
- tbox.props.addDocTab(alias, "onRight");
- }
- };
- this._labelSpan.innerHTML = `${self._fieldKey}: `;
- //MOVED
- if (node.attrs.docid) {
- DocServer.GetRefField(node.attrs.docid).
- then(async dashDoc => dashDoc instanceof Doc && runInAction(() => setDashDoc(dashDoc)));
- } else {
- setDashDoc(tbox.props.DataDoc || tbox.dataDoc);
- }
-
- //Moved
- this._reactionDisposer?.();
- this._reactionDisposer = reaction(() => { // this reaction will update the displayed text whenever the document's fieldKey's value changes
- const dashVal = this._dashDoc?.[self._fieldKey];
- return StrCast(dashVal).startsWith(":=") || dashVal === "" ? Doc.Layout(tbox.props.Document)[self._fieldKey] : dashVal;
- }, fval => {
- const boolVal = Cast(fval, "boolean", null);
- if (boolVal === true || boolVal === false) {
- this._fieldCheck.checked = boolVal;
- } else {
- this._fieldSpan.innerHTML = Field.toString(fval as Field) || "";
- }
- this._fieldCheck.style.display = (boolVal === true || boolVal === false) ? "inline-block" : "none";
- this._fieldSpan.style.display = !(fval === true || fval === false) ? (StrCast(fval) ? "" : "inline-block") : "none";
- }, { fireImmediately: true });
-
- //MOVED IN ORDER
- this._fieldWrapper.appendChild(this._labelSpan);
- this._fieldWrapper.appendChild(this._fieldCheck);
- this._fieldWrapper.appendChild(this._fieldSpan);
- this._fieldWrapper.appendChild(this._enumerables);
- (this as any).dom = this._fieldWrapper;
- //updateText(false);
- }
- //MOVED
- destroy() {
- this._reactionDisposer?.();
- }
- //moved
- selectNode() { }
-}
-
export class FootnoteView {
innerView: any;
outerView: any;
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 08dc21460..4b2aafac1 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -72,8 +72,8 @@ export class CurrentUserUtils {
}
if (doc["template-button-description"] === undefined) {
- const descriptionTemplate = Docs.Create.TextDocument("", { title: "text", _height: 100, _showTitle: "title" });
- Doc.GetProto(descriptionTemplate).layout = FormattedTextBox.LayoutString("description");
+ const descriptionTemplate = Docs.Create.TextDocument("", { title: "header", _height: 100 });
+ Doc.GetProto(descriptionTemplate).layout = "<div><FormattedTextBox {...props} background='orange' height='50px' fieldKey={'header'}/><FormattedTextBox {...props} height='calc(100% - 50px)' fieldKey={'text'}/></div>";
descriptionTemplate.isTemplateDoc = makeTemplate(descriptionTemplate, true, "descriptionView");
doc["template-button-description"] = CurrentUserUtils.ficon({
@@ -181,9 +181,13 @@ export class CurrentUserUtils {
doc["template-note-Idea"] as any as Doc, doc["template-note-Topic"] as any as Doc, doc["template-note-Todo"] as any as Doc],
{ title: "Note Layouts", _height: 75 }));
} else {
- const noteTypes = Cast(doc["template-notes"], Doc, null);
- DocListCastAsync(noteTypes).then(list => noteTypes.data = new List<Doc>([doc["template-note-Note"] as any as Doc,
- doc["template-note-Idea"] as any as Doc, doc["template-note-Topic"] as any as Doc, doc["template-note-Todo"] as any as Doc]));
+ const curNoteTypes = Cast(doc["template-notes"], Doc, null);
+ const requiredTypes = [doc["template-note-Note"] as any as Doc, doc["template-note-Idea"] as any as Doc,
+ doc["template-note-Topic"] as any as Doc, doc["template-note-Todo"] as any as Doc];
+ DocListCastAsync(curNoteTypes.data).then(async curNotes => {
+ await Promise.all(curNotes!);
+ requiredTypes.map(ntype => Doc.AddDocToList(curNoteTypes, "data", ntype));
+ });
}
return doc["template-notes"] as Doc;