Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tiptap/core

Package Overview
Dependencies
Maintainers
2
Versions
331
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/core - npm Package Compare versions

Comparing version 2.0.0-alpha.10 to 2.0.0-alpha.11

src/commands/deleteRange.ts

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-alpha.10...@tiptap/core@2.0.0-alpha.11) (2021-01-28)
### Bug Fixes
* don’t merge classes ([dba0c1a](https://github.com/ueberdosis/tiptap-next/commit/dba0c1ac15e9beda3ebd027c67c969a4fe7ae7c7))
# [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-alpha.9...@tiptap/core@2.0.0-alpha.10) (2021-01-06)

@@ -8,0 +19,0 @@

26

package.json
{
"name": "@tiptap/core",
"description": "headless rich text editor",
"version": "2.0.0-alpha.10",
"version": "2.0.0-alpha.11",
"homepage": "https://tiptap.dev",

@@ -27,10 +27,11 @@ "keywords": [

"dependencies": {
"@types/prosemirror-commands": "^1.0.3",
"@types/prosemirror-inputrules": "^1.0.3",
"@types/prosemirror-keymap": "^1.0.3",
"@types/prosemirror-model": "^1.11.1",
"@types/prosemirror-schema-list": "^1.0.1",
"@types/prosemirror-state": "^1.2.5",
"@types/prosemirror-transform": "^1.1.1",
"@types/prosemirror-view": "^1.16.1",
"@types/prosemirror-commands": "^1.0.4",
"@types/prosemirror-inputrules": "^1.0.4",
"@types/prosemirror-keymap": "^1.0.4",
"@types/prosemirror-model": "^1.11.2",
"@types/prosemirror-schema-list": "^1.0.2",
"@types/prosemirror-state": "^1.2.6",
"@types/prosemirror-tables": "^0.9.1",
"@types/prosemirror-transform": "^1.1.2",
"@types/prosemirror-view": "^1.17.1",
"prosemirror-commands": "^1.1.3",

@@ -41,9 +42,8 @@ "prosemirror-inputrules": "^1.1.3",

"prosemirror-schema-list": "^1.1.4",
"prosemirror-state": "^1.3.3",
"prosemirror-state": "^1.3.4",
"prosemirror-tables": "^1.1.1",
"prosemirror-transform": "^1.2.8",
"prosemirror-utils": "^1.0.0-0",
"prosemirror-transform": "^1.2.9",
"prosemirror-view": "^1.16.3"
},
"gitHead": "f0617771119effea972848c8a64693fc93a020d5"
"gitHead": "bca182a9d99681f002009c021a1aa6e494114f4b"
}
import { EditorState, TextSelection } from 'prosemirror-state'
import { Command, FocusPosition } from '../types'
import minMax from '../utilities/minMax'
import isTextSelection from '../helpers/isTextSelection'

@@ -45,2 +46,8 @@ function resolveSelection(state: EditorState, position: FocusPosition = null) {

// we don’t try to resolve a NodeSelection or CellSelection
if (dispatch && position === null && !isTextSelection(editor.state.selection)) {
view.focus()
return true
}
const { from, to } = resolveSelection(editor.state, position) || editor.state.selection

@@ -47,0 +54,0 @@ const { doc } = tr

@@ -1,5 +0,5 @@

import { findParentNode } from 'prosemirror-utils'
import { NodeType } from 'prosemirror-model'
import { Command } from '../types'
import getNodeType from '../helpers/getNodeType'
import findParentNode from '../helpers/findParentNode'
import isList from '../helpers/isList'

@@ -6,0 +6,0 @@

@@ -32,3 +32,3 @@ import { EditorState, Plugin, Transaction } from 'prosemirror-state'

private extensionManager!: ExtensionManager
public extensionManager!: ExtensionManager

@@ -400,2 +400,9 @@ private css!: HTMLStyleElement

/**
* Get the number of characters for the current document.
*/
public getCharacterCount() {
return this.state.doc.content.size - 2
}
/**
* Destroy the editor.

@@ -402,0 +409,0 @@ */

import { Plugin, Transaction } from 'prosemirror-state'
import { InputRule } from 'prosemirror-inputrules'
import { Editor } from './Editor'
import mergeDeep from './utilities/mergeDeep'
import { GlobalAttributes } from './types'

@@ -174,16 +175,10 @@

configure(options?: Partial<Options>) {
configure(options: Partial<Options> = {}) {
return Extension
.create<Options, Commands>(this.config as ExtensionConfig<Options, Commands>)
.#configure({
...this.config.defaultOptions,
...options,
})
.#configure(options)
}
#configure = (options: Partial<Options>) => {
this.options = {
...this.config.defaultOptions,
...options,
}
this.options = mergeDeep(this.config.defaultOptions, options) as Options

@@ -190,0 +185,0 @@ return this

import { keymap } from 'prosemirror-keymap'
import { Schema, Node as ProsemirrorNode } from 'prosemirror-model'
import { inputRules } from 'prosemirror-inputrules'
import { inputRules as inputRulesPlugin } from 'prosemirror-inputrules'
import { EditorView, Decoration } from 'prosemirror-view'

@@ -9,2 +9,3 @@ import { Editor } from './Editor'

import getSchemaTypeByName from './helpers/getSchemaTypeByName'
import getNodeType from './helpers/getNodeType'
import splitExtensions from './helpers/splitExtensions'

@@ -69,27 +70,2 @@ import getAttributesFromExtensions from './helpers/getAttributesFromExtensions'

get plugins() {
const plugins = this.extensions
.map(extension => {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.config.name, this.schema),
}
return extension.config.addProseMirrorPlugins.bind(context)()
})
.flat()
return [
...plugins,
...this.keymaps,
...this.pasteRules,
inputRules({ rules: this.inputRules }),
]
}
get inputRules() {
if (!this.editor.options.enableInputRules) {
return []
}
return this.extensions

@@ -103,21 +79,18 @@ .map(extension => {

return extension.config.addInputRules.bind(context)()
})
.flat()
}
const keymapPlugin = keymap(extension.config.addKeyboardShortcuts.bind(context)())
const inputRules = extension.config.addInputRules.bind(context)()
const inputRulePlugins = this.editor.options.enableInputRules && inputRules.length
? [inputRulesPlugin({ rules: inputRules })]
: []
const pasteRulePlugins = this.editor.options.enablePasteRules
? extension.config.addPasteRules.bind(context)()
: []
const plugins = extension.config.addProseMirrorPlugins.bind(context)()
get pasteRules() {
if (!this.editor.options.enablePasteRules) {
return []
}
return this.extensions
.map(extension => {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.config.name, this.schema),
}
return extension.config.addPasteRules.bind(context)()
return [
keymapPlugin,
...inputRulePlugins,
...pasteRulePlugins,
...plugins,
]
})

