@arbidocs/coedit 0.5.135 → 0.5.137
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/commands.cjs +18 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +2 -2
- package/dist/commands.d.ts +2 -2
- package/dist/commands.js +18 -1
- package/dist/commands.js.map +1 -1
- package/dist/{port-BbN5OZHx.d.cts → port-DXBNxZYw.d.cts} +2 -0
- package/dist/{port-BbN5OZHx.d.ts → port-DXBNxZYw.d.ts} +2 -0
- package/dist/server.cjs +16 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +16 -0
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
|
@@ -197,6 +197,8 @@ interface DefinitionsPort {
|
|
|
197
197
|
paste(body: string, text: string, covered: boolean, relationships?: string): boolean;
|
|
198
198
|
/** Split the caret's paragraph (Enter), the caret moving into the new one. */
|
|
199
199
|
splitParagraph(): void;
|
|
200
|
+
/** Join a temporary empty paragraph into its predecessor without changing text. */
|
|
201
|
+
joinEmptyParagraph?(firstId: string, emptyId: string): void;
|
|
200
202
|
/** Type plain text at the caret. */
|
|
201
203
|
typeText(text: string): void;
|
|
202
204
|
}
|
|
@@ -197,6 +197,8 @@ interface DefinitionsPort {
|
|
|
197
197
|
paste(body: string, text: string, covered: boolean, relationships?: string): boolean;
|
|
198
198
|
/** Split the caret's paragraph (Enter), the caret moving into the new one. */
|
|
199
199
|
splitParagraph(): void;
|
|
200
|
+
/** Join a temporary empty paragraph into its predecessor without changing text. */
|
|
201
|
+
joinEmptyParagraph?(firstId: string, emptyId: string): void;
|
|
200
202
|
/** Type plain text at the caret. */
|
|
201
203
|
typeText(text: string): void;
|
|
202
204
|
}
|
package/dist/server.cjs
CHANGED
|
@@ -35,6 +35,14 @@ var Y__namespace = /*#__PURE__*/_interopNamespace(Y);
|
|
|
35
35
|
var DEFINED_TERM_STYLE = "DefinedTerm";
|
|
36
36
|
var CROSS_REFERENCE_STYLE = "CrossReference";
|
|
37
37
|
var BROKEN_CROSS_REFERENCE_STYLE = "CrossReferenceBroken";
|
|
38
|
+
function engineOffset(paragraph, offset, pastDeletions = false) {
|
|
39
|
+
let out = offset;
|
|
40
|
+
for (const r of paragraph.revisions ?? [])
|
|
41
|
+
if (r.kind === "delete" && (r.offset < offset || pastDeletions && r.offset === offset))
|
|
42
|
+
out += r.length;
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
var engineLength = (paragraph) => engineOffset(paragraph, paragraph.text.length, true);
|
|
38
46
|
var WATCHED_STYLES = /* @__PURE__ */ new Set([BROKEN_CROSS_REFERENCE_STYLE]);
|
|
39
47
|
var attr = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
|
|
40
48
|
var FIELD_ATOM = "\uFFFC";
|
|
@@ -2725,6 +2733,14 @@ function roomCommandsPort(room, { revision, actorId } = {}) {
|
|
|
2725
2733
|
const next = paragraphs[paragraphs.findIndex((p) => p.id === point.paragraphId) + 1];
|
|
2726
2734
|
caret = next ? { paragraphId: next.id, offset: 0 } : point;
|
|
2727
2735
|
},
|
|
2736
|
+
joinEmptyParagraph: (firstId, emptyId) => {
|
|
2737
|
+
const paragraphs = readParagraphs(root());
|
|
2738
|
+
const index = paragraphs.findIndex((p) => p.id === firstId);
|
|
2739
|
+
const empty = paragraphs[index + 1];
|
|
2740
|
+
if (index < 0 || empty?.id !== emptyId || engineLength(empty) !== 0 || empty.bookmarks.length || empty.links.length)
|
|
2741
|
+
throw new Error("Only an adjacent temporary empty paragraph can be joined.");
|
|
2742
|
+
apply({ op: "joinParagraphs", firstId, secondId: emptyId });
|
|
2743
|
+
},
|
|
2728
2744
|
typeText: (text) => {
|
|
2729
2745
|
const point = at();
|
|
2730
2746
|
apply({
|