diff options
-rw-r--r-- | src/client/views/nodes/PresBox.tsx | 14 | ||||
-rw-r--r-- | src/client/views/nodes/WebBox.tsx | 2 | ||||
-rw-r--r-- | src/fields/util.ts | 10 |
3 files changed, 14 insertions, 12 deletions
diff --git a/src/client/views/nodes/PresBox.tsx b/src/client/views/nodes/PresBox.tsx index 80cf848e5..411c4f541 100644 --- a/src/client/views/nodes/PresBox.tsx +++ b/src/client/views/nodes/PresBox.tsx @@ -127,14 +127,16 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema> } @computed get selectedDoc() { return this.selectedDocumentView?.rootDoc; } + @action componentWillUnmount() { document.removeEventListener("keydown", this.keyEvents, true); - runInAction(() => this._presKeyEventsActive = false); + this._presKeyEventsActive = false; // Turn of progressivize editors this.turnOffEdit(true); } - componentDidMount = async () => { + @action + componentDidMount = () => { this.rootDoc.presBox = this.rootDoc; this.rootDoc._forceRenderEngine = "timeline"; this.rootDoc._replacedChrome = "replaced"; @@ -142,7 +144,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema> this.layoutDoc._gridGap = 0; this.layoutDoc._yMargin = 0; document.addEventListener("keydown", this.keyEvents, true); - runInAction(() => this._presKeyEventsActive = true); + this._presKeyEventsActive = true; this.turnOffEdit(true); DocListCastAsync((Doc.UserDoc().myPresentations as Doc).data).then(pres => !pres?.includes(this.rootDoc) && Doc.AddDocToList(Doc.UserDoc().myPresentations as Doc, "data", this.rootDoc)); @@ -763,10 +765,10 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps, PresBoxSchema> // Adds the index in the pres path graphically @computed get order() { const order: JSX.Element[] = []; - this.childDocs.forEach((doc, index) => { + this.childDocs.filter(doc => Cast(doc.presentationTargetDoc, Doc, null)).forEach((doc, index) => { const tagDoc = Cast(doc.presentationTargetDoc, Doc, null); - const srcContext = Cast(tagDoc?.context, Doc, null); - const width = NumCast(tagDoc?._width) / 10; + const srcContext = Cast(tagDoc.context, Doc, null); + const width = NumCast(tagDoc._width) / 10; const height = Math.max(NumCast(tagDoc._height) / 10, 15); const edge = Math.max(width, height); const fontSize = edge * 0.8; diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx index 787718aa0..de5546fa9 100644 --- a/src/client/views/nodes/WebBox.tsx +++ b/src/client/views/nodes/WebBox.tsx @@ -83,7 +83,7 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum if (iframe && iframe.contentDocument) { iframe.setAttribute("enable-annotation", "true"); iframe.contentDocument.addEventListener("click", undoBatch(action(e => { - const href = (e.target as any).href; + const href = e.target?.href; if (href) { this._url = href.replace(Utils.prepend(""), Cast(this.dataDoc[this.fieldKey], WebField, null)?.url.origin); this.submitURL(); diff --git a/src/fields/util.ts b/src/fields/util.ts index af743d9f2..ecb3fb343 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -379,12 +379,12 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any diff?.op === "$addToSet" ? { redo: () => { - receiver[prop].push(...diff.items.map((item: any) => item.hasOwnProperty("value") ? item.value() : item)); + receiver[prop].push(...diff.items.map((item: any) => item.value ? item.value() : item)); lastValue = ObjectField.MakeCopy(receiver[prop]); }, undo: action(() => { diff.items.forEach((item: any) => { - const ind = receiver[prop].indexOf(item.hasOwnProperty("value") ? item.value() : item); + const ind = receiver[prop].indexOf(item.value ? item.value() : item); ind !== -1 && receiver[prop].splice(ind, 1); }); lastValue = ObjectField.MakeCopy(receiver[prop]); @@ -394,15 +394,15 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any { redo: action(() => { diff.items.forEach((item: any) => { - const ind = receiver[prop].indexOf(item.hasOwnProperty("value") ? item.value() : item); + const ind = receiver[prop].indexOf(item.value ? item.value() : item); ind !== -1 && receiver[prop].splice(ind, 1); }); lastValue = ObjectField.MakeCopy(receiver[prop]); }), undo: () => { diff.items.forEach((item: any) => { - const ind = (prevValue as List<any>).indexOf(item.hasOwnProperty("value") ? item.value() : item); - ind !== -1 && receiver[prop].indexOf(item.hasOwnProperty("value") ? item.value() : item) === -1 && receiver[prop].splice(ind, 0, item); + const ind = (prevValue as List<any>).indexOf(item.value ? item.value() : item); + ind !== -1 && receiver[prop].indexOf(item.value ? item.value() : item) === -1 && receiver[prop].splice(ind, 0, item); }); lastValue = ObjectField.MakeCopy(receiver[prop]); } |