From f7edb2907a339db982560f9abd47b0a826557bce Mon Sep 17 00:00:00 2001 From: jiuqingsong Date: Sat, 17 Jun 2023 21:49:10 -0700 Subject: [PATCH 1/3] Demo site minor improvement --- .../controls/sidePane/snapshot/SnapshotPane.tsx | 15 +++++++++------ .../controls/sidePane/snapshot/SnapshotPlugin.tsx | 9 ++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/demo/scripts/controls/sidePane/snapshot/SnapshotPane.tsx b/demo/scripts/controls/sidePane/snapshot/SnapshotPane.tsx index ba09d292adbb..87b2096ccca4 100644 --- a/demo/scripts/controls/sidePane/snapshot/SnapshotPane.tsx +++ b/demo/scripts/controls/sidePane/snapshot/SnapshotPane.tsx @@ -5,7 +5,7 @@ const styles = require('./SnapshotPane.scss'); export interface SnapshotPaneProps { onTakeSnapshot: () => Snapshot; - onRestoreSnapshot: (snapshot: Snapshot) => void; + onRestoreSnapshot: (snapshot: Snapshot, triggerContentChangedEvent: boolean) => void; onMove: (moveStep: number) => void; } @@ -40,11 +40,14 @@ export default class SnapshotPane extends React.Component{'Take snapshot'}{' '} diff --git a/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx b/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx index 294fd9dd39be..e2a5be0400df 100644 --- a/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx +++ b/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx @@ -78,16 +78,19 @@ export default class SnapshotPlugin implements SidePanePlugin { private onMove = (step: number) => { const snapshot = this.snapshotService.move(step); - this.onRestoreSnapshot(snapshot); + this.onRestoreSnapshot(snapshot, false); }; - private onRestoreSnapshot = (snapshot: Snapshot) => { + private onRestoreSnapshot = (snapshot: Snapshot, triggerContentChangedEvent: boolean) => { this.editorInstance.focus(); this.editorInstance.setContent( this.component.snapshotToString(snapshot), false /*triggerContentChangedEvent*/ ); - this.editorInstance.triggerContentChangedEvent(ChangeSource.SetContent); + + if (triggerContentChangedEvent) { + this.editorInstance.triggerContentChangedEvent(ChangeSource.SetContent); + } }; private updateSnapshots = () => { From 292e577aa70135a0368a66d1fc17d48c1b61381f Mon Sep 17 00:00:00 2001 From: jiuqingsong Date: Sat, 17 Jun 2023 21:57:03 -0700 Subject: [PATCH 2/3] improve --- demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx b/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx index e2a5be0400df..4d8403ba8f95 100644 --- a/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx +++ b/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx @@ -85,12 +85,8 @@ export default class SnapshotPlugin implements SidePanePlugin { this.editorInstance.focus(); this.editorInstance.setContent( this.component.snapshotToString(snapshot), - false /*triggerContentChangedEvent*/ + triggerContentChangedEvent ); - - if (triggerContentChangedEvent) { - this.editorInstance.triggerContentChangedEvent(ChangeSource.SetContent); - } }; private updateSnapshots = () => { From cca32703bb46efe3558a741c5f7975ad03f25c8b Mon Sep 17 00:00:00 2001 From: jiuqingsong Date: Sat, 17 Jun 2023 23:43:30 -0700 Subject: [PATCH 3/3] fix build --- demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx b/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx index 4d8403ba8f95..58a167b181b1 100644 --- a/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx +++ b/demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx @@ -2,8 +2,8 @@ import * as React from 'react'; import SidePanePlugin from '../../SidePanePlugin'; import SnapshotPane from './SnapshotPane'; import UndoSnapshots from './UndoSnapshots'; -import { ChangeSource, IEditor, PluginEvent, PluginEventType } from 'roosterjs-editor-types'; import { createSnapshots } from 'roosterjs-editor-dom'; +import { IEditor, PluginEvent, PluginEventType } from 'roosterjs-editor-types'; import { Snapshot } from 'roosterjs-editor-types'; export default class SnapshotPlugin implements SidePanePlugin {