@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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "1.0.147",
3
+ "version": "1.0.148",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 232,
6
6
  "exports": [
package/dist/index.cjs CHANGED
@@ -25835,67 +25835,7 @@ var SlashCommand = import_core4.Extension.create({
25835
25835
  var import_core5 = require("@tiptap/core");
25836
25836
  var import_state2 = require("@tiptap/pm/state");
25837
25837
 
25838
- // src/components/UEditor/url-safety.ts
25839
- var LINK_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]);
25840
- var IMAGE_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
25841
- function normalizeUrlInput(raw) {
25842
- return raw.trim().replace(/[\u0000-\u001F\u007F\s]+/g, "");
25843
- }
25844
- function isProtocolRelativeUrl(value) {
25845
- return value.startsWith("//");
25846
- }
25847
- function isRelativeUrl(value) {
25848
- return value.startsWith("/") || value.startsWith("./") || value.startsWith("../") || value.startsWith("#");
25849
- }
25850
- function isDataImageUrl(value) {
25851
- return /^data:image\/(?:png|jpe?g|gif|webp|svg\+xml|bmp|x-icon|avif);base64,/i.test(value);
25852
- }
25853
- function isSafeUEditorUrl(raw, kind) {
25854
- const value = normalizeUrlInput(raw);
25855
- if (!value) return false;
25856
- if (kind === "image" && isDataImageUrl(value)) return true;
25857
- if (isRelativeUrl(value)) return true;
25858
- if (isProtocolRelativeUrl(value)) return false;
25859
- try {
25860
- const parsed = new URL(value);
25861
- return kind === "image" ? IMAGE_PROTOCOLS.has(parsed.protocol) : LINK_PROTOCOLS.has(parsed.protocol);
25862
- } catch {
25863
- return false;
25864
- }
25865
- }
25866
- function sanitizeUEditorUrl(raw, kind) {
25867
- const value = raw.trim();
25868
- if (!value) return "";
25869
- if (isSafeUEditorUrl(value, kind)) return normalizeUrlInput(value);
25870
- if (kind === "link" && !isProtocolRelativeUrl(value) && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value)) {
25871
- const withProtocol = `https://${value}`;
25872
- return isSafeUEditorUrl(withProtocol, kind) ? withProtocol : "";
25873
- }
25874
- return "";
25875
- }
25876
-
25877
- // src/components/UEditor/clipboard-images.ts
25878
- var DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE = 10 * 1024 * 1024;
25879
- var DEFAULT_UEDITOR_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif", "image/svg+xml"];
25880
- function getImageFiles(dataTransfer) {
25881
- if (!dataTransfer) return [];
25882
- const itemFiles = [];
25883
- const byKey = /* @__PURE__ */ new Map();
25884
- for (const item of Array.from(dataTransfer.items ?? [])) {
25885
- if (item.kind !== "file") continue;
25886
- if (!item.type.startsWith("image/")) continue;
25887
- const file = item.getAsFile();
25888
- if (!file) continue;
25889
- byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
25890
- }
25891
- itemFiles.push(...Array.from(byKey.values()));
25892
- if (itemFiles.length > 0) return itemFiles;
25893
- for (const file of Array.from(dataTransfer.files ?? [])) {
25894
- if (!file.type.startsWith("image/")) continue;
25895
- byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
25896
- }
25897
- return Array.from(byKey.values());
25898
- }
25838
+ // src/components/UEditor/clipboard-tables.ts
25899
25839
  function getClipboardData(dataTransfer, type) {
25900
25840
  try {
25901
25841
  return dataTransfer.getData(type) ?? "";
@@ -26044,6 +25984,68 @@ function getClipboardTsvTableContent(dataTransfer) {
26044
25984
  2
26045
25985
  );
26046
25986
  }
25987
+
25988
+ // src/components/UEditor/url-safety.ts
25989
+ var LINK_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]);
25990
+ var IMAGE_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
25991
+ function normalizeUrlInput(raw) {
25992
+ return raw.trim().replace(/[\u0000-\u001F\u007F\s]+/g, "");
25993
+ }
25994
+ function isProtocolRelativeUrl(value) {
25995
+ return value.startsWith("//");
25996
+ }
25997
+ function isRelativeUrl(value) {
25998
+ return value.startsWith("/") || value.startsWith("./") || value.startsWith("../") || value.startsWith("#");
25999
+ }
26000
+ function isDataImageUrl(value) {
26001
+ return /^data:image\/(?:png|jpe?g|gif|webp|svg\+xml|bmp|x-icon|avif);base64,/i.test(value);
26002
+ }
26003
+ function isSafeUEditorUrl(raw, kind) {
26004
+ const value = normalizeUrlInput(raw);
26005
+ if (!value) return false;
26006
+ if (kind === "image" && isDataImageUrl(value)) return true;
26007
+ if (isRelativeUrl(value)) return true;
26008
+ if (isProtocolRelativeUrl(value)) return false;
26009
+ try {
26010
+ const parsed = new URL(value);
26011
+ return kind === "image" ? IMAGE_PROTOCOLS.has(parsed.protocol) : LINK_PROTOCOLS.has(parsed.protocol);
26012
+ } catch {
26013
+ return false;
26014
+ }
26015
+ }
26016
+ function sanitizeUEditorUrl(raw, kind) {
26017
+ const value = raw.trim();
26018
+ if (!value) return "";
26019
+ if (isSafeUEditorUrl(value, kind)) return normalizeUrlInput(value);
26020
+ if (kind === "link" && !isProtocolRelativeUrl(value) && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value)) {
26021
+ const withProtocol = `https://${value}`;
26022
+ return isSafeUEditorUrl(withProtocol, kind) ? withProtocol : "";
26023
+ }
26024
+ return "";
26025
+ }
26026
+
26027
+ // src/components/UEditor/clipboard-images.ts
26028
+ var DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE = 10 * 1024 * 1024;
26029
+ var DEFAULT_UEDITOR_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif", "image/svg+xml"];
26030
+ function getImageFiles(dataTransfer) {
26031
+ if (!dataTransfer) return [];
26032
+ const itemFiles = [];
26033
+ const byKey = /* @__PURE__ */ new Map();
26034
+ for (const item of Array.from(dataTransfer.items ?? [])) {
26035
+ if (item.kind !== "file") continue;
26036
+ if (!item.type.startsWith("image/")) continue;
26037
+ const file = item.getAsFile();
26038
+ if (!file) continue;
26039
+ byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
26040
+ }
26041
+ itemFiles.push(...Array.from(byKey.values()));
26042
+ if (itemFiles.length > 0) return itemFiles;
26043
+ for (const file of Array.from(dataTransfer.files ?? [])) {
26044
+ if (!file.type.startsWith("image/")) continue;
26045
+ byKey.set(`${file.name}:${file.size}:${file.lastModified}`, file);
26046
+ }
26047
+ return Array.from(byKey.values());
26048
+ }
26047
26049
  function fileToDataUrl(file) {
26048
26050
  return new Promise((resolve, reject) => {
26049
26051
  const reader = new FileReader();