@dev.smartpricing/message-composer-layer 4.3.1 → 4.3.2-fix.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/app/api/client.ts CHANGED
@@ -15,7 +15,9 @@ function assertAppError(data: unknown): data is AppError {
15
15
  export const apiClient = createApiClient({
16
16
  baseURL: useRuntimeConfig().public.COMPOSER_API_URL as string,
17
17
  csrf: {
18
- cookieName: (useRuntimeConfig().public.ENV_CSRF_COOKIE_NAME as string) || 'smt_csrf',
18
+ // Same key and derivation as platform-layer's own client: the host sets the
19
+ // full cookie name (env-suffixed: smt_csrf / smt_csrf_stage / smt_csrf_dev).
20
+ cookieName: (useRuntimeConfig().public.CSRF_COOKIE_NAME as string) || 'smt_csrf',
19
21
  },
20
22
  auth: {
21
23
  refreshBaseURL:
@@ -10,6 +10,7 @@ import type {
10
10
  } from '@dev.smartpricing/message-composer-utils/types'
11
11
  import {
12
12
  buildLinkHTMLAttributes,
13
+ convertToWhatsappHeaderText,
13
14
  convertToWhatsappMarkdown,
14
15
  getTipTapExtensions,
15
16
  sanitizeContent,
@@ -25,7 +26,7 @@ const { t } = useI18n()
25
26
 
26
27
  const props = withDefaults(
27
28
  defineProps<{
28
- preset: 'whatsapp' | 'email'
29
+ preset: 'whatsapp' | 'whatsapp-header' | 'email'
29
30
  characterLimit?: number
30
31
  dynamicValues?: boolean
31
32
  defaultContext?: string
@@ -277,9 +278,12 @@ const toolbarItems = computed(() => {
277
278
  // WhatsApp markdown-aware character count
278
279
  // Meta counts the final markdown output (with *bold*, _italic_ marks),
279
280
  // so we must display that count instead of TipTap's document-model count.
281
+ const isWhatsapp = computed(() => props.preset === 'whatsapp' || props.preset === 'whatsapp-header')
280
282
  const whatsappCharCount = computed(() => {
281
- if (props.preset !== 'whatsapp' || !props.characterLimit || !text.value) return 0
282
- return convertToWhatsappMarkdown(text.value).length
283
+ if (!isWhatsapp.value || !props.characterLimit || !text.value) return 0
284
+ return props.preset === 'whatsapp-header'
285
+ ? convertToWhatsappHeaderText(text.value).length
286
+ : convertToWhatsappMarkdown(text.value).length
283
287
  })
284
288
 
285
289
  // Handlers
@@ -482,7 +486,7 @@ defineExpose({
482
486
  {{ $t('editor.validation.character_limit') }}
483
487
  </span>
484
488
  <span>
485
- {{ preset === 'whatsapp' ? whatsappCharCount : editor.storage.characterCount.characters() }}
489
+ {{ isWhatsapp ? whatsappCharCount : editor.storage.characterCount.characters() }}
486
490
  / {{ characterLimit }}
487
491
  </span>
488
492
  </p>
@@ -112,10 +112,7 @@ function isMultimedia(model: HeaderBlockV1): model is WaHeaderTypeV1Url {
112
112
  <div v-if="model.type === 'text'" class="mt-3">
113
113
  <RichTextEditor
114
114
  v-model:text="model.content"
115
- preset="whatsapp"
116
- bold
117
- italic
118
- emoji
115
+ preset="whatsapp-header"
119
116
  improve
120
117
  :character-limit="WA_HEADER_TEXT_MAX_LENGTH"
121
118
  dynamic-values
@@ -9,6 +9,7 @@ import { computed } from 'vue'
9
9
  import {
10
10
  generateWhatsappHtml,
11
11
  getTipTapExtensions,
12
+ sanitizeContent,
12
13
  } from '@dev.smartpricing/message-composer-utils/utils'
13
14
  import { useResolvedParametersQuery } from '~/queries/compilation'
14
15
 
@@ -51,9 +52,10 @@ const bodyHtml = computed(() => {
51
52
  const headerHtml = computed(() => {
52
53
  if (props.message.body.header.type !== 'text') return ''
53
54
  if (!props.message.body.header.content) return ''
55
+ const extensions = getTipTapExtensions({ preset: 'whatsapp-header' })
54
56
  const html = generateHTML(
55
- props.message.body.header.content,
56
- getTipTapExtensions({ preset: 'whatsapp-header' }),
57
+ sanitizeContent(props.message.body.header.content, extensions),
58
+ extensions,
57
59
  ).replaceAll('<p></p>', '<p>&nbsp;</p>')
58
60
  return replaceMentionsWithValues(html)
59
61
  })
@@ -1,7 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  import type { JSONContent } from '@tiptap/vue-3'
3
3
  import { generateHTML } from '@tiptap/vue-3'
4
- import { getTipTapExtensions } from '@dev.smartpricing/message-composer-utils/utils'
4
+ import {
5
+ getTipTapExtensions,
6
+ sanitizeContent,
7
+ } from '@dev.smartpricing/message-composer-utils/utils'
5
8
  import RichTextEditor from '@/components/Editor/RichTextEditor.vue'
6
9
  import { useAppContextStore } from '@/stores/appContext'
7
10
  import { WA_HEADER_TEXT_MAX_LENGTH } from '@dev.smartpricing/message-composer-utils/types'
@@ -23,7 +26,8 @@ const appContext = useAppContextStore()
23
26
  // Generate HTML for preview of base language with rich text support
24
27
  function generatePreviewHtml(content: JSONContent | undefined): string {
25
28
  if (!content) return ''
26
- return generateHTML(content, getTipTapExtensions({ preset: 'whatsapp-header' })).replaceAll(
29
+ const extensions = getTipTapExtensions({ preset: 'whatsapp-header' })
30
+ return generateHTML(sanitizeContent(content, extensions), extensions).replaceAll(
27
31
  '<p></p>',
28
32
  '<p>&nbsp;</p>',
29
33
  )
@@ -45,10 +49,7 @@ function generatePreviewHtml(content: JSONContent | undefined): string {
45
49
  <div class="flex-1">
46
50
  <RichTextEditor
47
51
  v-model:text="targetContent"
48
- preset="whatsapp"
49
- bold
50
- italic
51
- emoji
52
+ preset="whatsapp-header"
52
53
  dynamic-values
53
54
  :character-limit="WA_HEADER_TEXT_MAX_LENGTH"
54
55
  :data-testid="whatsappTranslatorHeaderTestIds.targetEditor"
package/nuxt.config.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  export default defineNuxtConfig({
2
2
  compatibilityDate: '2025-07-15',
3
3
  ssr: false,
4
- experimental: {
5
- viteEnvironmentApi: true,
6
- },
7
4
  devtools: { enabled: true },
8
5
  imports: {
9
6
  dirs: ['stores', 'queries'],
@@ -57,9 +54,11 @@ export default defineNuxtConfig({
57
54
  runtimeConfig: {
58
55
  public: {
59
56
  COMPOSER_API_URL: '',
57
+ // BACKEND_BASE_URL, PLATFORM_URL and CSRF_COOKIE_NAME are declared by
58
+ // platform-layer (extended above); the host sets them once for both.
60
59
  BACKEND_BASE_URL: '',
61
60
  PLATFORM_URL: '',
62
- ENV_CSRF_COOKIE_NAME: 'smt_csrf',
61
+ CSRF_COOKIE_NAME: '',
63
62
  },
64
63
  },
65
64
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev.smartpricing/message-composer-layer",
3
- "version": "4.3.1",
3
+ "version": "4.3.2-fix.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -12,7 +12,6 @@
12
12
  "app.config.ts"
13
13
  ],
14
14
  "dependencies": {
15
- "@dev.smartpricing/platform-layer": "^0.0.23",
16
15
  "@formkit/drag-and-drop": "^0.5.3",
17
16
  "@pinia/colada": "^1.3.0",
18
17
  "@tiptap/extension-character-count": "^3.23.4",
@@ -36,9 +35,10 @@
36
35
  "vue-router": "^5.0.7",
37
36
  "vue3-emoji-picker": "^1.1.8",
38
37
  "zod": "^4.4.3",
39
- "@dev.smartpricing/message-composer-utils": "4.3.1"
38
+ "@dev.smartpricing/message-composer-utils": "4.3.2-fix.1"
40
39
  },
41
40
  "devDependencies": {
41
+ "@dev.smartpricing/platform-layer": "^0.0.23",
42
42
  "@nuxt/eslint": "^1.15.2",
43
43
  "@nuxt/test-utils": "^4.0.3",
44
44
  "@playwright/test": "^1.60.0",
@@ -48,6 +48,7 @@
48
48
  "vue-tsc": "^3.2.9"
49
49
  },
50
50
  "peerDependencies": {
51
+ "@dev.smartpricing/platform-layer": ">=0.0.20",
51
52
  "nuxt-ui-layer": ">=1.3.0"
52
53
  },
53
54
  "scripts": {