Skip to content

Commit

Permalink
formatContentModel
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaroldi committed Jun 6, 2024
1 parent bf1533e commit 08c69bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@ export const formatContentModel: FormatContentModel = (
options,
domToModelOptions
) => {
const {
apiName,
onNodeCreated,
getChangeData,
changeSource,
rawEvent,
selectionOverride,
scrollCaretIntoView,
} = options || {};
const { onNodeCreated, getChangeData, rawEvent, selectionOverride, scrollCaretIntoView } =
options || {};
const model = core.api.createContentModel(core, domToModelOptions, selectionOverride);
const context: FormatContentModelContext = {
newEntities: [],
Expand Down Expand Up @@ -82,9 +75,9 @@ export const formatContentModel: FormatContentModel = (
eventType: 'contentChanged',
contentModel: clearModelCache ? undefined : model,
selection: clearModelCache ? undefined : selection,
source: changeSource || ChangeSource.Format,
source: options?.changeSource || ChangeSource.Format,
data: getChangeData?.(),
formatApiName: apiName,
formatApiName: options?.apiName,
changedEntities: getChangedEntities(context, rawEvent),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,9 @@ export class AutoFormatPlugin implements EditorPlugin {
shouldFraction ||
shouldOrdinals
);
}
},
formatOptions
);
if (formatOptions.changeSource) {
editor.triggerEvent('contentChanged', {
source: formatOptions.changeSource,
formatApiName: formatOptions.apiName,
});
}

break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ describe('Content Model Auto Format Plugin Test', () => {
changeSource: 'AutoFormat',
apiName: formatOptions.apiName,
});
expect(triggerEventSpy).toHaveBeenCalledWith('contentChanged', {
source: 'AutoFormat',
formatApiName: formatOptions.apiName,
});
});
}

Expand Down Expand Up @@ -397,10 +393,6 @@ describe('Content Model Auto Format Plugin Test', () => {
changeSource: 'AutoFormat',
apiName: formatOption.apiName,
});
expect(triggerEventSpy).toHaveBeenCalledWith('contentChanged', {
source: 'AutoFormat',
formatApiName: formatOption.apiName,
});
});
}

Expand Down Expand Up @@ -481,11 +473,6 @@ describe('Content Model Auto Format Plugin Test', () => {
changeSource: 'AutoFormat',
apiName: formatOption.apiName,
});

expect(triggerEventSpy).toHaveBeenCalledWith('contentChanged', {
source: 'AutoFormat',
formatApiName: formatOption.apiName,
});
});
}

Expand Down Expand Up @@ -552,11 +539,6 @@ describe('Content Model Auto Format Plugin Test', () => {
changeSource: 'AutoFormat',
apiName: formatOption.apiName,
});

expect(triggerEventSpy).toHaveBeenCalledWith('contentChanged', {
source: 'AutoFormat',
formatApiName: formatOption.apiName,
});
});
}

Expand Down

0 comments on commit 08c69bf

Please sign in to comment.