How to use tiptap-utils - 10 common examples

To help you get started, we’ve selected a few tiptap-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scrumpy / tiptap / packages / tiptap / src / Editor.js View on Github external
        [name]: (attrs = {}) => nodeIsActive(this.state, node, attrs),
      }), {})
github scrumpy / tiptap / packages / tiptap-commands / src / commands / toggleWrap.js View on Github external
return (state, dispatch, view) => {
    const isActive = nodeIsActive(state, type)

    if (isActive) {
      return lift(state, dispatch)
    }

    return wrapIn(type)(state, dispatch, view)
  }
}
github scrumpy / tiptap / packages / _legacy-tiptap / src / utils / buildMenuActions.js View on Github external
			const active = (attrs = {}) => nodeIsActive(state, schema.nodes[name], attrs)
			const command = commands[name] ? commands[name] : () => {}
github scrumpy / tiptap / packages / tiptap-commands / src / commands / toggleBlockType.js View on Github external
return (state, dispatch, view) => {
    const isActive = nodeIsActive(state, type, attrs)

    if (isActive) {
      return setBlockType(toggletype)(state, dispatch, view)
    }

    return setBlockType(type, attrs)(state, dispatch, view)
  }
}
github scrumpy / tiptap / packages / tiptap-extensions / src / marks / Link.js View on Github external
handleClick: (view, pos, event) => {
            const { schema } = view.state
            const attrs = getMarkAttrs(view.state, schema.marks.link)

            if (attrs.href && event.target instanceof HTMLAnchorElement) {
              event.stopPropagation()
              window.open(attrs.href)
            }
          },
        },
github scrumpy / tiptap / packages / _legacy-tiptap / src / utils / buildMenuActions.js View on Github external
.map(([name]) => {
			const active = () => markIsActive(state, schema.marks[name])
			const attrs = getMarkAttrs(state, schema.marks[name])
			const command = commands[name] ? commands[name] : () => {}
			return {
				name,
				active,
				attrs,
				command,
			}
		})
		.reduce((actions, {
github scrumpy / tiptap / packages / tiptap / src / Editor.js View on Github external
.reduce((marks, [name, mark]) => ({
        ...marks,
        [name]: getMarkAttrs(this.state, mark),
      }), {})
github apostrophecms / apostrophe / lib / modules / apostrophe-rich-text-widgets / src / apos / tiptap-extensions / Link.js View on Github external
handleClick(view, pos) {
            const { schema, doc, tr } = view.state;
            const range = getMarkRange(doc.resolve(pos), schema.marks.link);

            if (!range) {
              return;
            }

            const $start = doc.resolve(range.from);
            const $end = doc.resolve(range.to);
            const transaction = tr.setSelection(new TextSelection($start, $end));

            view.dispatch(transaction);
          }
        }
github scrumpy / tiptap / packages / tiptap / src / Utils / ComponentView.js View on Github external
getMarkPos() {
    const pos = this.view.posAtDOM(this.dom)
    const resolvedPos = this.view.state.doc.resolve(pos)
    const range = getMarkRange(resolvedPos, this.node.type)
    return range
  }
github scrumpy / tiptap / packages / tiptap / src / Editor.js View on Github external
        [name]: (attrs = {}) => markIsActive(this.state, mark, attrs),
      }), {})

tiptap-utils

Utility functions for tiptap

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis

Similar packages