Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue-779]: Grammarly conflicts #956

Merged
merged 5 commits into from
Nov 30, 2019
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
4 changes: 2 additions & 2 deletions dist/editor.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- `Fix` — On selection from end to start backspace is working as expected now [#869](https://github.com/codex-team/editor.js/issues/869)
— `Fix` — Fix flipper with empty dom iterator [#926](https://github.com/codex-team/editor.js/issues/926)
- `Fix` — Normalize node before walking through children at `isEmpty` method [943](https://github.com/codex-team/editor.js/issues/943)
— `Fix` — Fixed Grammarly conflict [#779](https://github.com/codex-team/editor.js/issues/779)

### 2.15.1

Expand Down
18 changes: 14 additions & 4 deletions src/components/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,20 @@ export default class Block {
* @return {HTMLElement}
*/
get pluginsContent(): HTMLElement {
const pluginsContent = this.holder.querySelector(`.${Block.CSS.content}`);

if (pluginsContent && pluginsContent.childNodes.length) {
return pluginsContent.childNodes[0] as HTMLElement;
const blockContentNodes = this.holder.querySelector(`.${Block.CSS.content}`);

if (blockContentNodes && blockContentNodes.childNodes.length) {
/**
* Editors Block content can contain different Nodes from extensions
* We use DOM isExtensionNode to ignore such Nodes and return first Block that does not match filtering list
*/
for (let child = blockContentNodes.childNodes.length - 1; child >= 0; child--) {
const contentNode = blockContentNodes.childNodes[child];

if (!$.isExtensionNode(contentNode)) {
return contentNode as HTMLElement;
}
}
}

return null;
Expand Down
12 changes: 12 additions & 0 deletions src/components/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,16 @@ export default class Dom {
if (typeof element === 'string') { return document.getElementById(element); }
return element;
}

/**
* Method checks passed Node if it is some extension Node
* @param {Node} node - any node
*/
public static isExtensionNode(node: Node): boolean {
const extensions = [
'GRAMMARLY-EXTENSION',
];

return node && extensions.includes(node.nodeName);
}
}