@underverse-ui/underverse 1.0.147 → 1.0.148

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.js CHANGED
@@ -25680,67 +25680,7 @@ var SlashCommand = Extension.create({
25680
25680
  import { Extension as Extension2 } from "@tiptap/core";
25681
25681
  import { Plugin as Plugin2 } from "@tiptap/pm/state";
25682
25682
 
25683
- // src/components/UEditor/url-safety.ts
25684
- var LINK_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]);
25685
- var IMAGE_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
25686
- function normalizeUrlInput(raw) {
25687
- return raw.trim().replace(/[\u0000-\u001F\u007F\s]+/g, "");
25688
- }
25689
- function isProtocolRelativeUrl(value) {
25690
- return value.startsWith("//");
25691
- }
25692
- function isRelativeUrl(value) {
25693
- return value.startsWith("/") || value.startsWith("./") || value.startsWith("../") || value.startsWith("#");
25694
- }
25695
- function isDataImageUrl(value) {
25696
- return /^data:image\/(?:png|jpe?g|gif|webp|svg\+xml|bmp|x-icon|avif);base64,/i.test(value);
25697
- }
25698
- function isSafeUEditorUrl(raw, kind) {
25699
- const value = normalizeUrlInput(raw);
25700
- if (!value) return false;
25701
- if (kind === "image" && isDataImageUrl(value)) return true;
25702
- if (isRelativeUrl(value)) return true;
25703
- if (isProtocolRelativeUrl(value)) return false;
25704
- try {
25705
- const parsed = new URL(value);
25706
- return kind === "image" ? IMAGE_PROTOCOLS.has(parsed.protocol) : LINK_PROTOCOLS.has(parsed.protocol);
25707
- } catch {
25708
- return false;
25709
- }
25710
- }
25711
- function sanitizeUEditorUrl(raw, kind) {
25712
- const value = raw.trim();
25713
- if (!value) return "";
25714
- if (isSafeUEditorUrl(value, kind)) return normalizeUrlInput(value);
25715
- if (kind === "link" && !isProtocolRelativeUrl(value) && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value)) {
25716
- const withProtocol = `https://${value}`;
25717
- return isSafeUEditorUrl(withProtocol, kind) ? withProtocol : "";
25718
- }
25719
- return "";
25720
- }
25721
-
25722
- // src/components/UEditor/clipboard-images.ts
25723
- var DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE = 10 * 1024 * 1024;
25724
- var DEFAULT_UEDITOR_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif", "image/svg+xml"];
25725
- function getImageFiles(dataTransfer) {
25726
- if (!dataTransfer) return [];
25727
- const itemFiles = [];
25728
- const byKey = /* @__PURE__ */ new Map();
25729
- for (const item of Array.from(dataTransfer.items ?? [])) {
25730
- if (item.kind !== "file") continue;
25731
- if (!item.type.startsWith("image/")) continue;
25732
- const file = item.getAsFile();
25733
- if (!file) continue;
25734
- byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
25735
- }
25736
- itemFiles.push(...Array.from(byKey.values()));
25737
- if (itemFiles.length > 0) return itemFiles;
25738
- for (const file of Array.from(dataTransfer.files ?? [])) {
25739
- if (!file.type.startsWith("image/")) continue;
25740
- byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
25741
- }
25742
- return Array.from(byKey.values());
25743
- }
25683
+ // src/components/UEditor/clipboard-tables.ts
25744
25684
  function getClipboardData(dataTransfer, type) {
25745
25685
  try {
25746
25686
  return dataTransfer.getData(type) ?? "";
@@ -25889,6 +25829,68 @@ function getClipboardTsvTableContent(dataTransfer) {
25889
25829
  2
25890
25830
  );
25891
25831
  }
25832
+
25833
+ // src/components/UEditor/url-safety.ts
25834
+ var LINK_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]);
25835
+ var IMAGE_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
25836
+ function normalizeUrlInput(raw) {
25837
+ return raw.trim().replace(/[\u0000-\u001F\u007F\s]+/g, "");
25838
+ }
25839
+ function isProtocolRelativeUrl(value) {
25840
+ return value.startsWith("//");
25841
+ }
25842
+ function isRelativeUrl(value) {
25843
+ return value.startsWith("/") || value.startsWith("./") || value.startsWith("../") || value.startsWith("#");
25844
+ }
25845
+ function isDataImageUrl(value) {
25846
+ return /^data:image\/(?:png|jpe?g|gif|webp|svg\+xml|bmp|x-icon|avif);base64,/i.test(value);
25847
+ }
25848
+ function isSafeUEditorUrl(raw, kind) {
25849
+ const value = normalizeUrlInput(raw);
25850
+ if (!value) return false;
25851
+ if (kind === "image" && isDataImageUrl(value)) return true;
25852
+ if (isRelativeUrl(value)) return true;
25853
+ if (isProtocolRelativeUrl(value)) return false;
25854
+ try {
25855
+ const parsed = new URL(value);
25856
+ return kind === "image" ? IMAGE_PROTOCOLS.has(parsed.protocol) : LINK_PROTOCOLS.has(parsed.protocol);
25857
+ } catch {
25858
+ return false;
25859
+ }
25860
+ }
25861
+ function sanitizeUEditorUrl(raw, kind) {
25862
+ const value = raw.trim();
25863
+ if (!value) return "";
25864
+ if (isSafeUEditorUrl(value, kind)) return normalizeUrlInput(value);
25865
+ if (kind === "link" && !isProtocolRelativeUrl(value) && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value)) {
25866
+ const withProtocol = `https://${value}`;
25867
+ return isSafeUEditorUrl(withProtocol, kind) ? withProtocol : "";
25868
+ }
25869
+ return "";
25870
+ }
25871
+
25872
+ // src/components/UEditor/clipboard-images.ts
25873
+ var DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE = 10 * 1024 * 1024;
25874
+ var DEFAULT_UEDITOR_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif", "image/svg+xml"];
25875
+ function getImageFiles(dataTransfer) {
25876
+ if (!dataTransfer) return [];
25877
+ const itemFiles = [];
25878
+ const byKey = /* @__PURE__ */ new Map();
25879
+ for (const item of Array.from(dataTransfer.items ?? [])) {
25880
+ if (item.kind !== "file") continue;
25881
+ if (!item.type.startsWith("image/")) continue;
25882
+ const file = item.getAsFile();
25883
+ if (!file) continue;
25884
+ byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
25885
+ }
25886
+ itemFiles.push(...Array.from(byKey.values()));
25887
+ if (itemFiles.length > 0) return itemFiles;
25888
+ for (const file of Array.from(dataTransfer.files ?? [])) {
25889
+ if (!file.type.startsWith("image/")) continue;
25890
+ byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
25891
+ }
25892
+ return Array.from(byKey.values());
25893
+ }
25892
25894
  function fileToDataUrl(file) {
25893
25895
  return new Promise((resolve, reject) => {
25894
25896
  const reader = new FileReader();