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

@udecode/plate-autoformat

Package Overview
Dependencies
Maintainers
2
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@udecode/plate-autoformat - npm Package Compare versions

Comparing version

to
38.0.1

dist/BaseAutoformatPlugin-C_XqNIwr.d.mts

7

dist/index.d.ts

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

import { A as AutoformatConfig, a as AutoformatRule, b as AutoformatBlockRule, c as AutoformatMarkRule, d as AutoformatTextRule, M as MatchRange } from './AutoformatPlugin-C3RmMfmF.js';
export { g as AutoformatCommonRule, e as AutoformatPlugin, h as AutoformatPluginOptions, f as AutoformatQueryOptions, G as GetMatchPointsReturnType, i as getMatchPoints } from './AutoformatPlugin-C3RmMfmF.js';
import { A as AutoformatConfig, a as AutoformatRule, b as AutoformatBlockRule, c as AutoformatMarkRule, d as AutoformatTextRule, M as MatchRange } from './BaseAutoformatPlugin-C_XqNIwr.js';
export { f as AutoformatCommonRule, g as AutoformatPluginOptions, e as AutoformatQueryOptions, B as BaseAutoformatPlugin, G as GetMatchPointsReturnType, h as getMatchPoints } from './BaseAutoformatPlugin-C_XqNIwr.js';
import { ExtendEditor, SlateEditor, TEditor } from '@udecode/plate-common';
import { Location } from 'slate';
import '@udecode/plate-core';

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

match: MatchRange | string;
trigger: AutoformatRule['trigger'];
trigger: AutoformatRule["trigger"];
}) => {

@@ -58,0 +59,0 @@ end: string;

@@ -50,3 +50,3 @@ "use strict";

__export(src_exports, {
AutoformatPlugin: () => AutoformatPlugin,
BaseAutoformatPlugin: () => BaseAutoformatPlugin,
autoformatArrow: () => autoformatArrow,

@@ -77,3 +77,3 @@ autoformatBlock: () => autoformatBlock,

// src/lib/AutoformatPlugin.ts
// src/lib/BaseAutoformatPlugin.ts
var import_plate_common7 = require("@udecode/plate-common");

@@ -122,3 +122,3 @@

triggerAtBlockStart = true,
type = import_plate_common.ParagraphPlugin.key
type = import_plate_common.BaseParagraphPlugin.key
}) => {

@@ -131,4 +131,3 @@ const matches = (0, import_castArray2.default)(_match);

});
if (!triggers.includes(text))
continue;
if (!triggers.includes(text)) continue;
let matchRange;

@@ -141,8 +140,6 @@ if (triggerAtBlockStart) {

});
if (hasVoidNode)
continue;
if (hasVoidNode) continue;
const textFromBlockStart = (0, import_plate_common.getEditorString)(editor, matchRange);
const isMatched = matchByRegex ? !!textFromBlockStart.match(end) : end === textFromBlockStart;
if (!isMatched)
continue;
if (!isMatched) continue;
} else {

@@ -153,9 +150,7 @@ matchRange = (0, import_plate_common.getRangeBefore)(editor, editor.selection, {

});
if (!matchRange)
continue;
if (!matchRange) continue;
}
if (!allowSameTypeAbove) {
const isBelowSameBlockType = (0, import_plate_common.someNode)(editor, { match: { type } });
if (isBelowSameBlockType)
continue;
if (isBelowSameBlockType) continue;
}

@@ -201,3 +196,3 @@ if (match.length > 1) {

const noWhiteSpaceRegex = new RegExp(`\\S+`);
return !text.match(noWhiteSpaceRegex);
return !noWhiteSpaceRegex.exec(text);
}

@@ -216,4 +211,3 @@ }

});
if (!beforeEndMatchPoint)
return;
if (!beforeEndMatchPoint) return;
}

@@ -228,4 +222,3 @@ let afterStartMatchPoint;

});
if (!afterStartMatchPoint)
return;
if (!afterStartMatchPoint) return;
beforeStartMatchPoint = (0, import_plate_common3.getPointBeforeLocation)(

@@ -251,4 +244,3 @@ editor,

var autoformatMark = (editor, { ignoreTrim, match: _match, text, trigger, type }) => {
if (!type)
return false;
if (!type) return false;
const selection = editor.selection;

@@ -261,7 +253,5 @@ const matches = (0, import_castArray3.default)(_match);

});
if (!triggers.includes(text))
continue;
if (!triggers.includes(text)) continue;
const matched = getMatchPoints(editor, { end, start });
if (!matched)
continue;
if (!matched) continue;
const { afterStartMatchPoint, beforeEndMatchPoint, beforeStartMatchPoint } = matched;

