@gitlab/ui 66.35.0 → 66.35.1

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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [66.35.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v66.35.0...v66.35.1) (2023-10-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlDuoChatMessage:** nextTick() when rendering GFM ([835900c](https://gitlab.com/gitlab-org/gitlab-ui/commit/835900cb9cf01e26b4e24120be3abc6f48c3c371))
7
+
1
8
  # [66.35.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v66.34.0...v66.35.0) (2023-10-20)
2
9
 
3
10
 
@@ -1,3 +1,4 @@
1
+ import { nextTick } from 'vue';
1
2
  import GlDuoUserFeedback from '../../../user_feedback/user_feedback';
2
3
  import { SafeHtmlDirective } from '../../../../../../directives/safe_html/safe_html';
3
4
  import { MESSAGE_MODEL_ROLES } from '../../constants';
@@ -60,7 +61,7 @@ var script = {
60
61
  if (!chunkId) {
61
62
  this.messageChunks = [];
62
63
  this.messageContent = this.content;
63
- this.renderGFM(this.$refs.content);
64
+ this.hydrateContentWithGFM();
64
65
  } else {
65
66
  this.messageChunks[chunkId] = content;
66
67
  this.messageContent = this.renderMarkdown(concatIndicesUntilEmpty(this.messageChunks));
@@ -81,7 +82,13 @@ var script = {
81
82
  if (this.message.chunkId) {
82
83
  this.messageChunks[this.message.chunkId] = this.message.content;
83
84
  }
84
- this.renderGFM(this.$refs.content);
85
+ this.hydrateContentWithGFM();
86
+ },
87
+ methods: {
88
+ async hydrateContentWithGFM() {
89
+ await nextTick();
90
+ this.renderGFM(this.$refs.content);
91
+ }
85
92
  }
86
93
  };
87
94
 
@@ -80,5 +80,12 @@ const MOCK_USER_PROMPT_MESSAGE = {
80
80
  timestamp: '2021-04-21T12:00:00.000Z',
81
81
  extras: null
82
82
  };
83
+ const renderMarkdown = content => content;
84
+ const renderGFM = el => {
85
+ const codeBlock = el.querySelectorAll('.markdown-code-block');
86
+ codeBlock.forEach(block => {
87
+ block === null || block === void 0 ? void 0 : block.classList.add('gl-bg-purple-50', 'gl-p-3', 'gl-mb-3');
88
+ });
89
+ };
83
90
 
84
- export { MOCK_CHUNK_RESPONSE_MESSAGE, MOCK_RESPONSE_MESSAGE, MOCK_RESPONSE_MESSAGE_FOR_STREAMING, MOCK_USER_PROMPT_MESSAGE, generateMockResponseChunks };
91
+ export { MOCK_CHUNK_RESPONSE_MESSAGE, MOCK_RESPONSE_MESSAGE, MOCK_RESPONSE_MESSAGE_FOR_STREAMING, MOCK_USER_PROMPT_MESSAGE, generateMockResponseChunks, renderGFM, renderMarkdown };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 20 Oct 2023 08:03:38 GMT
3
+ * Generated on Fri, 20 Oct 2023 18:59:55 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 20 Oct 2023 08:03:38 GMT
3
+ * Generated on Fri, 20 Oct 2023 18:59:55 GMT
4
4
  */
5
5
 
6
6
  :root.gl-dark {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 20 Oct 2023 08:03:38 GMT
3
+ * Generated on Fri, 20 Oct 2023 18:59:55 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#fff";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Fri, 20 Oct 2023 08:03:38 GMT
3
+ * Generated on Fri, 20 Oct 2023 18:59:55 GMT
4
4
  */
5
5
 
6
6
  export const BLACK = "#000";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Fri, 20 Oct 2023 08:03:38 GMT
3
+ // Generated on Fri, 20 Oct 2023 18:59:55 GMT
4
4
 
5
5
  $red-950: #fff4f3;
6
6
  $red-900: #fcf1ef;
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Fri, 20 Oct 2023 08:03:38 GMT
3
+ // Generated on Fri, 20 Oct 2023 18:59:55 GMT
4
4
 
5
5
  $gl-line-height-52: 3.25rem;
6
6
  $gl-line-height-44: 2.75rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "66.35.0",
3
+ "version": "66.35.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -1,10 +1,13 @@
1
- import { MOCK_USER_PROMPT_MESSAGE, MOCK_RESPONSE_MESSAGE } from '../../mock_data';
1
+ import {
2
+ MOCK_USER_PROMPT_MESSAGE,
3
+ MOCK_RESPONSE_MESSAGE,
4
+ renderGFM,
5
+ renderMarkdown,
6
+ } from '../../mock_data';
2
7
  import GlDuoChatConversation from './duo_chat_conversation.vue';
3
8
  import readme from './duo_chat_conversation.md';
4
9
 
5
10
  const defaultValue = (prop) => GlDuoChatConversation.props[prop].default;
6
- const renderMarkdown = (content) => content;
7
- const renderGFM = () => {};
8
11
 
9
12
  const generateProps = ({ messages = [], showDelimiter = defaultValue('showDelimiter') } = {}) => ({
10
13
  messages,
@@ -109,8 +109,9 @@ describe('DuoChatMessage', () => {
109
109
  });
110
110
 
111
111
  describe('message output', () => {
112
- it('hydrates the message with GLFM when mounting the component', () => {
112
+ it('hydrates the message with GLFM when mounting the component', async () => {
113
113
  createComponent();
114
+ await nextTick();
114
115
  expect(renderGFM).toHaveBeenCalled();
115
116
  });
116
117
 
@@ -327,6 +328,7 @@ describe('DuoChatMessage', () => {
327
328
  message: chunk1,
328
329
  },
329
330
  });
331
+ await nextTick();
330
332
  renderGFM.mockClear();
331
333
  expect(renderGFM).not.toHaveBeenCalled();
332
334
 
@@ -1,10 +1,12 @@
1
- import { MOCK_RESPONSE_MESSAGE, MOCK_USER_PROMPT_MESSAGE } from '../../mock_data';
1
+ import {
2
+ MOCK_RESPONSE_MESSAGE,
3
+ MOCK_USER_PROMPT_MESSAGE,
4
+ renderGFM,
5
+ renderMarkdown,
6
+ } from '../../mock_data';
2
7
  import GlDuoChatMessage from './duo_chat_message.vue';
3
8
  import readme from './duo_chat_message.md';
4
9
 
5
- const renderMarkdown = (content) => content;
6
- const renderGFM = () => {};
7
-
8
10
  const generateProps = ({ message = MOCK_RESPONSE_MESSAGE } = {}) => ({
9
11
  message,
10
12
  });
@@ -1,4 +1,5 @@
1
1
  <script>
2
+ import { nextTick } from 'vue';
2
3
  import GlDuoUserFeedback from '../../../user_feedback/user_feedback.vue';
3
4
  import { SafeHtmlDirective as SafeHtml } from '../../../../../../directives/safe_html/safe_html';
4
5
  import { MESSAGE_MODEL_ROLES } from '../../constants';
@@ -60,7 +61,7 @@ export default {
60
61
  if (!chunkId) {
61
62
  this.messageChunks = [];
62
63
  this.messageContent = this.content;
63
- this.renderGFM(this.$refs.content);
64
+ this.hydrateContentWithGFM();
64
65
  } else {
65
66
  this.messageChunks[chunkId] = content;
66
67
  this.messageContent = this.renderMarkdown(concatIndicesUntilEmpty(this.messageChunks));
@@ -81,7 +82,13 @@ export default {
81
82
  if (this.message.chunkId) {
82
83
  this.messageChunks[this.message.chunkId] = this.message.content;
83
84
  }
84
- this.renderGFM(this.$refs.content);
85
+ this.hydrateContentWithGFM();
86
+ },
87
+ methods: {
88
+ async hydrateContentWithGFM() {
89
+ await nextTick();
90
+ this.renderGFM(this.$refs.content);
91
+ },
85
92
  },
86
93
  };
87
94
  </script>
@@ -8,11 +8,10 @@ import {
8
8
  MOCK_RESPONSE_MESSAGE,
9
9
  MOCK_USER_PROMPT_MESSAGE,
10
10
  generateMockResponseChunks,
11
+ renderGFM,
12
+ renderMarkdown,
11
13
  } from './mock_data';
12
14
 
13
- const renderMarkdown = (content) => content;
14
- const renderGFM = () => {};
15
-
16
15
  const defaultValue = (prop) =>
17
16
  typeof GlDuoChat.props[prop].default === 'function'
18
17
  ? GlDuoChat.props[prop].default()
@@ -94,3 +94,11 @@ export const MOCK_USER_PROMPT_MESSAGE = {
94
94
  timestamp: '2021-04-21T12:00:00.000Z',
95
95
  extras: null,
96
96
  };
97
+
98
+ export const renderMarkdown = (content) => content;
99
+ export const renderGFM = (el) => {
100
+ const codeBlock = el.querySelectorAll('.markdown-code-block');
101
+ codeBlock.forEach((block) => {
102
+ block?.classList.add('gl-bg-purple-50', 'gl-p-3', 'gl-mb-3');
103
+ });
104
+ };