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
329
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.3 to 2.0.0-alpha.4

8

CHANGELOG.md

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

# [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-alpha.3...@tiptap/core@2.0.0-alpha.4) (2020-11-16)
**Note:** Version bump only for package @tiptap/core
# [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-alpha.2...@tiptap/core@2.0.0-alpha.3) (2020-11-16)

@@ -8,0 +16,0 @@

89

dist/packages/core/src/CommandManager.d.ts
import { EditorState, Transaction } from 'prosemirror-state';
import { SingleCommands, ChainedCommands, Editor, CommandSpec } from './Editor';
import { Editor } from './Editor';
import { SingleCommands, ChainedCommands, CanCommands, CommandSpec } from './types';
export default class CommandManager {

@@ -19,44 +20,3 @@ editor: Editor;

createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
createCan(startTr?: Transaction): {
chain: () => ChainedCommands;
blur: () => boolean;
clearContent: (emitUpdate?: Boolean | undefined) => boolean;
clearNodes: () => boolean;
deleteSelection: () => boolean;
extendMarkRange: (typeOrName: string | import("prosemirror-model").MarkType<any>) => boolean;
focus: (position?: number | boolean | "start" | "end" | null | undefined) => boolean;
insertHTML: (value: string) => boolean;
insertText: (value: string) => boolean;
liftListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
removeMark: (typeOrName: string | import("prosemirror-model").MarkType<any>) => boolean;
removeMarks: () => boolean;
resetNodeAttributes: (attributeNames?: string[] | undefined) => boolean;
scrollIntoView: () => boolean;
selectAll: () => boolean;
selectParentNode: () => boolean;
setBlockType: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
setContent: (content: string, emitUpdate?: Boolean | undefined, parseOptions?: {} | undefined) => boolean;
sinkListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
splitBlock: (options?: Partial<import("./commands/splitBlock").SplitBlockOptions> | undefined) => boolean;
splitListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
toggleBlockType: (typeOrName: string | import("prosemirror-model").NodeType<any>, toggleTypeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
toggleList: (listTypeOrName: string | import("prosemirror-model").NodeType<any>, itemTypeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
toggleMark: (typeOrName: string | import("prosemirror-model").MarkType<any>, attributes?: {} | undefined) => boolean;
toggleWrap: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
try: (commands: import("./Editor").Command[] | ((props: {
editor: Editor;
tr: Transaction<any>;
commands: SingleCommands;
can: () => SingleCommands & {
chain: () => ChainedCommands;
};
chain: () => ChainedCommands;
state: EditorState<any>;
view: import("prosemirror-view").EditorView<any>;
dispatch: ((args?: any) => any) | undefined;
}) => import("./Editor").Command[])) => boolean;
updateMarkAttributes: (typeOrName: string | import("prosemirror-model").MarkType<any>, attributes: {}) => boolean;
updateNodeAttributes: (attributes: {}) => boolean;
wrapInList: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
};
createCan(startTr?: Transaction): CanCommands;
buildProps(tr: Transaction, shouldDispatch?: boolean): {

@@ -69,44 +29,3 @@ tr: Transaction<any>;

chain: () => ChainedCommands;
can: () => {
chain: () => ChainedCommands;
blur: () => boolean;
clearContent: (emitUpdate?: Boolean | undefined) => boolean;
clearNodes: () => boolean;
deleteSelection: () => boolean;
extendMarkRange: (typeOrName: string | import("prosemirror-model").MarkType<any>) => boolean;
focus: (position?: number | boolean | "start" | "end" | null | undefined) => boolean;
insertHTML: (value: string) => boolean;
insertText: (value: string) => boolean;
liftListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
removeMark: (typeOrName: string | import("prosemirror-model").MarkType<any>) => boolean;
removeMarks: () => boolean;
resetNodeAttributes: (attributeNames?: string[] | undefined) => boolean;
scrollIntoView: () => boolean;
selectAll: () => boolean;
selectParentNode: () => boolean;
setBlockType: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
setContent: (content: string, emitUpdate?: Boolean | undefined, parseOptions?: {} | undefined) => boolean;
sinkListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
splitBlock: (options?: Partial<import("./commands/splitBlock").SplitBlockOptions> | undefined) => boolean;
splitListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
toggleBlockType: (typeOrName: string | import("prosemirror-model").NodeType<any>, toggleTypeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
toggleList: (listTypeOrName: string | import("prosemirror-model").NodeType<any>, itemTypeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
toggleMark: (typeOrName: string | import("prosemirror-model").MarkType<any>, attributes?: {} | undefined) => boolean;
toggleWrap: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
try: (commands: import("./Editor").Command[] | ((props: {
editor: Editor;
tr: Transaction<any>;
commands: SingleCommands;
can: () => SingleCommands & {
chain: () => ChainedCommands;
};
chain: () => ChainedCommands;
state: EditorState<any>;
view: import("prosemirror-view").EditorView<any>;
dispatch: ((args?: any) => any) | undefined;
}) => import("./Editor").Command[])) => boolean;
updateMarkAttributes: (typeOrName: string | import("prosemirror-model").MarkType<any>, attributes: {}) => boolean;
updateNodeAttributes: (attributes: {}) => boolean;
wrapInList: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
};
can: () => CanCommands;
readonly commands: {

@@ -113,0 +32,0 @@ [k: string]: (...args: any[]) => any;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: () => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (emitUpdate?: Boolean) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: () => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: () => Command;
export default _default;
import { MarkType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | MarkType) => Command;
export default _default;

@@ -1,4 +0,4 @@

import { Command } from '../Editor';
import { Command } from '../types';
declare type Position = 'start' | 'end' | number | boolean | null;
declare const _default: (position?: Position) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (value: string) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (value: string) => Command;
export default _default;
import { NodeType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | NodeType) => Command;
export default _default;
import { MarkType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | MarkType) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: () => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (attributeNames?: string[]) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: () => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: () => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: () => Command;
export default _default;
import { NodeType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | NodeType, attrs?: {}) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (content: string, emitUpdate?: Boolean, parseOptions?: {}) => Command;
export default _default;
import { NodeType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | NodeType) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
export interface SplitBlockOptions {

@@ -3,0 +3,0 @@ withAttributes: boolean;

import { NodeType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | NodeType) => Command;
export default _default;
import { NodeType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attrs?: {}) => Command;
export default _default;
import { NodeType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType) => Command;
export default _default;
import { MarkType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | MarkType, attributes?: {} | undefined) => Command;
export default _default;
import { NodeType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | NodeType, attrs?: {}) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (commands: Command[] | ((props: Parameters<Command>[0]) => Command[])) => Command;
export default _default;
import { MarkType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | MarkType, attributes: {}) => Command;
export default _default;

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

import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (attributes: {}) => Command;
export default _default;
import { NodeType } from 'prosemirror-model';
import { Command } from '../Editor';
import { Command } from '../types';
declare const _default: (typeOrName: string | NodeType, attrs?: {} | undefined) => Command;
export default _default;

@@ -1,54 +0,11 @@

import { EditorState, Plugin, Transaction } from 'prosemirror-state';
import { EditorState, Plugin } from 'prosemirror-state';
import { EditorView } from 'prosemirror-view';
import { Schema } from 'prosemirror-model';
import EventEmitter from './EventEmitter';
import { Extension } from './Extension';
import { Node } from './Node';
import { Mark } from './Mark';
import { Extensions, UnionToIntersection } from './types';
import { EditorOptions, EditorContent, CommandSpec } from './types';
import * as extensions from './extensions';
export { extensions };
export declare type Command = (props: {
editor: Editor;
tr: Transaction;
commands: SingleCommands;
can: () => SingleCommands & {
chain: () => ChainedCommands;
};
chain: () => ChainedCommands;
state: EditorState;
view: EditorView;
dispatch: ((args?: any) => any) | undefined;
}) => boolean;
export declare type CommandSpec = (...args: any[]) => Command;
export interface CommandsSpec {
[key: string]: CommandSpec;
export interface HTMLElement {
editor?: Editor;
}
export interface AllExtensions {
}
export declare type UnfilteredCommands = {
[Item in keyof AllExtensions]: AllExtensions[Item] extends Extension<any, infer ExtensionCommands> ? ExtensionCommands : AllExtensions[Item] extends Node<any, infer NodeCommands> ? NodeCommands : AllExtensions[Item] extends Mark<any, infer MarkCommands> ? MarkCommands : never;
};
export declare type ValuesOf<T> = T[keyof T];
export declare type KeysWithTypeOf<T, Type> = ({
[P in keyof T]: T[P] extends Type ? P : never;
})[keyof T];
export declare type AllCommands = UnionToIntersection<ValuesOf<Pick<UnfilteredCommands, KeysWithTypeOf<UnfilteredCommands, {}>>>>;
export declare type SingleCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any ? (...args: Parameters<AllCommands[Item]>) => boolean : never;
};
export declare type ChainedCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any ? (...args: Parameters<AllCommands[Item]>) => ChainedCommands : never;
} & {
run: () => boolean;
};
declare type EditorContent = string | JSON | null;
interface EditorOptions {
element: Element;
content: EditorContent;
extensions: Extensions;
injectCSS: boolean;
autoFocus: 'start' | 'end' | number | boolean | null;
editable: boolean;
}
export declare class Editor extends EventEmitter {

@@ -81,52 +38,11 @@ private proxy;

*/
get commands(): SingleCommands;
get commands(): import("./types").SingleCommands;
/**
* Create a command chain to call multiple commands at once.
*/
chain(): ChainedCommands;
chain(): import("./types").ChainedCommands;
/**
* Check if a command or a command chain can be executed. Without executing it.
*/
can(): {
chain: () => ChainedCommands;
blur: () => boolean;
clearContent: (emitUpdate?: Boolean | undefined) => boolean;
clearNodes: () => boolean;
deleteSelection: () => boolean;
extendMarkRange: (typeOrName: string | import("prosemirror-model").MarkType<any>) => boolean;
focus: (position?: number | boolean | "start" | "end" | null | undefined) => boolean;
insertHTML: (value: string) => boolean;
insertText: (value: string) => boolean;
liftListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
removeMark: (typeOrName: string | import("prosemirror-model").MarkType<any>) => boolean;
removeMarks: () => boolean;
resetNodeAttributes: (attributeNames?: string[] | undefined) => boolean;
scrollIntoView: () => boolean;
selectAll: () => boolean;
selectParentNode: () => boolean;
setBlockType: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
setContent: (content: string, emitUpdate?: Boolean | undefined, parseOptions?: {} | undefined) => boolean;
sinkListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
splitBlock: (options?: Partial<import("./commands/splitBlock").SplitBlockOptions> | undefined) => boolean;
splitListItem: (typeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
toggleBlockType: (typeOrName: string | import("prosemirror-model").NodeType<any>, toggleTypeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
toggleList: (listTypeOrName: string | import("prosemirror-model").NodeType<any>, itemTypeOrName: string | import("prosemirror-model").NodeType<any>) => boolean;
toggleMark: (typeOrName: string | import("prosemirror-model").MarkType<any>, attributes?: {} | undefined) => boolean;
toggleWrap: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
try: (commands: Command[] | ((props: {
editor: Editor;
tr: Transaction<any>;
commands: SingleCommands;
can: () => SingleCommands & {
chain: () => ChainedCommands;
};
chain: () => ChainedCommands;
state: EditorState<any>;
view: EditorView<any>;
dispatch: ((args?: any) => any) | undefined;
}) => Command[])) => boolean;
updateMarkAttributes: (typeOrName: string | import("prosemirror-model").MarkType<any>, attributes: {}) => boolean;
updateNodeAttributes: (attributes: {}) => boolean;
wrapInList: (typeOrName: string | import("prosemirror-model").NodeType<any>, attrs?: {} | undefined) => boolean;
};
can(): import("./types").CanCommands;
/**

@@ -155,3 +71,5 @@ * Inject CSS styles.

*/
registerCommands(commands: CommandsSpec): void;
registerCommands(commands: {
[key: string]: CommandSpec;
}): void;
/**

@@ -158,0 +76,0 @@ * Register a command.

import { Plugin } from 'prosemirror-state';
import { InputRule } from 'prosemirror-inputrules';
import { Editor } from './Editor';

@@ -41,3 +42,3 @@ import { GlobalAttributes } from './types';

editor: Editor;
}) => any[];
}) => InputRule[];
/**

@@ -49,3 +50,3 @@ * Paste rules

editor: Editor;
}) => any[];
}) => Plugin[];
/**

@@ -52,0 +53,0 @@ * ProseMirror plugins

@@ -14,1 +14,3 @@ export * from './Editor';

export { default as mergeAttributes } from './utils/mergeAttributes';
export interface AllExtensions {
}
import { DOMOutputSpec, MarkSpec, Mark as ProseMirrorMark, MarkType } from 'prosemirror-model';
import { Plugin } from 'prosemirror-state';
import { InputRule } from 'prosemirror-inputrules';
import { ExtensionConfig } from './Extension';

@@ -79,3 +80,3 @@ import { Attributes, Overwrite } from './types';

type: MarkType;
}) => any[];
}) => InputRule[];
/**

@@ -88,3 +89,3 @@ * Paste rules

type: MarkType;
}) => any[];
}) => Plugin[];
/**

@@ -91,0 +92,0 @@ * ProseMirror plugins

import { DOMOutputSpec, NodeSpec, Node as ProseMirrorNode, NodeType } from 'prosemirror-model';
import { Plugin } from 'prosemirror-state';
import { InputRule } from 'prosemirror-inputrules';
import { ExtensionConfig } from './Extension';

@@ -119,3 +120,3 @@ import { Attributes, NodeViewRenderer, Overwrite } from './types';

type: NodeType;
}) => any[];
}) => InputRule[];
/**

@@ -128,3 +129,3 @@ * Paste rules

type: NodeType;
}) => any[];
}) => Plugin[];
/**

@@ -131,0 +132,0 @@ * ProseMirror plugins

import { Node as ProseMirrorNode } from 'prosemirror-model';
import { Decoration, NodeView } from 'prosemirror-view';
import { EditorView, Decoration, NodeView } from 'prosemirror-view';
import { EditorState, Transaction } from 'prosemirror-state';
import { Extension } from './Extension';

@@ -7,3 +8,26 @@ import { Node } from './Node';

import { Editor } from './Editor';
import { AllExtensions } from '.';
export declare type Extensions = (Extension | Node | Mark)[];
export interface EditorOptions {
element: Element;
content: EditorContent;
extensions: Extensions;
injectCSS: boolean;
autoFocus: 'start' | 'end' | number | boolean | null;
editable: boolean;
}
export declare type EditorContent = string | JSON | null;
export declare type Command = (props: {
editor: Editor;
tr: Transaction;
commands: SingleCommands;
can: () => SingleCommands & {
chain: () => ChainedCommands;
};
chain: () => ChainedCommands;
state: EditorState;
view: EditorView;
dispatch: ((args?: any) => any) | undefined;
}) => boolean;
export declare type CommandSpec = (...args: any[]) => Command;
export declare type Attribute = {

@@ -31,3 +55,5 @@ default: any;

types: string[];
attributes: Attributes;
attributes: {
[key: string]: Attribute;
};
}[];

@@ -57,1 +83,20 @@ export declare type PickValue<T, K extends keyof T> = T[K];

export declare type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView;
export declare type UnfilteredCommands = {
[Item in keyof AllExtensions]: AllExtensions[Item] extends Extension<any, infer ExtensionCommands> ? ExtensionCommands : AllExtensions[Item] extends Node<any, infer NodeCommands> ? NodeCommands : AllExtensions[Item] extends Mark<any, infer MarkCommands> ? MarkCommands : never;
};
export declare type ValuesOf<T> = T[keyof T];
export declare type KeysWithTypeOf<T, Type> = ({
[P in keyof T]: T[P] extends Type ? P : never;
})[keyof T];
export declare type AllCommands = UnionToIntersection<ValuesOf<Pick<UnfilteredCommands, KeysWithTypeOf<UnfilteredCommands, {}>>>>;
export declare type SingleCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any ? (...args: Parameters<AllCommands[Item]>) => boolean : never;
};
export declare type ChainedCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any ? (...args: Parameters<AllCommands[Item]>) => ChainedCommands : never;
} & {
run: () => boolean;
};
export declare type CanCommands = SingleCommands & {
chain: () => ChainedCommands;
};
{
"name": "@tiptap/core",
"version": "2.0.0-alpha.3",
"version": "2.0.0-alpha.4",
"homepage": "https://tiptap.dev",

@@ -38,3 +38,3 @@ "keywords": [

},
"gitHead": "163c8f3034325a0ee530333030c595642a5e4b61"
"gitHead": "81d3cb236868b2ce4da1c0b1bcf5fd6faf801034"
}
import { EditorState, Transaction } from 'prosemirror-state'
import { Editor } from './Editor'
import {
SingleCommands,
ChainedCommands,
Editor,
CanCommands,
CommandSpec,
} from './Editor'
} from './types'
import getAllMethodNames from './utils/getAllMethodNames'

@@ -113,3 +114,3 @@

chain: () => this.createChain(tr, dispatch),
}
} as CanCommands
}

@@ -116,0 +117,0 @@

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

import { Command } from '../Editor'
import { Command } from '../types'

@@ -3,0 +3,0 @@ export default (): Command => ({ view }) => {

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

import { Command } from '../Editor'
import { Command } from '../types'

@@ -3,0 +3,0 @@ export default (emitUpdate: Boolean = false): Command => ({ commands }) => {

import { liftTarget } from 'prosemirror-transform'
import { Command } from '../Editor'
import { Command } from '../types'

@@ -4,0 +4,0 @@ export default (): Command => ({ state, tr, dispatch }) => {

import { deleteSelection } from 'prosemirror-commands'
import { Command } from '../Editor'
import { Command } from '../types'

@@ -4,0 +4,0 @@ export default (): Command => ({ state, dispatch }) => {

import { TextSelection } from 'prosemirror-state'
import { MarkType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import getMarkType from '../utils/getMarkType'

@@ -5,0 +5,0 @@ import getMarkRange from '../utils/getMarkRange'

import { TextSelection } from 'prosemirror-state'
import { Editor, Command } from '../Editor'
import { Editor } from '../Editor'
import { Command } from '../types'
import minMax from '../utils/minMax'

@@ -4,0 +5,0 @@

@@ -5,3 +5,3 @@ import { DOMParser } from 'prosemirror-model'

import elementFromString from '../utils/elementFromString'
import { Command } from '../Editor'
import { Command } from '../types'

@@ -8,0 +8,0 @@ // TODO: move to utils

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

import { Command } from '../Editor'
import { Command } from '../types'

@@ -3,0 +3,0 @@ export default (value: string): Command => ({ tr, dispatch }) => {

import { liftListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import getNodeType from '../utils/getNodeType'

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

import { MarkType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import getMarkType from '../utils/getMarkType'

@@ -4,0 +4,0 @@ import getMarkRange from '../utils/getMarkRange'

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

import { Command } from '../Editor'
import { Command } from '../types'

@@ -3,0 +3,0 @@ export default (): Command => ({ tr, state, dispatch }) => {

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

import { Command } from '../Editor'
import { Command } from '../types'

@@ -3,0 +3,0 @@ export default (attributeNames: string[] = []): Command => ({ tr, state, dispatch }) => {

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

import { Command } from '../Editor'
import { Command } from '../types'

@@ -3,0 +3,0 @@ export default (): Command => ({ tr, dispatch }) => {

import { selectAll } from 'prosemirror-commands'
import { Command } from '../Editor'
import { Command } from '../types'

@@ -4,0 +4,0 @@ export default (): Command => ({ state, dispatch }) => {

import { selectParentNode } from 'prosemirror-commands'
import { Command } from '../Editor'
import { Command } from '../types'

@@ -4,0 +4,0 @@ export default (): Command => ({ state, dispatch }) => {

import { NodeType } from 'prosemirror-model'
import { setBlockType } from 'prosemirror-commands'
import { Command } from '../Editor'
import { Command } from '../types'
import getNodeType from '../utils/getNodeType'

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

import { TextSelection } from 'prosemirror-state'
import { Command } from '../Editor'
import { Command } from '../types'

@@ -4,0 +4,0 @@ export default (content: string, emitUpdate: Boolean = false, parseOptions = {}): Command => ({ tr, editor, dispatch }) => {

import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import getNodeType from '../utils/getNodeType'

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

import { canSplit } from 'prosemirror-transform'
import { ContentMatch, Fragment } from 'prosemirror-model'
import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
import { Command } from '../Editor'
import { Command } from '../types'

@@ -6,0 +6,0 @@ function defaultBlockAt(match: ContentMatch) {

import { splitListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import getNodeType from '../utils/getNodeType'

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

import { NodeType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import nodeIsActive from '../utils/nodeIsActive'

@@ -4,0 +4,0 @@ import getNodeType from '../utils/getNodeType'

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

@@ -5,0 +5,0 @@ import isList from '../utils/isList'

import { toggleMark } from 'prosemirror-commands'
import { MarkType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import getMarkType from '../utils/getMarkType'

@@ -5,0 +5,0 @@ import markIsActive from '../utils/markIsActive'

import { wrapIn, lift } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import nodeIsActive from '../utils/nodeIsActive'

@@ -5,0 +5,0 @@ import getNodeType from '../utils/getNodeType'

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

import { Command } from '../Editor'
import { Command } from '../types'

@@ -3,0 +3,0 @@ export default (commands: Command[] | ((props: Parameters<Command>[0]) => Command[])): Command => props => {

import { MarkType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import getMarkType from '../utils/getMarkType'

@@ -4,0 +4,0 @@ import getMarkAttrs from '../utils/getMarkAttrs'

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

import { Command } from '../Editor'
import { Command } from '../types'

@@ -3,0 +3,0 @@ export default (attributes: {}): Command => ({ tr, state, dispatch }) => {

import { wrapInList } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model'
import { Command } from '../Editor'
import { Command } from '../types'
import getNodeType from '../utils/getNodeType'

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

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

import EventEmitter from './EventEmitter'
import { Extension } from './Extension'
import { Node } from './Node'
import { Mark } from './Mark'
import { Extensions, UnionToIntersection } from './types'
import { EditorOptions, EditorContent, CommandSpec } from './types'
import * as extensions from './extensions'

@@ -27,64 +24,6 @@ import style from './style'

export type Command = (props: {
editor: Editor,
tr: Transaction,
commands: SingleCommands,
can: () => SingleCommands & { chain: () => ChainedCommands },
chain: () => ChainedCommands,
state: EditorState,
view: EditorView,
dispatch: ((args?: any) => any) | undefined,
}) => boolean
export type CommandSpec = (...args: any[]) => Command
export interface CommandsSpec {
[key: string]: CommandSpec
}
export interface AllExtensions {}
export type UnfilteredCommands = {
[Item in keyof AllExtensions]: AllExtensions[Item] extends Extension<any, infer ExtensionCommands>
? ExtensionCommands
: AllExtensions[Item] extends Node<any, infer NodeCommands>
? NodeCommands
: AllExtensions[Item] extends Mark<any, infer MarkCommands>
? MarkCommands
: never
}
export type ValuesOf<T> = T[keyof T];
export type KeysWithTypeOf<T, Type> = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T]
export type AllCommands = UnionToIntersection<ValuesOf<Pick<UnfilteredCommands, KeysWithTypeOf<UnfilteredCommands, {}>>>>
export type SingleCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any
? (...args: Parameters<AllCommands[Item]>) => boolean
: never
}
export type ChainedCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any
? (...args: Parameters<AllCommands[Item]>) => ChainedCommands
: never
} & {
run: () => boolean
}
type EditorContent = string | JSON | null
interface HTMLElement {
export interface HTMLElement {
editor?: Editor
}
interface EditorOptions {
element: Element,
content: EditorContent,
extensions: Extensions,
injectCSS: boolean,
autoFocus: 'start' | 'end' | number | boolean | null,
editable: boolean,
}
@magicMethods

@@ -209,3 +148,3 @@ export class Editor extends EventEmitter {

*/
public registerCommands(commands: CommandsSpec) {
public registerCommands(commands: { [key: string]: CommandSpec }) {
Object

@@ -395,18 +334,2 @@ .entries(commands)

// public setParentComponent(component = null) {
// if (!component) {
// return
// }
// this.view.setProps({
// nodeViews: this.initNodeViews({
// parent: component,
// extensions: [
// ...this.builtInExtensions,
// ...this.options.extensions,
// ],
// }),
// })
// }
/**

@@ -413,0 +336,0 @@ * Get the document as JSON.

import { Plugin } from 'prosemirror-state'
import { InputRule } from 'prosemirror-inputrules'
import { Editor } from './Editor'

@@ -47,3 +48,3 @@ import { GlobalAttributes } from './types'

editor: Editor,
}) => any[],
}) => InputRule[],

@@ -56,3 +57,3 @@ /**

editor: Editor,
}) => any[],
}) => Plugin[],

@@ -59,0 +60,0 @@ /**

@@ -16,1 +16,3 @@ export * from './Editor'

export { default as mergeAttributes } from './utils/mergeAttributes'
export interface AllExtensions {}

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

import { Plugin } from 'prosemirror-state'
import { InputRule } from 'prosemirror-inputrules'
import { ExtensionConfig } from './Extension'

@@ -92,3 +93,3 @@ import { Attributes, Overwrite } from './types'

type: MarkType,
}) => any[],
}) => InputRule[],

@@ -102,3 +103,3 @@ /**

type: MarkType,
}) => any[],
}) => Plugin[],

@@ -105,0 +106,0 @@ /**

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

import { Plugin } from 'prosemirror-state'
import { InputRule } from 'prosemirror-inputrules'
import { ExtensionConfig } from './Extension'

@@ -127,3 +128,3 @@ import { Attributes, NodeViewRenderer, Overwrite } from './types'

type: NodeType,
}) => any[],
}) => InputRule[],

@@ -137,3 +138,3 @@ /**

type: NodeType,
}) => any[],
}) => Plugin[],

@@ -140,0 +141,0 @@ /**

import { Node as ProseMirrorNode } from 'prosemirror-model'
import { Decoration, NodeView } from 'prosemirror-view'
import { EditorView, Decoration, NodeView } from 'prosemirror-view'
import { EditorState, Transaction } from 'prosemirror-state'
import { Extension } from './Extension'

@@ -7,5 +8,30 @@ import { Node } from './Node'

import { Editor } from './Editor'
import { AllExtensions } from '.'
export type Extensions = (Extension | Node | Mark)[]
export interface EditorOptions {
element: Element,
content: EditorContent,
extensions: Extensions,
injectCSS: boolean,
autoFocus: 'start' | 'end' | number | boolean | null,
editable: boolean,
}
export type EditorContent = string | JSON | null
export type Command = (props: {
editor: Editor,
tr: Transaction,
commands: SingleCommands,
can: () => SingleCommands & { chain: () => ChainedCommands },
chain: () => ChainedCommands,
state: EditorState,
view: EditorView,
dispatch: ((args?: any) => any) | undefined,
}) => boolean
export type CommandSpec = (...args: any[]) => Command
export type Attribute = {

@@ -30,3 +56,5 @@ default: any,

types: string[],
attributes: Attributes,
attributes: {
[key: string]: Attribute
},
}[]

@@ -58,1 +86,31 @@

export type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView
export type UnfilteredCommands = {
[Item in keyof AllExtensions]: AllExtensions[Item] extends Extension<any, infer ExtensionCommands>
? ExtensionCommands
: AllExtensions[Item] extends Node<any, infer NodeCommands>
? NodeCommands
: AllExtensions[Item] extends Mark<any, infer MarkCommands>
? MarkCommands
: never
}
export type ValuesOf<T> = T[keyof T];
export type KeysWithTypeOf<T, Type> = ({[P in keyof T]: T[P] extends Type ? P : never })[keyof T]
export type AllCommands = UnionToIntersection<ValuesOf<Pick<UnfilteredCommands, KeysWithTypeOf<UnfilteredCommands, {}>>>>
export type SingleCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any
? (...args: Parameters<AllCommands[Item]>) => boolean
: never
}
export type ChainedCommands = {
[Item in keyof AllCommands]: AllCommands[Item] extends (...args: any[]) => any
? (...args: Parameters<AllCommands[Item]>) => ChainedCommands
: never
} & {
run: () => boolean
}
export type CanCommands = SingleCommands & { chain: () => ChainedCommands }

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

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