@gravity-ui/aikit 2.9.1 → 2.9.2
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/build/cjs/components/atoms/MarkdownRenderer/MarkdownRenderer.css +28 -4
- package/build/cjs/components/molecules/BaseMessage/BaseMessage.css +3 -0
- package/build/cjs/components/organisms/AssistantMessage/AssistantMessage.css +1 -0
- package/build/cjs/components/organisms/MessageList/MessageList.css +2 -0
- package/build/cjs/components/templates/ChatContent/ChatContent.css +1 -0
- package/build/cjs/hooks/useMarkdownTransform.js +2 -1
- package/build/cjs/hooks/useMarkdownTransform.js.map +1 -1
- package/build/cjs/package.json +1 -1
- package/build/cjs/themes/common.css +3 -0
- package/build/cjs/themes/variables.css +3 -0
- package/build/cjs/utils/markdownTableWrapPlugin.d.ts +4 -0
- package/build/cjs/utils/markdownTableWrapPlugin.js +29 -0
- package/build/cjs/utils/markdownTableWrapPlugin.js.map +1 -0
- package/build/cjs/utils/markdownUtils.d.ts +5 -0
- package/build/cjs/utils/markdownUtils.js +13 -0
- package/build/cjs/utils/markdownUtils.js.map +1 -1
- package/build/esm/components/atoms/MarkdownRenderer/MarkdownRenderer.css +28 -4
- package/build/esm/components/molecules/BaseMessage/BaseMessage.css +3 -0
- package/build/esm/components/organisms/AssistantMessage/AssistantMessage.css +1 -0
- package/build/esm/components/organisms/MessageList/MessageList.css +2 -0
- package/build/esm/components/templates/ChatContent/ChatContent.css +1 -0
- package/build/esm/hooks/useMarkdownTransform.js +3 -2
- package/build/esm/hooks/useMarkdownTransform.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/themes/common.css +3 -0
- package/build/esm/themes/variables.css +3 -0
- package/build/esm/utils/markdownTableWrapPlugin.d.ts +4 -0
- package/build/esm/utils/markdownTableWrapPlugin.js +26 -0
- package/build/esm/utils/markdownTableWrapPlugin.js.map +1 -0
- package/build/esm/utils/markdownUtils.d.ts +5 -0
- package/build/esm/utils/markdownUtils.js +11 -0
- package/build/esm/utils/markdownUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -87,18 +87,42 @@
|
|
|
87
87
|
display: none;
|
|
88
88
|
}
|
|
89
89
|
.g-aikit-markdown-renderer {
|
|
90
|
+
width: 100%;
|
|
90
91
|
max-width: 100%;
|
|
92
|
+
min-width: 0;
|
|
93
|
+
/* Scroll container injected by markdownTableWrapPlugin; text outside stays fixed */
|
|
94
|
+
}
|
|
95
|
+
.g-aikit-markdown-renderer__table-wrap {
|
|
96
|
+
width: 100%;
|
|
97
|
+
max-width: 100%;
|
|
98
|
+
min-width: 0;
|
|
91
99
|
overflow-x: auto;
|
|
92
|
-
|
|
100
|
+
}
|
|
101
|
+
.g-aikit-markdown-renderer {
|
|
102
|
+
/*
|
|
103
|
+
* Override @diplodoc/transform `.yfm table` (inline-block + max-width: 100%).
|
|
104
|
+
* min-width: 100% — narrow tables fill the message; width: max-content — columns size to content.
|
|
105
|
+
*/
|
|
93
106
|
}
|
|
94
107
|
.g-aikit-markdown-renderer table {
|
|
108
|
+
display: table;
|
|
95
109
|
table-layout: auto;
|
|
96
110
|
word-break: normal;
|
|
97
|
-
min-width: 100%;
|
|
98
111
|
width: max-content;
|
|
112
|
+
min-width: 100%;
|
|
113
|
+
max-width: none;
|
|
114
|
+
overflow: visible;
|
|
99
115
|
}
|
|
100
|
-
.g-aikit-markdown-renderer th
|
|
101
|
-
.g-aikit-markdown-renderer td {
|
|
116
|
+
.g-aikit-markdown-renderer table th {
|
|
102
117
|
word-break: normal;
|
|
103
118
|
white-space: nowrap;
|
|
119
|
+
overflow: visible;
|
|
120
|
+
}
|
|
121
|
+
.g-aikit-markdown-renderer table td {
|
|
122
|
+
max-width: var(--g-aikit-markdown-renderer-table-cell-max-width);
|
|
123
|
+
word-break: normal;
|
|
124
|
+
white-space: normal;
|
|
125
|
+
/* Wrap multi-word text at spaces within max-width */
|
|
126
|
+
overflow-wrap: normal;
|
|
127
|
+
overflow: visible;
|
|
104
128
|
}
|
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
}
|
|
7
7
|
.g-aikit-base-message_variant_user {
|
|
8
8
|
align-items: flex-end;
|
|
9
|
+
min-width: 0;
|
|
9
10
|
max-width: 90%;
|
|
10
11
|
}
|
|
11
12
|
.g-aikit-base-message_variant_system, .g-aikit-base-message_variant_assistant {
|
|
12
13
|
align-items: flex-start;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
max-width: 100%;
|
|
13
16
|
}
|
|
14
17
|
.g-aikit-base-message_btn-hover .g-aikit-base-message__actions {
|
|
15
18
|
visibility: hidden;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
min-height: 0;
|
|
7
|
+
min-width: 0;
|
|
7
8
|
flex: 1;
|
|
8
9
|
align-self: stretch;
|
|
9
10
|
}
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
display: flex;
|
|
12
13
|
flex-direction: column;
|
|
13
14
|
gap: var(--g-spacing-4);
|
|
15
|
+
min-width: 0;
|
|
14
16
|
}
|
|
15
17
|
.g-aikit-message-list_virtualized {
|
|
16
18
|
overflow: hidden;
|
|
@@ -19,6 +19,7 @@ function useMarkdownTransform(content, options) {
|
|
|
19
19
|
cacheRef.current.clear();
|
|
20
20
|
prevOptionsRef.current = options;
|
|
21
21
|
}
|
|
22
|
+
const transformOptions = (0, markdownUtils_1.mergeMarkdownTransformOptions)(options);
|
|
22
23
|
try {
|
|
23
24
|
const blocks = (0, parse_blocks_1.parseMarkdownIntoBlocks)(content);
|
|
24
25
|
const cache = cacheRef.current;
|
|
@@ -27,7 +28,7 @@ function useMarkdownTransform(content, options) {
|
|
|
27
28
|
let html = cache.get(block);
|
|
28
29
|
if (!html) {
|
|
29
30
|
try {
|
|
30
|
-
const result = (0, transform_1.default)(block,
|
|
31
|
+
const result = (0, transform_1.default)(block, transformOptions);
|
|
31
32
|
html = result.result.html;
|
|
32
33
|
cache.set(block, html);
|
|
33
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMarkdownTransform.js","sourceRoot":"../../../src","sources":["hooks/useMarkdownTransform.ts"],"names":[],"mappings":";;AASA,
|
|
1
|
+
{"version":3,"file":"useMarkdownTransform.js","sourceRoot":"../../../src","sources":["hooks/useMarkdownTransform.ts"],"names":[],"mappings":";;AASA,oDAgDC;;AAzDD,iCAAsC;AAEtC,4EAA4C;AAC5C,8CAA4C;AAG5C,6DAAsF;AACtF,2DAA8D;AAE9D,SAAgB,oBAAoB,CAAC,OAAe,EAAE,OAAqB;IACvE,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAsB,IAAI,GAAG,EAAE,CAAC,CAAC;IACxD,MAAM,cAAc,GAAG,IAAA,cAAM,EAA0B,OAAO,CAAC,CAAC;IAEhE,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAChB,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,cAAc,GAAG,CAAC,IAAA,+BAAe,EAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACzE,IAAI,cAAc,EAAE,CAAC;YACjB,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACzB,cAAc,CAAC,OAAO,GAAG,OAAO,CAAC;QACrC,CAAC;QAED,MAAM,gBAAgB,GAAG,IAAA,6CAA6B,EAAC,OAAO,CAAC,CAAC;QAEhE,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAA,sCAAuB,EAAC,OAAO,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC;YAC/B,MAAM,SAAS,GAAa,EAAE,CAAC;YAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBACzB,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;oBACR,IAAI,CAAC;wBACD,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;wBAClD,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;wBAC1B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAC3B,CAAC;oBAAC,WAAM,CAAC;wBACL,IAAI,GAAG,EAAE,CAAC;oBACd,CAAC;gBACL,CAAC;gBACD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YAED,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;YACzC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC7B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC7B,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACtB,CAAC;YACL,CAAC;YAED,OAAO,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,CAAC;QAAC,WAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import {useMemo, useRef} from 'react';\n\nimport transform from '@diplodoc/transform';\nimport '@diplodoc/transform/dist/js/yfm.js';\nimport {OptionsType} from '@diplodoc/transform/lib/typings';\n\nimport {areOptionsEqual, mergeMarkdownTransformOptions} from '../utils/markdownUtils';\nimport {parseMarkdownIntoBlocks} from '../utils/parse-blocks';\n\nexport function useMarkdownTransform(content: string, options?: OptionsType): string {\n const cacheRef = useRef<Map<string, string>>(new Map());\n const prevOptionsRef = useRef<OptionsType | undefined>(options);\n\n return useMemo(() => {\n if (!content) {\n return '';\n }\n\n const optionsChanged = !areOptionsEqual(prevOptionsRef.current, options);\n if (optionsChanged) {\n cacheRef.current.clear();\n prevOptionsRef.current = options;\n }\n\n const transformOptions = mergeMarkdownTransformOptions(options);\n\n try {\n const blocks = parseMarkdownIntoBlocks(content);\n const cache = cacheRef.current;\n const htmlParts: string[] = [];\n\n for (const block of blocks) {\n let html = cache.get(block);\n if (!html) {\n try {\n const result = transform(block, transformOptions);\n html = result.result.html;\n cache.set(block, html);\n } catch {\n html = '';\n }\n }\n htmlParts.push(html);\n }\n\n const currentBlocksSet = new Set(blocks);\n for (const key of cache.keys()) {\n if (!currentBlocksSet.has(key)) {\n cache.delete(key);\n }\n }\n\n return htmlParts.join('');\n } catch {\n return '';\n }\n }, [content, options]);\n}\n"]}
|
package/build/cjs/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.9.
|
|
1
|
+
{"version":"2.9.2","type":"commonjs","sideEffects":["*.css","*.scss"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtendedPluginWithCollect } from '@diplodoc/transform/lib/typings';
|
|
2
|
+
/** Matches `.g-aikit-markdown-renderer__table-wrap` in MarkdownRenderer.scss */
|
|
3
|
+
export declare const MARKDOWN_TABLE_WRAP_CLASS = "g-aikit-markdown-renderer__table-wrap";
|
|
4
|
+
export declare const markdownTableWrapPlugin: ExtendedPluginWithCollect;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.markdownTableWrapPlugin = exports.MARKDOWN_TABLE_WRAP_CLASS = void 0;
|
|
4
|
+
const cn_1 = require("./cn.js");
|
|
5
|
+
/** Matches `.g-aikit-markdown-renderer__table-wrap` in MarkdownRenderer.scss */
|
|
6
|
+
exports.MARKDOWN_TABLE_WRAP_CLASS = `${cn_1.NAMESPACE}markdown-renderer__table-wrap`;
|
|
7
|
+
function wrapTableRendererRules(md, openRule, closeRule) {
|
|
8
|
+
const defaultTableOpen = md.renderer.rules[openRule] ||
|
|
9
|
+
function (tokens, idx, options, _env, self) {
|
|
10
|
+
return self.renderToken(tokens, idx, options);
|
|
11
|
+
};
|
|
12
|
+
const defaultTableClose = md.renderer.rules[closeRule] ||
|
|
13
|
+
function (tokens, idx, options, _env, self) {
|
|
14
|
+
return self.renderToken(tokens, idx, options);
|
|
15
|
+
};
|
|
16
|
+
// eslint-disable-next-line no-param-reassign
|
|
17
|
+
md.renderer.rules[openRule] = function (tokens, idx, options, env, self) {
|
|
18
|
+
return `<div class="${exports.MARKDOWN_TABLE_WRAP_CLASS}">${defaultTableOpen(tokens, idx, options, env, self)}`;
|
|
19
|
+
};
|
|
20
|
+
// eslint-disable-next-line no-param-reassign
|
|
21
|
+
md.renderer.rules[closeRule] = function (tokens, idx, options, env, self) {
|
|
22
|
+
return `${defaultTableClose(tokens, idx, options, env, self)}</div>`;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.markdownTableWrapPlugin = ((md) => {
|
|
26
|
+
wrapTableRendererRules(md, 'table_open', 'table_close');
|
|
27
|
+
wrapTableRendererRules(md, 'yfm_table_open', 'yfm_table_close');
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=markdownTableWrapPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownTableWrapPlugin.js","sourceRoot":"../../../src","sources":["utils/markdownTableWrapPlugin.ts"],"names":[],"mappings":";;;AAEA,gCAA+B;AAE/B,gFAAgF;AACnE,QAAA,yBAAyB,GAAG,GAAG,cAAS,+BAA+B,CAAC;AAKrF,SAAS,sBAAsB,CAC3B,EAAc,EACd,QAAuB,EACvB,SAAyB;IAEzB,MAAM,gBAAgB,GAClB,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC3B,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;YACtC,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC,CAAC;IAEN,MAAM,iBAAiB,GACnB,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;QAC5B,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;YACtC,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC,CAAC;IAEN,6CAA6C;IAC7C,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI;QACnE,OAAO,eAAe,iCAAyB,KAAK,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;IAC5G,CAAC,CAAC;IAEF,6CAA6C;IAC7C,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI;QACpE,OAAO,GAAG,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC;IACzE,CAAC,CAAC;AACN,CAAC;AAEY,QAAA,uBAAuB,GAA8B,CAAC,CAAC,EAAc,EAAE,EAAE;IAClF,sBAAsB,CAAC,EAAE,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;IACxD,sBAAsB,CAAC,EAAE,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AACpE,CAAC,CAA8B,CAAC","sourcesContent":["import type {ExtendedPluginWithCollect, MarkdownIt} from '@diplodoc/transform/lib/typings';\n\nimport {NAMESPACE} from './cn';\n\n/** Matches `.g-aikit-markdown-renderer__table-wrap` in MarkdownRenderer.scss */\nexport const MARKDOWN_TABLE_WRAP_CLASS = `${NAMESPACE}markdown-renderer__table-wrap`;\n\ntype TableOpenRule = 'table_open' | 'yfm_table_open';\ntype TableCloseRule = 'table_close' | 'yfm_table_close';\n\nfunction wrapTableRendererRules(\n md: MarkdownIt,\n openRule: TableOpenRule,\n closeRule: TableCloseRule,\n): void {\n const defaultTableOpen =\n md.renderer.rules[openRule] ||\n function (tokens, idx, options, _env, self) {\n return self.renderToken(tokens, idx, options);\n };\n\n const defaultTableClose =\n md.renderer.rules[closeRule] ||\n function (tokens, idx, options, _env, self) {\n return self.renderToken(tokens, idx, options);\n };\n\n // eslint-disable-next-line no-param-reassign\n md.renderer.rules[openRule] = function (tokens, idx, options, env, self) {\n return `<div class=\"${MARKDOWN_TABLE_WRAP_CLASS}\">${defaultTableOpen(tokens, idx, options, env, self)}`;\n };\n\n // eslint-disable-next-line no-param-reassign\n md.renderer.rules[closeRule] = function (tokens, idx, options, env, self) {\n return `${defaultTableClose(tokens, idx, options, env, self)}</div>`;\n };\n}\n\nexport const markdownTableWrapPlugin: ExtendedPluginWithCollect = ((md: MarkdownIt) => {\n wrapTableRendererRules(md, 'table_open', 'table_close');\n wrapTableRendererRules(md, 'yfm_table_open', 'yfm_table_close');\n}) as ExtendedPluginWithCollect;\n"]}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { OptionsType } from '@diplodoc/transform/lib/typings';
|
|
2
2
|
export declare function areOptionsEqual(prev?: OptionsType, next?: OptionsType): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Prepends AIKit table-wrap plugin and restores @diplodoc/transform defaults.
|
|
5
|
+
* Explicit `plugins` in transform options replace defaults — user plugins are appended after.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mergeMarkdownTransformOptions(options?: OptionsType): OptionsType;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.areOptionsEqual = areOptionsEqual;
|
|
4
|
+
exports.mergeMarkdownTransformOptions = mergeMarkdownTransformOptions;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const plugins_1 = tslib_1.__importDefault(require("@diplodoc/transform/lib/plugins"));
|
|
7
|
+
const markdownTableWrapPlugin_1 = require("./markdownTableWrapPlugin.js");
|
|
4
8
|
function areOptionsEqual(prev, next) {
|
|
5
9
|
if (prev === next) {
|
|
6
10
|
return true;
|
|
@@ -20,4 +24,13 @@ function areOptionsEqual(prev, next) {
|
|
|
20
24
|
}
|
|
21
25
|
return true;
|
|
22
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Prepends AIKit table-wrap plugin and restores @diplodoc/transform defaults.
|
|
29
|
+
* Explicit `plugins` in transform options replace defaults — user plugins are appended after.
|
|
30
|
+
*/
|
|
31
|
+
function mergeMarkdownTransformOptions(options) {
|
|
32
|
+
var _a;
|
|
33
|
+
const userPlugins = (_a = options === null || options === void 0 ? void 0 : options.plugins) !== null && _a !== void 0 ? _a : [];
|
|
34
|
+
return Object.assign(Object.assign({}, options), { plugins: [markdownTableWrapPlugin_1.markdownTableWrapPlugin, ...plugins_1.default, ...userPlugins] });
|
|
35
|
+
}
|
|
23
36
|
//# sourceMappingURL=markdownUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownUtils.js","sourceRoot":"../../../src","sources":["utils/markdownUtils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"markdownUtils.js","sourceRoot":"../../../src","sources":["utils/markdownUtils.ts"],"names":[],"mappings":";;AAKA,0CAkBC;AAMD,sEAOC;;AApCD,sFAAsE;AAGtE,0EAAkE;AAElE,SAAgB,eAAe,CAAC,IAAkB,EAAE,IAAkB;IAClE,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,OAAqB;;IAC/D,MAAM,WAAW,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,EAAE,CAAC;IAE3C,uCACO,OAAO,KACV,OAAO,EAAE,CAAC,iDAAuB,EAAE,GAAG,iBAAuB,EAAE,GAAG,WAAW,CAAC,IAChF;AACN,CAAC","sourcesContent":["import defaultTransformPlugins from '@diplodoc/transform/lib/plugins';\nimport {OptionsType} from '@diplodoc/transform/lib/typings';\n\nimport {markdownTableWrapPlugin} from './markdownTableWrapPlugin';\n\nexport function areOptionsEqual(prev?: OptionsType, next?: OptionsType): boolean {\n if (prev === next) {\n return true;\n }\n if (!prev || !next) {\n return false;\n }\n const prevKeys = Object.keys(prev);\n const nextKeys = Object.keys(next);\n if (prevKeys.length !== nextKeys.length) {\n return false;\n }\n for (const key of prevKeys) {\n if (prev[key] !== next[key]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Prepends AIKit table-wrap plugin and restores @diplodoc/transform defaults.\n * Explicit `plugins` in transform options replace defaults — user plugins are appended after.\n */\nexport function mergeMarkdownTransformOptions(options?: OptionsType): OptionsType {\n const userPlugins = options?.plugins ?? [];\n\n return {\n ...options,\n plugins: [markdownTableWrapPlugin, ...defaultTransformPlugins, ...userPlugins],\n };\n}\n"]}
|
|
@@ -87,18 +87,42 @@
|
|
|
87
87
|
display: none;
|
|
88
88
|
}
|
|
89
89
|
.g-aikit-markdown-renderer {
|
|
90
|
+
width: 100%;
|
|
90
91
|
max-width: 100%;
|
|
92
|
+
min-width: 0;
|
|
93
|
+
/* Scroll container injected by markdownTableWrapPlugin; text outside stays fixed */
|
|
94
|
+
}
|
|
95
|
+
.g-aikit-markdown-renderer__table-wrap {
|
|
96
|
+
width: 100%;
|
|
97
|
+
max-width: 100%;
|
|
98
|
+
min-width: 0;
|
|
91
99
|
overflow-x: auto;
|
|
92
|
-
|
|
100
|
+
}
|
|
101
|
+
.g-aikit-markdown-renderer {
|
|
102
|
+
/*
|
|
103
|
+
* Override @diplodoc/transform `.yfm table` (inline-block + max-width: 100%).
|
|
104
|
+
* min-width: 100% — narrow tables fill the message; width: max-content — columns size to content.
|
|
105
|
+
*/
|
|
93
106
|
}
|
|
94
107
|
.g-aikit-markdown-renderer table {
|
|
108
|
+
display: table;
|
|
95
109
|
table-layout: auto;
|
|
96
110
|
word-break: normal;
|
|
97
|
-
min-width: 100%;
|
|
98
111
|
width: max-content;
|
|
112
|
+
min-width: 100%;
|
|
113
|
+
max-width: none;
|
|
114
|
+
overflow: visible;
|
|
99
115
|
}
|
|
100
|
-
.g-aikit-markdown-renderer th
|
|
101
|
-
.g-aikit-markdown-renderer td {
|
|
116
|
+
.g-aikit-markdown-renderer table th {
|
|
102
117
|
word-break: normal;
|
|
103
118
|
white-space: nowrap;
|
|
119
|
+
overflow: visible;
|
|
120
|
+
}
|
|
121
|
+
.g-aikit-markdown-renderer table td {
|
|
122
|
+
max-width: var(--g-aikit-markdown-renderer-table-cell-max-width);
|
|
123
|
+
word-break: normal;
|
|
124
|
+
white-space: normal;
|
|
125
|
+
/* Wrap multi-word text at spaces within max-width */
|
|
126
|
+
overflow-wrap: normal;
|
|
127
|
+
overflow: visible;
|
|
104
128
|
}
|
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
}
|
|
7
7
|
.g-aikit-base-message_variant_user {
|
|
8
8
|
align-items: flex-end;
|
|
9
|
+
min-width: 0;
|
|
9
10
|
max-width: 90%;
|
|
10
11
|
}
|
|
11
12
|
.g-aikit-base-message_variant_system, .g-aikit-base-message_variant_assistant {
|
|
12
13
|
align-items: flex-start;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
max-width: 100%;
|
|
13
16
|
}
|
|
14
17
|
.g-aikit-base-message_btn-hover .g-aikit-base-message__actions {
|
|
15
18
|
visibility: hidden;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
min-height: 0;
|
|
7
|
+
min-width: 0;
|
|
7
8
|
flex: 1;
|
|
8
9
|
align-self: stretch;
|
|
9
10
|
}
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
display: flex;
|
|
12
13
|
flex-direction: column;
|
|
13
14
|
gap: var(--g-spacing-4);
|
|
15
|
+
min-width: 0;
|
|
14
16
|
}
|
|
15
17
|
.g-aikit-message-list_virtualized {
|
|
16
18
|
overflow: hidden;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo, useRef } from 'react';
|
|
2
2
|
import transform from '@diplodoc/transform';
|
|
3
3
|
import '@diplodoc/transform/dist/js/yfm.js';
|
|
4
|
-
import { areOptionsEqual } from "../utils/markdownUtils.js";
|
|
4
|
+
import { areOptionsEqual, mergeMarkdownTransformOptions } from "../utils/markdownUtils.js";
|
|
5
5
|
import { parseMarkdownIntoBlocks } from "../utils/parse-blocks.js";
|
|
6
6
|
export function useMarkdownTransform(content, options) {
|
|
7
7
|
const cacheRef = useRef(new Map());
|
|
@@ -15,6 +15,7 @@ export function useMarkdownTransform(content, options) {
|
|
|
15
15
|
cacheRef.current.clear();
|
|
16
16
|
prevOptionsRef.current = options;
|
|
17
17
|
}
|
|
18
|
+
const transformOptions = mergeMarkdownTransformOptions(options);
|
|
18
19
|
try {
|
|
19
20
|
const blocks = parseMarkdownIntoBlocks(content);
|
|
20
21
|
const cache = cacheRef.current;
|
|
@@ -23,7 +24,7 @@ export function useMarkdownTransform(content, options) {
|
|
|
23
24
|
let html = cache.get(block);
|
|
24
25
|
if (!html) {
|
|
25
26
|
try {
|
|
26
|
-
const result = transform(block,
|
|
27
|
+
const result = transform(block, transformOptions);
|
|
27
28
|
html = result.result.html;
|
|
28
29
|
cache.set(block, html);
|
|
29
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMarkdownTransform.js","sourceRoot":"../../../src","sources":["hooks/useMarkdownTransform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAEtC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,oCAAoC,CAAC;AAG5C,OAAO,EAAC,eAAe,EAAC,kCAA+B;
|
|
1
|
+
{"version":3,"file":"useMarkdownTransform.js","sourceRoot":"../../../src","sources":["hooks/useMarkdownTransform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAEtC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,oCAAoC,CAAC;AAG5C,OAAO,EAAC,eAAe,EAAE,6BAA6B,EAAC,kCAA+B;AACtF,OAAO,EAAC,uBAAuB,EAAC,iCAA8B;AAE9D,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,OAAqB;IACvE,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,GAAG,EAAE,CAAC,CAAC;IACxD,MAAM,cAAc,GAAG,MAAM,CAA0B,OAAO,CAAC,CAAC;IAEhE,OAAO,OAAO,CAAC,GAAG,EAAE;QAChB,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,cAAc,GAAG,CAAC,eAAe,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACzE,IAAI,cAAc,EAAE,CAAC;YACjB,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACzB,cAAc,CAAC,OAAO,GAAG,OAAO,CAAC;QACrC,CAAC;QAED,MAAM,gBAAgB,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;QAEhE,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC;YAC/B,MAAM,SAAS,GAAa,EAAE,CAAC;YAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBACzB,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;oBACR,IAAI,CAAC;wBACD,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;wBAClD,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;wBAC1B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAC3B,CAAC;oBAAC,WAAM,CAAC;wBACL,IAAI,GAAG,EAAE,CAAC;oBACd,CAAC;gBACL,CAAC;gBACD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YAED,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;YACzC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC7B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC7B,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACtB,CAAC;YACL,CAAC;YAED,OAAO,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,CAAC;QAAC,WAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import {useMemo, useRef} from 'react';\n\nimport transform from '@diplodoc/transform';\nimport '@diplodoc/transform/dist/js/yfm.js';\nimport {OptionsType} from '@diplodoc/transform/lib/typings';\n\nimport {areOptionsEqual, mergeMarkdownTransformOptions} from '../utils/markdownUtils';\nimport {parseMarkdownIntoBlocks} from '../utils/parse-blocks';\n\nexport function useMarkdownTransform(content: string, options?: OptionsType): string {\n const cacheRef = useRef<Map<string, string>>(new Map());\n const prevOptionsRef = useRef<OptionsType | undefined>(options);\n\n return useMemo(() => {\n if (!content) {\n return '';\n }\n\n const optionsChanged = !areOptionsEqual(prevOptionsRef.current, options);\n if (optionsChanged) {\n cacheRef.current.clear();\n prevOptionsRef.current = options;\n }\n\n const transformOptions = mergeMarkdownTransformOptions(options);\n\n try {\n const blocks = parseMarkdownIntoBlocks(content);\n const cache = cacheRef.current;\n const htmlParts: string[] = [];\n\n for (const block of blocks) {\n let html = cache.get(block);\n if (!html) {\n try {\n const result = transform(block, transformOptions);\n html = result.result.html;\n cache.set(block, html);\n } catch {\n html = '';\n }\n }\n htmlParts.push(html);\n }\n\n const currentBlocksSet = new Set(blocks);\n for (const key of cache.keys()) {\n if (!currentBlocksSet.has(key)) {\n cache.delete(key);\n }\n }\n\n return htmlParts.join('');\n } catch {\n return '';\n }\n }, [content, options]);\n}\n"]}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.9.
|
|
1
|
+
{"version":"2.9.2","type":"module","sideEffects":["*.css","*.scss"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtendedPluginWithCollect } from '@diplodoc/transform/lib/typings';
|
|
2
|
+
/** Matches `.g-aikit-markdown-renderer__table-wrap` in MarkdownRenderer.scss */
|
|
3
|
+
export declare const MARKDOWN_TABLE_WRAP_CLASS = "g-aikit-markdown-renderer__table-wrap";
|
|
4
|
+
export declare const markdownTableWrapPlugin: ExtendedPluginWithCollect;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NAMESPACE } from "./cn.js";
|
|
2
|
+
/** Matches `.g-aikit-markdown-renderer__table-wrap` in MarkdownRenderer.scss */
|
|
3
|
+
export const MARKDOWN_TABLE_WRAP_CLASS = `${NAMESPACE}markdown-renderer__table-wrap`;
|
|
4
|
+
function wrapTableRendererRules(md, openRule, closeRule) {
|
|
5
|
+
const defaultTableOpen = md.renderer.rules[openRule] ||
|
|
6
|
+
function (tokens, idx, options, _env, self) {
|
|
7
|
+
return self.renderToken(tokens, idx, options);
|
|
8
|
+
};
|
|
9
|
+
const defaultTableClose = md.renderer.rules[closeRule] ||
|
|
10
|
+
function (tokens, idx, options, _env, self) {
|
|
11
|
+
return self.renderToken(tokens, idx, options);
|
|
12
|
+
};
|
|
13
|
+
// eslint-disable-next-line no-param-reassign
|
|
14
|
+
md.renderer.rules[openRule] = function (tokens, idx, options, env, self) {
|
|
15
|
+
return `<div class="${MARKDOWN_TABLE_WRAP_CLASS}">${defaultTableOpen(tokens, idx, options, env, self)}`;
|
|
16
|
+
};
|
|
17
|
+
// eslint-disable-next-line no-param-reassign
|
|
18
|
+
md.renderer.rules[closeRule] = function (tokens, idx, options, env, self) {
|
|
19
|
+
return `${defaultTableClose(tokens, idx, options, env, self)}</div>`;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export const markdownTableWrapPlugin = ((md) => {
|
|
23
|
+
wrapTableRendererRules(md, 'table_open', 'table_close');
|
|
24
|
+
wrapTableRendererRules(md, 'yfm_table_open', 'yfm_table_close');
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=markdownTableWrapPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownTableWrapPlugin.js","sourceRoot":"../../../src","sources":["utils/markdownTableWrapPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,gBAAa;AAE/B,gFAAgF;AAChF,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,SAAS,+BAA+B,CAAC;AAKrF,SAAS,sBAAsB,CAC3B,EAAc,EACd,QAAuB,EACvB,SAAyB;IAEzB,MAAM,gBAAgB,GAClB,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC3B,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;YACtC,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC,CAAC;IAEN,MAAM,iBAAiB,GACnB,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;QAC5B,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;YACtC,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC,CAAC;IAEN,6CAA6C;IAC7C,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI;QACnE,OAAO,eAAe,yBAAyB,KAAK,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;IAC5G,CAAC,CAAC;IAEF,6CAA6C;IAC7C,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,UAAU,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI;QACpE,OAAO,GAAG,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC;IACzE,CAAC,CAAC;AACN,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAA8B,CAAC,CAAC,EAAc,EAAE,EAAE;IAClF,sBAAsB,CAAC,EAAE,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;IACxD,sBAAsB,CAAC,EAAE,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AACpE,CAAC,CAA8B,CAAC","sourcesContent":["import type {ExtendedPluginWithCollect, MarkdownIt} from '@diplodoc/transform/lib/typings';\n\nimport {NAMESPACE} from './cn';\n\n/** Matches `.g-aikit-markdown-renderer__table-wrap` in MarkdownRenderer.scss */\nexport const MARKDOWN_TABLE_WRAP_CLASS = `${NAMESPACE}markdown-renderer__table-wrap`;\n\ntype TableOpenRule = 'table_open' | 'yfm_table_open';\ntype TableCloseRule = 'table_close' | 'yfm_table_close';\n\nfunction wrapTableRendererRules(\n md: MarkdownIt,\n openRule: TableOpenRule,\n closeRule: TableCloseRule,\n): void {\n const defaultTableOpen =\n md.renderer.rules[openRule] ||\n function (tokens, idx, options, _env, self) {\n return self.renderToken(tokens, idx, options);\n };\n\n const defaultTableClose =\n md.renderer.rules[closeRule] ||\n function (tokens, idx, options, _env, self) {\n return self.renderToken(tokens, idx, options);\n };\n\n // eslint-disable-next-line no-param-reassign\n md.renderer.rules[openRule] = function (tokens, idx, options, env, self) {\n return `<div class=\"${MARKDOWN_TABLE_WRAP_CLASS}\">${defaultTableOpen(tokens, idx, options, env, self)}`;\n };\n\n // eslint-disable-next-line no-param-reassign\n md.renderer.rules[closeRule] = function (tokens, idx, options, env, self) {\n return `${defaultTableClose(tokens, idx, options, env, self)}</div>`;\n };\n}\n\nexport const markdownTableWrapPlugin: ExtendedPluginWithCollect = ((md: MarkdownIt) => {\n wrapTableRendererRules(md, 'table_open', 'table_close');\n wrapTableRendererRules(md, 'yfm_table_open', 'yfm_table_close');\n}) as ExtendedPluginWithCollect;\n"]}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { OptionsType } from '@diplodoc/transform/lib/typings';
|
|
2
2
|
export declare function areOptionsEqual(prev?: OptionsType, next?: OptionsType): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Prepends AIKit table-wrap plugin and restores @diplodoc/transform defaults.
|
|
5
|
+
* Explicit `plugins` in transform options replace defaults — user plugins are appended after.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mergeMarkdownTransformOptions(options?: OptionsType): OptionsType;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import defaultTransformPlugins from '@diplodoc/transform/lib/plugins';
|
|
2
|
+
import { markdownTableWrapPlugin } from "./markdownTableWrapPlugin.js";
|
|
1
3
|
export function areOptionsEqual(prev, next) {
|
|
2
4
|
if (prev === next) {
|
|
3
5
|
return true;
|
|
@@ -17,4 +19,13 @@ export function areOptionsEqual(prev, next) {
|
|
|
17
19
|
}
|
|
18
20
|
return true;
|
|
19
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Prepends AIKit table-wrap plugin and restores @diplodoc/transform defaults.
|
|
24
|
+
* Explicit `plugins` in transform options replace defaults — user plugins are appended after.
|
|
25
|
+
*/
|
|
26
|
+
export function mergeMarkdownTransformOptions(options) {
|
|
27
|
+
var _a;
|
|
28
|
+
const userPlugins = (_a = options === null || options === void 0 ? void 0 : options.plugins) !== null && _a !== void 0 ? _a : [];
|
|
29
|
+
return Object.assign(Object.assign({}, options), { plugins: [markdownTableWrapPlugin, ...defaultTransformPlugins, ...userPlugins] });
|
|
30
|
+
}
|
|
20
31
|
//# sourceMappingURL=markdownUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownUtils.js","sourceRoot":"../../../src","sources":["utils/markdownUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdownUtils.js","sourceRoot":"../../../src","sources":["utils/markdownUtils.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAC,uBAAuB,EAAC,qCAAkC;AAElE,MAAM,UAAU,eAAe,CAAC,IAAkB,EAAE,IAAkB;IAClE,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAqB;;IAC/D,MAAM,WAAW,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,EAAE,CAAC;IAE3C,uCACO,OAAO,KACV,OAAO,EAAE,CAAC,uBAAuB,EAAE,GAAG,uBAAuB,EAAE,GAAG,WAAW,CAAC,IAChF;AACN,CAAC","sourcesContent":["import defaultTransformPlugins from '@diplodoc/transform/lib/plugins';\nimport {OptionsType} from '@diplodoc/transform/lib/typings';\n\nimport {markdownTableWrapPlugin} from './markdownTableWrapPlugin';\n\nexport function areOptionsEqual(prev?: OptionsType, next?: OptionsType): boolean {\n if (prev === next) {\n return true;\n }\n if (!prev || !next) {\n return false;\n }\n const prevKeys = Object.keys(prev);\n const nextKeys = Object.keys(next);\n if (prevKeys.length !== nextKeys.length) {\n return false;\n }\n for (const key of prevKeys) {\n if (prev[key] !== next[key]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Prepends AIKit table-wrap plugin and restores @diplodoc/transform defaults.\n * Explicit `plugins` in transform options replace defaults — user plugins are appended after.\n */\nexport function mergeMarkdownTransformOptions(options?: OptionsType): OptionsType {\n const userPlugins = options?.plugins ?? [];\n\n return {\n ...options,\n plugins: [markdownTableWrapPlugin, ...defaultTransformPlugins, ...userPlugins],\n };\n}\n"]}
|