99 lines
3.5 KiB
Diff
99 lines
3.5 KiB
Diff
diff --git a/src/link.ts b/src/link.ts
|
|
--- a/src/link.ts
|
|
+++ b/src/link.ts
|
|
@@ -6,6 +6,21 @@ import { autolink } from './helpers/autolink.js'
|
|
import { clickHandler } from './helpers/clickHandler.js'
|
|
import { pasteHandler } from './helpers/pasteHandler.js'
|
|
import { UNICODE_WHITESPACE_REGEX_GLOBAL } from './helpers/whitespace.js'
|
|
+
|
|
+const PRE_REGISTERED_PROTOCOLS = ['tel', 'callto', 'sms', 'cid', 'xmpp'] as const
|
|
+const linkifyProtocolFlag = '__tolariaTiptapLinkifyProtocolsRegistered'
|
|
+const linkifyGlobalObject = typeof globalThis === 'undefined'
|
|
+ ? undefined
|
|
+ : (globalThis as Record<string, boolean | undefined>)
|
|
+
|
|
+if (linkifyGlobalObject && !linkifyGlobalObject[linkifyProtocolFlag]) {
|
|
+ PRE_REGISTERED_PROTOCOLS.forEach((protocol) => {
|
|
+ registerCustomProtocol(protocol)
|
|
+ })
|
|
+
|
|
+ linkifyGlobalObject[linkifyProtocolFlag] = true
|
|
+}
|
|
|
|
export interface LinkProtocolOptions {
|
|
/**
|
|
diff --git a/dist/index.js b/dist/index.js
|
|
--- a/dist/index.js
|
|
+++ b/dist/index.js
|
|
@@ -8,6 +8,18 @@ var UNICODE_WHITESPACE_REGEX = new RegExp(UNICODE_WHITESPACE_PATTERN);
|
|
var UNICODE_WHITESPACE_REGEX_END = new RegExp(`${UNICODE_WHITESPACE_PATTERN}$`);
|
|
var UNICODE_WHITESPACE_REGEX_GLOBAL = new RegExp(UNICODE_WHITESPACE_PATTERN, "g");
|
|
|
|
+var PRE_REGISTERED_PROTOCOLS = ["tel", "callto", "sms", "cid", "xmpp"];
|
|
+var linkifyProtocolFlag = "__tolariaTiptapLinkifyProtocolsRegistered";
|
|
+var linkifyGlobalObject = typeof globalThis === "undefined" ? void 0 : globalThis;
|
|
+if (linkifyGlobalObject && !linkifyGlobalObject[linkifyProtocolFlag]) {
|
|
+ PRE_REGISTERED_PROTOCOLS.forEach((protocol) => {
|
|
+ registerCustomProtocol(protocol);
|
|
+ });
|
|
+ linkifyGlobalObject[linkifyProtocolFlag] = true;
|
|
+}
|
|
+
|
|
// src/helpers/autolink.ts
|
|
function isValidLinkStructure(tokens) {
|
|
if (tokens.length === 1) {
|
|
@@ -224,7 +236,8 @@ var Link = Mark.create({
|
|
});
|
|
},
|
|
onDestroy() {
|
|
- reset();
|
|
+ // Tolaria keeps a single editor shell alive across note swaps, so linkify's
|
|
+ // protocol registry must survive editor teardown and remount cycles.
|
|
},
|
|
inclusive() {
|
|
return this.options.autolink;
|
|
@@ -443,4 +444,4 @@ export {
|
|
isAllowedUri,
|
|
pasteRegex
|
|
};
|
|
-//# sourceMappingURL=index.js.map
|
|
\ No newline at end of file
|
|
+//# sourceMappingURL=index.js.map
|
|
diff --git a/dist/index.cjs b/dist/index.cjs
|
|
--- a/dist/index.cjs
|
|
+++ b/dist/index.cjs
|
|
@@ -10,6 +10,18 @@ var import_state3 = require("@tiptap/pm/state");
|
|
var import_linkifyjs2 = require("linkifyjs");
|
|
var import_whitespace = require("./helpers/whitespace.cjs");
|
|
|
|
+var PRE_REGISTERED_PROTOCOLS = ["tel", "callto", "sms", "cid", "xmpp"];
|
|
+var linkifyProtocolFlag = "__tolariaTiptapLinkifyProtocolsRegistered";
|
|
+var linkifyGlobalObject = typeof globalThis === "undefined" ? void 0 : globalThis;
|
|
+if (linkifyGlobalObject && !linkifyGlobalObject[linkifyProtocolFlag]) {
|
|
+ PRE_REGISTERED_PROTOCOLS.forEach((protocol) => {
|
|
+ (0, import_linkifyjs.registerCustomProtocol)(protocol);
|
|
+ });
|
|
+ linkifyGlobalObject[linkifyProtocolFlag] = true;
|
|
+}
|
|
+
|
|
// src/helpers/autolink.ts
|
|
function isValidLinkStructure(tokens) {
|
|
if (tokens.length === 1) {
|
|
@@ -253,7 +265,8 @@ var Link = import_core3.Mark.create({
|
|
});
|
|
},
|
|
onDestroy() {
|
|
- (0, import_linkifyjs3.reset)();
|
|
+ // Tolaria keeps a single editor shell alive across note swaps, so linkify's
|
|
+ // protocol registry must survive editor teardown and remount cycles.
|
|
},
|
|
inclusive() {
|
|
return this.options.autolink;
|
|
@@ -472,4 +473,4 @@ var index_default = Link;
|
|
isAllowedUri,
|
|
pasteRegex
|
|
});
|
|
-//# sourceMappingURL=index.cjs.map
|
|
\ No newline at end of file
|
|
+//# sourceMappingURL=index.cjs.map
|