diff --git a/packages-content-model/roosterjs-content-model-core/lib/corePlugin/EntityPlugin.ts b/packages-content-model/roosterjs-content-model-core/lib/corePlugin/EntityPlugin.ts index 2dc12f09383..0ad7d0e4109 100644 --- a/packages-content-model/roosterjs-content-model-core/lib/corePlugin/EntityPlugin.ts +++ b/packages-content-model/roosterjs-content-model-core/lib/corePlugin/EntityPlugin.ts @@ -148,6 +148,10 @@ class EntityPlugin implements PluginWithState { entity.entityFormat.id = this.ensureUniqueId(entityType, id ?? '', wrapper); wrapper.className = generateEntityClassNames(entity.entityFormat); + if (entity.entityFormat.isReadonly) { + wrapper.contentEditable = 'false'; + } + const eventResult = this.triggerEvent(editor, wrapper, operation, rawEvent); this.state.entityMap[entity.entityFormat.id] = { diff --git a/packages-content-model/roosterjs-content-model-core/test/corePlugin/EntityPluginTest.ts b/packages-content-model/roosterjs-content-model-core/test/corePlugin/EntityPluginTest.ts index 9bdf710ffe1..f303a9a430e 100644 --- a/packages-content-model/roosterjs-content-model-core/test/corePlugin/EntityPluginTest.ts +++ b/packages-content-model/roosterjs-content-model-core/test/corePlugin/EntityPluginTest.ts @@ -83,7 +83,7 @@ describe('EntityPlugin', () => { }, }); expect(wrapper.outerHTML).toBe( - '
' + '
' ); expect(triggerPluginEventSpy).toHaveBeenCalledTimes(1); expect(triggerPluginEventSpy).toHaveBeenCalledWith(PluginEventType.EntityOperation, { @@ -125,7 +125,7 @@ describe('EntityPlugin', () => { }, }); expect(wrapper.outerHTML).toBe( - '
' + '
' ); expect(triggerPluginEventSpy).toHaveBeenCalledTimes(1); expect(triggerPluginEventSpy).toHaveBeenCalledWith(PluginEventType.EntityOperation, { @@ -166,7 +166,7 @@ describe('EntityPlugin', () => { }, }); expect(wrapper.outerHTML).toBe( - '
' + '
' ); expect(triggerPluginEventSpy).toHaveBeenCalledTimes(1); expect(triggerPluginEventSpy).toHaveBeenCalledWith(PluginEventType.EntityOperation, { @@ -206,7 +206,7 @@ describe('EntityPlugin', () => { }, }); expect(wrapper.outerHTML).toBe( - '
' + '
' ); expect(triggerPluginEventSpy).toHaveBeenCalledTimes(1); expect(triggerPluginEventSpy).toHaveBeenCalledWith(PluginEventType.EntityOperation, { @@ -260,7 +260,7 @@ describe('EntityPlugin', () => { }, }); expect(wrapper.outerHTML).toBe( - '
' + '
' ); expect(triggerPluginEventSpy).toHaveBeenCalledTimes(2); expect(triggerPluginEventSpy).toHaveBeenCalledWith(PluginEventType.EntityOperation, { @@ -344,7 +344,7 @@ describe('EntityPlugin', () => { }, }); expect(wrapper.outerHTML).toBe( - '
' + '
' ); expect(triggerPluginEventSpy).toHaveBeenCalledTimes(1); expect(triggerPluginEventSpy).toHaveBeenCalledWith(PluginEventType.EntityOperation, { @@ -408,7 +408,7 @@ describe('EntityPlugin', () => { '
' ); expect(wrapper2.outerHTML).toBe( - '
' + '
' ); expect(triggerPluginEventSpy).toHaveBeenCalledTimes(2); expect(triggerPluginEventSpy).toHaveBeenCalledWith(PluginEventType.EntityOperation, { @@ -475,7 +475,7 @@ describe('EntityPlugin', () => { '
' ); expect(wrapper2.outerHTML).toBe( - '
' + '
' ); expect(triggerPluginEventSpy).toHaveBeenCalledTimes(1); expect(triggerPluginEventSpy).toHaveBeenCalledWith(PluginEventType.EntityOperation, {