@veltdev/slate-velt-comments-staging 1.0.1 → 1.0.2

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/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../node_modules/tslib/tslib.es6.js","../../src/constants.ts","../../src/velt.ts","../../src/editor.ts","../../src/store.ts","../../src/plugin.ts","../../src/SlateVeltComment.tsx","../../src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","export const Constants = {\n ATTRIBUTES: {\n EDITOR_ID: 'data-editor-id',\n LOCATION_ID: 'data-velt-location-id',\n },\n ELEMENT_TYPE: {\n VELT_COMMENT: 'veltComment',\n },\n};\n","var _a;\nexport class VeltService {\n}\n_a = VeltService;\nVeltService.selectedCommentsMap = new Map();\nVeltService.subscribers = new Map();\nVeltService.isSubscribed = false;\n/* eslint-disable @typescript-eslint/no-explicit-any */\nVeltService.getCommentElement = () => {\n try {\n const velt = window.Velt;\n if (velt === null || velt === void 0 ? void 0 : velt.getCommentElement) {\n return velt.getCommentElement();\n }\n return null;\n }\n catch (error) {\n _a.catchError('Error getting comment element:', error);\n return null;\n }\n};\nVeltService.addManualComment = ({ context, location, }) => {\n try {\n const commentElement = _a.getCommentElement();\n if (!commentElement)\n return Promise.resolve(null);\n return commentElement.addManualComment({ context, location });\n }\n catch (error) {\n _a.catchError('Error adding manual comment:', error);\n return Promise.resolve(null);\n }\n};\nVeltService.updateContext = ({ annotationId, context, }) => {\n try {\n const commentElement = _a.getCommentElement();\n if (!commentElement)\n return Promise.resolve(null);\n return commentElement.updateContext(annotationId, context);\n }\n catch (error) {\n _a.catchError('Error updating context:', error);\n }\n};\nVeltService.subscribeToSelectedCommentsMap = (id, subscriber) => {\n try {\n _a.subscribeToSelectedAnnotationsMapSingleton();\n _a.subscribers.set(id, subscriber);\n }\n catch (error) {\n _a.catchError('Error subscribing to selected comments map:', error);\n }\n};\nVeltService.unsubscribeFromSelectedCommentsMap = (id) => {\n try {\n _a.subscribers.delete(id);\n }\n catch (error) {\n _a.catchError('Error unsubscribing from selected comments map:', error);\n }\n};\nVeltService.catchError = (message, otherProperties) => {\n var _b;\n try {\n const url = 'https://api.velt.dev/sa';\n let properties = {};\n if (otherProperties && typeof otherProperties === 'object') {\n properties = Object.assign(Object.assign({}, properties), otherProperties);\n }\n if (message) {\n properties.message = message;\n }\n properties.sdkVersion = (_b = window.Velt) === null || _b === void 0 ? void 0 : _b.version;\n const body = {\n type: 'track',\n data: {\n event: 'tiptapVeltCommentsError',\n properties: properties,\n },\n };\n // fetch(url, {\n // method: 'POST',\n // headers: {\n // 'Content-Type': 'application/json',\n // },\n // body: JSON.stringify(body),\n // });\n }\n catch (error) {\n // handle error here\n }\n};\nVeltService.subscribeToSelectedAnnotationsMapSingleton = () => {\n var _b;\n try {\n if (_a.isSubscribed) {\n return;\n }\n const commentElement = _a.getCommentElement();\n if (commentElement && typeof (commentElement === null || commentElement === void 0 ? void 0 : commentElement.getSelectedComments) === 'function') {\n (_b = commentElement === null || commentElement === void 0 ? void 0 : commentElement.getSelectedComments()) === null || _b === void 0 ? void 0 : _b.subscribe((comments) => {\n const selectedCommentsMap = new Map();\n comments === null || comments === void 0 ? void 0 : comments.forEach((comment) => {\n if (comment === null || comment === void 0 ? void 0 : comment.annotationId) {\n selectedCommentsMap.set(comment === null || comment === void 0 ? void 0 : comment.annotationId, true);\n }\n });\n // Check if the maps are different\n const areMapsEqual = (map1, map2) => {\n if (map1.size !== map2.size)\n return false;\n for (const [key, value] of map1) {\n if (map2.get(key) !== value)\n return false;\n }\n return true;\n };\n // Skip update if maps are equal\n if (areMapsEqual(selectedCommentsMap, _a.selectedCommentsMap || new Map())) {\n return;\n }\n _a.updateSelectedCommentsMap(selectedCommentsMap);\n });\n _a.isSubscribed = true;\n }\n }\n catch (error) {\n return new Map();\n }\n};\nVeltService.updateSelectedCommentsMap = (selectedCommentsMap) => {\n try {\n _a.selectedCommentsMap = selectedCommentsMap;\n _a.subscribers.forEach((subscriber) => {\n if (typeof subscriber === 'function') {\n subscriber(_a.selectedCommentsMap);\n }\n });\n }\n catch (error) {\n _a.catchError('Error updating selected comments map:', error);\n }\n};\n","import { Editor, Node, Path, Element as SlateElement, Text, Transforms } from 'slate';\nimport { ReactEditor } from 'slate-react';\nimport { Constants } from './constants';\nimport { VeltService } from './velt';\nexport class EditorService {\n constructor(plugin) {\n this.getSelectedText = (editor) => {\n try {\n // Ensure there's a selection\n if (!editor.selection)\n return null;\n // Extract and return the selected text\n return Editor.string(editor, editor.selection);\n }\n catch (err) {\n VeltService.catchError('Error getting selected text:', err);\n return null;\n }\n };\n /**\n * Finds occurrences of a given text within a specified element or text\n * @param {Object} options - Configuration options for occurrence search\n * @param {string} options.searchText - The text to search for\n * @param {SlateElement|string} [options.scopeElement] - DOM element or text to search within\n * @param {number} [options.startOffset] - Optional starting offset for the search\n * @param {boolean} [options.caseSensitive] - Whether the search should be case-sensitive\n * @returns {Object} Occurrence details\n */\n this.findOccurrenceOfText = (options) => {\n try {\n const { searchText, scopeElement, startOffset = 0, caseSensitive = true } = options;\n // Validate input\n if (!searchText)\n return { total: 0, position: 0 };\n // Determine the text to search in\n const fullText = typeof scopeElement === 'string' ? scopeElement : (scopeElement === null || scopeElement === void 0 ? void 0 : scopeElement.textContent) || '';\n // Adjust search based on case sensitivity\n const searchMethod = caseSensitive\n ? (text) => text\n : (text) => text.toLowerCase();\n const processedFullText = searchMethod(fullText);\n const processedSearchText = searchMethod(searchText);\n // Find all occurrences\n const occurrences = [];\n let lastIndex = 0;\n while (true) {\n const matchIndex = processedFullText.indexOf(processedSearchText, lastIndex);\n if (matchIndex === -1)\n break;\n occurrences.push(matchIndex);\n lastIndex = matchIndex + processedSearchText.length;\n }\n // Calculate position\n const positionBeforeSelected = occurrences.filter((index) => index < startOffset).length + 1;\n return {\n total: occurrences.length,\n position: positionBeforeSelected,\n };\n }\n catch (error) {\n VeltService.catchError('Error finding occurrence of text:', error);\n return null;\n }\n };\n this.findOccurrenceOfSelectedText = (editor, scopeElement) => {\n var _a;\n try {\n // Get selected text\n const selectedText = this.getSelectedText(editor);\n // If no text selected, return 0\n if (!selectedText)\n return 0;\n if (!scopeElement) {\n // Determine which occurrence of the text this is within the document\n // This helps with maintaining comment positions during text edits\n let occurrence = 0;\n const allMatches = this.findAllMatches(editor, selectedText);\n const selection = editor.selection;\n if (selection) {\n const matchIndex = allMatches.findIndex((match) => {\n return (match.anchor.path.toString() === selection.anchor.path.toString() &&\n match.focus.path.toString() === selection.focus.path.toString() &&\n match.anchor.offset === selection.anchor.offset &&\n match.focus.offset === selection.focus.offset);\n });\n if (matchIndex !== -1) {\n occurrence = matchIndex + 1;\n }\n }\n return occurrence;\n }\n // Find the DOM node of the selection\n const domSelection = ReactEditor.toDOMNode(editor, editor);\n const startOffset = (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.offset;\n // Find occurrence\n const result = this.findOccurrenceOfText({\n searchText: selectedText,\n scopeElement: scopeElement || domSelection,\n startOffset,\n });\n return result === null || result === void 0 ? void 0 : result.position;\n }\n catch (error) {\n VeltService.catchError('Error finding occurrence of selected text:', error);\n return null;\n }\n };\n this.findAllMatches = (editor, textToSearch, options = { caseSensitive: true }) => {\n try {\n const { caseSensitive = true } = options;\n const matches = [];\n // If no text to search, return empty array\n if (!textToSearch)\n return matches;\n // Safely get text from a node\n const getText = (node) => {\n return typeof node === 'object' && node !== null && 'text' in node ? node.text : '';\n };\n // Check if a node is a text node\n const isTextNode = (node) => {\n return (typeof node === 'object' &&\n node !== null &&\n 'text' in node &&\n typeof node.text === 'string');\n };\n // Iterate through all text nodes in the document\n const searchInNode = (node, path) => {\n // Handle text nodes\n if (isTextNode(node)) {\n const text = getText(node);\n // Apply case sensitivity\n const searchText = caseSensitive ? textToSearch : textToSearch.toLowerCase();\n const nodeText = caseSensitive ? text : text.toLowerCase();\n // Find all matches in the current text node\n let lastIndex = 0;\n while (true) {\n const index = nodeText.indexOf(searchText, lastIndex);\n if (index === -1)\n break;\n // Create a range for this match\n const range = {\n anchor: { path, offset: index },\n focus: { path, offset: index + textToSearch.length },\n };\n matches.push(range);\n // Move the search forward\n lastIndex = index + 1;\n }\n }\n // Recursively search child nodes\n if ('children' in node && Array.isArray(node.children)) {\n node.children.forEach((child, index) => {\n searchInNode(child, [...path, index]);\n });\n }\n };\n // Start the search from the root of the document\n try {\n const [initialNode] = Editor.nodes(editor, {\n at: [],\n mode: 'highest',\n });\n if (initialNode) {\n searchInNode(initialNode[0], initialNode[1]);\n }\n }\n catch (error) {\n VeltService.catchError('Error searching in document:', error);\n }\n return matches;\n }\n catch (error) {\n VeltService.catchError('Error finding all matches:', error);\n return [];\n }\n };\n this.findParentNodeWithIdForSelection = (editor) => {\n try {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n const { anchor } = selection;\n const node = Node.get(editor, anchor.path);\n return this.findParentNodeWithId(editor, { node, path: anchor.path });\n }\n catch (error) {\n VeltService.catchError('Error finding parent node with ID for selection:', error);\n return null;\n }\n };\n this.findParentNodeWithId = (editor, options) => {\n var _a;\n try {\n let { node, path } = options || {};\n if (!node) {\n return null;\n }\n if (path) {\n node = Editor.node(editor, path)[0];\n }\n let domNode = null;\n let editorDOM = null;\n try {\n // Convert Slate path to DOM node\n domNode = ReactEditor.toDOMNode(editor, node);\n }\n catch (err) {\n // handle error here\n return null;\n }\n try {\n // Get the editor's DOM element\n editorDOM = ReactEditor.toDOMNode(editor, editor);\n }\n catch (err) {\n // handle error here\n return null;\n }\n // Default options\n const maxIterations = (_a = options === null || options === void 0 ? void 0 : options.maxIterations) !== null && _a !== void 0 ? _a : 100;\n const idPattern = options === null || options === void 0 ? void 0 : options.idPattern;\n let currentNode = domNode;\n let iterationCount = 0;\n while (currentNode && currentNode !== document.body && iterationCount < maxIterations) {\n // Check if we're still within the editor's DOM\n if (!editorDOM.contains(currentNode)) {\n return null;\n }\n // Check ID based on optional pattern or just presence of ID\n if (currentNode.id) {\n if (!idPattern || idPattern.test(currentNode.id)) {\n return currentNode;\n }\n }\n currentNode = currentNode.parentElement;\n iterationCount++;\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error finding parent node with ID:', error);\n return null;\n }\n };\n this.removeVeltCommentFromEditor = (editor, annotationId) => {\n try {\n // Validate input\n if (!editor || !annotationId) {\n throw new Error('Invalid input: editor and annotationId are required');\n }\n // Create an array to store paths of elements to remove\n const elementsToUnwrap = [];\n // Iterate through all nodes in the editor\n for (const [node, path] of Node.descendants(editor)) {\n // Check if the node is an element using the type\n if (EditorService.isVeltCommentText(node) &&\n node.annotationId === annotationId) {\n // Store the path of the element to be removed\n elementsToUnwrap.push(path);\n }\n }\n try {\n // Unwrap elements in reverse order to avoid path shifting issues\n elementsToUnwrap.reverse().forEach((path) => {\n const nodeAtPath = Editor.node(editor, path)[0];\n const elementAtNode = ReactEditor.toDOMNode(editor, nodeAtPath);\n if (elementAtNode === null || elementAtNode === void 0 ? void 0 : elementAtNode.isConnected) {\n Transforms.unwrapNodes(editor, {\n at: path,\n // This ensures only the wrapper is removed, keeping its children\n mode: 'lowest',\n });\n }\n });\n }\n catch (err) {\n VeltService.catchError('Error unwrapping elements:', err);\n }\n return true;\n }\n catch (error) {\n VeltService.catchError('Error removing Velt comment:', error);\n return false;\n }\n };\n // Helper function to highlight text with velt comment\n this.highlightTextWithVeltComment = (editor, annotation) => {\n var _a;\n try {\n const { text, targetTextNodeId, occurrence } = ((_a = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) || {};\n if (!text || !occurrence) {\n return;\n }\n const isWrapped = this.injectTag(editor, text, occurrence, annotation.annotationId, targetTextNodeId);\n if (isWrapped) {\n // Store the annotation data\n if (annotation.annotationId) {\n this.plugin.storeService.annotationStore.set(annotation.annotationId, {\n annotation,\n });\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error highlighting text with velt comment:', error);\n }\n };\n this.getEditorTextContent = (editor) => {\n try {\n return editor.children.map((node) => Node.string(node)).join('');\n }\n catch (error) {\n VeltService.catchError('Error getting editor text content:', error);\n return '';\n }\n };\n this.onSlateValueChange = ({ editor }) => {\n try {\n // Phase 1: Collect all annotations in the document\n const annotationsToCheck = this.collectDocumentAnnotations({ editor });\n // Early return if no annotations to process\n if (annotationsToCheck.size === 0)\n return;\n // Phase 2: Process each annotation to check for changes\n const changedAnnotations = new Map();\n for (const [annotationId] of annotationsToCheck) {\n // Get the stored annotation data\n const storedData = this.plugin.storeService.annotationStore.get(annotationId);\n if (!storedData)\n continue;\n // Find all nodes with this annotation ID\n const nodes = Array.from(Editor.nodes(editor, { at: [] }))\n .filter(([node]) => EditorService.isVeltCommentText(node))\n .filter(([node]) => node.annotationId === annotationId)\n .map(([node, path]) => ({\n node: node,\n pos: Editor.start(editor, path).offset,\n }));\n // Skip if no nodes found for this annotation\n if (!nodes.length)\n continue;\n const changes = this.processAnnotationChanges({ editor, annotationId });\n // Store changes if any detected\n if (changes) {\n changedAnnotations.set(annotationId, changes);\n }\n }\n // Phase 3: Apply updates for any annotations that changed\n if (changedAnnotations.size > 0) {\n this.updateVeltComments({ changes: changedAnnotations, editor });\n }\n }\n catch (error) {\n VeltService.catchError('Error in processVeltCommentChanges:', error);\n }\n };\n this.plugin = plugin;\n }\n // Phase 1: Collect all annotations in the document\n collectDocumentAnnotations({ editor, }) {\n try {\n const annotationsToCheck = new Map();\n // Traverse all nodes in the document\n Array.from(Editor.nodes(editor, { at: [] }))\n .filter(([node]) => EditorService.isVeltCommentText(node))\n .forEach(([node]) => {\n const veltNode = node;\n const annotationId = veltNode.annotationId;\n if (annotationId) {\n const storedData = this.plugin.storeService.annotationStore.get(annotationId);\n if (storedData === null || storedData === void 0 ? void 0 : storedData.annotation) {\n annotationsToCheck.set(annotationId, storedData.annotation);\n }\n }\n });\n return annotationsToCheck;\n }\n catch (error) {\n VeltService.catchError('Error collecting document annotations:', error);\n return new Map();\n }\n }\n processAnnotationChanges({ editor, annotationId, }) {\n var _a, _b, _c, _d;\n try {\n let targetNode = null;\n let targetElement = null;\n let targetPath = null;\n const annotation = (_a = this.plugin.storeService.annotationStore.get(annotationId)) === null || _a === void 0 ? void 0 : _a.annotation;\n if (!((_b = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _b === void 0 ? void 0 : _b.textEditorConfig)) {\n return null;\n }\n const { text, targetTextNodeId, occurrence } = ((_c = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _c === void 0 ? void 0 : _c.textEditorConfig) || {};\n const annotatedNodes = Array.from(Editor.nodes(editor, {\n at: [],\n match: (node) => EditorService.isVeltCommentText(node) &&\n node.annotationId === annotationId,\n mode: 'lowest',\n }));\n for (const [node, path] of annotatedNodes) {\n targetNode = node;\n targetPath = path;\n }\n if (!targetNode) {\n return null;\n }\n try {\n targetElement = ReactEditor.toDOMNode(editor, targetNode);\n if (!targetElement) {\n return null;\n }\n }\n catch (error) {\n return null;\n }\n // Extract and concatenate text from matched nodes\n const currentText = annotatedNodes\n .map(([node]) => Node.string(node))\n .join('');\n const currentTargetNode = this.findParentNodeWithId(editor, {\n node: targetNode,\n path: targetPath !== null && targetPath !== void 0 ? targetPath : undefined,\n });\n let currentTargetNodeId;\n if (currentTargetNode) {\n currentTargetNodeId = currentTargetNode.id;\n }\n let containerNode;\n let containerPath;\n if (currentTargetNode) {\n containerNode = ReactEditor.toSlateNode(editor, currentTargetNode);\n containerPath = ReactEditor.findPath(editor, containerNode);\n }\n const currentOccurrence = (_d = this.findTextOccurrenceOfNode(editor, targetNode, targetPath !== null && targetPath !== void 0 ? targetPath : undefined, containerNode, containerPath)) === null || _d === void 0 ? void 0 : _d.nodeOccurrencePosition;\n const textChanged = currentText !== text;\n const occurrenceChanged = currentOccurrence !== occurrence;\n const targetTextNodeIdChanged = targetTextNodeId !== currentTargetNodeId;\n if (textChanged || occurrenceChanged || targetTextNodeIdChanged) {\n return {\n contentChanged: textChanged,\n currentText,\n occurrenceChanged,\n currentOccurrence: currentOccurrence !== null && currentOccurrence !== void 0 ? currentOccurrence : 0,\n originalOccurrence: occurrence,\n annotationId,\n originalText: text,\n originalTargetTextNodeId: targetTextNodeId,\n newTargetTextNodeId: currentTargetNodeId,\n annotation,\n multiThreadAnnotationId: annotation === null || annotation === void 0 ? void 0 : annotation.multiThreadAnnotationId,\n targetTextNodeIdChanged,\n };\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error processing annotation changes:', error);\n return null;\n }\n }\n // Phase 3: Apply updates for any annotations that changed\n /**\n * Updates the Velt comment element with new annotation data\n */\n updateVeltComments({ changes, editor, }) {\n var _a;\n try {\n for (const [annotationId, changeData] of Array.from(changes.entries())) {\n try {\n if (!((_a = changeData.annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig))\n continue;\n const textEditorConfig = JSON.parse(JSON.stringify(changeData.annotation.context.textEditorConfig));\n if (changeData.contentChanged) {\n textEditorConfig.text = changeData.currentText;\n }\n if (changeData.occurrenceChanged) {\n textEditorConfig.occurrence = changeData.currentOccurrence;\n }\n if (changeData.targetTextNodeIdChanged) {\n textEditorConfig.targetTextNodeId = changeData.newTargetTextNodeId;\n }\n const context = Object.assign(Object.assign({}, changeData.annotation.context), { textEditorConfig });\n // Remove data from store\n this.plugin.storeService.annotationStore.remove(annotationId);\n this.removeVeltCommentFromEditor(editor, annotationId);\n VeltService.updateContext({ annotationId, context });\n }\n catch (error) {\n VeltService.catchError('Error updating Velt comments', error);\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error updating Velt comments', error);\n }\n }\n isElementInEditor(editor, element) {\n try {\n // Convert Slate editor to its DOM representation\n const editorElement = ReactEditor.toDOMNode(editor, editor);\n // Check if the target element is a descendant of the editor\n return editorElement.contains(element);\n }\n catch (error) {\n VeltService.catchError('Error checking element in editor:', error);\n return false;\n }\n }\n // Helper method to extract the traversal logic\n traverseNodesForText(currentNode, currentPath, textNodePositions, fullText) {\n try {\n if (Text.isText(currentNode)) {\n const start = fullText.length;\n fullText += currentNode.text;\n const end = fullText.length;\n textNodePositions.push({\n node: currentNode,\n path: currentPath,\n start,\n end,\n });\n }\n else if (SlateElement.isElement(currentNode)) {\n // Traverse child nodes\n for (let i = 0; i < currentNode.children.length; i++) {\n const childPath = [...currentPath, i];\n fullText = this.traverseNodesForText(currentNode.children[i], childPath, textNodePositions, fullText);\n }\n }\n return fullText;\n }\n catch (error) {\n VeltService.catchError('Error traversing nodes for text:', error);\n return '';\n }\n }\n collectSubtreeText(editor, node, path) {\n try {\n const textNodePositions = [];\n let fullText = '';\n // Special case for the root node (editor itself)\n if (path.length === 0) {\n // When path is [], we're at the editor root, so traverse all children\n for (let i = 0; i < editor.children.length; i++) {\n const childPath = [i];\n fullText = this.traverseNodesForText(editor.children[i], childPath, textNodePositions, fullText);\n }\n }\n else {\n // Normal case for non-root nodes\n fullText = this.traverseNodesForText(node, path, textNodePositions, fullText);\n }\n return { fullText, textNodePositions };\n }\n catch (error) {\n VeltService.catchError('Error collecting subtree text:', error);\n return { fullText: '', textNodePositions: [] };\n }\n }\n findTextOccurrence(editor, textToSearch, occurrence, targetElement) {\n try {\n // Convert target element to Slate node\n const targetNode = ReactEditor.toSlateNode(editor, targetElement);\n const targetPath = ReactEditor.findPath(editor, targetNode);\n // Collect all text from the subtree\n const { fullText, textNodePositions } = this.collectSubtreeText(editor, targetNode, targetPath);\n // Find all matches in the full text\n const matches = [];\n let match;\n const regex = new RegExp(textToSearch.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g');\n while ((match = regex.exec(fullText)) !== null) {\n matches.push({ index: match.index });\n }\n // If we don't have enough occurrences, return null\n if (matches.length < occurrence) {\n return null;\n }\n // Get the specific match\n const targetMatch = matches[occurrence - 1];\n // Find which text nodes the match spans\n const matchStart = targetMatch.index;\n const matchEnd = matchStart + textToSearch.length;\n // Find the range that covers this match\n let anchorNodeInfo;\n let focusNodeInfo;\n for (const nodePosition of textNodePositions) {\n // Check for anchor (start of match)\n if (matchStart >= nodePosition.start && matchStart < nodePosition.end) {\n anchorNodeInfo = nodePosition;\n }\n // Check for focus (end of match)\n if (matchEnd > nodePosition.start && matchEnd <= nodePosition.end) {\n focusNodeInfo = nodePosition;\n }\n // If we have both anchor and focus, we can create the range\n if (anchorNodeInfo && focusNodeInfo) {\n return {\n anchor: {\n path: anchorNodeInfo.path,\n offset: matchStart - anchorNodeInfo.start,\n },\n focus: {\n path: focusNodeInfo.path,\n offset: matchEnd - focusNodeInfo.start,\n },\n };\n }\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error in findTextOccurrence:', error);\n return null;\n }\n }\n injectTag(editor, textToSearch, occurrence, annotationId, targetElementId) {\n try {\n // If target element ID is provided, find the DOM element\n let targetElement = null;\n if (targetElementId) {\n targetElement = document.getElementById(targetElementId);\n // Validate target element\n if (!targetElement) {\n return false;\n }\n // Ensure the element is part of the editor\n if (!this.isElementInEditor(editor, targetElement)) {\n return false;\n }\n }\n else {\n targetElement = ReactEditor.toDOMNode(editor, editor);\n }\n // If no target element is specified, fall back to editor-wide search\n if (!targetElement) {\n return false;\n }\n // Find the range for the specific text occurrence\n const range = this.findTextOccurrence(editor, textToSearch, occurrence, targetElement);\n if (!range) {\n return false;\n }\n // Check if the range is already wrapped with a velt-comment-text element\n const isAlreadyWrapped = Array.from(Editor.nodes(editor, {\n at: range,\n match: (node) => EditorService.isVeltCommentText(node),\n })).length > 0;\n if (isAlreadyWrapped)\n return false;\n editor.wrapNodes({\n type: Constants.ELEMENT_TYPE.VELT_COMMENT,\n children: [],\n annotationId: annotationId,\n }, { at: range, split: true });\n return true;\n }\n catch (error) {\n VeltService.catchError('Error injecting tag:', error);\n return false;\n }\n }\n // for dynamic update\n /**\n * Find all occurrences of a specific text in the editor\n * @param {Editor} editor - The Slate.js editor instance\n * @param {string} searchText - The text to search for\n * @param {boolean} [caseSensitive=true] - Whether the search should be case-sensitive\n * @param {Node} [containerNode] - Optional container node to limit the search scope (if provided, only searches within this node)\n * @param {Path} [containerPath] - Optional path of the container node (will be calculated if not provided)\n * @returns {Array} Array of occurrence details\n */\n findAllTextOccurrences(editor, searchText, caseSensitive = true, containerNode, containerPath) {\n try {\n if (!searchText)\n return [];\n const occurrences = [];\n // Process search based on case sensitivity\n const processText = caseSensitive\n ? (text) => text\n : (text) => text.toLowerCase();\n const processedSearchText = processText(searchText);\n // Find container path if container node is provided but path isn't\n if (containerNode && !containerPath) {\n try {\n for (const [n, p] of Editor.nodes(editor)) {\n if (n === containerNode) {\n containerPath = p;\n break;\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error finding container path:', error);\n }\n }\n // Determine search scope\n const searchAt = containerPath || [];\n // Iterate through all text nodes in the scope\n for (const [node, path] of Editor.nodes(editor, {\n at: searchAt,\n match: (n) => Text.isText(n),\n })) {\n // Skip nodes that aren't within the container if container is specified\n if (containerPath &&\n !Path.isDescendant(path, containerPath) &&\n !Path.equals(path, containerPath)) {\n continue;\n }\n const nodeText = Node.string(node);\n const processedNodeText = processText(nodeText);\n let lastIndex = 0;\n let matchIndex;\n // Find all occurrences within this text node\n while ((matchIndex = processedNodeText.indexOf(processedSearchText, lastIndex)) !== -1) {\n // Create a point at the start of the match\n const start = { path, offset: matchIndex };\n // Create a point at the end of the match\n const end = { path, offset: matchIndex + searchText.length };\n // Create a range from start to end points\n const range = { anchor: start, focus: end };\n occurrences.push({\n node,\n path,\n range,\n startPoint: start,\n endPoint: end,\n text: nodeText.substring(matchIndex, matchIndex + searchText.length),\n });\n lastIndex = matchIndex + processedSearchText.length;\n }\n }\n return occurrences;\n }\n catch (error) {\n VeltService.catchError('Error finding all text occurrences:', error);\n return [];\n }\n }\n findTextOccurrenceOfNode(editor, node, nodePath, containerNode, containerPath) {\n try {\n // Get the text of the provided node\n const nodeText = Node.string(node);\n if (!nodeText.trim()) {\n // Return empty result for empty nodes\n return {\n node,\n nodePath,\n text: nodeText,\n totalOccurrences: 0,\n nodeOccurrencePosition: 0,\n textOccurrences: [],\n containerNode,\n containerPath,\n };\n }\n // Find the node's path if not provided\n if (!nodePath) {\n try {\n // Try to find the path using ReactEditor if applicable\n if ('findPath' in ReactEditor) {\n try {\n nodePath = ReactEditor.findPath(editor, node);\n }\n catch (reactError) {\n VeltService.catchError('Error finding path with ReactEditor:', reactError);\n }\n }\n // Fall back to manual search if needed\n if (!nodePath) {\n for (const [n, p] of Editor.nodes(editor)) {\n if (n === node) {\n nodePath = p;\n break;\n }\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error finding node path:', error);\n }\n }\n // Use findAllTextOccurrences to find all occurrences of this node's text\n // If containerNode is provided, search will be limited to that container\n const textOccurrences = this.findAllTextOccurrences(editor, nodeText, true, containerNode, containerPath);\n // Calculate occurrence position (1-based)\n let nodeOccurrencePosition = 0;\n if (nodePath) {\n // Find matching occurrence with the same path or where the node path is an ancestor\n for (let i = 0; i < textOccurrences.length; i++) {\n const occurrence = textOccurrences[i];\n // Check path relationships\n const isEqual = Path.equals(occurrence.path, nodePath);\n const isDescendant = Path.isAncestor(nodePath, occurrence.path);\n if (isEqual || isDescendant) {\n // Found the matching occurrence, using 1-based position index\n nodeOccurrencePosition = i + 1;\n break;\n }\n }\n }\n // Create detailed occurrence info\n const occurrenceInfo = {\n node,\n nodePath,\n text: nodeText,\n totalOccurrences: textOccurrences.length,\n nodeOccurrencePosition,\n textOccurrences,\n containerNode,\n containerPath,\n };\n return occurrenceInfo;\n }\n catch (error) {\n VeltService.catchError('Error finding text occurrence of node:', error);\n return null;\n }\n }\n}\nEditorService.getEditorId = (editor) => {\n var _a, _b;\n try {\n // Get the DOM node representing the editor\n const domNode = ReactEditor.toDOMNode(editor, editor);\n if (domNode) {\n return ((_b = (_a = domNode === null || domNode === void 0 ? void 0 : domNode.closest(`[${Constants.ATTRIBUTES.EDITOR_ID}]`)) === null || _a === void 0 ? void 0 : _a.getAttribute(Constants.ATTRIBUTES.EDITOR_ID)) !== null && _b !== void 0 ? _b : null);\n }\n // No parent with data-editor-id found\n return null;\n }\n catch (error) {\n // Handle cases where the editor might not be connected to the DOM\n VeltService.catchError('Error finding editor ID:', error);\n return null;\n }\n};\nEditorService.isVeltCommentText = (element) => {\n return element.type === Constants.ELEMENT_TYPE.VELT_COMMENT;\n};\n","import { VeltService } from './velt';\nexport class StoreService {\n constructor(plugin) {\n this.isSubscribed = false;\n this.globalStore = {\n editor: null,\n comments: [],\n filteredComments: [],\n selectedCommentsMap: new Map(),\n };\n // Global annotation storage\n this.globalAnnotationStore = new Map();\n /**\n * Helper to get and set annotations with debug messages\n */\n this.annotationStore = {\n get: (id) => {\n return this.globalAnnotationStore.get(id);\n },\n set: (id, data) => {\n this.globalAnnotationStore.set(id, data);\n },\n getAll: () => {\n return new Map(this.globalAnnotationStore);\n },\n clear: () => {\n this.globalAnnotationStore.clear();\n },\n remove: (id) => {\n this.globalAnnotationStore.delete(id);\n },\n };\n this.updateGlobalStore = (store) => {\n var _a, _b, _c;\n try {\n const comments = (store === null || store === void 0 ? void 0 : store.comments) || ((_a = this.globalStore) === null || _a === void 0 ? void 0 : _a.comments) || [];\n const newSelectedCommentsMap = (store === null || store === void 0 ? void 0 : store.selectedCommentsMap) || ((_b = this.globalStore) === null || _b === void 0 ? void 0 : _b.selectedCommentsMap) || new Map();\n const oldFilteredComments = ((_c = this.globalStore) === null || _c === void 0 ? void 0 : _c.filteredComments) || [];\n const filteredComments = comments.filter((annotation) => {\n var _a;\n return (((_a = annotation === null || annotation === void 0 ? void 0 : annotation.status) === null || _a === void 0 ? void 0 : _a.type) !== 'terminal' ||\n (newSelectedCommentsMap === null || newSelectedCommentsMap === void 0 ? void 0 : newSelectedCommentsMap.get(annotation === null || annotation === void 0 ? void 0 : annotation.annotationId)));\n });\n // Create a Set of new annotation IDs for O(1) lookup\n const newAnnotationIds = new Set(filteredComments.map((annotation) => annotation === null || annotation === void 0 ? void 0 : annotation.annotationId));\n // Get IDs of removed comments\n const removedAnnotationIds = oldFilteredComments\n .map((annotation) => annotation === null || annotation === void 0 ? void 0 : annotation.annotationId)\n .filter((id) => id && !newAnnotationIds.has(id));\n // Remove comments from editor using just IDs\n removedAnnotationIds.forEach((annotationId) => {\n var _a, _b;\n if (((_a = this.globalStore) === null || _a === void 0 ? void 0 : _a.editor) && annotationId) {\n this.plugin.editorService.removeVeltCommentFromEditor((_b = this.globalStore) === null || _b === void 0 ? void 0 : _b.editor, annotationId);\n }\n });\n this.globalStore = Object.assign(Object.assign(Object.assign({}, this.globalStore), store), { filteredComments });\n this.highlightCommentsFromGlobalStore();\n }\n catch (error) {\n // handle error\n VeltService.catchError('Error updating global store:', error);\n }\n };\n this.highlightCommentsFromGlobalStore = () => {\n var _a, _b;\n try {\n const { editor, filteredComments } = this.globalStore;\n if (!editor || !filteredComments)\n return;\n for (const annotation of filteredComments) {\n const textToFind = (_b = (_a = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) === null || _b === void 0 ? void 0 : _b.text;\n if (textToFind) {\n this.plugin.editorService.highlightTextWithVeltComment(editor, annotation);\n }\n }\n }\n catch (error) {\n // handle error\n VeltService.catchError('Error highlighting comments from global store:', error);\n }\n };\n this.plugin = plugin;\n try {\n VeltService.subscribeToSelectedCommentsMap(this.plugin.editorId, (selectedCommentsMap) => {\n try {\n this.updateGlobalStore({ selectedCommentsMap });\n }\n catch (error) {\n VeltService.catchError('Error updating global store:', error);\n }\n });\n }\n catch (error) {\n VeltService.catchError('Error subscribing to selected comments map:', error);\n }\n }\n}\nStoreService.storeInstanceMap = new Map();\n","import { EditorService } from './editor';\nimport { StoreService } from './store';\nconst instanceMap = new Map();\nexport class Plugin {\n constructor(editorId, editor) {\n this.previousEditorTextContent = '';\n this.editorId = editorId;\n this.editor = editor;\n this.editorService = new EditorService(this);\n this.storeService = new StoreService(this);\n if (editor) {\n this.setPreviousEditorTextContent(this.editorService.getEditorTextContent(editor));\n }\n }\n static getInstance(config) {\n let { editorId, editor } = config || {};\n if (!editorId) {\n editorId = 'default';\n }\n if (!instanceMap.has(editorId)) {\n instanceMap.set(editorId, new Plugin(editorId, editor));\n }\n return instanceMap.get(editorId);\n }\n getPreviousEditorTextContent() {\n return this.previousEditorTextContent;\n }\n setPreviousEditorTextContent(textContent) {\n this.previousEditorTextContent = textContent;\n }\n}\n","import React from 'react';\nexport const SlateVeltComment = (props) => {\n const { attributes, children, element } = props;\n const annotationId = element === null || element === void 0 ? void 0 : element.annotationId;\n return (React.createElement(\"velt-comment-text\", Object.assign({ \"annotation-id\": annotationId }, attributes), children));\n};\n","import { __awaiter } from \"tslib\";\nimport { Operation } from 'slate';\nimport { EditorService } from './editor';\nimport { Plugin } from './plugin';\nimport { VeltService } from './velt';\nexport { SlateVeltComment } from './SlateVeltComment';\nexport * from './types';\n// Plugin configuration\nexport const withVeltComments = (editor) => {\n const { isInline, isVoid, onChange } = editor;\n // Override isInline to treat Velt comment text elements as inline elements\n // This ensures comment text flows naturally within the document\n editor.isInline = (element) => {\n return EditorService.isVeltCommentText(element) ? true : isInline(element);\n };\n // Override isVoid to ensure Velt comment text elements are not void elements\n // This allows comment text to contain and display content\n editor.isVoid = (element) => {\n return EditorService.isVeltCommentText(element) ? false : isVoid(element);\n };\n // Add observer for value changes to track and update comments when text changes\n editor.onChange = () => {\n // Call the original onChange if it exists to preserve existing behavior\n if (onChange) {\n onChange();\n }\n // Only process text-related operations to avoid unnecessary updates\n const isTextChange = editor.operations.some((operation) => Operation.isTextOperation(operation));\n if (isTextChange) {\n // Update comment positions and states when text content changes\n onSlateValueChange({ editor });\n }\n };\n // Return the enhanced editor with Velt comments functionality\n return editor;\n};\nexport const triggerAddComment = (editor, config) => __awaiter(void 0, void 0, void 0, function* () {\n try {\n return addComment({ editor, context: config === null || config === void 0 ? void 0 : config.context });\n }\n catch (error) {\n VeltService.catchError('Error triggering add comment', error);\n }\n});\n/**\n * Creates a comment annotation for the currently selected text in the editor\n * This function handles the entire flow from getting the selected text to creating\n * the actual comment through the Velt service\n */\nexport const addComment = (_a) => __awaiter(void 0, [_a], void 0, function* ({ editorId, editor, context: clientContext, }) {\n var _b, _c;\n try {\n // get comment element from Velt sdk\n const commentElement = VeltService.getCommentElement();\n if (!commentElement)\n return;\n // Ensure we have an editor ID for proper tracking\n if (!editorId) {\n editorId = (_b = EditorService.getEditorId(editor)) !== null && _b !== void 0 ? _b : undefined;\n }\n // Initialize plugin instance with editor context\n const plugin = Plugin.getInstance({ editorId, editor });\n // Get text currently selected by the user\n const selectedText = plugin.editorService.getSelectedText(editor);\n // Exit if no text is selected - nothing to comment on\n if (!selectedText) {\n return;\n }\n // Find the parent node containing the selection to establish position context\n const targetTextNode = plugin.editorService.findParentNodeWithIdForSelection(editor);\n // Extract node ID and location information for proper positioning\n let targetTextNodeId = undefined;\n let locationId = null;\n if (targetTextNode) {\n targetTextNodeId = targetTextNode.id;\n // Find the closest parent with a location ID to properly anchor the comment\n locationId = (_c = targetTextNode\n .closest('[data-velt-location-id]')) === null || _c === void 0 ? void 0 : _c.getAttribute('data-velt-location-id');\n }\n const occurrence = plugin.editorService.findOccurrenceOfSelectedText(editor, targetTextNode !== null && targetTextNode !== void 0 ? targetTextNode : undefined);\n // Exit if we can't determine occurrence information\n if (!occurrence) {\n return;\n }\n // Initialize context object for the comment\n let context = {};\n if (clientContext && typeof clientContext === 'object') {\n context = Object.assign(Object.assign({}, context), clientContext);\n }\n // Add text editor specific configuration to context\n // This helps position and track the comment as document changes\n context.textEditorConfig = {\n text: selectedText,\n occurrence: occurrence,\n targetTextNodeId: targetTextNodeId,\n };\n if (editorId) {\n context.textEditorConfig.editorId = editorId;\n }\n // Short delay to prevent comment dialog from closing immediately\n // This improves user experience when interacting with comments\n yield new Promise((resolve) => setTimeout(resolve, 200));\n // Create location reference if we have a location ID\n let location;\n if (locationId) {\n location = { id: locationId };\n }\n try {\n // Create the actual comment through Velt service\n VeltService.addManualComment({ context, location });\n }\n catch (error) {\n VeltService.catchError('Error creating comment', error);\n }\n }\n catch (error) {\n VeltService.catchError('Error adding comment', error);\n }\n});\nexport function highlightComments(editor, commentAnnotations, editorId) {\n try {\n renderComments({ editor, editorId, commentAnnotations });\n }\n catch (error) {\n VeltService.catchError('Error highlighting tiptap-velt-comments', error);\n }\n}\nexport const renderComments = ({ editor, editorId, commentAnnotations }) => {\n var _a;\n try {\n if (editor) {\n if (!editorId) {\n editorId = (_a = EditorService.getEditorId(editor)) !== null && _a !== void 0 ? _a : undefined;\n }\n commentAnnotations = commentAnnotations === null || commentAnnotations === void 0 ? void 0 : commentAnnotations.filter((annotation) => {\n var _a, _b, _c;\n return !!((_a = annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) &&\n ((_c = (_b = annotation.context) === null || _b === void 0 ? void 0 : _b.textEditorConfig) === null || _c === void 0 ? void 0 : _c.editorId) === editorId;\n });\n const plugin = Plugin.getInstance({ editorId, editor });\n plugin.storeService.updateGlobalStore({ editor, comments: commentAnnotations });\n }\n }\n catch (error) {\n VeltService.catchError('Error highlighting tiptap-velt-comments', error);\n }\n};\nexport const onSlateValueChange = ({ editor, editorId, }) => {\n var _a;\n try {\n if (!editorId) {\n editorId = (_a = EditorService.getEditorId(editor)) !== null && _a !== void 0 ? _a : undefined;\n }\n const plugin = Plugin.getInstance({ editorId, editor });\n // Get the current editor text content\n const currentEditorTextContent = plugin.editorService.getEditorTextContent(editor);\n const previousEditorTextContent = plugin.getPreviousEditorTextContent();\n // Prevent unnecessary processing if content hasn't changed\n if (currentEditorTextContent === previousEditorTextContent)\n return;\n // Update the previous content for next comparison\n plugin.setPreviousEditorTextContent(currentEditorTextContent);\n plugin.editorService.onSlateValueChange({ editor });\n }\n catch (error) {\n VeltService.catchError('Error in processVeltCommentChanges:', error);\n }\n};\n"],"names":["__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","SuppressedError","Constants","EDITOR_ID","LOCATION_ID","VELT_COMMENT","_a","VeltService","selectedCommentsMap","Map","subscribers","isSubscribed","getCommentElement","velt","window","Velt","error","catchError","addManualComment","context","location","commentElement","updateContext","annotationId","subscribeToSelectedCommentsMap","id","subscriber","subscribeToSelectedAnnotationsMapSingleton","set","unsubscribeFromSelectedCommentsMap","delete","message","otherProperties","_b","properties","Object","assign","sdkVersion","version","getSelectedComments","subscribe","comments","forEach","comment","map1","map2","size","key","get","areMapsEqual","updateSelectedCommentsMap","EditorService","constructor","plugin","this","getSelectedText","editor","selection","Editor","string","err","findOccurrenceOfText","options","searchText","scopeElement","startOffset","caseSensitive","total","position","fullText","textContent","searchMethod","text","toLowerCase","processedFullText","processedSearchText","occurrences","lastIndex","matchIndex","indexOf","push","length","positionBeforeSelected","filter","index","findOccurrenceOfSelectedText","selectedText","occurrence","allMatches","findAllMatches","findIndex","match","anchor","path","toString","focus","offset","domSelection","ReactEditor","toDOMNode","textToSearch","matches","getText","node","isTextNode","searchInNode","nodeText","range","Array","isArray","children","child","initialNode","nodes","at","mode","findParentNodeWithIdForSelection","Node","findParentNodeWithId","domNode","editorDOM","maxIterations","idPattern","currentNode","iterationCount","document","body","contains","test","parentElement","removeVeltCommentFromEditor","Error","elementsToUnwrap","descendants","isVeltCommentText","reverse","nodeAtPath","elementAtNode","isConnected","Transforms","unwrapNodes","highlightTextWithVeltComment","annotation","targetTextNodeId","textEditorConfig","injectTag","storeService","annotationStore","getEditorTextContent","map","join","onSlateValueChange","annotationsToCheck","collectDocumentAnnotations","changedAnnotations","from","pos","start","changes","processAnnotationChanges","updateVeltComments","storedData","_c","_d","targetNode","targetElement","targetPath","annotatedNodes","currentText","currentTargetNode","undefined","currentTargetNodeId","containerNode","containerPath","toSlateNode","findPath","currentOccurrence","findTextOccurrenceOfNode","nodeOccurrencePosition","textChanged","occurrenceChanged","targetTextNodeIdChanged","contentChanged","originalOccurrence","originalText","originalTargetTextNodeId","newTargetTextNodeId","multiThreadAnnotationId","changeData","entries","JSON","parse","stringify","remove","isElementInEditor","element","traverseNodesForText","currentPath","textNodePositions","Text","isText","end","SlateElement","Element","isElement","i","childPath","collectSubtreeText","findTextOccurrence","regex","RegExp","replace","exec","matchStart","matchEnd","anchorNodeInfo","focusNodeInfo","nodePosition","targetElementId","getElementById","wrapNodes","type","split","findAllTextOccurrences","processText","n","p","searchAt","Path","isDescendant","equals","processedNodeText","startPoint","endPoint","substring","nodePath","trim","totalOccurrences","textOccurrences","reactError","isEqual","isAncestor","getEditorId","closest","getAttribute","StoreService","globalStore","filteredComments","globalAnnotationStore","data","getAll","clear","updateGlobalStore","store","newSelectedCommentsMap","oldFilteredComments","status","newAnnotationIds","Set","has","editorService","highlightCommentsFromGlobalStore","editorId","storeInstanceMap","instanceMap","Plugin","previousEditorTextContent","setPreviousEditorTextContent","getInstance","config","getPreviousEditorTextContent","addComment","clientContext","targetTextNode","locationId","setTimeout","renderComments","commentAnnotations","currentEditorTextContent","props","attributes","React","createElement","isInline","isVoid","onChange","operations","some","operation","Operation","isTextOperation"],"mappings":"gFAkHO,SAASA,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBO,KAAKR,EAAWK,EAAY,CAC9GH,GAAMN,EAAYA,EAAUa,MAAMhB,EAASC,GAAc,KAAKS,OACtE,GACA,CA8MkD,mBAApBO,iBAAiCA,gBCxUxD,MAAMC,EACG,CACRC,UAAW,iBACXC,YAAa,yBAHRF,EAKK,CACVG,aAAc,eCNtB,IAAIC,EACG,MAAMC,GAEbD,EAAKC,EACLA,EAAYC,oBAAsB,IAAIC,IACtCF,EAAYG,YAAc,IAAID,IAC9BF,EAAYI,cAAe,EAE3BJ,EAAYK,kBAAoB,KAC5B,IACI,MAAMC,EAAOC,OAAOC,KACpB,OAAIF,aAAmC,EAASA,EAAKD,mBAC1CC,EA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1K,EAAW,iDCmHvH,SAA2BtD,EAAQ6N,EAAoBf,GAC1D,IACIc,EAAe,CAAE5N,SAAQ8M,WAAUe,sBACtC,CACD,MAAOrQ,GACHT,EAAYU,WAAW,0CAA2CD,EACrE,CACL,kFA1FiC,CAACwC,EAAQqN,IAAW9R,OAAU,OAAQ,OAAQ,GAAQ,YACnF,IACI,OAAOgS,EAAW,CAAEvN,SAAQrC,QAAS0P,aAAuC,EAASA,EAAO1P,SAC/F,CACD,MAAOH,GACHT,EAAYU,WAAW,+BAAgCD,EAC1D,CACL,6BAnCiCwC,IAC7B,MAAMmO,SAAEA,EAAQC,OAAEA,EAAMC,SAAEA,GAAarO,EAyBvC,OAtBAA,EAAOmO,SAAYxF,KACRhJ,EAAcmF,kBAAkB6D,IAAkBwF,EAASxF,GAItE3I,EAAOoO,OAAUzF,IACNhJ,EAAcmF,kBAAkB6D,IAAmByF,EAAOzF,GAGrE3I,EAAOqO,SAAW,KAEVA,GACAA,IAGiBrO,EAAOsO,WAAWC,MAAMC,GAAcC,YAAUC,gBAAgBF,MAGjFzI,EAAmB,CAAE/F,UACxB,EAGEA,CAAM","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.js","sources":["../../node_modules/tslib/tslib.es6.js","../../src/constants.ts","../../src/velt.ts","../../src/editor.ts","../../src/store.ts","../../src/plugin.ts","../../src/SlateVeltComment.tsx","../../src/index.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nvar ownKeys = function(o) {\r\n ownKeys = Object.getOwnPropertyNames || function (o) {\r\n var ar = [];\r\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\r\n return ar;\r\n };\r\n return ownKeys(o);\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","export const Constants = {\n ATTRIBUTES: {\n EDITOR_ID: 'data-editor-id',\n LOCATION_ID: 'data-velt-location-id',\n },\n ELEMENT_TYPE: {\n VELT_COMMENT: 'veltComment',\n },\n};\n","var _a;\nexport class VeltService {\n}\n_a = VeltService;\nVeltService.selectedCommentsMap = new Map();\nVeltService.subscribers = new Map();\nVeltService.isSubscribed = false;\n/* eslint-disable @typescript-eslint/no-explicit-any */\nVeltService.getCommentElement = () => {\n try {\n const velt = window.Velt;\n if (velt === null || velt === void 0 ? void 0 : velt.getCommentElement) {\n return velt.getCommentElement();\n }\n return null;\n }\n catch (error) {\n _a.catchError('Error getting comment element:', error);\n return null;\n }\n};\nVeltService.addManualComment = ({ context, location, }) => {\n try {\n const commentElement = _a.getCommentElement();\n if (!commentElement)\n return Promise.resolve(null);\n return commentElement.addManualComment({ context, location });\n }\n catch (error) {\n _a.catchError('Error adding manual comment:', error);\n return Promise.resolve(null);\n }\n};\nVeltService.updateContext = ({ annotationId, context, }) => {\n try {\n const commentElement = _a.getCommentElement();\n if (!commentElement)\n return Promise.resolve(null);\n return commentElement.updateContext(annotationId, context);\n }\n catch (error) {\n _a.catchError('Error updating context:', error);\n }\n};\nVeltService.subscribeToSelectedCommentsMap = (id, subscriber) => {\n try {\n _a.subscribeToSelectedAnnotationsMapSingleton();\n _a.subscribers.set(id, subscriber);\n }\n catch (error) {\n _a.catchError('Error subscribing to selected comments map:', error);\n }\n};\nVeltService.unsubscribeFromSelectedCommentsMap = (id) => {\n try {\n _a.subscribers.delete(id);\n }\n catch (error) {\n _a.catchError('Error unsubscribing from selected comments map:', error);\n }\n};\nVeltService.catchError = (message, otherProperties) => {\n var _b;\n try {\n const url = 'https://api.velt.dev/sa';\n let properties = {};\n if (otherProperties && typeof otherProperties === 'object') {\n properties = Object.assign(Object.assign({}, properties), otherProperties);\n }\n if (message) {\n properties.message = message;\n }\n properties.sdkVersion = (_b = window.Velt) === null || _b === void 0 ? void 0 : _b.version;\n const body = {\n type: 'track',\n data: {\n event: 'tiptapVeltCommentsError',\n properties: properties,\n },\n };\n // fetch(url, {\n // method: 'POST',\n // headers: {\n // 'Content-Type': 'application/json',\n // },\n // body: JSON.stringify(body),\n // });\n }\n catch (error) {\n // handle error here\n }\n};\nVeltService.subscribeToSelectedAnnotationsMapSingleton = () => {\n var _b;\n try {\n if (_a.isSubscribed) {\n return;\n }\n const commentElement = _a.getCommentElement();\n if (commentElement && typeof (commentElement === null || commentElement === void 0 ? void 0 : commentElement.getSelectedComments) === 'function') {\n (_b = commentElement === null || commentElement === void 0 ? void 0 : commentElement.getSelectedComments()) === null || _b === void 0 ? void 0 : _b.subscribe((comments) => {\n const selectedCommentsMap = new Map();\n comments === null || comments === void 0 ? void 0 : comments.forEach((comment) => {\n if (comment === null || comment === void 0 ? void 0 : comment.annotationId) {\n selectedCommentsMap.set(comment === null || comment === void 0 ? void 0 : comment.annotationId, true);\n }\n });\n // Check if the maps are different\n const areMapsEqual = (map1, map2) => {\n if (map1.size !== map2.size)\n return false;\n for (const [key, value] of map1) {\n if (map2.get(key) !== value)\n return false;\n }\n return true;\n };\n // Skip update if maps are equal\n if (areMapsEqual(selectedCommentsMap, _a.selectedCommentsMap || new Map())) {\n return;\n }\n _a.updateSelectedCommentsMap(selectedCommentsMap);\n });\n _a.isSubscribed = true;\n }\n }\n catch (error) {\n return new Map();\n }\n};\nVeltService.updateSelectedCommentsMap = (selectedCommentsMap) => {\n try {\n _a.selectedCommentsMap = selectedCommentsMap;\n _a.subscribers.forEach((subscriber) => {\n if (typeof subscriber === 'function') {\n subscriber(_a.selectedCommentsMap);\n }\n });\n }\n catch (error) {\n _a.catchError('Error updating selected comments map:', error);\n }\n};\n","import { Editor, Node, Path, Element as SlateElement, Text, Transforms } from 'slate';\nimport { ReactEditor } from 'slate-react';\nimport { Constants } from './constants';\nimport { VeltService } from './velt';\nexport class EditorService {\n constructor(plugin) {\n this.getSelectedText = (editor) => {\n try {\n // Ensure there's a selection\n if (!editor.selection)\n return null;\n // Extract and return the selected text\n return Editor.string(editor, editor.selection);\n }\n catch (err) {\n VeltService.catchError('Error getting selected text:', err);\n return null;\n }\n };\n /**\n * Finds occurrences of a given text within a specified element or text\n * @param {Object} options - Configuration options for occurrence search\n * @param {string} options.searchText - The text to search for\n * @param {SlateElement|string} [options.scopeElement] - DOM element or text to search within\n * @param {number} [options.startOffset] - Optional starting offset for the search\n * @param {boolean} [options.caseSensitive] - Whether the search should be case-sensitive\n * @returns {Object} Occurrence details\n */\n this.findOccurrenceOfText = (options) => {\n try {\n const { searchText, scopeElement, startOffset = 0, caseSensitive = true } = options;\n // Validate input\n if (!searchText)\n return { total: 0, position: 0 };\n // Determine the text to search in\n const fullText = typeof scopeElement === 'string' ? scopeElement : (scopeElement === null || scopeElement === void 0 ? void 0 : scopeElement.textContent) || '';\n // Adjust search based on case sensitivity\n const searchMethod = caseSensitive\n ? (text) => text\n : (text) => text.toLowerCase();\n const processedFullText = searchMethod(fullText);\n const processedSearchText = searchMethod(searchText);\n // Find all occurrences\n const occurrences = [];\n let lastIndex = 0;\n while (true) {\n const matchIndex = processedFullText.indexOf(processedSearchText, lastIndex);\n if (matchIndex === -1)\n break;\n occurrences.push(matchIndex);\n lastIndex = matchIndex + processedSearchText.length;\n }\n // Calculate position\n const positionBeforeSelected = occurrences.filter((index) => index < startOffset).length + 1;\n return {\n total: occurrences.length,\n position: positionBeforeSelected,\n };\n }\n catch (error) {\n VeltService.catchError('Error finding occurrence of text:', error);\n return null;\n }\n };\n this.findOccurrenceOfSelectedText = (editor, scopeElement) => {\n var _a;\n try {\n // Get selected text\n const selectedText = this.getSelectedText(editor);\n // If no text selected, return 0\n if (!selectedText)\n return 0;\n if (!scopeElement) {\n // Determine which occurrence of the text this is within the document\n // This helps with maintaining comment positions during text edits\n let occurrence = 0;\n const allMatches = this.findAllMatches(editor, selectedText);\n const selection = editor.selection;\n if (selection) {\n const matchIndex = allMatches.findIndex((match) => {\n return (match.anchor.path.toString() === selection.anchor.path.toString() &&\n match.focus.path.toString() === selection.focus.path.toString() &&\n match.anchor.offset === selection.anchor.offset &&\n match.focus.offset === selection.focus.offset);\n });\n if (matchIndex !== -1) {\n occurrence = matchIndex + 1;\n }\n }\n return occurrence;\n }\n // Find the DOM node of the selection\n const domSelection = ReactEditor.toDOMNode(editor, editor);\n const startOffset = (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.offset;\n // Find occurrence\n const result = this.findOccurrenceOfText({\n searchText: selectedText,\n scopeElement: scopeElement || domSelection,\n startOffset,\n });\n return result === null || result === void 0 ? void 0 : result.position;\n }\n catch (error) {\n VeltService.catchError('Error finding occurrence of selected text:', error);\n return null;\n }\n };\n this.findAllMatches = (editor, textToSearch, options = { caseSensitive: true }) => {\n try {\n const { caseSensitive = true } = options;\n const matches = [];\n // If no text to search, return empty array\n if (!textToSearch)\n return matches;\n // Safely get text from a node\n const getText = (node) => {\n return typeof node === 'object' && node !== null && 'text' in node ? node.text : '';\n };\n // Check if a node is a text node\n const isTextNode = (node) => {\n return (typeof node === 'object' &&\n node !== null &&\n 'text' in node &&\n typeof node.text === 'string');\n };\n // Iterate through all text nodes in the document\n const searchInNode = (node, path) => {\n // Handle text nodes\n if (isTextNode(node)) {\n const text = getText(node);\n // Apply case sensitivity\n const searchText = caseSensitive ? textToSearch : textToSearch.toLowerCase();\n const nodeText = caseSensitive ? text : text.toLowerCase();\n // Find all matches in the current text node\n let lastIndex = 0;\n while (true) {\n const index = nodeText.indexOf(searchText, lastIndex);\n if (index === -1)\n break;\n // Create a range for this match\n const range = {\n anchor: { path, offset: index },\n focus: { path, offset: index + textToSearch.length },\n };\n matches.push(range);\n // Move the search forward\n lastIndex = index + 1;\n }\n }\n // Recursively search child nodes\n if ('children' in node && Array.isArray(node.children)) {\n node.children.forEach((child, index) => {\n searchInNode(child, [...path, index]);\n });\n }\n };\n // Start the search from the root of the document\n try {\n const [initialNode] = Editor.nodes(editor, {\n at: [],\n mode: 'highest',\n });\n if (initialNode) {\n searchInNode(initialNode[0], initialNode[1]);\n }\n }\n catch (error) {\n VeltService.catchError('Error searching in document:', error);\n }\n return matches;\n }\n catch (error) {\n VeltService.catchError('Error finding all matches:', error);\n return [];\n }\n };\n this.findParentNodeWithIdForSelection = (editor) => {\n try {\n const { selection } = editor;\n if (!selection) {\n return null;\n }\n const { anchor } = selection;\n const node = Node.get(editor, anchor.path);\n return this.findParentNodeWithId(editor, { node, path: anchor.path });\n }\n catch (error) {\n VeltService.catchError('Error finding parent node with ID for selection:', error);\n return null;\n }\n };\n this.findParentNodeWithId = (editor, options) => {\n var _a;\n try {\n let { node, path } = options || {};\n if (!node) {\n return null;\n }\n if (path) {\n node = Editor.node(editor, path)[0];\n }\n let domNode = null;\n let editorDOM = null;\n try {\n // Convert Slate path to DOM node\n domNode = ReactEditor.toDOMNode(editor, node);\n }\n catch (err) {\n // handle error here\n return null;\n }\n try {\n // Get the editor's DOM element\n editorDOM = ReactEditor.toDOMNode(editor, editor);\n }\n catch (err) {\n // handle error here\n return null;\n }\n // Default options\n const maxIterations = (_a = options === null || options === void 0 ? void 0 : options.maxIterations) !== null && _a !== void 0 ? _a : 100;\n const idPattern = options === null || options === void 0 ? void 0 : options.idPattern;\n let currentNode = domNode;\n let iterationCount = 0;\n while (currentNode && currentNode !== document.body && iterationCount < maxIterations) {\n // Check if we're still within the editor's DOM\n if (!editorDOM.contains(currentNode)) {\n return null;\n }\n // Check ID based on optional pattern or just presence of ID\n if (currentNode.id) {\n if (!idPattern || idPattern.test(currentNode.id)) {\n return currentNode;\n }\n }\n currentNode = currentNode.parentElement;\n iterationCount++;\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error finding parent node with ID:', error);\n return null;\n }\n };\n this.removeVeltCommentFromEditor = (editor, annotationId) => {\n try {\n // Validate input\n if (!editor || !annotationId) {\n throw new Error('Invalid input: editor and annotationId are required');\n }\n // Create an array to store paths of elements to remove\n const elementsToUnwrap = [];\n // Iterate through all nodes in the editor\n for (const [node, path] of Node.descendants(editor)) {\n // Check if the node is an element using the type\n if (EditorService.isVeltCommentText(node) &&\n node.annotationId === annotationId) {\n // Store the path of the element to be removed\n elementsToUnwrap.push(path);\n }\n }\n try {\n // Unwrap elements in reverse order to avoid path shifting issues\n elementsToUnwrap.reverse().forEach((path) => {\n const nodeAtPath = Editor.node(editor, path)[0];\n const elementAtNode = ReactEditor.toDOMNode(editor, nodeAtPath);\n if (elementAtNode === null || elementAtNode === void 0 ? void 0 : elementAtNode.isConnected) {\n const unwrapNodes = () => {\n Transforms.unwrapNodes(editor, {\n at: path,\n // This ensures only the wrapper is removed, keeping its children\n mode: 'lowest',\n });\n };\n const HistoryEditor = EditorService.getHistoryEditor();\n if (HistoryEditor && typeof HistoryEditor.withoutSaving === 'function') {\n HistoryEditor.withoutSaving(editor, () => {\n unwrapNodes();\n });\n }\n else {\n unwrapNodes();\n }\n }\n });\n }\n catch (err) {\n VeltService.catchError('Error unwrapping elements:', err);\n }\n return true;\n }\n catch (error) {\n VeltService.catchError('Error removing Velt comment:', error);\n return false;\n }\n };\n // Helper function to highlight text with velt comment\n this.highlightTextWithVeltComment = (editor, annotation) => {\n var _a;\n try {\n const { text, targetTextNodeId, occurrence } = ((_a = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) || {};\n if (!text || !occurrence) {\n return;\n }\n const isWrapped = this.injectTag(editor, text, occurrence, annotation.annotationId, targetTextNodeId);\n if (isWrapped) {\n // Store the annotation data\n if (annotation.annotationId) {\n this.plugin.storeService.annotationStore.set(annotation.annotationId, {\n annotation,\n });\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error highlighting text with velt comment:', error);\n }\n };\n this.getEditorTextContent = (editor) => {\n try {\n return editor.children.map((node) => Node.string(node)).join('');\n }\n catch (error) {\n VeltService.catchError('Error getting editor text content:', error);\n return '';\n }\n };\n this.onSlateValueChange = ({ editor }) => {\n try {\n // Phase 1: Collect all annotations in the document\n const annotationsToCheck = this.collectDocumentAnnotations({ editor });\n // Early return if no annotations to process\n if (annotationsToCheck.size === 0)\n return;\n // Phase 2: Process each annotation to check for changes\n const changedAnnotations = new Map();\n for (const [annotationId] of annotationsToCheck) {\n // Get the stored annotation data\n const storedData = this.plugin.storeService.annotationStore.get(annotationId);\n if (!storedData)\n continue;\n // Find all nodes with this annotation ID\n const nodes = Array.from(Editor.nodes(editor, { at: [] }))\n .filter(([node]) => EditorService.isVeltCommentText(node))\n .filter(([node]) => node.annotationId === annotationId)\n .map(([node, path]) => ({\n node: node,\n pos: Editor.start(editor, path).offset,\n }));\n // Skip if no nodes found for this annotation\n if (!nodes.length)\n continue;\n const changes = this.processAnnotationChanges({ editor, annotationId });\n // Store changes if any detected\n if (changes) {\n changedAnnotations.set(annotationId, changes);\n }\n }\n // Phase 3: Apply updates for any annotations that changed\n if (changedAnnotations.size > 0) {\n this.updateVeltComments({ changes: changedAnnotations, editor });\n }\n }\n catch (error) {\n VeltService.catchError('Error in processVeltCommentChanges:', error);\n }\n };\n this.injectTag = (editor, textToSearch, occurrence, annotationId, targetElementId) => {\n try {\n // If target element ID is provided, find the DOM element\n let targetElement = null;\n if (targetElementId) {\n targetElement = document.getElementById(targetElementId);\n // Validate target element\n if (!targetElement) {\n return false;\n }\n // Ensure the element is part of the editor\n if (!this.isElementInEditor(editor, targetElement)) {\n return false;\n }\n }\n else {\n targetElement = ReactEditor.toDOMNode(editor, editor);\n }\n // If no target element is specified, fall back to editor-wide search\n if (!targetElement) {\n return false;\n }\n // Find the range for the specific text occurrence\n const range = this.findTextOccurrence(editor, textToSearch, occurrence, targetElement);\n if (!range) {\n return false;\n }\n // Check if the range is already wrapped with a velt-comment-text element\n const isAlreadyWrapped = Array.from(Editor.nodes(editor, {\n at: range,\n match: (node) => EditorService.isVeltCommentText(node),\n })).length > 0;\n if (isAlreadyWrapped)\n return false;\n const wrapNodes = () => {\n editor.wrapNodes({\n type: Constants.ELEMENT_TYPE.VELT_COMMENT,\n children: [],\n annotationId: annotationId,\n }, { at: range, split: true });\n };\n const HistoryEditor = EditorService.getHistoryEditor();\n // If history editor is available, use it to wrap nodes without saving\n if (HistoryEditor && typeof HistoryEditor.withoutSaving === 'function') {\n HistoryEditor.withoutSaving(editor, () => {\n wrapNodes();\n });\n }\n else {\n // Fallback if withoutSaving isn't available\n // Just perform the operation directly\n wrapNodes();\n }\n return true;\n }\n catch (error) {\n VeltService.catchError('Error injecting tag:', error);\n return false;\n }\n };\n this.plugin = plugin;\n }\n // Phase 1: Collect all annotations in the document\n collectDocumentAnnotations({ editor, }) {\n try {\n const annotationsToCheck = new Map();\n // Traverse all nodes in the document\n Array.from(Editor.nodes(editor, { at: [] }))\n .filter(([node]) => EditorService.isVeltCommentText(node))\n .forEach(([node]) => {\n const veltNode = node;\n const annotationId = veltNode.annotationId;\n if (annotationId) {\n const storedData = this.plugin.storeService.annotationStore.get(annotationId);\n if (storedData === null || storedData === void 0 ? void 0 : storedData.annotation) {\n annotationsToCheck.set(annotationId, storedData.annotation);\n }\n }\n });\n return annotationsToCheck;\n }\n catch (error) {\n VeltService.catchError('Error collecting document annotations:', error);\n return new Map();\n }\n }\n processAnnotationChanges({ editor, annotationId, }) {\n var _a, _b, _c, _d;\n try {\n let targetNode = null;\n let targetElement = null;\n let targetPath = null;\n const annotation = (_a = this.plugin.storeService.annotationStore.get(annotationId)) === null || _a === void 0 ? void 0 : _a.annotation;\n if (!((_b = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _b === void 0 ? void 0 : _b.textEditorConfig)) {\n return null;\n }\n const { text, targetTextNodeId, occurrence } = ((_c = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _c === void 0 ? void 0 : _c.textEditorConfig) || {};\n const annotatedNodes = Array.from(Editor.nodes(editor, {\n at: [],\n match: (node) => EditorService.isVeltCommentText(node) &&\n node.annotationId === annotationId,\n mode: 'lowest',\n }));\n for (const [node, path] of annotatedNodes) {\n targetNode = node;\n targetPath = path;\n }\n if (!targetNode) {\n return null;\n }\n try {\n targetElement = ReactEditor.toDOMNode(editor, targetNode);\n if (!targetElement) {\n return null;\n }\n }\n catch (error) {\n return null;\n }\n // Extract and concatenate text from matched nodes\n const currentText = annotatedNodes\n .map(([node]) => Node.string(node))\n .join('');\n if (!currentText) {\n return null;\n }\n const currentTargetNode = this.findParentNodeWithId(editor, {\n node: targetNode,\n path: targetPath !== null && targetPath !== void 0 ? targetPath : undefined,\n });\n let currentTargetNodeId;\n if (currentTargetNode) {\n currentTargetNodeId = currentTargetNode.id;\n }\n let containerNode;\n let containerPath;\n if (currentTargetNode) {\n containerNode = ReactEditor.toSlateNode(editor, currentTargetNode);\n containerPath = ReactEditor.findPath(editor, containerNode);\n }\n const currentOccurrence = (_d = this.findTextOccurrenceOfNode(editor, targetNode, targetPath !== null && targetPath !== void 0 ? targetPath : undefined, containerNode, containerPath)) === null || _d === void 0 ? void 0 : _d.nodeOccurrencePosition;\n if (!currentOccurrence) {\n return null;\n }\n const textChanged = currentText !== text;\n const occurrenceChanged = currentOccurrence !== occurrence;\n const targetTextNodeIdChanged = targetTextNodeId !== currentTargetNodeId;\n if (textChanged || occurrenceChanged || targetTextNodeIdChanged) {\n return {\n contentChanged: textChanged,\n currentText,\n occurrenceChanged,\n currentOccurrence: currentOccurrence !== null && currentOccurrence !== void 0 ? currentOccurrence : 0,\n originalOccurrence: occurrence,\n annotationId,\n originalText: text,\n originalTargetTextNodeId: targetTextNodeId,\n newTargetTextNodeId: currentTargetNodeId,\n annotation,\n multiThreadAnnotationId: annotation === null || annotation === void 0 ? void 0 : annotation.multiThreadAnnotationId,\n targetTextNodeIdChanged,\n };\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error processing annotation changes:', error);\n return null;\n }\n }\n // Phase 3: Apply updates for any annotations that changed\n /**\n * Updates the Velt comment element with new annotation data\n */\n updateVeltComments({ changes, editor, }) {\n var _a;\n try {\n for (const [annotationId, changeData] of Array.from(changes.entries())) {\n try {\n if (!((_a = changeData.annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig))\n continue;\n const textEditorConfig = JSON.parse(JSON.stringify(changeData.annotation.context.textEditorConfig));\n if (changeData.contentChanged) {\n textEditorConfig.text = changeData.currentText;\n }\n if (changeData.occurrenceChanged) {\n textEditorConfig.occurrence = changeData.currentOccurrence;\n }\n if (changeData.targetTextNodeIdChanged) {\n textEditorConfig.targetTextNodeId = changeData.newTargetTextNodeId;\n }\n const context = Object.assign(Object.assign({}, changeData.annotation.context), { textEditorConfig });\n // Remove data from store\n this.plugin.storeService.annotationStore.remove(annotationId);\n this.removeVeltCommentFromEditor(editor, annotationId);\n VeltService.updateContext({ annotationId, context });\n }\n catch (error) {\n VeltService.catchError('Error updating Velt comments', error);\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error updating Velt comments', error);\n }\n }\n isElementInEditor(editor, element) {\n try {\n // Convert Slate editor to its DOM representation\n const editorElement = ReactEditor.toDOMNode(editor, editor);\n // Check if the target element is a descendant of the editor\n return editorElement.contains(element);\n }\n catch (error) {\n VeltService.catchError('Error checking element in editor:', error);\n return false;\n }\n }\n // Helper method to extract the traversal logic\n traverseNodesForText(currentNode, currentPath, textNodePositions, fullText) {\n try {\n if (Text.isText(currentNode)) {\n const start = fullText.length;\n fullText += currentNode.text;\n const end = fullText.length;\n textNodePositions.push({\n node: currentNode,\n path: currentPath,\n start,\n end,\n });\n }\n else if (SlateElement.isElement(currentNode)) {\n // Traverse child nodes\n for (let i = 0; i < currentNode.children.length; i++) {\n const childPath = [...currentPath, i];\n fullText = this.traverseNodesForText(currentNode.children[i], childPath, textNodePositions, fullText);\n }\n }\n return fullText;\n }\n catch (error) {\n VeltService.catchError('Error traversing nodes for text:', error);\n return '';\n }\n }\n collectSubtreeText(editor, node, path) {\n try {\n const textNodePositions = [];\n let fullText = '';\n // Special case for the root node (editor itself)\n if (path.length === 0) {\n // When path is [], we're at the editor root, so traverse all children\n for (let i = 0; i < editor.children.length; i++) {\n const childPath = [i];\n fullText = this.traverseNodesForText(editor.children[i], childPath, textNodePositions, fullText);\n }\n }\n else {\n // Normal case for non-root nodes\n fullText = this.traverseNodesForText(node, path, textNodePositions, fullText);\n }\n return { fullText, textNodePositions };\n }\n catch (error) {\n VeltService.catchError('Error collecting subtree text:', error);\n return { fullText: '', textNodePositions: [] };\n }\n }\n findTextOccurrence(editor, textToSearch, occurrence, targetElement) {\n try {\n // Convert target element to Slate node\n const targetNode = ReactEditor.toSlateNode(editor, targetElement);\n const targetPath = ReactEditor.findPath(editor, targetNode);\n // Collect all text from the subtree\n const { fullText, textNodePositions } = this.collectSubtreeText(editor, targetNode, targetPath);\n // Find all matches in the full text\n const matches = [];\n let match;\n const regex = new RegExp(textToSearch.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g');\n while ((match = regex.exec(fullText)) !== null) {\n matches.push({ index: match.index });\n }\n // If we don't have enough occurrences, return null\n if (matches.length < occurrence) {\n return null;\n }\n // Get the specific match\n const targetMatch = matches[occurrence - 1];\n // Find which text nodes the match spans\n const matchStart = targetMatch.index;\n const matchEnd = matchStart + textToSearch.length;\n // Find the range that covers this match\n let anchorNodeInfo;\n let focusNodeInfo;\n for (const nodePosition of textNodePositions) {\n // Check for anchor (start of match)\n if (matchStart >= nodePosition.start && matchStart < nodePosition.end) {\n anchorNodeInfo = nodePosition;\n }\n // Check for focus (end of match)\n if (matchEnd > nodePosition.start && matchEnd <= nodePosition.end) {\n focusNodeInfo = nodePosition;\n }\n // If we have both anchor and focus, we can create the range\n if (anchorNodeInfo && focusNodeInfo) {\n return {\n anchor: {\n path: anchorNodeInfo.path,\n offset: matchStart - anchorNodeInfo.start,\n },\n focus: {\n path: focusNodeInfo.path,\n offset: matchEnd - focusNodeInfo.start,\n },\n };\n }\n }\n return null;\n }\n catch (error) {\n VeltService.catchError('Error in findTextOccurrence:', error);\n return null;\n }\n }\n // for dynamic update\n /**\n * Find all occurrences of a specific text in the editor\n * @param {Editor} editor - The Slate.js editor instance\n * @param {string} searchText - The text to search for\n * @param {boolean} [caseSensitive=true] - Whether the search should be case-sensitive\n * @param {Node} [containerNode] - Optional container node to limit the search scope (if provided, only searches within this node)\n * @param {Path} [containerPath] - Optional path of the container node (will be calculated if not provided)\n * @returns {Array} Array of occurrence details\n */\n findAllTextOccurrences(editor, searchText, caseSensitive = true, containerNode, containerPath) {\n try {\n if (!searchText)\n return [];\n const occurrences = [];\n // Process search based on case sensitivity\n const processText = caseSensitive\n ? (text) => text\n : (text) => text.toLowerCase();\n const processedSearchText = processText(searchText);\n // Find container path if container node is provided but path isn't\n if (containerNode && !containerPath) {\n try {\n for (const [n, p] of Editor.nodes(editor)) {\n if (n === containerNode) {\n containerPath = p;\n break;\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error finding container path:', error);\n }\n }\n // Determine search scope\n const searchAt = containerPath || [];\n // Iterate through all text nodes in the scope\n for (const [node, path] of Editor.nodes(editor, {\n at: searchAt,\n match: (n) => Text.isText(n),\n })) {\n // Skip nodes that aren't within the container if container is specified\n if (containerPath &&\n !Path.isDescendant(path, containerPath) &&\n !Path.equals(path, containerPath)) {\n continue;\n }\n const nodeText = Node.string(node);\n const processedNodeText = processText(nodeText);\n let lastIndex = 0;\n let matchIndex;\n // Find all occurrences within this text node\n while ((matchIndex = processedNodeText.indexOf(processedSearchText, lastIndex)) !== -1) {\n // Create a point at the start of the match\n const start = { path, offset: matchIndex };\n // Create a point at the end of the match\n const end = { path, offset: matchIndex + searchText.length };\n // Create a range from start to end points\n const range = { anchor: start, focus: end };\n occurrences.push({\n node,\n path,\n range,\n startPoint: start,\n endPoint: end,\n text: nodeText.substring(matchIndex, matchIndex + searchText.length),\n });\n lastIndex = matchIndex + processedSearchText.length;\n }\n }\n return occurrences;\n }\n catch (error) {\n VeltService.catchError('Error finding all text occurrences:', error);\n return [];\n }\n }\n findTextOccurrenceOfNode(editor, node, nodePath, containerNode, containerPath) {\n try {\n // Get the text of the provided node\n const nodeText = Node.string(node);\n if (!nodeText.trim()) {\n // Return empty result for empty nodes\n return {\n node,\n nodePath,\n text: nodeText,\n totalOccurrences: 0,\n nodeOccurrencePosition: 0,\n textOccurrences: [],\n containerNode,\n containerPath,\n };\n }\n // Find the node's path if not provided\n if (!nodePath) {\n try {\n // Try to find the path using ReactEditor if applicable\n if ('findPath' in ReactEditor) {\n try {\n nodePath = ReactEditor.findPath(editor, node);\n }\n catch (reactError) {\n VeltService.catchError('Error finding path with ReactEditor:', reactError);\n }\n }\n // Fall back to manual search if needed\n if (!nodePath) {\n for (const [n, p] of Editor.nodes(editor)) {\n if (n === node) {\n nodePath = p;\n break;\n }\n }\n }\n }\n catch (error) {\n VeltService.catchError('Error finding node path:', error);\n }\n }\n // Use findAllTextOccurrences to find all occurrences of this node's text\n // If containerNode is provided, search will be limited to that container\n const textOccurrences = this.findAllTextOccurrences(editor, nodeText, true, containerNode, containerPath);\n // Calculate occurrence position (1-based)\n let nodeOccurrencePosition = 0;\n if (nodePath) {\n // Find matching occurrence with the same path or where the node path is an ancestor\n for (let i = 0; i < textOccurrences.length; i++) {\n const occurrence = textOccurrences[i];\n // Check path relationships\n const isEqual = Path.equals(occurrence.path, nodePath);\n const isDescendant = Path.isAncestor(nodePath, occurrence.path);\n if (isEqual || isDescendant) {\n // Found the matching occurrence, using 1-based position index\n nodeOccurrencePosition = i + 1;\n break;\n }\n }\n }\n // Create detailed occurrence info\n const occurrenceInfo = {\n node,\n nodePath,\n text: nodeText,\n totalOccurrences: textOccurrences.length,\n nodeOccurrencePosition,\n textOccurrences,\n containerNode,\n containerPath,\n };\n return occurrenceInfo;\n }\n catch (error) {\n VeltService.catchError('Error finding text occurrence of node:', error);\n return null;\n }\n }\n}\nEditorService.setHistoryEditor = (historyEditor) => {\n EditorService.HistoryEditor = historyEditor;\n};\nEditorService.getHistoryEditor = () => {\n return EditorService.HistoryEditor;\n};\nEditorService.getEditorId = (editor) => {\n var _a, _b;\n try {\n // Get the DOM node representing the editor\n const domNode = ReactEditor.toDOMNode(editor, editor);\n if (domNode) {\n return ((_b = (_a = domNode === null || domNode === void 0 ? void 0 : domNode.closest(`[${Constants.ATTRIBUTES.EDITOR_ID}]`)) === null || _a === void 0 ? void 0 : _a.getAttribute(Constants.ATTRIBUTES.EDITOR_ID)) !== null && _b !== void 0 ? _b : null);\n }\n // No parent with data-editor-id found\n return null;\n }\n catch (error) {\n // Handle cases where the editor might not be connected to the DOM\n VeltService.catchError('Error finding editor ID:', error);\n return null;\n }\n};\nEditorService.isVeltCommentText = (element) => {\n return element.type === Constants.ELEMENT_TYPE.VELT_COMMENT;\n};\n","import { VeltService } from './velt';\nexport class StoreService {\n constructor(plugin) {\n this.isSubscribed = false;\n this.globalStore = {\n editor: null,\n comments: [],\n filteredComments: [],\n selectedCommentsMap: new Map(),\n };\n // Global annotation storage\n this.globalAnnotationStore = new Map();\n /**\n * Helper to get and set annotations with debug messages\n */\n this.annotationStore = {\n get: (id) => {\n return this.globalAnnotationStore.get(id);\n },\n set: (id, data) => {\n this.globalAnnotationStore.set(id, data);\n },\n getAll: () => {\n return new Map(this.globalAnnotationStore);\n },\n clear: () => {\n this.globalAnnotationStore.clear();\n },\n remove: (id) => {\n this.globalAnnotationStore.delete(id);\n },\n };\n this.updateGlobalStore = (store) => {\n var _a, _b, _c;\n try {\n const comments = (store === null || store === void 0 ? void 0 : store.comments) || ((_a = this.globalStore) === null || _a === void 0 ? void 0 : _a.comments) || [];\n const newSelectedCommentsMap = (store === null || store === void 0 ? void 0 : store.selectedCommentsMap) || ((_b = this.globalStore) === null || _b === void 0 ? void 0 : _b.selectedCommentsMap) || new Map();\n const oldFilteredComments = ((_c = this.globalStore) === null || _c === void 0 ? void 0 : _c.filteredComments) || [];\n const filteredComments = comments.filter((annotation) => {\n var _a;\n return (((_a = annotation === null || annotation === void 0 ? void 0 : annotation.status) === null || _a === void 0 ? void 0 : _a.type) !== 'terminal' ||\n (newSelectedCommentsMap === null || newSelectedCommentsMap === void 0 ? void 0 : newSelectedCommentsMap.get(annotation === null || annotation === void 0 ? void 0 : annotation.annotationId)));\n });\n // Create a Set of new annotation IDs for O(1) lookup\n const newAnnotationIds = new Set(filteredComments.map((annotation) => annotation === null || annotation === void 0 ? void 0 : annotation.annotationId));\n // Get IDs of removed comments\n const removedAnnotationIds = oldFilteredComments\n .map((annotation) => annotation === null || annotation === void 0 ? void 0 : annotation.annotationId)\n .filter((id) => id && !newAnnotationIds.has(id));\n // Remove comments from editor using just IDs\n removedAnnotationIds.forEach((annotationId) => {\n var _a, _b;\n if (((_a = this.globalStore) === null || _a === void 0 ? void 0 : _a.editor) && annotationId) {\n this.plugin.editorService.removeVeltCommentFromEditor((_b = this.globalStore) === null || _b === void 0 ? void 0 : _b.editor, annotationId);\n }\n });\n this.globalStore = Object.assign(Object.assign(Object.assign({}, this.globalStore), store), { filteredComments });\n this.highlightCommentsFromGlobalStore();\n }\n catch (error) {\n // handle error\n VeltService.catchError('Error updating global store:', error);\n }\n };\n this.highlightCommentsFromGlobalStore = () => {\n var _a, _b;\n try {\n const { editor, filteredComments } = this.globalStore;\n if (!editor || !filteredComments)\n return;\n for (const annotation of filteredComments) {\n const textToFind = (_b = (_a = annotation === null || annotation === void 0 ? void 0 : annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) === null || _b === void 0 ? void 0 : _b.text;\n if (textToFind) {\n this.plugin.editorService.highlightTextWithVeltComment(editor, annotation);\n }\n }\n }\n catch (error) {\n // handle error\n VeltService.catchError('Error highlighting comments from global store:', error);\n }\n };\n this.plugin = plugin;\n try {\n VeltService.subscribeToSelectedCommentsMap(this.plugin.editorId, (selectedCommentsMap) => {\n try {\n this.updateGlobalStore({ selectedCommentsMap });\n }\n catch (error) {\n VeltService.catchError('Error updating global store:', error);\n }\n });\n }\n catch (error) {\n VeltService.catchError('Error subscribing to selected comments map:', error);\n }\n }\n}\nStoreService.storeInstanceMap = new Map();\n","import { EditorService } from './editor';\nimport { StoreService } from './store';\nconst instanceMap = new Map();\nexport class Plugin {\n constructor(editorId, editor) {\n this.previousEditorTextContent = '';\n this.editorId = editorId;\n this.editor = editor;\n this.editorService = new EditorService(this);\n this.storeService = new StoreService(this);\n if (editor) {\n this.setPreviousEditorTextContent(this.editorService.getEditorTextContent(editor));\n }\n }\n static getInstance(config) {\n let { editorId, editor } = config || {};\n if (!editorId) {\n editorId = 'default';\n }\n if (!instanceMap.has(editorId)) {\n instanceMap.set(editorId, new Plugin(editorId, editor));\n }\n return instanceMap.get(editorId);\n }\n getPreviousEditorTextContent() {\n return this.previousEditorTextContent;\n }\n setPreviousEditorTextContent(textContent) {\n this.previousEditorTextContent = textContent;\n }\n}\n","import React from 'react';\nexport const SlateVeltComment = (props) => {\n const { attributes, children, element } = props;\n const annotationId = element === null || element === void 0 ? void 0 : element.annotationId;\n return (React.createElement(\"velt-comment-text\", Object.assign({ \"annotation-id\": annotationId }, attributes), children));\n};\n","import { __awaiter } from \"tslib\";\nimport { Operation } from 'slate';\nimport { EditorService } from './editor';\nimport { Plugin } from './plugin';\nimport { VeltService } from './velt';\nexport { SlateVeltComment } from './SlateVeltComment';\nexport * from './types';\n// Plugin configuration\nexport const withVeltComments = (editor, options) => {\n const { isInline, isVoid, onChange } = editor;\n if (options === null || options === void 0 ? void 0 : options.HistoryEditor) {\n EditorService.setHistoryEditor(options.HistoryEditor);\n }\n // Override isInline to treat Velt comment text elements as inline elements\n // This ensures comment text flows naturally within the document\n editor.isInline = (element) => {\n return EditorService.isVeltCommentText(element) ? true : isInline(element);\n };\n // Override isVoid to ensure Velt comment text elements are not void elements\n // This allows comment text to contain and display content\n editor.isVoid = (element) => {\n return EditorService.isVeltCommentText(element) ? false : isVoid(element);\n };\n // Add observer for value changes to track and update comments when text changes\n editor.onChange = () => {\n // Call the original onChange if it exists to preserve existing behavior\n if (onChange) {\n onChange();\n }\n // Only process text-related operations to avoid unnecessary updates\n const isTextChange = editor.operations.some((operation) => Operation.isTextOperation(operation));\n if (isTextChange) {\n // Update comment positions and states when text content changes\n onSlateValueChange({ editor });\n }\n };\n // Return the enhanced editor with Velt comments functionality\n return editor;\n};\nexport const triggerAddComment = (editor, config) => __awaiter(void 0, void 0, void 0, function* () {\n try {\n return addComment({ editor, context: config === null || config === void 0 ? void 0 : config.context });\n }\n catch (error) {\n VeltService.catchError('Error triggering add comment', error);\n }\n});\n/**\n * Creates a comment annotation for the currently selected text in the editor\n * This function handles the entire flow from getting the selected text to creating\n * the actual comment through the Velt service\n */\nexport const addComment = (_a) => __awaiter(void 0, [_a], void 0, function* ({ editorId, editor, context: clientContext, }) {\n var _b, _c;\n try {\n // get comment element from Velt sdk\n const commentElement = VeltService.getCommentElement();\n if (!commentElement)\n return;\n // Ensure we have an editor ID for proper tracking\n if (!editorId) {\n editorId = (_b = EditorService.getEditorId(editor)) !== null && _b !== void 0 ? _b : undefined;\n }\n // Initialize plugin instance with editor context\n const plugin = Plugin.getInstance({ editorId, editor });\n // Get text currently selected by the user\n const selectedText = plugin.editorService.getSelectedText(editor);\n // Exit if no text is selected - nothing to comment on\n if (!selectedText) {\n return;\n }\n // Find the parent node containing the selection to establish position context\n const targetTextNode = plugin.editorService.findParentNodeWithIdForSelection(editor);\n // Extract node ID and location information for proper positioning\n let targetTextNodeId = undefined;\n let locationId = null;\n if (targetTextNode) {\n targetTextNodeId = targetTextNode.id;\n // Find the closest parent with a location ID to properly anchor the comment\n locationId = (_c = targetTextNode\n .closest('[data-velt-location-id]')) === null || _c === void 0 ? void 0 : _c.getAttribute('data-velt-location-id');\n }\n const occurrence = plugin.editorService.findOccurrenceOfSelectedText(editor, targetTextNode !== null && targetTextNode !== void 0 ? targetTextNode : undefined);\n // Exit if we can't determine occurrence information\n if (!occurrence) {\n return;\n }\n // Initialize context object for the comment\n let context = {};\n if (clientContext && typeof clientContext === 'object') {\n context = Object.assign(Object.assign({}, context), clientContext);\n }\n // Add text editor specific configuration to context\n // This helps position and track the comment as document changes\n context.textEditorConfig = {\n text: selectedText,\n occurrence: occurrence,\n targetTextNodeId: targetTextNodeId,\n };\n if (editorId) {\n context.textEditorConfig.editorId = editorId;\n }\n // Short delay to prevent comment dialog from closing immediately\n // This improves user experience when interacting with comments\n yield new Promise((resolve) => setTimeout(resolve, 200));\n // Create location reference if we have a location ID\n let location;\n if (locationId) {\n location = { id: locationId };\n }\n try {\n // Create the actual comment through Velt service\n VeltService.addManualComment({ context, location });\n }\n catch (error) {\n VeltService.catchError('Error creating comment', error);\n }\n }\n catch (error) {\n VeltService.catchError('Error adding comment', error);\n }\n});\nexport function highlightComments(editor, commentAnnotations, editorId) {\n try {\n renderComments({ editor, editorId, commentAnnotations });\n }\n catch (error) {\n VeltService.catchError('Error highlighting tiptap-velt-comments', error);\n }\n}\nexport const renderComments = ({ editor, editorId, commentAnnotations }) => {\n var _a;\n try {\n if (editor) {\n if (!editorId) {\n editorId = (_a = EditorService.getEditorId(editor)) !== null && _a !== void 0 ? _a : undefined;\n }\n commentAnnotations = commentAnnotations === null || commentAnnotations === void 0 ? void 0 : commentAnnotations.filter((annotation) => {\n var _a, _b, _c;\n return !!((_a = annotation.context) === null || _a === void 0 ? void 0 : _a.textEditorConfig) &&\n ((_c = (_b = annotation.context) === null || _b === void 0 ? void 0 : _b.textEditorConfig) === null || _c === void 0 ? void 0 : _c.editorId) === editorId;\n });\n const plugin = Plugin.getInstance({ editorId, editor });\n plugin.storeService.updateGlobalStore({ editor, comments: commentAnnotations });\n }\n }\n catch (error) {\n VeltService.catchError('Error highlighting tiptap-velt-comments', error);\n }\n};\nexport const onSlateValueChange = ({ editor, editorId, }) => {\n var _a;\n try {\n if (!editorId) {\n editorId = (_a = EditorService.getEditorId(editor)) !== null && _a !== void 0 ? _a : undefined;\n }\n const plugin = Plugin.getInstance({ editorId, editor });\n // Get the current editor text content\n const currentEditorTextContent = plugin.editorService.getEditorTextContent(editor);\n const previousEditorTextContent = plugin.getPreviousEditorTextContent();\n // Prevent unnecessary processing if content hasn't changed\n if (currentEditorTextContent === previousEditorTextContent)\n return;\n // Update the previous content for next comparison\n plugin.setPreviousEditorTextContent(currentEditorTextContent);\n plugin.editorService.onSlateValueChange({ editor });\n }\n catch (error) {\n VeltService.catchError('Error in processVeltCommentChanges:', error);\n }\n};\n"],"names":["__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","SuppressedError","Constants","EDITOR_ID","LOCATION_ID","VELT_COMMENT","_a","VeltService","selectedCommentsMap","Map","subscribers","isSubscribed","getCommentElement","velt","window","Velt","error","catchError","addManualComment","context","location","commentElement","updateContext","annotationId","subscribeToSelectedCommentsMap","id","subscriber","subscribeToSelectedAnnotationsMapSingleton","set","unsubscribeFromSelectedCommentsMap","delete","message","otherProperties","_b","properties","Object","assign","sdkVersion","version","getSelectedComments","subscribe","comments","forEach","comment","map1","map2","size","key","get","areMapsEqual","updateSelectedCommentsMap","EditorService","constructor","plugin","this","getSelectedText","editor","selection","Editor","string","err","findOccurrenceOfText","options","searchText","scopeElement","startOffset","caseSensitive","total","position","fullText","textContent","searchMethod","text","toLowerCase","processedFullText","processedSearchText","occurrences","lastIndex","matchIndex","indexOf","push","length","positionBeforeSelected","filter","index","findOccurrenceOfSelectedText","selectedText","occurrence","allMatches","findAllMatches","findIndex","match","anchor","path","toString","focus","offset","domSelection","ReactEditor","toDOMNode","textToSearch","matches","getText","node","isTextNode","searchInNode","nodeText","range","Array","isArray","children","child","initialNode","nodes","at","mode","findParentNodeWithIdForSelection","Node","findParentNodeWithId","domNode","editorDOM","maxIterations","idPattern","currentNode","iterationCount","document","body","contains","test","parentElement","removeVeltCommentFromEditor","Error","elementsToUnwrap","descendants","isVeltCommentText","reverse","nodeAtPath","elementAtNode","isConnected","unwrapNodes","Transforms","HistoryEditor","getHistoryEditor","withoutSaving","highlightTextWithVeltComment","annotation","targetTextNodeId","textEditorConfig","injectTag","storeService","annotationStore","getEditorTextContent","map","join","onSlateValueChange","annotationsToCheck","collectDocumentAnnotations","changedAnnotations","from","pos","start","changes","processAnnotationChanges","updateVeltComments","targetElementId","targetElement","getElementById","isElementInEditor","findTextOccurrence","wrapNodes","type","split","storedData","_c","_d","targetNode","targetPath","annotatedNodes","currentText","currentTargetNode","undefined","currentTargetNodeId","containerNode","containerPath","toSlateNode","findPath","currentOccurrence","findTextOccurrenceOfNode","nodeOccurrencePosition","textChanged","occurrenceChanged","targetTextNodeIdChanged","contentChanged","originalOccurrence","originalText","originalTargetTextNodeId","newTargetTextNodeId","multiThreadAnnotationId","changeData","entries","JSON","parse","stringify","remove","element","traverseNodesForText","currentPath","textNodePositions","Text","isText","end","SlateElement","Element","isElement","i","childPath","collectSubtreeText","regex","RegExp","replace","exec","matchStart","matchEnd","anchorNodeInfo","focusNodeInfo","nodePosition","findAllTextOccurrences","processText","n","p","searchAt","Path","isDescendant","equals","processedNodeText","startPoint","endPoint","substring","nodePath","trim","totalOccurrences","textOccurrences","reactError","isEqual","isAncestor","setHistoryEditor","historyEditor","getEditorId","closest","getAttribute","StoreService","globalStore","filteredComments","globalAnnotationStore","data","getAll","clear","updateGlobalStore","store","newSelectedCommentsMap","oldFilteredComments","status","newAnnotationIds","Set","has","editorService","highlightCommentsFromGlobalStore","editorId","storeInstanceMap","instanceMap","Plugin","previousEditorTextContent","setPreviousEditorTextContent","getInstance","config","getPreviousEditorTextContent","addComment","clientContext","targetTextNode","locationId","setTimeout","renderComments","commentAnnotations","currentEditorTextContent","props","attributes","React","createElement","isInline","isVoid","onChange","operations","some","operation","Operation","isTextOperation"],"mappings":"gFAkHO,SAASA,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBO,KAAKR,EAAWK,EAAY,CAC9GH,GAAMN,EAAYA,EAAUa,MAAMhB,EAASC,GAAc,KAAKS,OACtE,GACA,CA8MkD,mBAApBO,iBAAiCA,gBCxUxD,MAAMC,EACG,CACRC,UAAW,iBACXC,YAAa,yBAHRF,EAKK,CACVG,aAAc,eCNtB,IAAIC,EACG,MAAMC,GAEbD,EAAKC,EACLA,EAAYC,oBAAsB,IAAIC,IACtCF,EAAYG,YAAc,IAAID,IAC9BF,EAAYI,cAAe,EAE3BJ,EAAYK,kBAAoB,KAC5B,IACI,MAAMC,EAAOC,OAAOC,KACpB,OAAIF,aAAmC,EAASA,EAAKD,mBAC1CC,EAAKD,o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B,EAGEA,CAAM","x_google_ignoreList":[0]}
@@ -20,7 +20,10 @@ export interface AnnotationChange {
20
20
  }
21
21
  export declare class EditorService {
22
22
  plugin: Plugin;
23
+ private static HistoryEditor?;
23
24
  constructor(plugin: Plugin);
25
+ static setHistoryEditor: (historyEditor: any) => void;
26
+ static getHistoryEditor: () => any;
24
27
  static getEditorId: (editor: Editor) => string | null;
25
28
  static isVeltCommentText: (element: SlateElement) => boolean;
26
29
  getSelectedText: (editor: Editor) => string | null;
@@ -4,7 +4,10 @@ export { SlateVeltComment } from './SlateVeltComment';
4
4
  export * from './types';
5
5
  export interface VeltCommentsEditor extends Editor {
6
6
  }
7
- export declare const withVeltComments: <T extends Editor>(editor: T) => T & VeltCommentsEditor;
7
+ export interface VeltCommentsEditorOptions {
8
+ HistoryEditor?: any;
9
+ }
10
+ export declare const withVeltComments: <T extends Editor>(editor: T, options?: VeltCommentsEditorOptions) => T & VeltCommentsEditor;
8
11
  export interface VeltCommentConfig {
9
12
  context?: unknown;
10
13
  }