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-beta.43 to 2.0.0-beta.44

dist/packages/core/src/commands/insertContentAt.d.ts

11

CHANGELOG.md

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

# [2.0.0-beta.44](https://github.com/ueberdosis/tiptap/compare/@tiptap/core@2.0.0-beta.43...@tiptap/core@2.0.0-beta.44) (2021-05-05)
### Features
* remove deprecated commands insertHTML, insertNode and insertText ([86d570f](https://github.com/ueberdosis/tiptap/commit/86d570fb79b89a061cf1a5374a377ed6d9bca49e))
# [2.0.0-beta.43](https://github.com/ueberdosis/tiptap/compare/@tiptap/core@2.0.0-beta.42...@tiptap/core@2.0.0-beta.43) (2021-05-05)

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

8

dist/packages/core/src/extensions/commands.d.ts

@@ -15,5 +15,3 @@ import { Extension } from '../Extension';

import * as insertContent from '../commands/insertContent';
import * as insertHTML from '../commands/insertHTML';
import * as insertNode from '../commands/insertNode';
import * as insertText from '../commands/insertText';
import * as insertContentAt from '../commands/insertContentAt';
import * as joinBackward from '../commands/joinBackward';

@@ -67,5 +65,3 @@ import * as joinForward from '../commands/joinForward';

export { insertContent };
export { insertHTML };
export { insertNode };
export { insertText };
export { insertContentAt };
export { joinBackward };

@@ -72,0 +68,0 @@ export { joinForward };

@@ -7,2 +7,2 @@ import { Schema, Node as ProseMirrorNode, Fragment, ParseOptions } from 'prosemirror-model';

};
export default function createNodeFromContent(content: Content, schema: Schema, options?: CreateNodeFromContentOptions): string | ProseMirrorNode | Fragment;
export default function createNodeFromContent(content: Content, schema: Schema, options?: CreateNodeFromContentOptions): ProseMirrorNode | Fragment;

@@ -54,3 +54,11 @@ import { Node as ProseMirrorNode, Mark as ProseMirrorMark, ParseOptions } from 'prosemirror-model';

}
export declare type Content = string | Record<string, any> | null;
export declare type HTMLContent = string;
export declare type JSONContent = {
type: string;
attrs?: Record<string, any>;
content?: JSONContent[];
text?: string;
[key: string]: any;
};
export declare type Content = HTMLContent | JSONContent | JSONContent[] | null;
export declare type CommandProps = {

@@ -57,0 +65,0 @@ editor: Editor;

{
"name": "@tiptap/core",
"description": "headless rich text editor",
"version": "2.0.0-beta.43",
"version": "2.0.0-beta.44",
"homepage": "https://tiptap.dev",

@@ -20,3 +20,2 @@ "keywords": [

"module": "dist/tiptap-core.esm.js",
"unpkg": "dist/tiptap-core.bundle.umd.min.js",
"types": "dist/packages/core/src/index.d.ts",

@@ -45,3 +44,3 @@ "files": [

},
"gitHead": "d955c9372a84c7c281ba255e19fdcb86ab51416c"
"gitHead": "c64520b74dab6b127c78960c1bd0af237b1f68fb"
}

@@ -1,3 +0,1 @@

import createNodeFromContent from '../helpers/createNodeFromContent'
import selectionToInsertionEnd from '../helpers/selectionToInsertionEnd'
import { Command, RawCommands, Content } from '../types'

@@ -16,23 +14,4 @@

export const insertContent: RawCommands['insertContent'] = value => ({ tr, dispatch, editor }) => {
if (dispatch) {
const content = createNodeFromContent(value, editor.schema)
if (typeof content === 'string') {
tr.insertText(content)
tr.scrollIntoView()
return true
}
if (!tr.selection.empty) {
tr.deleteSelection()
}
tr.insert(tr.selection.anchor, content)
selectionToInsertionEnd(tr, tr.steps.length - 1, -1)
tr.scrollIntoView()
}
return true
export const insertContent: RawCommands['insertContent'] = value => ({ tr, commands }) => {
return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value)
}

@@ -16,2 +16,4 @@ import { NodeType } from 'prosemirror-model'

export const replace: RawCommands['replace'] = (typeOrName, attributes = {}) => ({ state, commands }) => {
console.warn('[tiptap warn]: replace() is deprecated. please use insertContent() instead.')
const { from, to } = state.selection

@@ -18,0 +20,0 @@ const range = { from, to }

@@ -17,2 +17,4 @@ import { NodeType } from 'prosemirror-model'

export const replaceRange: RawCommands['replaceRange'] = (range, typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
console.warn('[tiptap warn]: replaceRange() is deprecated. please use insertContent() instead.')
const type = getNodeType(typeOrName, state.schema)

@@ -19,0 +21,0 @@ const { from, to } = range

@@ -15,5 +15,3 @@ import { Extension } from '../Extension'

import * as insertContent from '../commands/insertContent'
import * as insertHTML from '../commands/insertHTML'
import * as insertNode from '../commands/insertNode'
import * as insertText from '../commands/insertText'
import * as insertContentAt from '../commands/insertContentAt'
import * as joinBackward from '../commands/joinBackward'

@@ -68,5 +66,3 @@ import * as joinForward from '../commands/joinForward'

export { insertContent }
export { insertHTML }
export { insertNode }
export { insertText }
export { insertContentAt }
export { joinBackward }

@@ -126,5 +122,3 @@ export { joinForward }

...insertContent,
...insertHTML,
...insertNode,
...insertText,
...insertContentAt,
...joinBackward,

@@ -131,0 +125,0 @@ ...joinForward,

@@ -20,3 +20,3 @@ import {

options?: CreateNodeFromContentOptions,
): string | ProseMirrorNode | Fragment {
): ProseMirrorNode | Fragment {
options = {

@@ -28,4 +28,8 @@ slice: true,

if (content && typeof content === 'object') {
if (typeof content === 'object' && content !== null) {
try {
if (Array.isArray(content)) {
return Fragment.fromArray(content.map(item => schema.nodeFromJSON(item)))
}
return schema.nodeFromJSON(content)

@@ -46,13 +50,7 @@ } catch (error) {

if (typeof content === 'string') {
const isHTML = content.trim().startsWith('<') && content.trim().endsWith('>')
const parser = DOMParser.fromSchema(schema)
if (isHTML || !options.slice) {
const parser = DOMParser.fromSchema(schema)
return options.slice
? parser.parseSlice(elementFromString(content), options.parseOptions).content
: parser.parse(elementFromString(content), options.parseOptions)
}
return content
return options.slice
? parser.parseSlice(elementFromString(content), options.parseOptions).content
: parser.parse(elementFromString(content), options.parseOptions)
}

@@ -59,0 +57,0 @@

@@ -63,4 +63,14 @@ import {

export type Content = string | Record<string, any> | null
export type HTMLContent = string
export type JSONContent = {
type: string,
attrs?: Record<string, any>,
content?: JSONContent[],
text?: string,
[key: string]: any,
}
export type Content = HTMLContent | JSONContent | JSONContent[] | null
export type CommandProps = {

@@ -67,0 +77,0 @@ editor: Editor,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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