aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-09-10 20:10:58 -0400
committerbobzel <zzzman@gmail.com>2020-09-10 20:10:58 -0400
commit51eea45ec6ee39cb83ee3b0780ad262b8b8b5dd8 (patch)
tree0552d9d7be43a80fc641ecb33b8251d4317695d4 /src/client/views/collections
parent57d7a09f7b8834382ab2974f70a2c5be7a694cd7 (diff)
made basic progressivized slides using TreeView
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionTreeView.scss13
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx49
-rw-r--r--src/client/views/collections/CollectionView.tsx2
-rw-r--r--src/client/views/collections/TabDocView.tsx4
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeView.tsx24
5 files changed, 74 insertions, 18 deletions
diff --git a/src/client/views/collections/CollectionTreeView.scss b/src/client/views/collections/CollectionTreeView.scss
index e192f1760..3f437b799 100644
--- a/src/client/views/collections/CollectionTreeView.scss
+++ b/src/client/views/collections/CollectionTreeView.scss
@@ -30,6 +30,14 @@
padding-left: 0;
}
+ .outline-bullet {
+ position: relative;
+ width: 15px;
+ color: $intermediate-color;
+ margin-top: 3px;
+ transform: scale(0.5);
+ }
+
.bullet {
position: relative;
width: 15px;
@@ -106,11 +114,14 @@
cursor: pointer;
}
+.treeViewItem-border-outline,
.treeViewItem-border {
display: flex;
- border-left: dashed 1px #00000042;
overflow: hidden;
}
+.treeViewItem-border{
+ border-left: dashed 1px #00000042;
+}
.treeViewItem-header-editing,
.treeViewItem-header {
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index d2b86d3c6..a6975f517 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -181,22 +181,38 @@ class TreeView extends React.Component<TreeViewProps> {
fontStyle={style}
fontSize={12}
GetValue={() => StrCast(this.doc[key])}
- SetValue={undoBatch((value: string) => {
- Doc.SetInPlace(this.doc, key, value, false) || true;
- Doc.SetInPlace(this.doc, "editTitle", undefined, false);
+ SetValue={undoBatch((value: string, shiftKey: boolean, enterKey: boolean) => {
+ if (this.props.treeView.doc.treeViewOutlineMode && enterKey) {
+ Doc.SetInPlace(this.doc, key, value, false);
+ const doc = Docs.Create.FreeformDocument([], { title: "", x: 0, y: 0, _width: 100, _height: 25, templates: new List<string>([Templates.Title.Layout]) });
+ Doc.SetInPlace(this.doc, "editTitle", undefined, false);
+ Doc.SetInPlace(doc, "editTitle", "*", false);
+ this.props.addDocument(doc);
+ doc.context = this.props.treeView.Document;
+ } else {
+ Doc.SetInPlace(this.doc, key, value, false) || true;
+ Doc.SetInPlace(this.doc, "editTitle", undefined, false);
+ }
})}
OnFillDown={undoBatch((value: string) => {
Doc.SetInPlace(this.doc, key, value, false);
- const doc = Docs.Create.FreeformDocument([], { title: "-", x: 0, y: 0, _width: 100, _height: 25, templates: new List<string>([Templates.Title.Layout]) });
+ const doc = Docs.Create.FreeformDocument([], { title: "", x: 0, y: 0, _width: 100, _height: 25, templates: new List<string>([Templates.Title.Layout]) });
Doc.SetInPlace(this.doc, "editTitle", undefined, false);
Doc.SetInPlace(doc, "editTitle", "*", false);
- return this.props.addDocument(doc);
+ const added = this.props.addDocument(doc);
+ doc.context = this.props.treeView.Document;
+ return added;
})}
onClick={() => {
SelectionManager.DeselectAll();
Doc.UserDoc().activeSelection = new List([this.doc]);
return false;
}}
+ OnEmpty={undoBatch(() => {
+ if (this.props.treeView.doc.treeViewOutlineMode) {
+ this.props.removeDoc?.(this.doc);
+ }
+ })}
OnTab={undoBatch((shift?: boolean) => {
shift ? this.props.outdentDocument?.() : this.props.indentDocument?.();
setTimeout(() => Doc.SetInPlace(this.doc, "editTitle", `${this.props.treeView._uniqueId}`, false), 0);
@@ -398,13 +414,25 @@ class TreeView extends React.Component<TreeViewProps> {
e.stopPropagation();
}
+ @computed get renderOutlineBullet() {
+ TraceMobx();
+ return <div className="outline-bullet"
+ title={this.childDocs?.length ? `click to see ${this.childDocs?.length} items` : "view fields"}
+ onClick={this.bulletClick}
+ style={{ opacity: NumCast(this.doc.opacity, 1) }}>
+ {<FontAwesomeIcon icon={"circle"} />}
+ </div>;
+ }
@computed get renderBullet() {
TraceMobx();
const checked = this.doc.type === DocumentType.COL ? undefined : this.onCheckedClick ? (this.doc.treeViewChecked ?? "unchecked") : undefined;
return <div className="bullet"
title={this.childDocs?.length ? `click to see ${this.childDocs?.length} items` : "view fields"}
onClick={this.bulletClick}
- style={{ color: StrCast(this.doc.color, checked === "unchecked" ? "white" : "inherit"), opacity: checked === "unchecked" ? undefined : 0.4 }}>
+ style={{
+ color: StrCast(this.doc.color, checked === "unchecked" ? "white" : "inherit"),
+ opacity: checked === "unchecked" ? undefined : 0.4
+ }}>
{<FontAwesomeIcon icon={checked === "check" ? "check" : (checked === "x" ? "times" : checked === "unchecked" ? "square" : !this.treeViewOpen ? (this.childDocs?.length ? "caret-square-right" : "caret-right") : (this.childDocs?.length ? "caret-square-down" : "caret-down"))} />}
</div>;
}
@@ -521,10 +549,10 @@ class TreeView extends React.Component<TreeViewProps> {
}
}}
onPointerEnter={this.onPointerEnter} onPointerLeave={this.onPointerLeave}>
- {this.renderBullet}
+ {this.props.treeView.props.Document.treeViewOutlineMode ? this.renderOutlineBullet : this.renderBullet}
{this.renderTitle}
</div>
- <div className="treeViewItem-border" style={{ borderColor: sorting === undefined ? undefined : sorting ? "crimson" : "blue" }}>
+ <div className={`treeViewItem-border${this.props.treeView.props.Document.treeViewOutlineMode ? "outline" : ""}`} style={{ borderColor: sorting === undefined ? undefined : sorting ? "crimson" : "blue" }}>
{!this.treeViewOpen || this.props.renderedIds.indexOf(this.doc[Id]) !== -1 ? (null) : this.renderContent}
</div>
</li>
@@ -617,6 +645,7 @@ class TreeView extends React.Component<TreeViewProps> {
Doc.AddDocToList(docs[i - 1], fieldKey, child);
docs[i - 1].treeViewOpen = true;
remove(child);
+ child.context = treeView.Document;
}
}
};
@@ -627,6 +656,7 @@ class TreeView extends React.Component<TreeViewProps> {
Doc.AddDocToList(parentCollectionDoc, fieldKey, child, parentPrevSibling, false);
parentCollectionDoc.treeViewOpen = true;
remove(child);
+ child.context = treeView.Document;
}
};
const addDocument = (doc: Doc | Doc[], relativeTo?: Doc, before?: boolean) => {
@@ -729,8 +759,11 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
flg && Doc.AddDocToList(this.doc[DataSym], this.props.fieldKey, doc, relativeTo, before, false, false, false), true);
if (this.doc.resolvedDataDoc instanceof Promise) {
this.doc.resolvedDataDoc.then((resolved: any) => doAddDoc(doc));
+ } else if (relativeTo === undefined) {
+ this.props.addDocument(doc);
} else {
doAddDoc(doc);
+ (doc instanceof Doc ? [doc] : doc).forEach(d => d.context = this.props.Document);
}
return true;
}
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 6939399e6..7084aba40 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -391,7 +391,7 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
ChildLayoutTemplate: this.childLayoutTemplate,
ChildLayoutString: this.childLayoutString,
};
- const boxShadow = Doc.UserDoc().renderStyle === "comic" || this.props.Document._isBackground || this.collectionViewType === CollectionViewType.Linear ? undefined :
+ const boxShadow = Doc.UserDoc().renderStyle === "comic" || this.props.Document.treeViewOutlineMode || this.props.Document._isBackground || this.collectionViewType === CollectionViewType.Linear ? undefined :
`${CurrentUserUtils.ActiveDashboard?.darkScheme ? "rgb(30, 32, 31) " : "#9c9396 "} ${StrCast(this.props.Document.boxShadow, "0.2vw 0.2vw 0.8vw")}`;
return (<div className={"collectionView"} onContextMenu={this.onContextMenu}
style={{ pointerEvents: this.props.Document._isBackground ? "none" : undefined, boxShadow }}>
diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index 5ace82b3c..aa1852250 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -146,6 +146,10 @@ export class TabDocView extends React.Component<TabDocViewProps> {
CollectionDockingView.AddSplit(curPres, "right");
}
DocumentManager.Instance.jumpToDocument(doc, false, undefined, Cast(doc.context, Doc, null));
+ setTimeout(() => {
+ curPres._itemIndex = DocListCast(curPres.data).length - 1;
+ doc.treeViewOutlineMode && PresBox.Instance.progressivizeChild(null as any);
+ }, 100);
}
}
}
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index deb7e68e8..ebad3bf45 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -116,15 +116,23 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
})();
e.stopPropagation();
} else if (e.key === "b" && e.ctrlKey) {
+ // e.preventDefault();
+ // navigator.clipboard.readText().then(text => {
+ // const ns = text.split("\n").filter(t => t.trim() !== "\r" && t.trim() !== "");
+ // if (ns.length === 1 && text.startsWith("http")) {
+ // this.props.addDocument(Docs.Create.ImageDocument(text, { _nativeWidth: 300, _width: 300, x: x, y: y }));// paste an image from its URL in the paste buffer
+ // } else {
+ // this.pasteTable(ns, x, y);
+ // }
+ // });
+ // e.stopPropagation();
+
e.preventDefault();
- navigator.clipboard.readText().then(text => {
- const ns = text.split("\n").filter(t => t.trim() !== "\r" && t.trim() !== "");
- if (ns.length === 1 && text.startsWith("http")) {
- this.props.addDocument(Docs.Create.ImageDocument(text, { _nativeWidth: 300, _width: 300, x: x, y: y }));// paste an image from its URL in the paste buffer
- } else {
- this.pasteTable(ns, x, y);
- }
- });
+ const slide = Doc.copyDragFactory(Doc.UserDoc().emptySlide as Doc)!;
+ slide.x = x;
+ slide.y = y;
+ this.props.addDocument(slide);
+ setTimeout(() => SelectionManager.SelectDoc(DocumentManager.Instance.getDocumentView(slide)!, false));
e.stopPropagation();
} else if (!e.ctrlKey && !e.metaKey) {
FormattedTextBox.SelectOnLoadChar = FormattedTextBox.DefaultLayout ? e.key : "";