@gitlab/ui 98.4.0 → 98.5.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/CHANGELOG.md +7 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/constants.js +5 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +24 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/package.json +2 -2
- package/src/components/experimental/duo/chat/components/duo_chat_message/constants.js +3 -0
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.scss +31 -2
- package/src/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.vue +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [98.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v98.4.0...v98.5.0) (2024-10-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **DuoChatMessage:** add max height for code blocks in messages ([4493ca9](https://gitlab.com/gitlab-org/gitlab-ui/commit/4493ca9fca716aee2c4fb7b06abe0e90f60aa7e0))
|
|
7
|
+
|
|
1
8
|
# [98.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v98.3.0...v98.4.0) (2024-10-24)
|
|
2
9
|
|
|
3
10
|
|
package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import throttle from 'lodash/throttle';
|
|
1
2
|
import GlIcon from '../../../../../base/icon/icon';
|
|
2
3
|
import GlLoadingIcon from '../../../../../base/loading_icon/loading_icon';
|
|
3
4
|
import { GlTooltipDirective } from '../../../../../../directives/tooltip';
|
|
@@ -13,6 +14,7 @@ import { renderDuoChatMarkdownPreview } from '../../markdown_renderer';
|
|
|
13
14
|
import { CopyCodeElement } from './copy_code_element';
|
|
14
15
|
import { InsertCodeSnippetElement } from './insert_code_snippet_element';
|
|
15
16
|
import { concatUntilEmpty } from './utils';
|
|
17
|
+
import { DUO_CODE_SCRIM_BOTTOM_CLASS, DUO_CODE_SCRIM_OFFSET, DUO_CODE_SCRIM_TOP_CLASS } from './constants';
|
|
16
18
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
17
19
|
|
|
18
20
|
const i18n = {
|
|
@@ -195,6 +197,7 @@ var script = {
|
|
|
195
197
|
if (!this.isChunk && this.$refs.content) {
|
|
196
198
|
this.$nextTick(this.renderGFM(this.$refs.content));
|
|
197
199
|
}
|
|
200
|
+
this.detectScrollableCodeBlocks();
|
|
198
201
|
},
|
|
199
202
|
logEvent(e) {
|
|
200
203
|
this.$emit('track-feedback', {
|
|
@@ -218,6 +221,27 @@ var script = {
|
|
|
218
221
|
messageId: this.message.id,
|
|
219
222
|
contextItem
|
|
220
223
|
});
|
|
224
|
+
},
|
|
225
|
+
detectScrollableCodeBlocks() {
|
|
226
|
+
const codeBlocks = document.querySelectorAll('.duo-chat-message pre');
|
|
227
|
+
codeBlocks.forEach(e => {
|
|
228
|
+
if (e.scrollHeight > e.offsetHeight) {
|
|
229
|
+
e.classList.add(DUO_CODE_SCRIM_BOTTOM_CLASS);
|
|
230
|
+
e.addEventListener('scroll', throttle(() => this.toggleScrolling(e), 200));
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
toggleScrolling(e) {
|
|
235
|
+
if (e.scrollHeight - e.scrollTop <= e.offsetHeight + DUO_CODE_SCRIM_OFFSET) {
|
|
236
|
+
e.classList.remove(DUO_CODE_SCRIM_BOTTOM_CLASS);
|
|
237
|
+
} else {
|
|
238
|
+
e.classList.add(DUO_CODE_SCRIM_BOTTOM_CLASS);
|
|
239
|
+
}
|
|
240
|
+
if (e.scrollTop > DUO_CODE_SCRIM_OFFSET) {
|
|
241
|
+
e.classList.add(DUO_CODE_SCRIM_TOP_CLASS);
|
|
242
|
+
} else {
|
|
243
|
+
e.classList.remove(DUO_CODE_SCRIM_TOP_CLASS);
|
|
244
|
+
}
|
|
221
245
|
}
|
|
222
246
|
}
|
|
223
247
|
};
|