@@ -127,14 +100,2 @@ .flat()

get keymaps() {
return this.extensions.map(extension => {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.config.name, this.schema),
}
return keymap(extension.config.addKeyboardShortcuts.bind(context)())
})
}
get nodeViews() {

@@ -152,8 +113,6 @@ const { editor } = this

editor,
type: getSchemaTypeByName(extension.config.name, this.schema),
type: getNodeType(extension.config.name, this.schema),
}
const renderer = extension.config.addNodeView?.call(context) as NodeViewRenderer
// @ts-ignore
const renderer = extension.config.addNodeView?.bind(context)?.() as NodeViewRenderer
const nodeview = (

@@ -181,2 +140,21 @@ node: ProsemirrorNode,

get textSerializers() {
const { editor } = this
const { nodeExtensions } = splitExtensions(this.extensions)
return Object.fromEntries(nodeExtensions
.filter(extension => !!extension.config.renderText)
.map(extension => {
const context = {
options: extension.options,
editor,
type: getNodeType(extension.config.name, this.schema),
}
const textSerializer = (props: { node: ProsemirrorNode }) => extension.config.renderText?.call(context, props)
return [extension.config.name, textSerializer]
}))
}
}

@@ -7,2 +7,3 @@ import { Extension } from '../Extension'

import * as createParagraphNear from '../commands/createParagraphNear'
import * as deleteRange from '../commands/deleteRange'
import * as deleteSelection from '../commands/deleteSelection'

@@ -21,2 +22,4 @@ import * as exitCode from '../commands/exitCode'

import * as newlineInCode from '../commands/newlineInCode'
import * as replace from '../commands/replace'
import * as replaceRange from '../commands/replaceRange'
import * as resetNodeAttributes from '../commands/resetNodeAttributes'

