@tiptap/core 3.11.0 → 3.12.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 +44 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -4
- package/dist/index.d.ts +75 -4
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Editor.ts +10 -0
- package/src/Mark.ts +1 -1
- package/src/Node.ts +1 -1
- package/src/helpers/MappablePosition.ts +66 -0
- package/src/helpers/index.ts +1 -0
- package/src/types.ts +35 -1
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
Extension: () => Extension,
|
|
27
27
|
Fragment: () => Fragment6,
|
|
28
28
|
InputRule: () => InputRule,
|
|
29
|
+
MappablePosition: () => MappablePosition,
|
|
29
30
|
Mark: () => Mark,
|
|
30
31
|
MarkView: () => MarkView,
|
|
31
32
|
Node: () => Node3,
|
|
@@ -45,6 +46,7 @@ __export(index_exports, {
|
|
|
45
46
|
createDocument: () => createDocument,
|
|
46
47
|
createElement: () => h,
|
|
47
48
|
createInlineMarkdownSpec: () => createInlineMarkdownSpec,
|
|
49
|
+
createMappablePosition: () => createMappablePosition,
|
|
48
50
|
createNodeFromContent: () => createNodeFromContent,
|
|
49
51
|
createStyleTag: () => createStyleTag,
|
|
50
52
|
defaultBlockAt: () => defaultBlockAt,
|
|
@@ -85,6 +87,7 @@ __export(index_exports, {
|
|
|
85
87
|
getTextBetween: () => getTextBetween,
|
|
86
88
|
getTextContentFromNodes: () => getTextContentFromNodes,
|
|
87
89
|
getTextSerializersFromSchema: () => getTextSerializersFromSchema,
|
|
90
|
+
getUpdatedPosition: () => getUpdatedPosition,
|
|
88
91
|
h: () => h,
|
|
89
92
|
injectExtensionAttributesToParseRule: () => injectExtensionAttributesToParseRule,
|
|
90
93
|
inputRulesPlugin: () => inputRulesPlugin,
|
|
@@ -2251,6 +2254,37 @@ function isNodeSelection(value) {
|
|
|
2251
2254
|
return value instanceof import_state7.NodeSelection;
|
|
2252
2255
|
}
|
|
2253
2256
|
|
|
2257
|
+
// src/helpers/MappablePosition.ts
|
|
2258
|
+
var MappablePosition = class _MappablePosition {
|
|
2259
|
+
constructor(position) {
|
|
2260
|
+
this.position = position;
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Creates a MappablePosition from a JSON object.
|
|
2264
|
+
*/
|
|
2265
|
+
static fromJSON(json) {
|
|
2266
|
+
return new _MappablePosition(json.position);
|
|
2267
|
+
}
|
|
2268
|
+
/**
|
|
2269
|
+
* Converts the MappablePosition to a JSON object.
|
|
2270
|
+
*/
|
|
2271
|
+
toJSON() {
|
|
2272
|
+
return {
|
|
2273
|
+
position: this.position
|
|
2274
|
+
};
|
|
2275
|
+
}
|
|
2276
|
+
};
|
|
2277
|
+
function getUpdatedPosition(position, transaction) {
|
|
2278
|
+
const mapResult = transaction.mapping.mapResult(position.position);
|
|
2279
|
+
return {
|
|
2280
|
+
position: new MappablePosition(mapResult.pos),
|
|
2281
|
+
mapResult
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2284
|
+
function createMappablePosition(position) {
|
|
2285
|
+
return new MappablePosition(position);
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2254
2288
|
// src/helpers/posToDOMRect.ts
|
|
2255
2289
|
function posToDOMRect(view, from, to) {
|
|
2256
2290
|
const minPos = 0;
|
|
@@ -4603,6 +4637,13 @@ var Editor = class extends EventEmitter {
|
|
|
4603
4637
|
};
|
|
4604
4638
|
this.isCapturingTransaction = false;
|
|
4605
4639
|
this.capturedTransaction = null;
|
|
4640
|
+
/**
|
|
4641
|
+
* Returns a set of utilities for working with positions and ranges.
|
|
4642
|
+
*/
|
|
4643
|
+
this.utils = {
|
|
4644
|
+
getUpdatedPosition,
|
|
4645
|
+
createMappablePosition
|
|
4646
|
+
};
|
|
4606
4647
|
this.setOptions(options);
|
|
4607
4648
|
this.createExtensionManager();
|
|
4608
4649
|
this.createCommandManager();
|
|
@@ -6756,6 +6797,7 @@ var Tracker = class {
|
|
|
6756
6797
|
Extension,
|
|
6757
6798
|
Fragment,
|
|
6758
6799
|
InputRule,
|
|
6800
|
+
MappablePosition,
|
|
6759
6801
|
Mark,
|
|
6760
6802
|
MarkView,
|
|
6761
6803
|
Node,
|
|
@@ -6775,6 +6817,7 @@ var Tracker = class {
|
|
|
6775
6817
|
createDocument,
|
|
6776
6818
|
createElement,
|
|
6777
6819
|
createInlineMarkdownSpec,
|
|
6820
|
+
createMappablePosition,
|
|
6778
6821
|
createNodeFromContent,
|
|
6779
6822
|
createStyleTag,
|
|
6780
6823
|
defaultBlockAt,
|
|
@@ -6815,6 +6858,7 @@ var Tracker = class {
|
|
|
6815
6858
|
getTextBetween,
|
|
6816
6859
|
getTextContentFromNodes,
|
|
6817
6860
|
getTextSerializersFromSchema,
|
|
6861
|
+
getUpdatedPosition,
|
|
6818
6862
|
h,
|
|
6819
6863
|
injectExtensionAttributesToParseRule,
|
|
6820
6864
|
inputRulesPlugin,
|