@input/pen-core 0.1.9 → 0.2.0

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
@@ -8826,6 +8826,10 @@ function handleGraphemeCaret(editor, param, direction) {
8826
8826
  if (fromCell !== void 0) {
8827
8827
  return finishNonVertical(editor, fromCell);
8828
8828
  }
8829
+ const collapsed = collapseTextRange(editor, param, direction);
8830
+ if (collapsed !== void 0) {
8831
+ return finishNonVertical(editor, collapsed);
8832
+ }
8829
8833
  const focus = readTextFocus(editor);
8830
8834
  if (!focus) {
8831
8835
  return false;
@@ -8844,6 +8848,18 @@ function handleGraphemeCaret(editor, param, direction) {
8844
8848
  selection: extendSelection(editor, param.extend, next)
8845
8849
  });
8846
8850
  }
8851
+ function collapseTextRange(editor, param, direction) {
8852
+ const selection = editor.selection;
8853
+ if (param.extend || !selection || selection.type !== "text" || isCollapsed(selection)) {
8854
+ return void 0;
8855
+ }
8856
+ const ordered = documentOrderedTextPoints(editor, selection);
8857
+ if (!ordered) {
8858
+ return void 0;
8859
+ }
8860
+ const edge = direction === 1 ? ordered.end : ordered.start;
8861
+ return { selection: collapsedAt(edge.blockId, edge.offset) };
8862
+ }
8847
8863
  function handleWordCaret(editor, param, direction) {
8848
8864
  const fromCellEdit = handleCellEditingCaret(
8849
8865
  editor,
@@ -9077,7 +9093,7 @@ function crossBlock(editor, blockId, direction) {
9077
9093
  };
9078
9094
  }
9079
9095
  function documentEdgePoint(editor, edge) {
9080
- const order = editor.documentState.blockOrder;
9096
+ const order = getVisibleBlockIds(editor);
9081
9097
  if (order.length === 0) {
9082
9098
  return null;
9083
9099
  }
package/dist/index.d.cts CHANGED
@@ -1102,6 +1102,7 @@ declare const assetProviderFacet: _input_pen_types.Facet<unknown, unknown>;
1102
1102
  declare const toolRuntimeFacet: _input_pen_types.Facet<unknown, unknown>;
1103
1103
  declare const announcerFacet: _input_pen_types.Facet<unknown, unknown>;
1104
1104
  declare const streamingTargetFacet: _input_pen_types.Facet<unknown, unknown>;
1105
+ /** Facet that publishes the smooth-stream controller, or null when the extension is not installed. */
1105
1106
  declare const smoothStreamControllerFacet: _input_pen_types.Facet<unknown, unknown>;
1106
1107
 
1107
1108
  declare function affectedBlockIdsFromSummary(summary: Pick<ChangeSummary, "blockText" | "structural">, documentOrder?: readonly string[]): string[];
package/dist/index.d.ts CHANGED
@@ -1102,6 +1102,7 @@ declare const assetProviderFacet: _input_pen_types.Facet<unknown, unknown>;
1102
1102
  declare const toolRuntimeFacet: _input_pen_types.Facet<unknown, unknown>;
1103
1103
  declare const announcerFacet: _input_pen_types.Facet<unknown, unknown>;
1104
1104
  declare const streamingTargetFacet: _input_pen_types.Facet<unknown, unknown>;
1105
+ /** Facet that publishes the smooth-stream controller, or null when the extension is not installed. */
1105
1106
  declare const smoothStreamControllerFacet: _input_pen_types.Facet<unknown, unknown>;
1106
1107
 
1107
1108
  declare function affectedBlockIdsFromSummary(summary: Pick<ChangeSummary, "blockText" | "structural">, documentOrder?: readonly string[]): string[];
package/dist/index.mjs CHANGED
@@ -8604,6 +8604,10 @@ function handleGraphemeCaret(editor, param, direction) {
8604
8604
  if (fromCell !== void 0) {
8605
8605
  return finishNonVertical(editor, fromCell);
8606
8606
  }
8607
+ const collapsed = collapseTextRange(editor, param, direction);
8608
+ if (collapsed !== void 0) {
8609
+ return finishNonVertical(editor, collapsed);
8610
+ }
8607
8611
  const focus = readTextFocus(editor);
8608
8612
  if (!focus) {
8609
8613
  return false;
@@ -8622,6 +8626,18 @@ function handleGraphemeCaret(editor, param, direction) {
8622
8626
  selection: extendSelection(editor, param.extend, next)
8623
8627
  });
8624
8628
  }
8629
+ function collapseTextRange(editor, param, direction) {
8630
+ const selection = editor.selection;
8631
+ if (param.extend || !selection || selection.type !== "text" || isCollapsed(selection)) {
8632
+ return void 0;
8633
+ }
8634
+ const ordered = documentOrderedTextPoints(editor, selection);
8635
+ if (!ordered) {
8636
+ return void 0;
8637
+ }
8638
+ const edge = direction === 1 ? ordered.end : ordered.start;
8639
+ return { selection: collapsedAt(edge.blockId, edge.offset) };
8640
+ }
8625
8641
  function handleWordCaret(editor, param, direction) {
8626
8642
  const fromCellEdit = handleCellEditingCaret(
8627
8643
  editor,
@@ -8855,7 +8871,7 @@ function crossBlock(editor, blockId, direction) {
8855
8871
  };
8856
8872
  }
8857
8873
  function documentEdgePoint(editor, edge) {
8858
- const order = editor.documentState.blockOrder;
8874
+ const order = getVisibleBlockIds(editor);
8859
8875
  if (order.length === 0) {
8860
8876
  return null;
8861
8877
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@input/pen-core",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Headless, extension-first editor engine for human-AI co-authoring",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/input-systems/pen#readme",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "sideEffects": false,
45
45
  "dependencies": {
46
- "@input/pen-yjs": "^0.1.9",
47
- "@input/pen-types": "^0.1.9"
46
+ "@input/pen-yjs": "^0.2.0",
47
+ "@input/pen-types": "^0.2.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "tsup": "^8.4.0",