@@ -274,4 +264,3 @@ const matchRange = {

const matchText = (0, import_plate_common4.getEditorString)(editor, matchRange);
if (matchText.trim() !== matchText)
continue;
if (matchText.trim() !== matchText) continue;
}

@@ -318,7 +307,5 @@ if (end) {

});
if (!triggers.includes(text))
continue;
if (!triggers.includes(text)) continue;
const matched = getMatchPoints(editor, { end, start });
if (!matched)
continue;
if (!matched) continue;
const { afterStartMatchPoint, beforeEndMatchPoint, beforeStartMatchPoint } = matched;

@@ -364,8 +351,6 @@ if (end) {

var _a;
if (!(0, import_plate_common6.isCollapsed)(editor.selection))
return insertText2(text);
if (!(0, import_plate_common6.isCollapsed)(editor.selection)) return insertText2(text);
for (const rule of getOptions().rules) {
const { insertTrigger, mode = "text", query } = rule;
if (query && !query(editor, __spreadProps(__spreadValues({}, rule), { text })))
continue;
if (query && !query(editor, __spreadProps(__spreadValues({}, rule), { text }))) continue;
const autoformatter = {

@@ -387,6 +372,6 @@ block: autoformatBlock,

// src/lib/AutoformatPlugin.ts
var AutoformatPlugin = (0, import_plate_common7.createTSlatePlugin)({
// src/lib/BaseAutoformatPlugin.ts
var BaseAutoformatPlugin = (0, import_plate_common7.createTSlatePlugin)({
key: "autoformat",
extendEditor: withAutoformat,
key: "autoformat",
options: {

@@ -834,3 +819,3 @@ rules: []

0 && (module.exports = {
AutoformatPlugin,
BaseAutoformatPlugin,
autoformatArrow,

@@ -837,0 +822,0 @@ autoformatBlock,

import * as _udecode_plate_core_react from '@udecode/plate-core/react';
import * as _udecode_plate_core from '@udecode/plate-core';
import { h as AutoformatPluginOptions, A as AutoformatConfig } from '../AutoformatPlugin-C3RmMfmF.js';
import { g as AutoformatPluginOptions, A as AutoformatConfig } from '../BaseAutoformatPlugin-C_XqNIwr.js';
import { KeyboardHandler } from '@udecode/plate-common/react';

@@ -5,0 +5,0 @@ import '@udecode/plate-common';

@@ -50,3 +50,3 @@ "use strict";

__export(react_exports, {
AutoformatPlugin: () => AutoformatPlugin2,
AutoformatPlugin: () => AutoformatPlugin,
onKeyDownAutoformat: () => onKeyDownAutoformat

@@ -59,3 +59,3 @@ });

// src/lib/AutoformatPlugin.ts
// src/lib/BaseAutoformatPlugin.ts
var import_plate_common7 = require("@udecode/plate-common");

@@ -104,3 +104,3 @@

triggerAtBlockStart = true,
type = import_plate_common.ParagraphPlugin.key
type = import_plate_common.BaseParagraphPlugin.key
}) => {

@@ -113,4 +113,3 @@ const matches = (0, import_castArray2.default)(_match);

});
if (!triggers.includes(text))
continue;
if (!triggers.includes(text)) continue;
let matchRange;

@@ -123,8 +122,6 @@ if (triggerAtBlockStart) {

});
if (hasVoidNode)
continue;
if (hasVoidNode) continue;
const textFromBlockStart = (0, import_plate_common.getEditorString)(editor, matchRange);
const isMatched = matchByRegex ? !!textFromBlockStart.match(end) : end === textFromBlockStart;
if (!isMatched)
continue;
if (!isMatched) continue;
} else {

@@ -135,9 +132,7 @@ matchRange = (0, import_plate_common.getRangeBefore)(editor, editor.selection, {

});
if (!matchRange)
continue;
if (!matchRange) continue;
}
if (!allowSameTypeAbove) {
const isBelowSameBlockType = (0, import_plate_common.someNode)(editor, { match: { type } });
if (isBelowSameBlockType)
continue;
if (isBelowSameBlockType) continue;
}

@@ -183,3 +178,3 @@ if (match.length > 1) {

const noWhiteSpaceRegex = new RegExp(`\\S+`);
return !text.match(noWhiteSpaceRegex);
return !noWhiteSpaceRegex.exec(text);
}

@@ -198,4 +193,3 @@ }

});
if (!beforeEndMatchPoint)
return;
if (!beforeEndMatchPoint) return;
}

@@ -210,4 +204,3 @@ let afterStartMatchPoint;

});
if (!afterStartMatchPoint)
return;
if (!afterStartMatchPoint) return;
beforeStartMatchPoint = (0, import_plate_common3.getPointBeforeLocation)(

@@ -233,4 +226,3 @@ editor,

var autoformatMark = (editor, { ignoreTrim, match: _match, text, trigger, type }) => {
if (!type)
return false;
if (!type) return false;
const selection = editor.selection;

@@ -243,7 +235,5 @@ const matches = (0, import_castArray3.default)(_match);

});
if (!triggers.includes(text))
continue;
if (!triggers.includes(text)) continue;
const matched = getMatchPoints(editor, { end, start });
if (!matched)
continue;
if (!matched) continue;
const { afterStartMatchPoint, beforeEndMatchPoint, beforeStartMatchPoint } = matched;

