@im-more/dsh-matrix 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/cordis.patch.yml +14 -0
- package/lib/index.js +2401 -0
- package/lib/index.js.map +1 -0
- package/lib/types/as.d.ts +33 -0
- package/lib/types/as.d.ts.map +1 -0
- package/lib/types/as.js +237 -0
- package/lib/types/as.js.map +1 -0
- package/lib/types/bot.d.ts +109 -0
- package/lib/types/bot.d.ts.map +1 -0
- package/lib/types/bot.js +234 -0
- package/lib/types/bot.js.map +1 -0
- package/lib/types/config.d.ts +59 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +67 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/decode.d.ts +56 -0
- package/lib/types/decode.d.ts.map +1 -0
- package/lib/types/decode.js +298 -0
- package/lib/types/decode.js.map +1 -0
- package/lib/types/errors.d.ts +45 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +120 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/html.d.ts +44 -0
- package/lib/types/html.d.ts.map +1 -0
- package/lib/types/html.js +286 -0
- package/lib/types/html.js.map +1 -0
- package/lib/types/identity.d.ts +20 -0
- package/lib/types/identity.d.ts.map +1 -0
- package/lib/types/identity.js +136 -0
- package/lib/types/identity.js.map +1 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +5 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/media.d.ts +54 -0
- package/lib/types/media.d.ts.map +1 -0
- package/lib/types/media.js +94 -0
- package/lib/types/media.js.map +1 -0
- package/lib/types/mentions.d.ts +58 -0
- package/lib/types/mentions.d.ts.map +1 -0
- package/lib/types/mentions.js +94 -0
- package/lib/types/mentions.js.map +1 -0
- package/lib/types/modes/html.d.ts +13 -0
- package/lib/types/modes/html.d.ts.map +1 -0
- package/lib/types/modes/html.js +242 -0
- package/lib/types/modes/html.js.map +1 -0
- package/lib/types/modes/shared.d.ts +164 -0
- package/lib/types/modes/shared.d.ts.map +1 -0
- package/lib/types/modes/shared.js +312 -0
- package/lib/types/modes/shared.js.map +1 -0
- package/lib/types/request.d.ts +82 -0
- package/lib/types/request.d.ts.map +1 -0
- package/lib/types/request.js +206 -0
- package/lib/types/request.js.map +1 -0
- package/lib/types/rooms.d.ts +83 -0
- package/lib/types/rooms.d.ts.map +1 -0
- package/lib/types/rooms.js +177 -0
- package/lib/types/rooms.js.map +1 -0
- package/lib/types/send.d.ts +76 -0
- package/lib/types/send.d.ts.map +1 -0
- package/lib/types/send.js +172 -0
- package/lib/types/send.js.map +1 -0
- package/lib/types/types.d.ts +418 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/types.js +134 -0
- package/lib/types/types.js.map +1 -0
- package/package.json +65 -3
- package/src/as.ts +293 -0
- package/src/bot.ts +338 -0
- package/src/config.ts +100 -0
- package/src/decode.ts +392 -0
- package/src/errors.ts +149 -0
- package/src/html.ts +325 -0
- package/src/identity.ts +165 -0
- package/src/index.ts +14 -0
- package/src/media.ts +132 -0
- package/src/mentions.ts +134 -0
- package/src/modes/html.ts +346 -0
- package/src/modes/shared.ts +485 -0
- package/src/request.ts +295 -0
- package/src/rooms.ts +232 -0
- package/src/send.ts +275 -0
- package/src/types.ts +633 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,IAAI,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,EACL,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,MAAM,IAAI,YAAY,GAC5B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MatrixBot, MatrixBot as default } from "./bot.js";
|
|
2
|
+
export { Config, configError, routePath, } from "./config.js";
|
|
3
|
+
export { classifyMatrixError, isTokenFailure, MatrixApiError, } from "./errors.js";
|
|
4
|
+
export { MatrixClient } from "./request.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,IAAI,OAAO,EAAoB,MAAM,UAAU,CAAA;AAC5E,OAAO,EACL,MAAM,EACN,WAAW,EACX,SAAS,GAEV,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,GAEf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAA6B,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media in both directions.
|
|
3
|
+
*
|
|
4
|
+
* Outbound: Matrix has a standalone upload endpoint, so `upload` fetches the bytes and posts them to
|
|
5
|
+
* `/_matrix/media/v3/upload`, returning the `mxc://` content URI as the platform key. Inbound: an `mxc://` source needs
|
|
6
|
+
* credentials, so decoding rewrites it to the bot's `satori:` route and the route downloads through the authenticated
|
|
7
|
+
* `/_matrix/client/v1/media/download` endpoint (v1.11 retired the unauthenticated form).
|
|
8
|
+
*/
|
|
9
|
+
import type { PrepareContext, ResolvedResource, ResourceRef } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
import type { MatrixClient } from './request.ts';
|
|
11
|
+
/** What the upload knows beyond the resource key: the platform needs a name, MIME type and size in the event. */
|
|
12
|
+
export interface MatrixMediaExtra {
|
|
13
|
+
name?: string;
|
|
14
|
+
mime?: string;
|
|
15
|
+
size?: number;
|
|
16
|
+
}
|
|
17
|
+
/** A parsed `mxc://<server-name>/<media-id>` URI. */
|
|
18
|
+
export interface MxcUri {
|
|
19
|
+
serverName: string;
|
|
20
|
+
mediaId: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parse one Matrix content URI.
|
|
24
|
+
* @param uri - an `mxc://` URI.
|
|
25
|
+
* @returns its server name and media id, or undefined for any other URI.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseMxc(uri: string): MxcUri | undefined;
|
|
28
|
+
/** The bot surface the internal source needs (`Bot.getInternalUrl`). */
|
|
29
|
+
export interface InternalSourceHost {
|
|
30
|
+
getInternalUrl(path: string, init?: Record<string, string>): string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The `satori:` source of one content URI, served through the bot's `/media` route.
|
|
34
|
+
* @param host - the receiving bot.
|
|
35
|
+
* @param uri - an `mxc://` URI.
|
|
36
|
+
* @returns the internal source, or undefined when the URI is not a content URI.
|
|
37
|
+
*/
|
|
38
|
+
export declare function internalMediaSource(host: InternalSourceHost, uri: string): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Upload one resource and return its `mxc://` key.
|
|
41
|
+
*
|
|
42
|
+
* @param client - the bot's Client-Server client.
|
|
43
|
+
* @param ref - the resource placeholder produced by a mode handler.
|
|
44
|
+
* @param ctx - prepare context (fetch and cancellation).
|
|
45
|
+
* @returns the platform key and the name/MIME/size the event carries.
|
|
46
|
+
*/
|
|
47
|
+
export declare function uploadResource(client: MatrixClient, ref: ResourceRef, ctx: PrepareContext): Promise<ResolvedResource>;
|
|
48
|
+
/**
|
|
49
|
+
* Turn one homeserver media answer into the response the host sees.
|
|
50
|
+
* @param response - the authenticated download answer.
|
|
51
|
+
* @returns the same bytes and metadata, or `502` when the homeserver refused or lost them.
|
|
52
|
+
*/
|
|
53
|
+
export declare function mediaResponse(response: Response): Response;
|
|
54
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/media.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EACZ,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD,iHAAiH;AACjH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,qDAAqD;AACrD,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMxD;AAED,wEAAwE;AACxE,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;CACpE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,kBAAkB,EACxB,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAMpB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAoC3B;AAKD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAQ1D"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media in both directions.
|
|
3
|
+
*
|
|
4
|
+
* Outbound: Matrix has a standalone upload endpoint, so `upload` fetches the bytes and posts them to
|
|
5
|
+
* `/_matrix/media/v3/upload`, returning the `mxc://` content URI as the platform key. Inbound: an `mxc://` source needs
|
|
6
|
+
* credentials, so decoding rewrites it to the bot's `satori:` route and the route downloads through the authenticated
|
|
7
|
+
* `/_matrix/client/v1/media/download` endpoint (v1.11 retired the unauthenticated form).
|
|
8
|
+
*/
|
|
9
|
+
import { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
/**
|
|
11
|
+
* Parse one Matrix content URI.
|
|
12
|
+
* @param uri - an `mxc://` URI.
|
|
13
|
+
* @returns its server name and media id, or undefined for any other URI.
|
|
14
|
+
*/
|
|
15
|
+
export function parseMxc(uri) {
|
|
16
|
+
if (!uri.startsWith('mxc://'))
|
|
17
|
+
return undefined;
|
|
18
|
+
const rest = uri.slice('mxc://'.length);
|
|
19
|
+
const slash = rest.indexOf('/');
|
|
20
|
+
if (slash <= 0 || slash === rest.length - 1)
|
|
21
|
+
return undefined;
|
|
22
|
+
return { serverName: rest.slice(0, slash), mediaId: rest.slice(slash + 1) };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The `satori:` source of one content URI, served through the bot's `/media` route.
|
|
26
|
+
* @param host - the receiving bot.
|
|
27
|
+
* @param uri - an `mxc://` URI.
|
|
28
|
+
* @returns the internal source, or undefined when the URI is not a content URI.
|
|
29
|
+
*/
|
|
30
|
+
export function internalMediaSource(host, uri) {
|
|
31
|
+
const parsed = parseMxc(uri);
|
|
32
|
+
if (parsed === undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
return host.getInternalUrl('/media', {
|
|
35
|
+
mxc: `${parsed.serverName}/${parsed.mediaId}`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Upload one resource and return its `mxc://` key.
|
|
40
|
+
*
|
|
41
|
+
* @param client - the bot's Client-Server client.
|
|
42
|
+
* @param ref - the resource placeholder produced by a mode handler.
|
|
43
|
+
* @param ctx - prepare context (fetch and cancellation).
|
|
44
|
+
* @returns the platform key and the name/MIME/size the event carries.
|
|
45
|
+
*/
|
|
46
|
+
export async function uploadResource(client, ref, ctx) {
|
|
47
|
+
let fetched;
|
|
48
|
+
try {
|
|
49
|
+
fetched = await ctx.fetch(ref.src, ctx.signal);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
// Nothing was uploaded, so nothing can have been published.
|
|
53
|
+
throw new PlatformError('invalid', `matrix: the resource "${ref.src}" could not be read`, {
|
|
54
|
+
published: 'no',
|
|
55
|
+
cause: error,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const name = ref.meta.name ?? fetched.name ?? 'file';
|
|
59
|
+
const mime = ref.meta.mime ?? fetched.mime;
|
|
60
|
+
const answer = await client.upload(name, fetched.data, mime, ctx.signal);
|
|
61
|
+
const contentUri = answer.content_uri;
|
|
62
|
+
if (contentUri === undefined || contentUri === '') {
|
|
63
|
+
throw new PlatformError('invalid', 'matrix: the upload answered without a content_uri', {
|
|
64
|
+
published: 'no',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
key: contentUri,
|
|
69
|
+
extra: {
|
|
70
|
+
name,
|
|
71
|
+
...(mime === undefined ? {} : { mime }),
|
|
72
|
+
size: fetched.data.byteLength,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Response headers a `satori:` media route mirrors from the homeserver. The length is left to the response body. */
|
|
77
|
+
const MIRRORED_HEADERS = ['content-type', 'content-disposition'];
|
|
78
|
+
/**
|
|
79
|
+
* Turn one homeserver media answer into the response the host sees.
|
|
80
|
+
* @param response - the authenticated download answer.
|
|
81
|
+
* @returns the same bytes and metadata, or `502` when the homeserver refused or lost them.
|
|
82
|
+
*/
|
|
83
|
+
export function mediaResponse(response) {
|
|
84
|
+
if (!response.ok)
|
|
85
|
+
return new Response(null, { status: 502 });
|
|
86
|
+
const headers = new Headers();
|
|
87
|
+
for (const name of MIRRORED_HEADERS) {
|
|
88
|
+
const value = response.headers.get(name);
|
|
89
|
+
if (value !== null)
|
|
90
|
+
headers.set(name, value);
|
|
91
|
+
}
|
|
92
|
+
return new Response(response.body, { status: response.status, headers });
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/media.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAqBlE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAA;IAC/C,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC/B,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IAC7D,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAA;AAC7E,CAAC;AAOD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAwB,EACxB,GAAW;IAEX,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE;QACnC,GAAG,EAAE,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,OAAO,EAAE;K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,CAAA;AACH,CAAC;AAED,qHAAqH;AACrH,MAAM,gBAAgB,GAAG,CAAC,cAAc,EAAE,qBAAqB,CAAU,CAAA;AAEzE;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IAC5D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;IAC7B,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACxC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC9C,CAAC;IACD,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;AAC1E,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mentions in both directions.
|
|
3
|
+
*
|
|
4
|
+
* Inbound, `m.mentions` is authoritative for `self`/`all`, because guessing from a display name is what the
|
|
5
|
+
* specification warns against; a `matrix.to` link decoded into an `at` element covers older clients that did not write
|
|
6
|
+
* the field, and a bare `@room` in the body covers the pre-v1.7 room mention. Outbound, `at` elements collect into
|
|
7
|
+
* `m.mentions` (one object per draft, always present) and render as `matrix.to` links.
|
|
8
|
+
*/
|
|
9
|
+
import type { Element, UserRef } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
/** The `m.mentions` content object (always written, empty when nothing is mentioned). */
|
|
11
|
+
export interface MatrixMentionWire {
|
|
12
|
+
user_ids?: string[];
|
|
13
|
+
room?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** The `m.mentions` field as an event carries it. */
|
|
16
|
+
export interface MatrixMentionContent {
|
|
17
|
+
user_ids?: string[];
|
|
18
|
+
room?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Decoded mention facts of one inbound event. */
|
|
21
|
+
export interface MatrixMentions {
|
|
22
|
+
self: boolean;
|
|
23
|
+
all: boolean;
|
|
24
|
+
users: UserRef[];
|
|
25
|
+
}
|
|
26
|
+
/** Mutable collection used while assembling one draft. */
|
|
27
|
+
export interface MentionSet {
|
|
28
|
+
readonly users: string[];
|
|
29
|
+
room: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** One mention a mode handler found while rendering. */
|
|
32
|
+
export interface MentionNode {
|
|
33
|
+
user?: string;
|
|
34
|
+
room?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** A new empty collection. */
|
|
37
|
+
export declare function createMentionSet(): MentionSet;
|
|
38
|
+
/**
|
|
39
|
+
* Add one handler's mention to a draft's collection.
|
|
40
|
+
* @param set - the draft's collection.
|
|
41
|
+
* @param mention - the mention; a user id or a room mention.
|
|
42
|
+
*/
|
|
43
|
+
export declare function addMention(set: MentionSet, mention: MentionNode | undefined): void;
|
|
44
|
+
/** The wire object of one collection; `{}` when it mentions nobody. */
|
|
45
|
+
export declare function mentionWire(set: MentionSet): MatrixMentionWire;
|
|
46
|
+
/**
|
|
47
|
+
* Decode the mention facts of one inbound event.
|
|
48
|
+
*
|
|
49
|
+
* @param content - the event content, whose `m.mentions` is authoritative when present.
|
|
50
|
+
* @param body - the plain body, for the legacy `@room` form.
|
|
51
|
+
* @param elements - the decoded content tree, for `matrix.to` links and mention labels.
|
|
52
|
+
* @param selfId - the bot's Matrix user id.
|
|
53
|
+
* @returns `self`/`all` flags and the users the message mentions.
|
|
54
|
+
*/
|
|
55
|
+
export declare function decodeMentions(content: {
|
|
56
|
+
'm.mentions'?: MatrixMentionContent;
|
|
57
|
+
}, body: string | undefined, elements: readonly Element[], selfId: string): MatrixMentions;
|
|
58
|
+
//# sourceMappingURL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,EAAE,SAAS,OAAO,EAAE,EAC5B,MAAM,EAAE,MAAM,GACb,cAAc,CA2BhB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mentions in both directions.
|
|
3
|
+
*
|
|
4
|
+
* Inbound, `m.mentions` is authoritative for `self`/`all`, because guessing from a display name is what the
|
|
5
|
+
* specification warns against; a `matrix.to` link decoded into an `at` element covers older clients that did not write
|
|
6
|
+
* the field, and a bare `@room` in the body covers the pre-v1.7 room mention. Outbound, `at` elements collect into
|
|
7
|
+
* `m.mentions` (one object per draft, always present) and render as `matrix.to` links.
|
|
8
|
+
*/
|
|
9
|
+
/** A new empty collection. */
|
|
10
|
+
export function createMentionSet() {
|
|
11
|
+
return { users: [], room: false };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Add one handler's mention to a draft's collection.
|
|
15
|
+
* @param set - the draft's collection.
|
|
16
|
+
* @param mention - the mention; a user id or a room mention.
|
|
17
|
+
*/
|
|
18
|
+
export function addMention(set, mention) {
|
|
19
|
+
if (mention === undefined)
|
|
20
|
+
return;
|
|
21
|
+
if (mention.user !== undefined && !set.users.includes(mention.user))
|
|
22
|
+
set.users.push(mention.user);
|
|
23
|
+
if (mention.room === true)
|
|
24
|
+
set.room = true;
|
|
25
|
+
}
|
|
26
|
+
/** The wire object of one collection; `{}` when it mentions nobody. */
|
|
27
|
+
export function mentionWire(set) {
|
|
28
|
+
return {
|
|
29
|
+
...(set.users.length === 0 ? {} : { user_ids: [...set.users] }),
|
|
30
|
+
...(set.room ? { room: true } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Whether the plain body carries the old standalone `@room` form. */
|
|
34
|
+
function bodyMentionsRoom(body) {
|
|
35
|
+
if (body === undefined)
|
|
36
|
+
return false;
|
|
37
|
+
return /(^|\s)@room(?=\s|$)/.test(body);
|
|
38
|
+
}
|
|
39
|
+
/** Every `at[type=user]` of a decoded tree, in document order. */
|
|
40
|
+
function atElements(elements) {
|
|
41
|
+
const out = [];
|
|
42
|
+
const walk = (nodes) => {
|
|
43
|
+
for (const node of nodes) {
|
|
44
|
+
if (node.type === 'at') {
|
|
45
|
+
if (node.attrs.type === 'user')
|
|
46
|
+
out.push(node);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
walk(node.children);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
walk(elements);
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Decode the mention facts of one inbound event.
|
|
57
|
+
*
|
|
58
|
+
* @param content - the event content, whose `m.mentions` is authoritative when present.
|
|
59
|
+
* @param body - the plain body, for the legacy `@room` form.
|
|
60
|
+
* @param elements - the decoded content tree, for `matrix.to` links and mention labels.
|
|
61
|
+
* @param selfId - the bot's Matrix user id.
|
|
62
|
+
* @returns `self`/`all` flags and the users the message mentions.
|
|
63
|
+
*/
|
|
64
|
+
export function decodeMentions(content, body, elements, selfId) {
|
|
65
|
+
const declared = content['m.mentions'];
|
|
66
|
+
const declaredIds = Array.isArray(declared?.user_ids)
|
|
67
|
+
? declared.user_ids.filter((id) => typeof id === 'string')
|
|
68
|
+
: [];
|
|
69
|
+
const users = [];
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
for (const element of atElements(elements)) {
|
|
72
|
+
const id = element.attrs.id;
|
|
73
|
+
if (id === undefined || seen.has(id))
|
|
74
|
+
continue;
|
|
75
|
+
seen.add(id);
|
|
76
|
+
users.push({
|
|
77
|
+
id,
|
|
78
|
+
...(element.attrs.name === undefined ? {} : { name: element.attrs.name }),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
for (const id of declaredIds) {
|
|
82
|
+
if (seen.has(id))
|
|
83
|
+
continue;
|
|
84
|
+
seen.add(id);
|
|
85
|
+
users.push({ id });
|
|
86
|
+
}
|
|
87
|
+
const selfByElement = users.some((user) => user.id === selfId);
|
|
88
|
+
return {
|
|
89
|
+
self: selfId !== '' && (declaredIds.includes(selfId) || selfByElement),
|
|
90
|
+
all: declared?.room === true || bodyMentionsRoom(body),
|
|
91
|
+
users,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=mentions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mentions.js","sourceRoot":"","sources":["../../src/mentions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmCH,8BAA8B;AAC9B,MAAM,UAAU,gBAAgB;IAC9B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,GAAe,EACf,OAAgC;IAEhC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAM;IACjC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;QACjE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;QAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;AAC5C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,WAAW,CAAC,GAAe;IACzC,OAAO;QACL,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpC,CAAA;AACH,CAAC;AAED,sEAAsE;AACtE,SAAS,gBAAgB,CAAC,IAAwB;IAChD,IAAI,IAAI,KAAK,SAAS;QAA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AAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,SAAQ;QAC9C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACZ,KAAK,CAAC,IAAI,CAAC;YACT,EAAE;YACF,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC1E,CAAC,CAAA;IACJ,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,SAAQ;QAC1B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACZ,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACpB,CAAC;IACD,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,CAAA;IAC9D,OAAO;QACL,IAAI,EAAE,MAAM,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC;QACtE,GAAG,EAAE,QAAQ,EAAE,IAAI,KAAK,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC;QACtD,KAAK;KACN,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `html` mode: Matrix's `org.matrix.custom.html` rich text, with the plain `body` produced from the same traversal.
|
|
3
|
+
*
|
|
4
|
+
* Native tags are the specification's allowed subset (`b`/`i`/`u`/`s`/`del`/`code`/`pre`/`a`/`p`/`blockquote`/lists/
|
|
5
|
+
* headings/table/details/spoiler); everything else takes the core fallback and is reported as degraded. A user mention
|
|
6
|
+
* renders as a `matrix.to` link and collects into `m.mentions`; `@room` is the room mention. Media never stays inline:
|
|
7
|
+
* each media element becomes its own event and is reported as moved when it stood in phrasing content.
|
|
8
|
+
*/
|
|
9
|
+
import type { Mode } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
import type { MatrixModeTypes } from './shared.ts';
|
|
11
|
+
/** Build the `html` mode. */
|
|
12
|
+
export declare function createHtmlMode(): Mode<MatrixModeTypes>;
|
|
13
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/modes/html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAiB,MAAM,oCAAoC,CAAA;AAc7E,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,aAAa,CAAA;AAqD9D,6BAA6B;AAC7B,wBAAgB,cAAc,IAAI,IAAI,CAAC,eAAe,CAAC,CA2QtD"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `html` mode: Matrix's `org.matrix.custom.html` rich text, with the plain `body` produced from the same traversal.
|
|
3
|
+
*
|
|
4
|
+
* Native tags are the specification's allowed subset (`b`/`i`/`u`/`s`/`del`/`code`/`pre`/`a`/`p`/`blockquote`/lists/
|
|
5
|
+
* headings/table/details/spoiler); everything else takes the core fallback and is reported as degraded. A user mention
|
|
6
|
+
* renders as a `matrix.to` link and collects into `m.mentions`; `@room` is the room mention. Media never stays inline:
|
|
7
|
+
* each media element becomes its own event and is reported as moved when it stood in phrasing content.
|
|
8
|
+
*/
|
|
9
|
+
import { ElementRegistry } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
import { addMention, createMentionSet } from "../mentions.js";
|
|
11
|
+
import { assembleDrafts, escapeAttribute, escapeHtml, htmlNode, inlineRun, inlineWrapper, mediaNode, mentionNodes, serializeDraft, } from "./shared.js";
|
|
12
|
+
/** The `matrix.to` prefix of a room or user link. */
|
|
13
|
+
const MATRIX_LINK = 'https://matrix.to/#/';
|
|
14
|
+
/** Wrap the inline text of `children` in one tag, letting media of the subtree follow it. */
|
|
15
|
+
function wrap(tag, ctx, children, textSuffix = '') {
|
|
16
|
+
return inlineWrapper(tag, ctx.render(children), textSuffix);
|
|
17
|
+
}
|
|
18
|
+
/** Prefix every line of a blockquote text projection with `> `. */
|
|
19
|
+
function quoteText(text) {
|
|
20
|
+
const body = text.replace(/\n+$/, '');
|
|
21
|
+
if (body === '')
|
|
22
|
+
return '\n\n';
|
|
23
|
+
return `${body
|
|
24
|
+
.split('\n')
|
|
25
|
+
.map((line) => `> ${line}`)
|
|
26
|
+
.join('\n')}\n\n`;
|
|
27
|
+
}
|
|
28
|
+
/** The text of one table cell, with block children separated by a space. */
|
|
29
|
+
function cellText(ctx, cell) {
|
|
30
|
+
return cell.children
|
|
31
|
+
.map((child) => ctx.text([child]))
|
|
32
|
+
.filter((part) => part.trim() !== '')
|
|
33
|
+
.join(' ')
|
|
34
|
+
.replace(/\s+/g, ' ')
|
|
35
|
+
.trim();
|
|
36
|
+
}
|
|
37
|
+
/** The `- ` / `1. ` marker of one list item, plus its task-list box. */
|
|
38
|
+
function listMarker(el, ctx) {
|
|
39
|
+
const parent = ctx.ancestors[ctx.ancestors.length - 1];
|
|
40
|
+
let marker = '- ';
|
|
41
|
+
if (parent?.type === 'ol') {
|
|
42
|
+
const start = typeof parent.attrs.start === 'number' ? parent.attrs.start : 1;
|
|
43
|
+
const index = parent.children.indexOf(el);
|
|
44
|
+
marker = `${start + Math.max(0, index)}. `;
|
|
45
|
+
}
|
|
46
|
+
if (el.attrs.checked === true)
|
|
47
|
+
marker += '[x] ';
|
|
48
|
+
else if (el.attrs.checked === false)
|
|
49
|
+
marker += '[ ] ';
|
|
50
|
+
return marker;
|
|
51
|
+
}
|
|
52
|
+
/** Build the `html` mode. */
|
|
53
|
+
export function createHtmlMode() {
|
|
54
|
+
const elements = new ElementRegistry()
|
|
55
|
+
.register('text', (el) => htmlNode(escapeHtml(el.attrs.content), el.attrs.content))
|
|
56
|
+
.register('br', () => htmlNode('<br/>', '\n'))
|
|
57
|
+
.register('p', (el, ctx) => wrap('p', ctx, el.children, '\n\n'))
|
|
58
|
+
.register('b', (el, ctx) => wrap('strong', ctx, el.children))
|
|
59
|
+
.register('i', (el, ctx) => wrap('em', ctx, el.children))
|
|
60
|
+
.register('u', (el, ctx) => wrap('u', ctx, el.children))
|
|
61
|
+
.register('s', (el, ctx) => wrap('del', ctx, el.children))
|
|
62
|
+
.register('spoiler', (el, ctx) => {
|
|
63
|
+
const run = inlineRun(ctx.render(el.children));
|
|
64
|
+
// The hidden text reaches `formatted_body` only: `body` must not repeat what the spoiler hides.
|
|
65
|
+
return [
|
|
66
|
+
htmlNode(`<span data-mx-spoiler>${run.html}</span>`, '[剧透]', mentionNodes(run.mentions)),
|
|
67
|
+
...run.rest,
|
|
68
|
+
];
|
|
69
|
+
})
|
|
70
|
+
.register('code', (el, ctx) => {
|
|
71
|
+
const content = ctx.text(el.children);
|
|
72
|
+
return htmlNode(`<code>${escapeHtml(content)}</code>`, content);
|
|
73
|
+
})
|
|
74
|
+
.register('pre', (el, ctx) => {
|
|
75
|
+
const content = ctx.text(el.children);
|
|
76
|
+
const language = el.attrs.lang;
|
|
77
|
+
const html = language === undefined || language === ''
|
|
78
|
+
? `<pre>${escapeHtml(content)}</pre>`
|
|
79
|
+
: `<pre><code class="language-${escapeAttribute(language)}">${escapeHtml(content)}</code></pre>`;
|
|
80
|
+
return htmlNode(html, `${content}\n\n`);
|
|
81
|
+
}, { variants: ['lang'] })
|
|
82
|
+
.register('a', (el, ctx) => {
|
|
83
|
+
const run = inlineRun(ctx.render(el.children));
|
|
84
|
+
const href = el.attrs.href;
|
|
85
|
+
const label = run.html === '' ? escapeHtml(href) : run.html;
|
|
86
|
+
const plain = run.text === '' ? href : run.text;
|
|
87
|
+
return [
|
|
88
|
+
htmlNode(`<a href="${escapeAttribute(href)}">${label}</a>`, plain === href ? href : `${plain} (${href})`, mentionNodes(run.mentions)),
|
|
89
|
+
...run.rest,
|
|
90
|
+
];
|
|
91
|
+
})
|
|
92
|
+
.register('at', (el) => {
|
|
93
|
+
if (el.attrs.type === 'all')
|
|
94
|
+
return htmlNode('@room', '@room', [{ room: true }]);
|
|
95
|
+
if (el.attrs.type === 'user' && el.attrs.id !== undefined) {
|
|
96
|
+
const id = el.attrs.id;
|
|
97
|
+
const label = escapeHtml(el.attrs.name ?? id);
|
|
98
|
+
return htmlNode(`<a href="${MATRIX_LINK}${escapeAttribute(id)}">${label}</a>`, el.attrs.name ?? id, [{ user: id }]);
|
|
99
|
+
}
|
|
100
|
+
return htmlNode(escapeHtml(el.attrs.name ?? el.attrs.id ?? el.attrs.type), el.attrs.name ?? el.attrs.id ?? '');
|
|
101
|
+
}, { variants: ['user', 'all'] })
|
|
102
|
+
.register('channel', (el) => {
|
|
103
|
+
const id = el.attrs.id;
|
|
104
|
+
const label = escapeHtml(el.attrs.name ?? id);
|
|
105
|
+
return htmlNode(`<a href="${MATRIX_LINK}${escapeAttribute(id)}">${label}</a>`, el.attrs.name ?? id);
|
|
106
|
+
})
|
|
107
|
+
.register('emoji', (el) => {
|
|
108
|
+
const label = `:${el.attrs.name ?? el.attrs.id}:`;
|
|
109
|
+
return htmlNode(escapeHtml(label), label);
|
|
110
|
+
})
|
|
111
|
+
.register('h1', (el, ctx) => wrap('h1', ctx, el.children, '\n\n'))
|
|
112
|
+
.register('h2', (el, ctx) => wrap('h2', ctx, el.children, '\n\n'))
|
|
113
|
+
.register('h3', (el, ctx) => wrap('h3', ctx, el.children, '\n\n'))
|
|
114
|
+
.register('h4', (el, ctx) => wrap('h4', ctx, el.children, '\n\n'))
|
|
115
|
+
.register('h5', (el, ctx) => wrap('h5', ctx, el.children, '\n\n'))
|
|
116
|
+
.register('h6', (el, ctx) => wrap('h6', ctx, el.children, '\n\n'))
|
|
117
|
+
.register('blockquote', (el, ctx) => {
|
|
118
|
+
const run = inlineRun(ctx.render(el.children));
|
|
119
|
+
return [
|
|
120
|
+
htmlNode(`<blockquote>${run.html}</blockquote>`, quoteText(run.text), mentionNodes(run.mentions)),
|
|
121
|
+
...run.rest,
|
|
122
|
+
];
|
|
123
|
+
})
|
|
124
|
+
.register('ul', (el, ctx) => wrap('ul', ctx, el.children))
|
|
125
|
+
.register('ol', (el, ctx) => {
|
|
126
|
+
const run = inlineRun(ctx.render(el.children));
|
|
127
|
+
const start = typeof el.attrs.start === 'number' ? ` start="${el.attrs.start}"` : '';
|
|
128
|
+
return [
|
|
129
|
+
htmlNode(`<ol${start}>${run.html}</ol>`, run.text, mentionNodes(run.mentions)),
|
|
130
|
+
...run.rest,
|
|
131
|
+
];
|
|
132
|
+
})
|
|
133
|
+
.register('li', (el, ctx) => {
|
|
134
|
+
const run = inlineRun(ctx.render(el.children));
|
|
135
|
+
const box = el.attrs.checked === true
|
|
136
|
+
? '[x] '
|
|
137
|
+
: el.attrs.checked === false
|
|
138
|
+
? '[ ] '
|
|
139
|
+
: '';
|
|
140
|
+
return [
|
|
141
|
+
htmlNode(`<li>${box}${run.html}</li>`, `${listMarker(el, ctx)}${run.text}\n`, mentionNodes(run.mentions)),
|
|
142
|
+
...run.rest,
|
|
143
|
+
];
|
|
144
|
+
}, { variants: ['checked', 'nested'] })
|
|
145
|
+
.register('hr', () => htmlNode('<hr/>', '\n---\n'))
|
|
146
|
+
.register('table', (el, ctx) => {
|
|
147
|
+
const rows = el.children.filter((child) => child.type === 'tr');
|
|
148
|
+
const first = rows[0];
|
|
149
|
+
const header = first !== undefined &&
|
|
150
|
+
first.children.length > 0 &&
|
|
151
|
+
first.children.every((cell) => cell.type === 'th')
|
|
152
|
+
? first
|
|
153
|
+
: undefined;
|
|
154
|
+
const bodyRows = header === undefined ? rows : rows.slice(1);
|
|
155
|
+
const renderedRow = (row) => inlineRun(ctx.render([row]));
|
|
156
|
+
const headerRun = header === undefined ? undefined : renderedRow(header);
|
|
157
|
+
const bodyRuns = bodyRows.map(renderedRow);
|
|
158
|
+
const html = [
|
|
159
|
+
'<table>',
|
|
160
|
+
headerRun === undefined ? '' : `<thead>${headerRun.html}</thead>`,
|
|
161
|
+
`<tbody>${bodyRuns.map((run) => run.html).join('')}</tbody>`,
|
|
162
|
+
'</table>',
|
|
163
|
+
].join('');
|
|
164
|
+
const headerCells = header === undefined
|
|
165
|
+
? []
|
|
166
|
+
: header.children
|
|
167
|
+
.filter((cell) => cell.type === 'th' || cell.type === 'td')
|
|
168
|
+
.map((cell) => cellText(ctx, cell));
|
|
169
|
+
const lines = bodyRows.map((row) => row.children
|
|
170
|
+
.filter((cell) => cell.type === 'th' || cell.type === 'td')
|
|
171
|
+
.map((cell, index) => {
|
|
172
|
+
const value = cellText(ctx, cell);
|
|
173
|
+
const head = headerCells[index];
|
|
174
|
+
return head === undefined || head === ''
|
|
175
|
+
? value
|
|
176
|
+
: `${head}: ${value}`;
|
|
177
|
+
})
|
|
178
|
+
.join(' | '));
|
|
179
|
+
const mentions = createMentionSet();
|
|
180
|
+
for (const run of [headerRun, ...bodyRuns]) {
|
|
181
|
+
if (run === undefined)
|
|
182
|
+
continue;
|
|
183
|
+
for (const mention of mentionNodes(run.mentions))
|
|
184
|
+
addMention(mentions, mention);
|
|
185
|
+
}
|
|
186
|
+
const text = lines.join('\n');
|
|
187
|
+
return [
|
|
188
|
+
htmlNode(html, text === '' ? '' : `${text}\n`, mentionNodes(mentions)),
|
|
189
|
+
...(headerRun?.rest ?? []),
|
|
190
|
+
...bodyRuns.flatMap((run) => run.rest),
|
|
191
|
+
];
|
|
192
|
+
}, { variants: ['align'] })
|
|
193
|
+
.register('tr', (el, ctx) => {
|
|
194
|
+
const run = inlineRun(ctx.render(el.children));
|
|
195
|
+
return [
|
|
196
|
+
htmlNode(`<tr>${run.html}</tr>`, run.text, mentionNodes(run.mentions)),
|
|
197
|
+
...run.rest,
|
|
198
|
+
];
|
|
199
|
+
})
|
|
200
|
+
.register('th', (el, ctx) => {
|
|
201
|
+
const run = inlineRun(ctx.render(el.children));
|
|
202
|
+
const align = el.attrs.align === undefined
|
|
203
|
+
? ''
|
|
204
|
+
: ` align="${escapeAttribute(el.attrs.align)}"`;
|
|
205
|
+
return [
|
|
206
|
+
htmlNode(`<th${align}>${run.html}</th>`, run.text, mentionNodes(run.mentions)),
|
|
207
|
+
...run.rest,
|
|
208
|
+
];
|
|
209
|
+
})
|
|
210
|
+
.register('td', (el, ctx) => {
|
|
211
|
+
const run = inlineRun(ctx.render(el.children));
|
|
212
|
+
const align = el.attrs.align === undefined
|
|
213
|
+
? ''
|
|
214
|
+
: ` align="${escapeAttribute(el.attrs.align)}"`;
|
|
215
|
+
return [
|
|
216
|
+
htmlNode(`<td${align}>${run.html}</td>`, run.text, mentionNodes(run.mentions)),
|
|
217
|
+
...run.rest,
|
|
218
|
+
];
|
|
219
|
+
}, { variants: ['block'] })
|
|
220
|
+
.register('details', (el, ctx) => {
|
|
221
|
+
const run = inlineRun(ctx.render(el.children));
|
|
222
|
+
const open = el.attrs.open === true ? ' open' : '';
|
|
223
|
+
return [
|
|
224
|
+
htmlNode(`<details${open}>${run.html}</details>`, `▸ ${run.text}`, mentionNodes(run.mentions)),
|
|
225
|
+
...run.rest,
|
|
226
|
+
];
|
|
227
|
+
})
|
|
228
|
+
.register('summary', (el, ctx) => wrap('summary', ctx, el.children, '\n'))
|
|
229
|
+
.register('small', (el, ctx) => ctx.render(el.children))
|
|
230
|
+
.register('img', (el, ctx) => mediaNode(el, ctx), { variants: ['inline'] })
|
|
231
|
+
.register('audio', (el, ctx) => mediaNode(el, ctx))
|
|
232
|
+
.register('video', (el, ctx) => mediaNode(el, ctx))
|
|
233
|
+
.register('file', (el, ctx) => mediaNode(el, ctx));
|
|
234
|
+
return {
|
|
235
|
+
id: 'html',
|
|
236
|
+
elements,
|
|
237
|
+
limits: {},
|
|
238
|
+
assemble: (nodes) => assembleDrafts(nodes),
|
|
239
|
+
serialize: (prepared, ctx) => serializeDraft(prepared, ctx),
|
|
240
|
+
};
|
|
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