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

@prosekit/core

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prosekit/core - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

7

./src/index.ts

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

export { addMark, type AddMarkOptions } from './commands/add-mark'
export { toggleMark, type ToggleMarkOptions } from './commands/toggle-mark'
export { toggleNode, type ToggleNodeOptions } from './commands/toggle-node'
export { addMark } from './commands/add-mark'
export { toggleMark } from './commands/toggle-mark'
export { insertNode } from './commands/insert-node'
export { toggleNode } from './commands/toggle-node'
export { Editor, createEditor, type EditorOptions } from './editor/editor'

@@ -5,0 +6,0 @@ export { Facet, FacetExtension, type FacetOptions } from './facets/facet'

import { Attrs } from '@prosekit/pm/model';
import { Attrs as Attrs_2 } from 'prosemirror-model';
import { Command } from '@prosekit/pm/state';

@@ -14,4 +15,6 @@ import type { ConditionalExcept } from 'type-fest';

import { MarkType } from '@prosekit/pm/model';
import { Node as Node_2 } from 'prosemirror-model';
import type { NodeSpec } from '@prosekit/pm/model';
import { NodeType } from '@prosekit/pm/model';
import { NodeType as NodeType_2 } from 'prosemirror-model';
import { NodeViewConstructor } from '@prosekit/pm/view';

@@ -34,7 +37,3 @@ import { Options } from 'tsup';

declare function addMark(options: AddMarkOptions): Command;
export { addMark }
export { addMark as addMark_alias_1 }
declare interface AddMarkOptions {
declare function addMark(options: {
type: string | MarkType;

@@ -50,5 +49,5 @@ attrs?: Attrs | null;

to?: number;
}
export { AddMarkOptions }
export { AddMarkOptions as AddMarkOptions_alias_1 }
}): Command;
export { addMark }
export { addMark as addMark_alias_1 }

@@ -129,15 +128,10 @@ export declare function applyAction(operator: Action): Command;

insertNode: [{
node: ProseMirrorNode;
node: Node_2;
pos?: number | undefined;
}];
wrap: [{
nodeType: NodeType;
attrs?: Attrs | null | undefined;
nodeType: NodeType_2;
attrs?: Attrs_2 | null | undefined;
}];
setBlockType: [{
nodeType: NodeType;
attrs?: Attrs | null | undefined;
from?: number | undefined;
to?: number | undefined;
}];
setBlockType: [nodeType: NodeType_2, attrs?: Attrs_2 | null | undefined];
selectAll: [];

@@ -439,7 +433,26 @@ };