@@ -256,4 +246,3 @@ const matchRange = {

const matchText = (0, import_plate_common4.getEditorString)(editor, matchRange);
if (matchText.trim() !== matchText)
continue;
if (matchText.trim() !== matchText) continue;
}

@@ -300,7 +289,5 @@ if (end) {

});
if (!triggers.includes(text))
continue;
if (!triggers.includes(text)) continue;
const matched = getMatchPoints(editor, { end, start });
if (!matched)
continue;
if (!matched) continue;
const { afterStartMatchPoint, beforeEndMatchPoint, beforeStartMatchPoint } = matched;

@@ -346,8 +333,6 @@ if (end) {

var _a;
if (!(0, import_plate_common6.isCollapsed)(editor.selection))
return insertText3(text);
if (!(0, import_plate_common6.isCollapsed)(editor.selection)) return insertText3(text);
for (const rule of getOptions().rules) {
const { insertTrigger, mode = "text", query } = rule;
if (query && !query(editor, __spreadProps(__spreadValues({}, rule), { text })))
continue;
if (query && !query(editor, __spreadProps(__spreadValues({}, rule), { text }))) continue;
const autoformatter = {

@@ -369,6 +354,6 @@ block: autoformatBlock,

// src/lib/AutoformatPlugin.ts
var AutoformatPlugin = (0, import_plate_common7.createTSlatePlugin)({
// src/lib/BaseAutoformatPlugin.ts
var BaseAutoformatPlugin = (0, import_plate_common7.createTSlatePlugin)({
key: "autoformat",
extendEditor: withAutoformat,
key: "autoformat",
options: {

@@ -388,13 +373,8 @@ rules: []

const { enableUndoOnDelete, rules } = getOptions();
if (event.defaultPrevented)
return false;
if (!(0, import_plate_common8.isHotkey)("backspace", { byKey: true }, event))
return false;
if (!rules)
return false;
if (!enableUndoOnDelete)
return false;
if (event.defaultPrevented) return false;
if (!(0, import_plate_common8.isHotkey)("backspace", { byKey: true }, event)) return false;
if (!rules) return false;
if (!enableUndoOnDelete) return false;
const { selection } = editor;
if (!selection || !import_slate.Range.isCollapsed(selection))
return;
if (!selection || !import_slate.Range.isCollapsed(selection)) return;
const [start, end] = import_slate.Range.edges(selection);

@@ -405,12 +385,8 @@ const before = (0, import_plate_common8.getPointBefore)(editor, end, {

});
if (!start)
return false;
if (!before)
return false;
if (!start) return false;
if (!before) return false;
const charRange = { anchor: before, focus: start };
if (!charRange)
return false;
if (!charRange) return false;
const char = (0, import_plate_common8.getEditorString)(editor, charRange);
if (!char)
return false;
if (!char) return false;
const matchers = [...rules].filter((rule2) => {

@@ -423,4 +399,3 @@ const textRule = rule2;

});
if (!matchers || matchers.length === 0)
return false;
if (!matchers || matchers.length === 0) return false;
event.preventDefault();

@@ -441,3 +416,3 @@ (0, import_plate_common8.deleteBackward)(editor, { unit: "character" });

// src/react/AutoformatPlugin.tsx
var AutoformatPlugin2 = (0, import_react.toPlatePlugin)(AutoformatPlugin, {
var AutoformatPlugin = (0, import_react.toPlatePlugin)(BaseAutoformatPlugin, {
handlers: {

@@ -444,0 +419,0 @@ onKeyDown: onKeyDownAutoformat

{
"name": "@udecode/plate-autoformat",
"version": "38.0.0",
"version": "38.0.1",
"description": "Autoformatting plugin for Plate",

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

"peerDependencies": {
"@udecode/plate-common": ">=38.0.0",
"@udecode/plate-common": ">=38.0.1",
"react": ">=16.8.0",

@@ -62,0 +62,0 @@ "react-dom": ">=16.8.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet