Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions demo/scripts/controls/sidePane/snapshot/SnapshotPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -40,11 +40,14 @@ export default class SnapshotPane extends React.Component<SnapshotPaneProps, Sna
<button onClick={this.takeSnapshot}>{'Take snapshot'}</button>{' '}
<button
onClick={() =>
this.props.onRestoreSnapshot({
html: this.textarea.value,
metadata: null,
knownColors: [],
})
this.props.onRestoreSnapshot(
{
html: this.textarea.value,
metadata: null,
knownColors: [],
},
true
)
}>
{'Restore snapshot'}
</button>
Expand Down
9 changes: 4 additions & 5 deletions demo/scripts/controls/sidePane/snapshot/SnapshotPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -78,16 +78,15 @@ 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*/
triggerContentChangedEvent
);
this.editorInstance.triggerContentChangedEvent(ChangeSource.SetContent);
};

private updateSnapshots = () => {
Expand Down