export declare function insertNode({ node, pos, }: {
declare function insertNode(options: {
node: ProseMirrorNode;
pos?: number;
}): Command;
declare function insertNode(options: {
attrs?: Attrs;
type: string;
pos?: number;
}): Command;
export { insertNode }
export { insertNode as insertNode_alias_1 }
export declare function insertNode_alias_2({ node, pos, }: {
node: ProseMirrorNode;
pos?: number;
}): Action;
export declare function insertText({ text, from, to, }: {
text: string;
from?: number;
to?: number;
}): Command;
export declare const isMac: boolean;

@@ -576,2 +589,4 @@

export declare function selectAll(): Command;
/**

@@ -590,2 +605,9 @@ * A JSON representation of the prosemirror selection.

export declare function setBlockType({ nodeType, attrs, from, to, }: {
nodeType: NodeType;
attrs?: Attrs | null;
from?: number;
to?: number;
}): Command;
/**

@@ -645,24 +667,16 @@ * @internal

declare function toggleMark(options: ToggleMarkOptions): Command;
declare function toggleMark({ type, attrs, }: {
type: string | MarkType;
attrs?: Attrs | null;
}): Command;
export { toggleMark }
export { toggleMark as toggleMark_alias_1 }
declare interface ToggleMarkOptions {
type: string | MarkType;
declare function toggleNode({ type, attrs, }: {
type: string | NodeType;
attrs?: Attrs | null;
}
export { ToggleMarkOptions }
export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
declare function toggleNode(options: ToggleNodeOptions): Command;
}): Command;
export { toggleNode }
export { toggleNode as toggleNode_alias_1 }
declare interface ToggleNodeOptions {
type: string | NodeType;
attrs?: Attrs | null;
}
export { ToggleNodeOptions }
export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
declare type Tuple5<T> = [T, T, T, T, T];

@@ -696,2 +710,7 @@

export declare function wrap({ nodeType, attrs, }: {
nodeType: NodeType;
attrs?: Attrs | null;
}): Command;
export { }
export { addMark } from './_tsup-dts-rollup';
export { AddMarkOptions } from './_tsup-dts-rollup';
export { toggleMark } from './_tsup-dts-rollup';
export { ToggleMarkOptions } from './_tsup-dts-rollup';
export { insertNode } from './_tsup-dts-rollup';
export { toggleNode } from './_tsup-dts-rollup';
export { ToggleNodeOptions } from './_tsup-dts-rollup';
export { Editor } from './_tsup-dts-rollup';

@@ -8,0 +6,0 @@ export { createEditor } from './_tsup-dts-rollup';

@@ -43,15 +43,17 @@ // src/commands/add-mark.ts

import "@prosekit/pm/state";
function toggleMark(options) {
function toggleMark({
type,
attrs
}) {
return (state, dispatch, view) => {
return baseToggleMark(
getMarkType(state.schema, options.type),
options.attrs
)(state, dispatch, view);
return baseToggleMark(getMarkType(state.schema, type), attrs)(
state,
dispatch,
view
);
};
}
// src/commands/toggle-node.ts
import { setBlockType } from "@prosekit/pm/commands";
import "@prosekit/pm/model";
import "@prosekit/pm/state";
// src/commands/insert-node.ts
import { insertPoint } from "@prosekit/pm/transform";

@@ -71,2 +73,30 @@ // src/utils/get-node-type.ts

// src/commands/insert-node.ts
function insertNode(options) {
return (state, dispatch) => {
var _a;
const node = options.node ? options.node : options.type ? getNodeType(state.schema, options.type).createChecked(options.attrs) : null;
if (!node) {
throw new ProseKitError("You must provide either a node or a type");
}
const insertPos = insertPoint(
state.doc,
(_a = options.pos) != null ? _a : state.selection.to,
node.type
);
if (insertPos == null)
return false;
if (dispatch) {
const tr = state.tr.insert(insertPos, node);
dispatch(tr);
}
return true;
};
}
// src/commands/toggle-node.ts
import { setBlockType } from "@prosekit/pm/commands";
import "@prosekit/pm/model";
import "@prosekit/pm/state";
// src/utils/object-euqal.ts

@@ -116,5 +146,8 @@ function objectEqual(a, b) {

// src/commands/toggle-node.ts
function toggleNode(options) {
function toggleNode({
type,
attrs
}) {
return (state, dispatch, view) => {
if (isNodeActive(state, options.type, options.attrs)) {
if (isNodeActive(state, type, attrs)) {
const defaultType = state.schema.topNodeType.contentMatch.defaultType;

@@ -126,4 +159,4 @@ if (!defaultType) {

} else {
const nodeType = getNodeType(state.schema, options.type);
return setBlockType(nodeType, options.attrs)(state, dispatch, view);
const nodeType = getNodeType(state.schema, type);
return setBlockType(nodeType, attrs)(state, dispatch, view);
}

@@ -783,5 +816,69 @@ };

// src/extensions/command.ts
import { setBlockType as setBlockType2 } from "@prosekit/pm/commands";
// src/commands/insert-text.ts
function insertText({
text,
from,
to
}) {
return (state, dispatch) => {
if (text) {
dispatch == null ? void 0 : dispatch(state.tr.insertText(text, from, to));
}
return true;
};
}
// src/commands/select-all.ts
import { AllSelection } from "@prosekit/pm/state";
function selectAll() {
return (state, dispatch) => {
dispatch == null ? void 0 : dispatch(state.tr.setSelection(new AllSelection(state.doc)));
return true;
};
}
// src/commands/wrap.ts
import "@prosekit/pm/model";
import { AllSelection } from "@prosekit/pm/state";
import { findWrapping, insertPoint } from "@prosekit/pm/transform";
import "@prosekit/pm/state";
import { findWrapping } from "@prosekit/pm/transform";
function wrap({
nodeType,
attrs
}) {
return (state, dispatch) => {
const { $from, $to } = state.selection;
const range = $from.blockRange($to);
if (!range)
return false;
const wrapping = findWrapping(range, nodeType, attrs);
if (!wrapping)
return false;
dispatch == null ? void 0 : dispatch(state.tr.wrap(range, wrapping));
return true;
};
}
// src/extensions/actions.ts
import "@prosekit/pm/model";
import { Selection as Selection2 } from "@prosekit/pm/state";
import { insertPoint as insertPoint2 } from "@prosekit/pm/transform";
function insertNode2({
node,
pos
}) {
return ({ tr }) => {
const insertPos = insertPoint2(tr.doc, pos != null ? pos : tr.selection.to, node.type);
if (insertPos == null) {
return false;
}
tr.insert(insertPos, node);
const $pos = tr.doc.resolve(insertPos);
tr.setSelection(Selection2.near($pos));
return true;
};
}
// src/extensions/command.ts
function defineCommands(commands) {

@@ -792,65 +889,7 @@ return commandFacet.extension([commands]);

return defineCommands({
insertText: ({
text,
from,
to
}) => {
return (state, dispatch) => {
if (text) {
dispatch == null ? void 0 : dispatch(state.tr.insertText(text, from, to));
}
return true;
};
},
insertNode: ({ node, pos }) => {
return (state, dispatch) => {
const insertPos = insertPoint(
state.doc,
pos != null ? pos : state.selection.to,
node.type
);
if (insertPos == null)
return false;
if (dispatch) {
const tr = state.tr.insert(insertPos, node);
dispatch(tr);
}
return true;
};
},
wrap: ({
nodeType,
attrs
}) => {
return (state, dispatch) => {
const { $from, $to } = state.selection;
const range = $from.blockRange($to);
if (!range)
return false;
const wrapping = findWrapping(range, nodeType, attrs);
if (!wrapping)
return false;
dispatch == null ? void 0 : dispatch(state.tr.wrap(range, wrapping));
return true;
};
},
setBlockType: ({
nodeType,
attrs,
from,
to
}) => {
return (state, dispatch) => {
from = from != null ? from : state.selection.from;
to = from != null ? from : state.selection.from;
dispatch == null ? void 0 : dispatch(state.tr.setBlockType(from, to, nodeType, attrs));
return true;
};
},
selectAll: () => {
return (state, dispatch) => {
dispatch == null ? void 0 : dispatch(state.tr.setSelection(new AllSelection(state.doc)));
return true;
};
}
insertText,
insertNode: insertNode2,
wrap,
setBlockType: setBlockType2,
selectAll
});

@@ -1169,2 +1208,3 @@ }

getNodeType,
insertNode,
pluginFacet,

@@ -1171,0 +1211,0 @@ toggleMark,

{
"name": "@prosekit/core",
"type": "module",
"version": "0.0.13",
"version": "0.0.14",
"private": false,

@@ -6,0 +6,0 @@ "author": {

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