@input/pen-core 0.1.4 → 0.1.5
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 +31 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +31 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -715,6 +715,20 @@ var suggestion = {
|
|
|
715
715
|
};
|
|
716
716
|
|
|
717
717
|
// src/schema/registry.ts
|
|
718
|
+
var RESERVED_INLINE_ATOM_PROP = "type";
|
|
719
|
+
function assertInlineAtomPropKeys(schema) {
|
|
720
|
+
if (schema.kind !== "node") {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
if (schema.propSchema != null && Object.prototype.hasOwnProperty.call(
|
|
724
|
+
schema.propSchema,
|
|
725
|
+
RESERVED_INLINE_ATOM_PROP
|
|
726
|
+
)) {
|
|
727
|
+
throw new Error(
|
|
728
|
+
`Inline atom schema "${schema.type}" cannot declare a prop named "${RESERVED_INLINE_ATOM_PROP}": that key is the Y.Text embed discriminator, so the prop cannot be stored (SCH1). Rename the prop.`
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
718
732
|
function passthroughBlockSchema(type) {
|
|
719
733
|
return {
|
|
720
734
|
type,
|
|
@@ -737,6 +751,12 @@ var SchemaRegistryImpl = class _SchemaRegistryImpl {
|
|
|
737
751
|
_onUnknownBlock;
|
|
738
752
|
_onUnknownInline;
|
|
739
753
|
constructor(config) {
|
|
754
|
+
for (const schema of config.inlines ?? []) {
|
|
755
|
+
assertInlineAtomPropKeys(schema);
|
|
756
|
+
}
|
|
757
|
+
for (const schema of config.systemMarks ?? []) {
|
|
758
|
+
assertInlineAtomPropKeys(schema);
|
|
759
|
+
}
|
|
740
760
|
this._blocks = new Map(
|
|
741
761
|
config.blocks?.map((schema) => [schema.type, schema])
|
|
742
762
|
);
|
|
@@ -9057,6 +9077,17 @@ function handleVerticalCaret(editor, param, direction) {
|
|
|
9057
9077
|
}
|
|
9058
9078
|
const measured = measureVerticalStep(editor, focus, direction);
|
|
9059
9079
|
if (measured) {
|
|
9080
|
+
const measuredBlockId = measured.point.blockId;
|
|
9081
|
+
if (!isEditableTextBlock(editor, measuredBlockId) && getBlockInputMode(editor, measuredBlockId) !== "table") {
|
|
9082
|
+
setVerticalCaretGoalX(editor, null);
|
|
9083
|
+
return {
|
|
9084
|
+
selection: extendSelection(
|
|
9085
|
+
editor,
|
|
9086
|
+
param.extend,
|
|
9087
|
+
blockSelectionResult([measuredBlockId])
|
|
9088
|
+
)
|
|
9089
|
+
};
|
|
9090
|
+
}
|
|
9060
9091
|
setVerticalCaretGoalX(editor, measured.goalX);
|
|
9061
9092
|
return {
|
|
9062
9093
|
selection: extendSelection(editor, param.extend, measured.point)
|
package/dist/index.d.cts
CHANGED
|
@@ -143,8 +143,9 @@ type DefineBlockConfig = Omit<Partial<BlockSchema<string, Record<string, PropSch
|
|
|
143
143
|
propSchema?: Record<string, unknown>;
|
|
144
144
|
aiDescription?: string;
|
|
145
145
|
};
|
|
146
|
+
type DefinedA11y<Type extends string> = BlockA11ySpec & ((spec: BlockA11ySpec) => BlockSchema<Type, Record<string, PropSchema>, ContentType>);
|
|
146
147
|
type DefinedBlockSchema<Type extends string = string> = Omit<BlockSchema<Type, Record<string, PropSchema>, ContentType>, "a11y"> & {
|
|
147
|
-
a11y
|
|
148
|
+
a11y: DefinedA11y<Type>;
|
|
148
149
|
};
|
|
149
150
|
declare function defineBlock<Type extends string>(type: Type, config: DefineBlockConfig): DefinedBlockSchema<Type>;
|
|
150
151
|
declare function defineBlock<Type extends string>(config: DefineBlockConfig & {
|
package/dist/index.d.ts
CHANGED
|
@@ -143,8 +143,9 @@ type DefineBlockConfig = Omit<Partial<BlockSchema<string, Record<string, PropSch
|
|
|
143
143
|
propSchema?: Record<string, unknown>;
|
|
144
144
|
aiDescription?: string;
|
|
145
145
|
};
|
|
146
|
+
type DefinedA11y<Type extends string> = BlockA11ySpec & ((spec: BlockA11ySpec) => BlockSchema<Type, Record<string, PropSchema>, ContentType>);
|
|
146
147
|
type DefinedBlockSchema<Type extends string = string> = Omit<BlockSchema<Type, Record<string, PropSchema>, ContentType>, "a11y"> & {
|
|
147
|
-
a11y
|
|
148
|
+
a11y: DefinedA11y<Type>;
|
|
148
149
|
};
|
|
149
150
|
declare function defineBlock<Type extends string>(type: Type, config: DefineBlockConfig): DefinedBlockSchema<Type>;
|
|
150
151
|
declare function defineBlock<Type extends string>(config: DefineBlockConfig & {
|
package/dist/index.mjs
CHANGED
|
@@ -479,6 +479,20 @@ var suggestion = {
|
|
|
479
479
|
};
|
|
480
480
|
|
|
481
481
|
// src/schema/registry.ts
|
|
482
|
+
var RESERVED_INLINE_ATOM_PROP = "type";
|
|
483
|
+
function assertInlineAtomPropKeys(schema) {
|
|
484
|
+
if (schema.kind !== "node") {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (schema.propSchema != null && Object.prototype.hasOwnProperty.call(
|
|
488
|
+
schema.propSchema,
|
|
489
|
+
RESERVED_INLINE_ATOM_PROP
|
|
490
|
+
)) {
|
|
491
|
+
throw new Error(
|
|
492
|
+
`Inline atom schema "${schema.type}" cannot declare a prop named "${RESERVED_INLINE_ATOM_PROP}": that key is the Y.Text embed discriminator, so the prop cannot be stored (SCH1). Rename the prop.`
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
482
496
|
function passthroughBlockSchema(type) {
|
|
483
497
|
return {
|
|
484
498
|
type,
|
|
@@ -501,6 +515,12 @@ var SchemaRegistryImpl = class _SchemaRegistryImpl {
|
|
|
501
515
|
_onUnknownBlock;
|
|
502
516
|
_onUnknownInline;
|
|
503
517
|
constructor(config) {
|
|
518
|
+
for (const schema of config.inlines ?? []) {
|
|
519
|
+
assertInlineAtomPropKeys(schema);
|
|
520
|
+
}
|
|
521
|
+
for (const schema of config.systemMarks ?? []) {
|
|
522
|
+
assertInlineAtomPropKeys(schema);
|
|
523
|
+
}
|
|
504
524
|
this._blocks = new Map(
|
|
505
525
|
config.blocks?.map((schema) => [schema.type, schema])
|
|
506
526
|
);
|
|
@@ -8838,6 +8858,17 @@ function handleVerticalCaret(editor, param, direction) {
|
|
|
8838
8858
|
}
|
|
8839
8859
|
const measured = measureVerticalStep(editor, focus, direction);
|
|
8840
8860
|
if (measured) {
|
|
8861
|
+
const measuredBlockId = measured.point.blockId;
|
|
8862
|
+
if (!isEditableTextBlock(editor, measuredBlockId) && getBlockInputMode(editor, measuredBlockId) !== "table") {
|
|
8863
|
+
setVerticalCaretGoalX(editor, null);
|
|
8864
|
+
return {
|
|
8865
|
+
selection: extendSelection(
|
|
8866
|
+
editor,
|
|
8867
|
+
param.extend,
|
|
8868
|
+
blockSelectionResult([measuredBlockId])
|
|
8869
|
+
)
|
|
8870
|
+
};
|
|
8871
|
+
}
|
|
8841
8872
|
setVerticalCaretGoalX(editor, measured.goalX);
|
|
8842
8873
|
return {
|
|
8843
8874
|
selection: extendSelection(editor, param.extend, measured.point)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@input/pen-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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.
|
|
47
|
-
"@input/pen-types": "^0.1.
|
|
46
|
+
"@input/pen-yjs": "^0.1.5",
|
|
47
|
+
"@input/pen-types": "^0.1.5"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"tsup": "^8.4.0",
|