Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "html" prop #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package/text-clamp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand All @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ import TextClamp from 'vue3-text-clamp';
<code>false</code>
</p>
</li>
<li>
<p>
<code>html: boolean</code>
</p>
<p>{{ t("props8") }}</p>
<p>
{{ t("default") }}
<code>false</code>
</p>
</li>
</ul>
<div class="divider text-center" :data-content="t('api2')"></div>
<ul>
Expand Down
1 change: 1 addition & 0 deletions src/plugins/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: ",
Expand Down