Skip to content

Commit 957748e

Browse files
committed
IBX-6149: Richtext: Anchor is duplicated when entering newline
1 parent 2d56ff4 commit 957748e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/bundle/Resources/public/js/CKEditor/anchor/anchor-editing.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,24 @@ class IbexaAnchorEditing extends Plugin {
2020
}
2121

2222
init() {
23-
const { model } = this.editor;
23+
const { commands, model } = this.editor;
2424

2525
model.schema.extend('$block', { allowAttributes: 'anchor' });
2626
model.schema.extend('embed', { allowAttributes: 'anchor' });
2727
model.schema.extend('embedInline', { allowAttributes: 'anchor' });
2828
model.schema.extend('embedImage', { allowAttributes: 'anchor' });
2929
model.schema.extend('customTag', { allowAttributes: 'anchor' });
3030

31+
commands.get('enter').on('afterExecute', () => {
32+
const blocks = model.document.selection.getSelectedBlocks();
33+
34+
for (const block of blocks) {
35+
model.change((writer) => {
36+
writer.removeAttribute('anchor', block);
37+
});
38+
}
39+
});
40+
3141
this.defineConverters();
3242
}
3343
}

0 commit comments

Comments
 (0)