@zero-library/common 2.2.5 → 2.2.7

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/dist/index.cjs.js CHANGED
@@ -305,10 +305,14 @@ try {
305
305
  md.use(alertInlinePlugin);
306
306
  } catch {
307
307
  }
308
+ var filterMarkdown = (content = "") => {
309
+ if (!content) return content;
310
+ return content.replace(/<!--[\s\S]*?(?:-->|$)/g, "");
311
+ };
308
312
  var RenderMarkdown_default = ({ content = "", searchValue, customComponents, ...rest }) => {
309
313
  const reactContent = React16.useMemo(() => {
310
314
  if (!content) return null;
311
- const { text: preprocessed, placeholders } = alertMarkClean(content);
315
+ const { text: preprocessed, placeholders } = alertMarkClean(filterMarkdown(content));
312
316
  let rawHtml = md.render(preprocessed);
313
317
  rawHtml = searchValue ? highlightKeywords(rawHtml, [searchValue]) : rawHtml;
314
318
  let lazyIndex = -1;
@@ -1227,6 +1231,19 @@ function formatSize(value, options = {}) {
1227
1231
  }
1228
1232
  return `${toFixed(size, precision2, !trimZero)}${UNIT_LIST[index]}`;
1229
1233
  }
1234
+ var markdownToText = (() => {
1235
+ const md2 = new markdownit__default.default({
1236
+ html: true,
1237
+ linkify: true,
1238
+ typographer: false
1239
+ });
1240
+ return (markdown) => {
1241
+ if (!isString(markdown)) return "";
1242
+ const html = md2.render(markdown);
1243
+ const text = html.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&#39;/g, "'").trim();
1244
+ return text;
1245
+ };
1246
+ })();
1230
1247
 
1231
1248
  // src/hooks/useDeepEffect.ts
1232
1249
  var useDeepEffect_default = (effect, deps) => {
@@ -1904,6 +1921,20 @@ var ProtectedView = ({
1904
1921
  ] })
1905
1922
  ] }) });
1906
1923
  };
1924
+ var openLinksNewTabPlugin = () => {
1925
+ const onAnnotationLayerRender = (e) => {
1926
+ e.container.querySelectorAll(".rpv-core__annotation--link a").forEach((linkEle) => {
1927
+ const href = linkEle.getAttribute("href");
1928
+ if (href && isExternal(href)) {
1929
+ linkEle.setAttribute("target", "_blank");
1930
+ linkEle.setAttribute("rel", "noopener noreferrer");
1931
+ }
1932
+ });
1933
+ };
1934
+ return {
1935
+ onAnnotationLayerRender
1936
+ };
1937
+ };
1907
1938
  var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumbnails = true, onSetPassword, onSetPageNo }) => {
1908
1939
  const embedRef = React16.useRef(null);
1909
1940
  const [sizes, setSizes] = React16.useState([0]);
@@ -2035,10 +2066,11 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
2035
2066
  plugins: [
2036
2067
  pageNavigationPluginInstance,
2037
2068
  thumbnailPluginInstance,
2038
- zoomPluginInstance
2069
+ zoomPluginInstance,
2039
2070
  // printPluginInstance,
2040
2071
  // rotatePluginInstance,
2041
2072
  // searchPluginInstance,
2073
+ openLinksNewTabPlugin()
2042
2074
  ],
2043
2075
  onPageChange,
2044
2076
  renderError,
@@ -6096,6 +6128,7 @@ exports.isSet = isSet;
6096
6128
  exports.isString = isString;
6097
6129
  exports.isUnDef = isUnDef;
6098
6130
  exports.isWindow = isWindow;
6131
+ exports.markdownToText = markdownToText;
6099
6132
  exports.minus = minus;
6100
6133
  exports.objToOptions = objToOptions;
6101
6134
  exports.plus = plus;