@nextcloud/vue
Version:
Nextcloud vue components
21 lines (20 loc) • 447 B
JavaScript
import linkifyStr from "linkify-string";
const Linkify = (text) => {
return linkifyStr(text, {
defaultProtocol: "https",
target: "_blank",
className: "external linkified",
attributes: {
rel: "nofollow noopener noreferrer"
}
});
};
const directive = function(el, binding) {
if (binding.value?.linkify === true) {
el.innerHTML = Linkify(binding.value.text);
}
};
export {
directive as default,
directive
};