diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2020-06-27 22:54:06 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2020-06-27 22:54:06 -0400 |
commit | bacf327d709af79ccc207a1aef27dfb72e70ac40 (patch) | |
tree | 90ded472814e243106dbe75e0311028b42647238 /src | |
parent | b340defb4a4b8c5b7604099e7b0fb5b6846f70aa (diff) |
set LivePlayground to be the default for view-oriented fields
Diffstat (limited to 'src')
-rw-r--r-- | src/client/DocServer.ts | 15 | ||||
-rw-r--r-- | src/client/views/MainView.tsx | 3 | ||||
-rw-r--r-- | src/fields/util.ts | 6 |
3 files changed, 14 insertions, 10 deletions
diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index c7dfb0b23..2a7a7c59a 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -31,16 +31,19 @@ export namespace DocServer { export enum WriteMode { Default = 0, //Anything goes - Playground = 1, - LiveReadonly = 2, - LivePlayground = 3, + Playground = 1, //Playground (write own/no read) + LiveReadonly = 2,//Live Readonly (no write/read others) + LivePlayground = 3,//Live Playground (write own/read others) } - - export let AclsMode = WriteMode.Default; - const fieldWriteModes: { [field: string]: WriteMode } = {}; const docsWithUpdates: { [field: string]: Set<Doc> } = {}; + export var PlaygroundFields: string[]; + export function setPlaygroundFields(livePlayougroundFields: string[]) { + DocServer.PlaygroundFields = livePlayougroundFields; + livePlayougroundFields.forEach(f => DocServer.setFieldWriteMode(f, DocServer.WriteMode.LivePlayground)); + } + export function setFieldWriteMode(field: string, writeMode: WriteMode) { fieldWriteModes[field] = writeMode; if (writeMode !== WriteMode.Playground) { diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index d1957c4af..d7e7db592 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -81,7 +81,10 @@ export class MainView extends React.Component { public isPointerDown = false; + componentDidMount() { + DocServer.setPlaygroundFields(["panTransformType", "transition", "_panX", "_panY", "scale", "_viewType"]); // can play with these fields on someone else's + const tag = document.createElement('script'); const proto = DocServer.GetRefField("rtfProto").then(proto => { diff --git a/src/fields/util.ts b/src/fields/util.ts index ad7b6ea7a..c4affb2d7 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -10,6 +10,7 @@ import { DocServer } from "../client/DocServer"; import { ComputedField } from "./ScriptField"; import { ScriptCast } from "./Types"; + function _readOnlySetter(): never { throw new Error("Documents can't be modified in read-only mode"); } @@ -110,7 +111,7 @@ const layoutProps = ["panX", "panY", "width", "height", "nativeWidth", "nativeHe "LODdisable", "chromeStatus", "viewType", "gridGap", "xMargin", "yMargin", "autoHeight"]; export function setter(target: any, in_prop: string | symbol | number, value: any, receiver: any): boolean { let prop = in_prop; - if (target[AclSym] && !_overrideAcl) return true; + if (target[AclSym] && !_overrideAcl && !DocServer.PlaygroundFields.includes(in_prop.toString())) return true; if (typeof prop === "string" && prop !== "__id" && prop !== "__fields" && (prop.startsWith("_") || layoutProps.includes(prop))) { if (!prop.startsWith("_")) { console.log(prop + " is deprecated - switch to _" + prop); @@ -155,9 +156,6 @@ export function getter(target: any, in_prop: string | symbol | number, receiver: function getFieldImpl(target: any, prop: string | number, receiver: any, ignoreProto: boolean = false): any { receiver = receiver || target[SelfProxy]; - if (target === undefined) { - console.log(""); - } let field = target.__fields[prop]; for (const plugin of getterPlugins) { const res = plugin(receiver, prop, field); |