Skip to content

Commit

Permalink
Merge branch 'master' into u/jisong/225625
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuqingSong authored Sep 8, 2023
2 parents ad6e53d + b77c854 commit 8e26611
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ export const switchShadowEdit: SwitchShadowEdit = (editorCore, isOn): void => {

if (isOn != !!core.lifecycle.shadowEditFragment) {
if (isOn) {
if (!core.cachedModel) {
core.cachedModel = core.api.createContentModel(core);
}

const model = !core.cachedModel ? core.api.createContentModel(core) : null;
const range = core.api.getSelectionRange(core, true /*tryGetFromCache*/);

// Fake object, not used in Content Model Editor, just to satisfy original editor code
Expand All @@ -35,6 +32,12 @@ export const switchShadowEdit: SwitchShadowEdit = (editorCore, isOn): void => {
false /*broadcast*/
);

// This need to be done after EnteredShadowEdit event is triggered since EnteredShadowEdit event will cause a SelectionChanged event
// if current selection is table selection or image selection
if (!core.cachedModel && model) {
core.cachedModel = model;
}

core.lifecycle.shadowEditSelectionPath = selectionPath;
core.lifecycle.shadowEditFragment = fragment;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('switchShadowEdit', () => {

describe('was off', () => {
it('no cache, isOn', () => {
core.cachedModel = undefined;
switchShadowEdit(core, true);

expect(createContentModel).toHaveBeenCalledWith(core);
Expand Down

0 comments on commit 8e26611

Please sign in to comment.