@sofereditor/core 0.6.0 → 0.7.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 +20 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -84,6 +84,7 @@ __export(index_exports, {
|
|
|
84
84
|
insertText: () => insertText,
|
|
85
85
|
isCollapsed: () => isCollapsed,
|
|
86
86
|
isCommandOrigin: () => isCommandOrigin,
|
|
87
|
+
isEmbedAdjacentToCaret: () => isEmbedAdjacentToCaret,
|
|
87
88
|
isImageEmbed: () => isImageEmbed,
|
|
88
89
|
isKnownBlockType: () => isKnownBlockType,
|
|
89
90
|
isLegacySerializedDocument: () => isLegacySerializedDocument,
|
|
@@ -1171,6 +1172,24 @@ function deleteForward(ctx) {
|
|
|
1171
1172
|
}
|
|
1172
1173
|
});
|
|
1173
1174
|
}
|
|
1175
|
+
function isEmbedAdjacentToCaret(ctx, direction) {
|
|
1176
|
+
const sel = ctx.getSelection();
|
|
1177
|
+
if (!isCollapsed(sel)) return false;
|
|
1178
|
+
const pos = sel.focus;
|
|
1179
|
+
const yText = ctx.doc.textAt(pos.blockIndex, pos.cellIndex);
|
|
1180
|
+
if (!yText) return false;
|
|
1181
|
+
const delta = yText.toDelta();
|
|
1182
|
+
let cursor = 0;
|
|
1183
|
+
for (const op of delta) {
|
|
1184
|
+
const len = typeof op.insert === "string" ? op.insert.length : 1;
|
|
1185
|
+
const opStart = cursor;
|
|
1186
|
+
const opEnd = cursor + len;
|
|
1187
|
+
cursor = opEnd;
|
|
1188
|
+
const matches = direction === "backward" ? opEnd === pos.offset : opStart === pos.offset;
|
|
1189
|
+
if (matches) return isImageEmbed(op.insert);
|
|
1190
|
+
}
|
|
1191
|
+
return false;
|
|
1192
|
+
}
|
|
1174
1193
|
var booleanMarks = /* @__PURE__ */ new Set(["bold", "italic", "underline", "strike"]);
|
|
1175
1194
|
function toggleMark(ctx, name, value) {
|
|
1176
1195
|
const sel = ctx.getSelection();
|
|
@@ -2377,6 +2396,7 @@ var EditorHistory = class {
|
|
|
2377
2396
|
insertText,
|
|
2378
2397
|
isCollapsed,
|
|
2379
2398
|
isCommandOrigin,
|
|
2399
|
+
isEmbedAdjacentToCaret,
|
|
2380
2400
|
isImageEmbed,
|
|
2381
2401
|
isKnownBlockType,
|
|
2382
2402
|
isLegacySerializedDocument,
|