@reiwuzen/blocky 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -37,7 +37,6 @@ __export(index_exports, {
37
37
  duplicateBlock: () => duplicateBlock,
38
38
  duplicateBlockAfter: () => duplicateBlockAfter,
39
39
  formatNodes: () => formatNodes,
40
- formatParagraphBlock: () => stripPrefix,
41
40
  generateId: () => generateId,
42
41
  indentBlock: () => indentBlock,
43
42
  insertAt: () => insertAt,
@@ -567,12 +566,14 @@ function stripPrefix(block, prefix) {
567
566
  return [{ ...first, text: stripped }, ...block.content.slice(1)];
568
567
  }
569
568
  function applyMarkdownTransform(block, cursorOffset) {
570
- if (block.type !== "paragraph") return import_result4.Result.Ok({ block, converted: false });
569
+ if (block.type !== "paragraph")
570
+ return import_result4.Result.Ok({ block, converted: false });
571
571
  const text = getRawText(block);
572
- const match = Object.keys(TRIGGERS).sort((a, b) => b.length - a.length).find((trigger) => text === trigger || text.startsWith(trigger + " "));
573
- if (!match) return import_result4.Result.Ok({ block, converted: false });
574
- const triggerEnd = match.length + 1;
575
- if (cursorOffset < triggerEnd) return import_result4.Result.Ok({ block, converted: false });
572
+ const match = Object.keys(TRIGGERS).sort((a, b) => b.length - a.length).find((trigger) => text === trigger);
573
+ if (!match)
574
+ return import_result4.Result.Ok({ block, converted: false });
575
+ if (cursorOffset < match.length)
576
+ return import_result4.Result.Ok({ block, converted: false });
576
577
  const targetType = TRIGGERS[match];
577
578
  const strippedContent = stripPrefix(block, match);
578
579
  const converted = {
@@ -895,7 +896,6 @@ var currentBlocks = (history) => history.present.blocks;
895
896
  duplicateBlock,
896
897
  duplicateBlockAfter,
897
898
  formatNodes,
898
- formatParagraphBlock,
899
899
  generateId,
900
900
  indentBlock,
901
901
  insertAt,
package/dist/index.d.cts CHANGED
@@ -118,7 +118,6 @@ type TransformResult = {
118
118
  /** true if the block type was actually changed, false if no trigger matched */
119
119
  converted: boolean;
120
120
  };
121
- declare function stripPrefix(block: Block<"paragraph">, prefix: string): Block<"paragraph">["content"];
122
121
  /**
123
122
  * Attempt to convert a paragraph block into another type based on a
124
123
  * Markdown-style prefix typed by the user.
@@ -323,4 +322,4 @@ declare function duplicateBlockAfter(blocks: AnyBlock[], id: string, newId?: str
323
322
  */
324
323
  declare function moveBlock(blocks: AnyBlock[], id: string, direction: "up" | "down"): Result<AnyBlock[], string>;
325
324
 
326
- export { type AnyBlock, type Block, type BlockContent, type BlockMeta, type BlockType, type History, type HistoryEntry, type Node, type NodeSelection, applyMarkdownTransform, areBlocksSame, canRedo, canUndo, changeBlockType, createBlock, createBlockAfter, createHistory, currentBlocks, deleteBlock, deleteLastChar, deleteRange, deserialize, deserializeNodes, duplicateBlock, duplicateBlockAfter, formatNodes, stripPrefix as formatParagraphBlock, generateId, indentBlock, insertAt, insertBlockAfter, mergeAdjacentNodes, mergeBlocks, moveBlock, outdentBlock, push, redo, removeLink, replaceRange, serialize, serializeNodes, setLink, splitBlock, toMarkdown, toPlainText, toggleBold, toggleColor, toggleHighlight, toggleItalic, toggleStrikethrough, toggleTodo, toggleUnderline, undo };
325
+ export { type AnyBlock, type Block, type BlockContent, type BlockMeta, type BlockType, type History, type HistoryEntry, type Node, type NodeSelection, applyMarkdownTransform, areBlocksSame, canRedo, canUndo, changeBlockType, createBlock, createBlockAfter, createHistory, currentBlocks, deleteBlock, deleteLastChar, deleteRange, deserialize, deserializeNodes, duplicateBlock, duplicateBlockAfter, formatNodes, generateId, indentBlock, insertAt, insertBlockAfter, mergeAdjacentNodes, mergeBlocks, moveBlock, outdentBlock, push, redo, removeLink, replaceRange, serialize, serializeNodes, setLink, splitBlock, toMarkdown, toPlainText, toggleBold, toggleColor, toggleHighlight, toggleItalic, toggleStrikethrough, toggleTodo, toggleUnderline, undo };
package/dist/index.d.ts CHANGED
@@ -118,7 +118,6 @@ type TransformResult = {
118
118
  /** true if the block type was actually changed, false if no trigger matched */
119
119
  converted: boolean;
120
120
  };
121
- declare function stripPrefix(block: Block<"paragraph">, prefix: string): Block<"paragraph">["content"];
122
121
  /**
123
122
  * Attempt to convert a paragraph block into another type based on a
124
123
  * Markdown-style prefix typed by the user.
@@ -323,4 +322,4 @@ declare function duplicateBlockAfter(blocks: AnyBlock[], id: string, newId?: str
323
322
  */
324
323
  declare function moveBlock(blocks: AnyBlock[], id: string, direction: "up" | "down"): Result<AnyBlock[], string>;
325
324
 
326
- export { type AnyBlock, type Block, type BlockContent, type BlockMeta, type BlockType, type History, type HistoryEntry, type Node, type NodeSelection, applyMarkdownTransform, areBlocksSame, canRedo, canUndo, changeBlockType, createBlock, createBlockAfter, createHistory, currentBlocks, deleteBlock, deleteLastChar, deleteRange, deserialize, deserializeNodes, duplicateBlock, duplicateBlockAfter, formatNodes, stripPrefix as formatParagraphBlock, generateId, indentBlock, insertAt, insertBlockAfter, mergeAdjacentNodes, mergeBlocks, moveBlock, outdentBlock, push, redo, removeLink, replaceRange, serialize, serializeNodes, setLink, splitBlock, toMarkdown, toPlainText, toggleBold, toggleColor, toggleHighlight, toggleItalic, toggleStrikethrough, toggleTodo, toggleUnderline, undo };
325
+ export { type AnyBlock, type Block, type BlockContent, type BlockMeta, type BlockType, type History, type HistoryEntry, type Node, type NodeSelection, applyMarkdownTransform, areBlocksSame, canRedo, canUndo, changeBlockType, createBlock, createBlockAfter, createHistory, currentBlocks, deleteBlock, deleteLastChar, deleteRange, deserialize, deserializeNodes, duplicateBlock, duplicateBlockAfter, formatNodes, generateId, indentBlock, insertAt, insertBlockAfter, mergeAdjacentNodes, mergeBlocks, moveBlock, outdentBlock, push, redo, removeLink, replaceRange, serialize, serializeNodes, setLink, splitBlock, toMarkdown, toPlainText, toggleBold, toggleColor, toggleHighlight, toggleItalic, toggleStrikethrough, toggleTodo, toggleUnderline, undo };
package/dist/index.js CHANGED
@@ -498,12 +498,14 @@ function stripPrefix(block, prefix) {
498
498
  return [{ ...first, text: stripped }, ...block.content.slice(1)];
499
499
  }
500
500
  function applyMarkdownTransform(block, cursorOffset) {
501
- if (block.type !== "paragraph") return Result4.Ok({ block, converted: false });
501
+ if (block.type !== "paragraph")
502
+ return Result4.Ok({ block, converted: false });
502
503
  const text = getRawText(block);
503
- const match = Object.keys(TRIGGERS).sort((a, b) => b.length - a.length).find((trigger) => text === trigger || text.startsWith(trigger + " "));
504
- if (!match) return Result4.Ok({ block, converted: false });
505
- const triggerEnd = match.length + 1;
506
- if (cursorOffset < triggerEnd) return Result4.Ok({ block, converted: false });
504
+ const match = Object.keys(TRIGGERS).sort((a, b) => b.length - a.length).find((trigger) => text === trigger);
505
+ if (!match)
506
+ return Result4.Ok({ block, converted: false });
507
+ if (cursorOffset < match.length)
508
+ return Result4.Ok({ block, converted: false });
507
509
  const targetType = TRIGGERS[match];
508
510
  const strippedContent = stripPrefix(block, match);
509
511
  const converted = {
@@ -825,7 +827,6 @@ export {
825
827
  duplicateBlock,
826
828
  duplicateBlockAfter,
827
829
  formatNodes,
828
- stripPrefix as formatParagraphBlock,
829
830
  generateId,
830
831
  indentBlock,
831
832
  insertAt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reiwuzen/blocky",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Pure TypeScript block editor engine. Headless, framework-agnostic — content mutation, formatting, transforms, serialization, and history.",
5
5
  "author": "Rei WuZen",
6
6
  "license": "ISC",