From 6049b5a318dd3e151a2cf647c41724614594c2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 23 Jul 2019 18:30:25 +0200 Subject: [PATCH] add nodeEqualsType util --- packages/tiptap-utils/src/index.js | 1 + packages/tiptap-utils/src/utils/nodeEqualsType.js | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 packages/tiptap-utils/src/utils/nodeEqualsType.js diff --git a/packages/tiptap-utils/src/index.js b/packages/tiptap-utils/src/index.js index 2a37713da..416af39c3 100644 --- a/packages/tiptap-utils/src/index.js +++ b/packages/tiptap-utils/src/index.js @@ -1,4 +1,5 @@ export { default as getMarkAttrs } from './utils/getMarkAttrs' export { default as getMarkRange } from './utils/getMarkRange' export { default as markIsActive } from './utils/markIsActive' +export { default as nodeEqualsType } from './utils/nodeEqualsType' export { default as nodeIsActive } from './utils/nodeIsActive' diff --git a/packages/tiptap-utils/src/utils/nodeEqualsType.js b/packages/tiptap-utils/src/utils/nodeEqualsType.js new file mode 100644 index 000000000..09d0f6f0f --- /dev/null +++ b/packages/tiptap-utils/src/utils/nodeEqualsType.js @@ -0,0 +1,3 @@ +export default function nodeEqualsType({ types, node }) { + return (Array.isArray(types) && types.includes(node.type)) || node.type === types +}