From 48c124a9eb3add93fd5ffeb2019f0c874b2fc919 Mon Sep 17 00:00:00 2001 From: ptdev Date: Sun, 28 Jul 2024 23:57:14 +0100 Subject: [PATCH 1/3] Add "html" prop Sometimes the input already has some html tags (e.g.: p, br, etc) that we want to render as if we were using v-html. This adds a "html" boolean prop that allows that. --- package/text-clamp.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package/text-clamp.vue b/package/text-clamp.vue index f41def6..a61028b 100644 --- a/package/text-clamp.vue +++ b/package/text-clamp.vue @@ -42,12 +42,14 @@ const props = withDefaults( location?: "start" | "middle" | "end"; ellipsis?: string; autoResize?: boolean; + html?: boolean; }>(), { expanded: false, location: "end", ellipsis: "…", autoResize: false, + html: false, } ); const emits = defineEmits<{ @@ -71,7 +73,7 @@ const realMaxHeight = computed(() => { }); const applyChange = () => { - textRef.value && (textRef.value.textContent = realText.value); + textRef.value && (props?.html ? textRef.value.innerHTML = realText.value : textRef.value.textContent = realText.value); }; const update = () => { if (state.localExpanded) return; From 6369edc2195eb5202c269b69f57aaeff7bc0c409 Mon Sep 17 00:00:00 2001 From: ptdev Date: Mon, 29 Jul 2024 00:17:18 +0100 Subject: [PATCH 2/3] Update en-US.ts --- src/plugins/locales/en-US.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/locales/en-US.ts b/src/plugins/locales/en-US.ts index 1981c7a..6e9fce5 100644 --- a/src/plugins/locales/en-US.ts +++ b/src/plugins/locales/en-US.ts @@ -27,6 +27,7 @@ export default { props5: "The location of the ellipsis.", props6: "Whether to observe the root element's size.", props7: "Whether the clamped area is expanded(Supports .sync modifier).", + props8: "Used to render any html on the string. Use only with trusted input.", api2: "↓ Slots", beforeScope: "Slot scope: ", From 6e7238841d4dfa890aa72f514683155e7d440d9c Mon Sep 17 00:00:00 2001 From: ptdev Date: Mon, 29 Jul 2024 00:18:04 +0100 Subject: [PATCH 3/3] Update App.vue --- src/App.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/App.vue b/src/App.vue index d36fa24..f7f77ab 100644 --- a/src/App.vue +++ b/src/App.vue @@ -334,6 +334,16 @@ import TextClamp from 'vue3-text-clamp'; false

+
  • +

    + html: boolean +

    +

    {{ t("props8") }}

    +

    + {{ t("default") }} + false +

    +