@@ -55,2 +58,3 @@ import * as scrollIntoView from '../commands/scrollIntoView'

...createParagraphNear,
...deleteRange,
...deleteSelection,

@@ -69,2 +73,4 @@ ...exitCode,

...newlineInCode,
...replace,
...replaceRange,
...resetNodeAttributes,

@@ -71,0 +77,0 @@ ...scrollIntoView,

@@ -27,3 +27,3 @@ import { Plugin, PluginKey } from 'prosemirror-state'

return true
return false
},

@@ -39,3 +39,3 @@ blur: (view, event) => {

return true
return false
},

@@ -42,0 +42,0 @@ },

@@ -0,1 +1,2 @@

export { ClipboardTextSerializer } from './clipboardTextSerializer'
export { Commands } from './commands'

@@ -2,0 +3,0 @@ export { Editable } from './editable'

@@ -39,2 +39,3 @@ import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model'

isolating: callOrReturn(extension.config.isolating, context),
tableRole: callOrReturn(extension.config.tableRole, context),
attrs: Object.fromEntries(extensionAttributes.map(extensionAttribute => {

@@ -41,0 +42,0 @@ return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }]

@@ -19,3 +19,7 @@ export * from './Editor'

export { default as isNodeActive } from './helpers/isNodeActive'
export { default as isNodeSelection } from './helpers/isNodeSelection'
export { default as isTextSelection } from './helpers/isTextSelection'
export { default as isCellSelection } from './helpers/isCellSelection'
export { default as findParentNodeClosestToPos } from './helpers/findParentNodeClosestToPos'
export interface AllExtensions {}

@@ -10,2 +10,3 @@ import {

import { ExtensionConfig } from './Extension'
import mergeDeep from './utilities/mergeDeep'
import { Attributes, Overwrite } from './types'

@@ -235,16 +236,10 @@ import { Editor } from './Editor'

configure(options?: Partial<Options>) {
configure(options: Partial<Options> = {}) {
return Mark
.create<Options, Commands>(this.config as MarkConfig<Options, Commands>)
.#configure({
...this.config.defaultOptions,
...options,
})
.#configure(options)
}
#configure = (options: Partial<Options>) => {
this.options = {
...this.config.defaultOptions,
...options,
}
this.options = mergeDeep(this.config.defaultOptions, options) as Options

@@ -251,0 +246,0 @@ return this

@@ -0,1 +1,2 @@

// @ts-nocheck
import {

@@ -10,2 +11,3 @@ DOMOutputSpec,

import { ExtensionConfig } from './Extension'
import mergeDeep from './utilities/mergeDeep'
import { Attributes, NodeViewRenderer, Overwrite } from './types'

@@ -71,2 +73,7 @@ import { Editor } from './Editor'

/**
* Table Role
*/
tableRole?: NodeSpec['tableRole'] | ((this: { options: Options }) => NodeSpec['tableRole']),
/**
* Parse HTML

@@ -94,2 +101,16 @@ */

/**
* Render Text
*/
renderText?: ((
this: {
options: Options,
editor: Editor,
type: NodeType,
},
props: {
node: ProseMirrorNode,
}
) => string) | null,
/**
* Add Attributes

@@ -263,2 +284,3 @@ */

renderHTML: null,
renderText: null,
addAttributes: () => ({}),

@@ -290,16 +312,10 @@ addNodeView: null,

configure(options?: Partial<Options>) {
configure(options: Partial<Options> = {}) {
return Node
.create<Options, Commands>(this.config as NodeConfig<Options, Commands>)
.#configure({
...this.config.defaultOptions,
...options,
})
.#configure(options)
}
#configure = (options: Partial<Options>) => {
this.options = {
...this.config.defaultOptions,
...options,
}
this.options = mergeDeep(this.config.defaultOptions, options) as Options

@@ -306,0 +322,0 @@ return this

@@ -100,3 +100,3 @@ import { Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model'

export type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView
export type NodeViewRenderer = (props: NodeViewRendererProps) => (NodeView | {})

@@ -134,1 +134,8 @@ export type UnfilteredCommands = {

export type FocusPosition = 'start' | 'end' | number | boolean | null
export type Range = {
from: number,
to: number,
}
export type Predicate = (node: ProseMirrorNode) => boolean
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc