New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@prosekit/core

Package Overview
Dependencies
Maintainers
1
Versions
111
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.7.14 to 0.7.15

dist/chunk-B3WEP4DD.js

6

dist/prosekit-core-test.js

@@ -9,3 +9,3 @@ import {

setupEditorExtension
} from "./chunk-6DIFWJEG.js";
} from "./chunk-B3WEP4DD.js";

@@ -76,4 +76,4 @@ // src/test/test-editor.ts

const tags = doc.tags;
const $a = maybeResolve(doc, tags == null ? void 0 : tags.a);
const $b = maybeResolve(doc, tags == null ? void 0 : tags.b);
const $a = maybeResolve(doc, tags?.a);
const $b = maybeResolve(doc, tags?.b);
if ($a) {

@@ -80,0 +80,0 @@ if ($a.parent.inlineContent) {

@@ -41,2 +41,4 @@ export { addMark } from './_tsup-dts-rollup.js';

export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup.js';
export { defineClipboardSerializer } from './_tsup-dts-rollup.js';
export { ClipboardSerializerOptions } from './_tsup-dts-rollup.js';
export { defineBaseCommands } from './_tsup-dts-rollup.js';

@@ -172,2 +174,3 @@ export { defineCommands } from './_tsup-dts-rollup.js';

export { isAtBlockStart } from './_tsup-dts-rollup.js';
export { isElement } from './_tsup-dts-rollup.js';
export { isInCodeBlock } from './_tsup-dts-rollup.js';

@@ -174,0 +177,0 @@ export { isMarkAbsent } from './_tsup-dts-rollup.js';

@@ -42,3 +42,3 @@ import {

union
} from "./chunk-6DIFWJEG.js";
} from "./chunk-B3WEP4DD.js";

@@ -48,10 +48,9 @@ // src/commands/add-mark.ts

return (state, dispatch) => {
var _a, _b;
const mark = getMarkType(state.schema, options.type).create(options.attrs);
const from = (_a = options.from) != null ? _a : state.selection.from;
const to = (_b = options.to) != null ? _b : state.selection.to;
const from = options.from ?? state.selection.from;
const to = options.to ?? state.selection.to;
if (from > to) {
return false;
}
dispatch == null ? void 0 : dispatch(state.tr.addMark(from, to, mark));
dispatch?.(state.tr.addMark(from, to, mark));
return true;

@@ -133,3 +132,3 @@ };

return (state, dispatch) => {
const $pos = (options == null ? void 0 : options.pos) == null ? state.selection.$to : state.doc.resolve(options.pos);
const $pos = options?.pos == null ? state.selection.$to : state.doc.resolve(options.pos);
const depth = $pos.parent.isTextblock ? $pos.depth - 1 : $pos.depth;

@@ -171,3 +170,2 @@ const parent = $pos.node(depth);

return (state, dispatch) => {
var _a;
const node = options.node ? options.node : options.type ? getNodeType(state.schema, options.type).createAndFill(options.attrs) : null;

@@ -177,3 +175,3 @@ assert(node, "You must provide either a node or a type");

state.doc,
(_a = options.pos) != null ? _a : state.selection.anchor,
options.pos ?? state.selection.anchor,
node.type

@@ -194,11 +192,10 @@ );

return (state, dispatch) => {
var _a, _b;
const markType = getMarkType(state.schema, options.type);
const mark = options.attrs ? markType.create(options.attrs) : markType;
const from = (_a = options.from) != null ? _a : state.selection.from;
const to = (_b = options.to) != null ? _b : state.selection.to;
const from = options.from ?? state.selection.from;
const to = options.to ?? state.selection.to;
if (from > to) {
return false;
}
dispatch == null ? void 0 : dispatch(state.tr.removeMark(from, to, mark));
dispatch?.(state.tr.removeMark(from, to, mark));
return true;

@@ -233,3 +230,3 @@ };

const { pos, node } = found;
dispatch == null ? void 0 : dispatch(state.tr.delete(pos, pos + node.nodeSize));
dispatch?.(state.tr.delete(pos, pos + node.nodeSize));
return true;

@@ -244,6 +241,6 @@ };

function getCustomSelection(state, from, to) {
const pos = from != null ? from : to;
const pos = from ?? to;
if (pos != null) {
const $from = state.doc.resolve(from != null ? from : pos);
const $to = state.doc.resolve(to != null ? to : pos);
const $from = state.doc.resolve(from ?? pos);
const $to = state.doc.resolve(to ?? pos);
return TextSelection4.between($from, $to);

@@ -304,6 +301,5 @@ }

return (state, dispatch) => {
var _a, _b;
const nodeTypes = getNodeTypes(state.schema, options.type);
const from = (_a = options.pos) != null ? _a : state.selection.from;
const to = (_b = options.pos) != null ? _b : state.selection.to;
const from = options.pos ?? state.selection.from;
const to = options.pos ?? state.selection.to;
const positions = [];

@@ -380,3 +376,3 @@ state.doc.nodesBetween(from, to, (node, pos) => {

if (!wrapping) return false;
dispatch == null ? void 0 : dispatch(state.tr.wrap(range, wrapping));
dispatch?.(state.tr.wrap(range, wrapping));
return true;

@@ -405,9 +401,8 @@ };

return (state, dispatch) => {
var _a, _b;
const from = (_a = options == null ? void 0 : options.from) != null ? _a : state.selection.from;
const to = (_b = options == null ? void 0 : options.to) != null ? _b : state.selection.to;
const from = options?.from ?? state.selection.from;
const to = options?.to ?? state.selection.to;
if (from > to) return false;
const tr = state.tr;
if (unsetTextBlockType(tr, from, to)) {
dispatch == null ? void 0 : dispatch(tr);
dispatch?.(tr);
return true;

@@ -446,7 +441,6 @@ }

return (state, dispatch) => {
var _a, _b;
const from = (_a = options == null ? void 0 : options.from) != null ? _a : state.selection.from;
const to = (_b = options == null ? void 0 : options.to) != null ? _b : state.selection.to;
const from = options?.from ?? state.selection.from;
const to = options?.to ?? state.selection.to;
if (from > to) return false;
dispatch == null ? void 0 : dispatch(state.tr.removeMark(from, to));
dispatch?.(state.tr.removeMark(from, to));
return true;

@@ -463,2 +457,103 @@ };

// src/extensions/clipboard-serializer.ts
import {
DOMSerializer
} from "@prosekit/pm/model";
import {
PluginKey,
ProseMirrorPlugin
} from "@prosekit/pm/state";
// src/extensions/plugin.ts
import {
Plugin
} from "@prosekit/pm/state";
function definePlugin(plugin) {
if (plugin instanceof Plugin || Array.isArray(plugin) && plugin.every((p) => p instanceof Plugin)) {
return definePluginPayload(() => plugin);
}
if (typeof plugin === "function") {
return definePluginPayload(plugin);
}
throw new TypeError("Invalid plugin");
}
function definePluginPayload(payload) {
return defineFacetPayload(pluginFacet, [payload]);
}
var pluginFacet = defineFacet({
reducer: (payloads) => {
return ({ schema }) => {
const plugins = [];
for (const payload of payloads) {
if (payload instanceof Plugin) {
plugins.push(payload);
} else if (Array.isArray(payload) && payload.every((p) => p instanceof Plugin)) {
plugins.push(...payload);
} else if (typeof payload === "function") {
plugins.push(...[payload({ schema })].flat());
} else {
throw new ProseKitError("Invalid plugin");
}
}
plugins.reverse();
return { plugins };
};
},
parent: stateFacet
});
// src/extensions/clipboard-serializer.ts
function mergeWrappers(wrappers) {
return (fn) => wrappers.filter(isNotNullish).reduce((fn2, wrapper) => wrapper(fn2), fn);
}
function wrapFunction(fn, wrapper) {
return wrapper ? wrapper(fn) : fn;
}
var CustomDOMSerializer = class extends DOMSerializer {
constructor(nodes, marks, serializeFragmentWrapper, serializeNodeWrapper) {
super(nodes, marks);
this.serializeFragmentWrapper = serializeFragmentWrapper;
this.serializeNodeWrapper = serializeNodeWrapper;
}
serializeFragment(...args) {
const fn = (...args2) => super.serializeFragment(...args2);
return wrapFunction(fn, this.serializeFragmentWrapper)(...args);
}
serializeNode(...args) {
const fn = (...args2) => super.serializeNode(...args2);
return wrapFunction(fn, this.serializeNodeWrapper)(...args);
}
};
function createCustomDOMSerializer(schema, options) {
const nodesFromSchema = (...args) => DOMSerializer.nodesFromSchema(...args);
const marksFromSchema = (...args) => DOMSerializer.marksFromSchema(...args);
const nodes = wrapFunction(nodesFromSchema, options.nodesFromSchemaWrapper)(schema);
const marks = wrapFunction(marksFromSchema, options.marksFromSchemaWrapper)(schema);
return new CustomDOMSerializer(nodes, marks, options.serializeFragmentWrapper, options.serializeNodeWrapper);
}
var clipboardSerializerFacet = defineFacet({
reducer: (inputs) => {
const options = {
serializeFragmentWrapper: mergeWrappers(inputs.map((input) => input.serializeFragmentWrapper)),
serializeNodeWrapper: mergeWrappers(inputs.map((input) => input.serializeNodeWrapper)),
nodesFromSchemaWrapper: mergeWrappers(inputs.map((input) => input.nodesFromSchemaWrapper)),
marksFromSchemaWrapper: mergeWrappers(inputs.map((input) => input.marksFromSchemaWrapper))
};
return ({ schema }) => {
const clipboardSerializer = createCustomDOMSerializer(schema, options);
return [
new ProseMirrorPlugin({
key: new PluginKey("prosekit-clipboard-serializer"),
props: { clipboardSerializer }
})
];
};
},
singleton: true,
parent: pluginFacet
});
function defineClipboardSerializer(options) {
return defineFacetPayload(clipboardSerializerFacet, [options]);
}
// src/commands/insert-text.ts

@@ -468,3 +563,3 @@ function insertText({ text, from, to }) {

if (text) {
dispatch == null ? void 0 : dispatch(state.tr.insertText(text, from, to));
dispatch?.(state.tr.insertText(text, from, to));
}

@@ -481,3 +576,3 @@ return true;

return (state, dispatch) => {
dispatch == null ? void 0 : dispatch(state.tr.setSelection(new AllSelection(state.doc)));
dispatch?.(state.tr.setSelection(new AllSelection(state.doc)));
return true;

@@ -527,3 +622,2 @@ };

reducer: (specs) => {
var _a;
let nodes = OrderedMap.from({});

@@ -534,4 +628,4 @@ let marks = OrderedMap.from({});

nodes = nodes.append(spec.nodes);
marks = marks.append((_a = spec.marks) != null ? _a : {});
topNode = topNode != null ? topNode : spec.topNode;
marks = marks.append(spec.marks ?? {});
topNode = topNode ?? spec.topNode;
}

@@ -582,11 +676,10 @@ return { nodes, marks, topNode };

function mergeSpecs(a, b) {
var _a, _b, _c, _d, _e, _f;
const attrs = {};
const attrNames = /* @__PURE__ */ new Set([
...Object.keys((_a = a.attrs) != null ? _a : {}),
...Object.keys((_b = b.attrs) != null ? _b : {})
...Object.keys(a.attrs ?? {}),
...Object.keys(b.attrs ?? {})
]);
for (const name of attrNames) {
const attrSpecA = (_c = a.attrs) == null ? void 0 : _c[name];
const attrSpecB = (_d = b.attrs) == null ? void 0 : _d[name];
const attrSpecA = a.attrs?.[name];
const attrSpecB = b.attrs?.[name];
const attrSpecMerged = mergeObjects(attrSpecA, attrSpecB);

@@ -597,3 +690,3 @@ if (attrSpecMerged) {

}
const parseDOM = [...(_e = a.parseDOM) != null ? _e : [], ...(_f = b.parseDOM) != null ? _f : []];
const parseDOM = [...a.parseDOM ?? [], ...b.parseDOM ?? []];
return mergeObjects(a, b, { attrs, parseDOM });

@@ -606,6 +699,3 @@ }

const dom = toDOM(node, ...args);
const pairs = options.map((option) => {
var _a;
return (_a = option.toDOM) == null ? void 0 : _a.call(option, node.attrs[option.attr]);
}).filter(isNotNullish);
const pairs = options.map((option) => option.toDOM?.(node.attrs[option.attr])).filter(isNotNullish);
return insertOutputSpecAttrs(dom, pairs);

@@ -620,6 +710,5 @@ };

getAttrs: (dom) => {
var _a, _b;
const baseAttrs = (_b = (_a = existingGetAttrs == null ? void 0 : existingGetAttrs(dom)) != null ? _a : existingAttrs) != null ? _b : {};
const baseAttrs = existingGetAttrs?.(dom) ?? existingAttrs ?? {};
if (baseAttrs === false || !dom || !isElement(dom)) {
return baseAttrs != null ? baseAttrs : null;
return baseAttrs ?? null;
}

@@ -748,45 +837,5 @@ const insertedAttrs = {};

import {
PluginKey,
ProseMirrorPlugin
PluginKey as PluginKey2,
ProseMirrorPlugin as ProseMirrorPlugin2
} from "@prosekit/pm/state";
// src/extensions/plugin.ts
import {
Plugin
} from "@prosekit/pm/state";
function definePlugin(plugin) {
if (plugin instanceof Plugin || Array.isArray(plugin) && plugin.every((p) => p instanceof Plugin)) {
return definePluginPayload(() => plugin);
}
if (typeof plugin === "function") {
return definePluginPayload(plugin);
}
throw new TypeError("Invalid plugin");
}
function definePluginPayload(payload) {
return defineFacetPayload(pluginFacet, [payload]);
}
var pluginFacet = defineFacet({
reducer: (payloads) => {
return ({ schema }) => {
const plugins = [];
for (const payload of payloads) {
if (payload instanceof Plugin) {
plugins.push(payload);
} else if (Array.isArray(payload) && payload.every((p) => p instanceof Plugin)) {
plugins.push(...payload);
} else if (typeof payload === "function") {
plugins.push(...[payload({ schema })].flat());
} else {
throw new ProseKitError("Invalid plugin");
}
}
plugins.reverse();
return { plugins };
};
},
parent: stateFacet
});
// src/extensions/events/plugin-view.ts
function defineMountHandler(handler) {

@@ -809,3 +858,3 @@ return definePluginViewFacetPayload(["mount", handler]);

let unmountHandlers = [];
const plugin = new ProseMirrorPlugin({
const plugin = new ProseMirrorPlugin2({
key: pluginKey,

@@ -850,3 +899,3 @@ view: (view) => {

});
var pluginKey = new PluginKey("prosekit-plugin-view-handler");
var pluginKey = new PluginKey2("prosekit-plugin-view-handler");

@@ -864,4 +913,4 @@ // src/extensions/events/doc-change.ts

import {
PluginKey as PluginKey2,
ProseMirrorPlugin as ProseMirrorPlugin2
PluginKey as PluginKey3,
ProseMirrorPlugin as ProseMirrorPlugin3
} from "@prosekit/pm/state";

@@ -906,3 +955,2 @@

const update = (payloads) => {
var _a;
let hasNewEvent = false;

@@ -922,8 +970,8 @@ for (const [event] of payloads) {

for (const [event, setHandlers] of Object.entries(setHandlersMap)) {
const handlers = (_a = map[event]) != null ? _a : [];
const handlers = map[event] ?? [];
setHandlers(handlers);
}
if (hasNewEvent) {
plugin = new ProseMirrorPlugin2({
key: new PluginKey2("prosekit-dom-event-handler"),
plugin = new ProseMirrorPlugin3({
key: new PluginKey3("prosekit-dom-event-handler"),
props: { handleDOMEvents: combinedHandlerMap }

@@ -935,3 +983,3 @@ });

update(inputs);
return plugin != null ? plugin : [];
return plugin ?? [];
};

@@ -946,4 +994,4 @@ },

import {
PluginKey as PluginKey3,
ProseMirrorPlugin as ProseMirrorPlugin3
PluginKey as PluginKey4,
ProseMirrorPlugin as ProseMirrorPlugin4
} from "@prosekit/pm/state";

@@ -1014,19 +1062,18 @@ function defineEventFacetPayload(payload) {

const update = (entries) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
const map = groupEntries(entries);
setKeyDownHandlers((_a = map.keyDown) != null ? _a : []);
setKeyPressHandlers((_b = map.keyPress) != null ? _b : []);
setTextInputHandlers((_c = map.textInput) != null ? _c : []);
setClickOnHandlers((_d = map.clickOn) != null ? _d : []);
setClickHandlers((_e = map.click) != null ? _e : []);
setDoubleClickOnHandlers((_f = map.doubleClickOn) != null ? _f : []);
setDoubleClickHandlers((_g = map.doubleClick) != null ? _g : []);
setTripleClickOnHandlers((_h = map.tripleClickOn) != null ? _h : []);
setTripleClickHandlers((_i = map.tripleClick) != null ? _i : []);
setPasteHandlers((_j = map.paste) != null ? _j : []);
setDropHandlers((_k = map.drop) != null ? _k : []);
setScrollToSelectionHandlers((_l = map.scrollToSelection) != null ? _l : []);
setKeyDownHandlers(map.keyDown ?? []);
setKeyPressHandlers(map.keyPress ?? []);
setTextInputHandlers(map.textInput ?? []);
setClickOnHandlers(map.clickOn ?? []);
setClickHandlers(map.click ?? []);
setDoubleClickOnHandlers(map.doubleClickOn ?? []);
setDoubleClickHandlers(map.doubleClick ?? []);
setTripleClickOnHandlers(map.tripleClickOn ?? []);
setTripleClickHandlers(map.tripleClick ?? []);
setPasteHandlers(map.paste ?? []);
setDropHandlers(map.drop ?? []);
setScrollToSelectionHandlers(map.scrollToSelection ?? []);
};
const plugin = new ProseMirrorPlugin3({
key: new PluginKey3("prosekit-editor-event"),
const plugin = new ProseMirrorPlugin4({
key: new PluginKey4("prosekit-editor-event"),
props: {

@@ -1075,3 +1122,3 @@ handleKeyDown,

Plugin as Plugin2,
PluginKey as PluginKey4
PluginKey as PluginKey5
} from "@prosekit/pm/state";

@@ -1119,3 +1166,3 @@ import mapValues from "just-map-values";

}
var keymapPluginKey = new PluginKey4("prosekit-keymap");
var keymapPluginKey = new PluginKey5("prosekit-keymap");

@@ -1174,4 +1221,3 @@ // src/extensions/history.ts

function defineBaseKeymap(options) {
var _a;
const priority = (_a = options == null ? void 0 : options.priority) != null ? _a : 1 /* low */;
const priority = options?.priority ?? 1 /* low */;
return withPriority(defineKeymap(customBaseKeymap), priority);

@@ -1241,4 +1287,4 @@ }

import {
PluginKey as PluginKey5,
ProseMirrorPlugin as ProseMirrorPlugin4
PluginKey as PluginKey6,
ProseMirrorPlugin as ProseMirrorPlugin5
} from "@prosekit/pm/state";

@@ -1257,4 +1303,4 @@ function defineMarkView(options) {

return () => [
new ProseMirrorPlugin4({
key: new PluginKey5("prosekit-mark-view"),
new ProseMirrorPlugin5({
key: new PluginKey6("prosekit-mark-view"),
props: { markViews }

@@ -1269,4 +1315,4 @@ })

import {
PluginKey as PluginKey6,
ProseMirrorPlugin as ProseMirrorPlugin5
PluginKey as PluginKey7,
ProseMirrorPlugin as ProseMirrorPlugin6
} from "@prosekit/pm/state";

@@ -1294,4 +1340,4 @@ function defineMarkViewFactory(options) {

return () => [
new ProseMirrorPlugin5({
key: new PluginKey6("prosekit-mark-view-effect"),
new ProseMirrorPlugin6({
key: new PluginKey7("prosekit-mark-view-effect"),
props: { markViews }

@@ -1306,4 +1352,4 @@ })

import {
PluginKey as PluginKey7,
ProseMirrorPlugin as ProseMirrorPlugin6
PluginKey as PluginKey8,
ProseMirrorPlugin as ProseMirrorPlugin7
} from "@prosekit/pm/state";

@@ -1322,4 +1368,4 @@ function defineNodeView(options) {

return () => [
new ProseMirrorPlugin6({
key: new PluginKey7("prosekit-node-view"),
new ProseMirrorPlugin7({
key: new PluginKey8("prosekit-node-view"),
props: { nodeViews }

@@ -1334,4 +1380,4 @@ })

import {
PluginKey as PluginKey8,
ProseMirrorPlugin as ProseMirrorPlugin7
PluginKey as PluginKey9,
ProseMirrorPlugin as ProseMirrorPlugin8
} from "@prosekit/pm/state";

@@ -1359,4 +1405,4 @@ function defineNodeViewFactory(options) {

return () => [
new ProseMirrorPlugin7({
key: new PluginKey8("prosekit-node-view-effect"),
new ProseMirrorPlugin8({
key: new PluginKey9("prosekit-node-view-effect"),
props: { nodeViews }

@@ -1408,3 +1454,3 @@ })

return "ab".replace(new RegExp("(?<=a)b", "g"), "c") === "ac";
} catch (e) {
} catch {
return false;

@@ -1520,2 +1566,3 @@ }

defineClickOnHandler,
defineClipboardSerializer,
defineCommands,

@@ -1572,2 +1619,3 @@ defineDOMEventHandler,

isAtBlockStart,
isElement,
isFragment,

@@ -1574,0 +1622,0 @@ isInCodeBlock,

{
"name": "@prosekit/core",
"type": "module",
"version": "0.7.14",
"version": "0.7.15",
"private": false,

@@ -48,15 +48,15 @@ "author": {

"prosemirror-splittable": "^0.1.1",
"type-fest": "^4.30.2",
"type-fest": "^4.32.0",
"@prosekit/pm": "^0.1.9"
},
"devDependencies": {
"@vitest/browser": "^2.1.8",
"@vitest/browser": "^3.0.4",
"tsup": "^8.3.5",
"typescript": "~5.6.3",
"vitest": "^2.1.8",
"typescript": "~5.7.2",
"vitest": "^3.0.4",
"@prosekit/dev": "0.0.0"
},
"scripts": {
"build:tsup": "tsup",
"build:tsc": "tsc -b tsconfig.json"
"build:tsc": "tsc -b tsconfig.json",
"build:tsup": "tsup"
},

@@ -63,0 +63,0 @@ "types": "./dist/prosekit-core.d.ts",

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

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