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
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class CachePlugin implements PluginWithState<CachePluginState> {
constructor(option: EditorOptions, contentDiv: HTMLDivElement) {
this.state = {
domIndexer: new DomIndexerImpl(
option.experimentalFeatures &&
option.experimentalFeatures.indexOf('PersistCache') >= 0,
option.experimentalFeatures &&
option.experimentalFeatures.indexOf(
'KeepSelectionMarkerWhenEnteringTextNode'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ function unindex(node: Partial<IndexedSegmentNode>) {
* Implementation of DomIndexer
*/
export class DomIndexerImpl implements DomIndexer {
constructor(
private readonly persistCache?: boolean,
private readonly keepSelectionMarkerWhenEnteringTextNode?: boolean
) {}
constructor(private readonly keepSelectionMarkerWhenEnteringTextNode?: boolean) {}

onSegment(segmentNode: Node, paragraph: ContentModelParagraph, segment: ContentModelSegment[]) {
const indexedText = segmentNode as IndexedSegmentNode;
Expand Down Expand Up @@ -349,10 +346,6 @@ export class DomIndexerImpl implements DomIndexer {
}

reconcileChildList(addedNodes: ArrayLike<Node>, removedNodes: ArrayLike<Node>): boolean {
if (!this.persistCache) {
return false;
}

let canHandle = true;
const context: ReconcileChildListContext = {
segIndex: -1,
Expand Down Expand Up @@ -554,10 +547,6 @@ export class DomIndexerImpl implements DomIndexer {
}

this.onSegment(textNode, paragraph, textSegments);

if (!this.persistCache) {
delete paragraph.cachedElement;
}
} else if (first?.segmentType == 'Entity' && first == last) {
const wrapper = first.wrapper;
const index = paragraph.segments.indexOf(first);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class CopyPastePlugin implements PluginWithState<CopyPastePluginState> {
private editor: IEditor | null = null;
private disposer: (() => void) | null = null;
private state: CopyPastePluginState;
private customCopyCutEnabled: boolean = false;

/**
* Construct a new instance of CopyPastePlugin
Expand Down Expand Up @@ -82,7 +81,6 @@ class CopyPastePlugin implements PluginWithState<CopyPastePluginState> {
beforeDispatch: e => this.onCutCopy(e, true /*isCut*/),
},
});
this.customCopyCutEnabled = editor.isExperimentalFeatureEnabled('CustomCopyCut');
}

/**
Expand Down Expand Up @@ -160,7 +158,7 @@ class CopyPastePlugin implements PluginWithState<CopyPastePluginState> {
isCut,
}).range;

if (this.customCopyCutEnabled && isClipboardEvent(event)) {
if (isClipboardEvent(event)) {
event.preventDefault();
const text = contentModelToText(pasteModel);
event.clipboardData?.setData('text/html', tempDiv.innerHTML);
Expand Down Expand Up @@ -235,10 +233,7 @@ class CopyPastePlugin implements PluginWithState<CopyPastePluginState> {
tempDiv.style.left = '0';
tempDiv.style.userSelect = 'text';
tempDiv.contentEditable = 'true';

if (!this.customCopyCutEnabled) {
doc.body.appendChild(tempDiv);
}
doc.body.appendChild(tempDiv);

this.state.tempDiv = tempDiv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ describe('domIndexerImpl.reconcileSelection', () => {
});

it("Keeps selection marker's format when moving selection from an empty div to a text node inside", () => {
domIndexerImpl = new DomIndexerImpl(undefined, true);
domIndexerImpl = new DomIndexerImpl(true);
const divNode = document.createElement('div');
const textNode = document.createTextNode('t') as any;
divNode.appendChild(textNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ describe('CopyPastePlugin |', () => {

describe('withCustomCopyCutEnabled |', () => {
beforeEach(() => {
editor.isExperimentalFeatureEnabled = () => true;
plugin.initialize(editor);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
export type ExperimentalFeature =
/**
* When this feature is enabled, we will persist a content model in memory as long as we can,
* @deprecated When this feature is enabled, we will persist a content model in memory as long as we can,
* and use cached element when write back if it is not changed.
*/
| 'PersistCache'
Expand All @@ -20,8 +20,9 @@ export type ExperimentalFeature =
*/
| 'HandleEnterKey'
/**
* Prevent default browser behavior for copy/cut event,
* and set the clipboard data with custom implementation.
* @deprecated
* Prevent default browser behavior for copy/cut event,
* and set the clipboard data with custom implementation.
*/
| 'CustomCopyCut'
/**
Expand Down
Loading