aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/PropertiesView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-11-29 10:02:34 -0500
committerbobzel <zzzman@gmail.com>2023-11-29 10:02:34 -0500
commitba3b3f6f261074bd3f35012bde8730f5d4a36905 (patch)
tree6f6c7b141f8bc5881113378801d4b2940cfde36a /src/client/views/PropertiesView.tsx
parentac360607bee82f0fef769eada99dc0b3f85ae70a (diff)
numerous changes to fix bugs and to fix/remove old or hacky code. fixed doc dec resizing. moving this.rootDoc => this.Document . fixing template artifacts.
Diffstat (limited to 'src/client/views/PropertiesView.tsx')
-rw-r--r--src/client/views/PropertiesView.tsx47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 1b9b26111..8f37a0564 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -63,7 +63,11 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
}
@computed get selectedDoc() {
- return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc || Doc.ActiveDashboard;
+ return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.Document || Doc.ActiveDashboard;
+ }
+
+ @computed get selectedLayoutDoc() {
+ return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.layoutDoc || Doc.ActiveDashboard;
}
@computed get selectedDocumentView() {
if (SelectionManager.Views().length) return SelectionManager.Views()[0];
@@ -126,13 +130,13 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
return [CollectionViewType.Stacking, CollectionViewType.NoteTaking].includes(this.selectedDoc?.type_collection as any);
}
- rtfWidth = () => (!this.selectedDoc ? 0 : Math.min(NumCast(this.selectedDoc?._width), this.props.width - 20));
- rtfHeight = () => (!this.selectedDoc ? 0 : this.rtfWidth() <= NumCast(this.selectedDoc?._width) ? Math.min(NumCast(this.selectedDoc?._height), this.MAX_EMBED_HEIGHT) : this.MAX_EMBED_HEIGHT);
+ rtfWidth = () => (!this.selectedLayoutDoc ? 0 : Math.min(NumCast(this.selectedLayoutDoc?._width), this.props.width - 20));
+ rtfHeight = () => (!this.selectedLayoutDoc ? 0 : this.rtfWidth() <= NumCast(this.selectedLayoutDoc?._width) ? Math.min(NumCast(this.selectedLayoutDoc?._height), this.MAX_EMBED_HEIGHT) : this.MAX_EMBED_HEIGHT);
@action
docWidth = () => {
- if (this.selectedDoc) {
- const layoutDoc = this.selectedDoc;
+ const layoutDoc = this.selectedLayoutDoc;
+ if (layoutDoc) {
const aspect = Doc.NativeAspect(layoutDoc, undefined, !layoutDoc._layout_fitWidth);
if (aspect) return Math.min(NumCast(layoutDoc._width), Math.min(this.MAX_EMBED_HEIGHT * aspect, this.props.width - 20));
return Doc.NativeWidth(layoutDoc) ? Math.min(NumCast(layoutDoc._width), this.props.width - 20) : this.props.width - 20;
@@ -142,8 +146,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@action
docHeight = () => {
- if (this.selectedDoc && this.dataDoc) {
- const layoutDoc = this.selectedDoc;
+ const layoutDoc = this.selectedLayoutDoc;
+ if (layoutDoc && this.dataDoc) {
return Math.max(
70,
Math.min(
@@ -288,7 +292,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
return (
<div ref={this.propertiesDocViewRef} style={{ pointerEvents: 'none', display: 'inline-block', height: panelHeight() }} key={this.selectedDoc[Id]}>
<DocumentView
- Document={layoutDoc}
+ Document={this.selectedDoc}
DataDoc={this.dataDoc}
renderDepth={1}
fitContentsToBox={returnTrue}
@@ -328,7 +332,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
*/
@undoBatch
changePermissions = (e: any, user: string) => {
- const docs = (SelectionManager.Views().length < 2 ? [this.selectedDoc] : SelectionManager.Views().map(dv => dv.props.Document)).filter(doc => doc).map(doc => (this.layoutDocAcls ? doc! : DocCast(doc)[DocData]));
+ const docs = SelectionManager.Views().length < 2 ? [this.selectedDoc] : SelectionManager.Views().map(dv => (this.layoutDocAcls ? dv.layoutDoc : dv.dataDoc));
SharingManager.Instance.shareFromPropertiesSidebar(user, e.currentTarget.value as SharingPermissions, docs, this.layoutDocAcls);
};
@@ -453,7 +457,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
const individualTableEntries = [];
const usersAdded: string[] = []; // all shared users being added - organized by denormalized email
- const seldoc = this.layoutDocAcls || !this.selectedDoc ? this.selectedDoc : Doc.GetProto(this.selectedDoc);
+ const seldoc = this.layoutDocAcls ? this.selectedLayoutDoc : this.selectedDoc?.[DocData];
// adds each user to usersAdded
SharingManager.Instance.users.forEach(eachUser => {
var userOnDoc = true;
@@ -630,10 +634,11 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@action
rotate = (angle: number) => {
const _centerPoints: { X: number; Y: number }[] = [];
- if (this.selectedDoc) {
- const doc = this.selectedDoc;
- if (doc.type === DocumentType.INK && doc.x && doc.y && doc._width && doc._height && doc.data) {
- const ink = Cast(doc.data, InkField)?.inkData;
+ const doc = this.selectedDoc;
+ const layout = this.selectedLayoutDoc;
+ if (doc && layout) {
+ if (doc.type === DocumentType.INK && doc.x && doc.y && layout._width && layout._height && doc.data) {
+ const ink = Cast(doc.stroke, InkField)?.inkData;
if (ink) {
const xs = ink.map(p => p.X);
const ys = ink.map(p => p.Y);
@@ -646,9 +651,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
}
var index = 0;
- if (doc.type === DocumentType.INK && doc.x && doc.y && doc._width && doc._height && doc.data) {
- doc.rotation = NumCast(doc.rotation) + angle;
- const inks = Cast(doc.data, InkField)?.inkData;
+ if (doc.type === DocumentType.INK && doc.x && doc.y && layout._width && layout._height && doc.data) {
+ layout.rotation = NumCast(layout.rotation) + angle;
+ const inks = Cast(doc.stroke, InkField)?.inkData;
if (inks) {
const newPoints: { X: number; Y: number }[] = [];
inks.forEach(ink => {
@@ -656,7 +661,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
const newY = Math.sin(angle) * (ink.X - _centerPoints[index].X) + Math.cos(angle) * (ink.Y - _centerPoints[index].Y) + _centerPoints[index].Y;
newPoints.push({ X: newX, Y: newY });
});
- doc.data = new InkField(newPoints);
+ doc.stroke = new InkField(newPoints);
const xs = newPoints.map(p => p.X);
const ys = newPoints.map(p => p.Y);
const left = Math.min(...xs);
@@ -664,8 +669,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
const right = Math.max(...xs);
const bottom = Math.max(...ys);
- doc._height = bottom - top;
- doc._width = right - left;
+ layout._height = bottom - top;
+ layout._width = right - left;
}
index++;
}
@@ -1178,7 +1183,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
return (
<>
<PropertiesSection title="Appearance" isOpen={this.openAppearance} setIsOpen={bool => (this.openAppearance = bool)} onDoubleClick={() => this.CloseAll()}>
- {this.selectedDoc?.layout_isSvg ? this.appearanceEditor : null}
+ {this.selectedLayoutDoc?.layout_isSvg ? this.appearanceEditor : null}
</PropertiesSection>
<PropertiesSection title="Transform" isOpen={this.openTransform} setIsOpen={bool => (this.openTransform = bool)} onDoubleClick={() => this.CloseAll()}>
{this.transformEditor}