PageSourceSearch

https://discours.netlify.app/scripts/ctrl-editor-poc-5a16c25b.js

js discours.netlify.app collected 2026-10-03 10:40:49 UTC 28,626 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkdiscours_io_frontend=globalThis.webpackChunkdiscours_io_frontend||[]).push([[831],{6823(e,t,n){function o(e){const t=e.includes("?")?"&":"?";return`${e}${t}editorProtocol=${a}`}n.d(t,{NP:()=>i,Wu:()=>o,iv:()=>a});const a="2",i="X-Editor-Protocol"},9507(e,t,n){n.r(t),n.d(t,{default:()=>r}),n(12849);var o=n(59217),a=n(7573),i=n(6823);angular.module("discours.pages").controller("EditorPocCtrl",["$scope","$timeout","$interval","$location","loginService","localStorageService","DISCOURS_ENV","HOCUSPOCUS_SERVER","Notification","NOTIFICATION_MESSAGES",function(e,t,r,s,c,l,d,u,m,g){function p(){if(e.editorInstance)try{const t={html:e.editorInstance.getHTML(),documentId:O,timestamp:Date.now(),version:e.documentVersion||1};l.set(M+O,JSON.stringify(t)),U("[EditorPocCtrl] Draft backup saved to localStorage")}catch(e){}}function f(){try{l.remove(M+O)}catch(e){}}function h(t){e.editorInstance&&e.editorInstance.commands.removeComment(t.id),e.removeCommentFromYMap(t.id);const n=e.comments.findIndex(e=>e.id===t.id);n>-1&&e.comments.splice(n,1),e.activeCommentId=null}function b(){const t=e.editorInstance?e.editorInstance.getHTML():e.content,n=(0,a.Wf)(t);return{title:e.documentTitle||"Без названия",body:n,author:e.currentUser.name||e.currentUser.path,authorLink:e.currentUser.path?`/@${e.currentUser.path}`:null,category:e.documentCategory||null,categoryLink:e.documentCategorySlug?`/category/${e.documentCategorySlug}`:null,thumborId:e.documentThumbor||null,imageCaption:e.documentImageCaption||null,tags:e.documentTags||[],publishedAt:new Date,views:0,preview:!0,createdBy:{_id:e.currentUser._id},editable:!1,application:{}}}function v(){P&&t.cancel(P),P=t(function(){P=null;const t=document.querySelector(".post-preview, .tiptap-preview-mode");if(!t)return void(e.showBottomEditButton=!1);const n=3*window.innerHeight;e.showBottomEditButton=t.scrollHeight>n},200)}function C(){F||(F=setTimeout(function(){F=null,e.previewMode&&v()},250))}function S(){if(e.editorInstance)try{j?(e.suggestions=j.extractSuggestions(e.editorInstance),e.$applyAsync()):Promise.all([n.e(272),n.e(929),n.e(411),n.e(753),n.e(68),n.e(45)]).then(n.bind(n,36090)).then(t=>{e.$$destroyed||(j=t,e.suggestions=t.extractSuggestions(e.editorInstance),e.$applyAsync())}).catch(e=>{})}catch(e){}}function y(t){if(!("development"===d||"development_local"===d)&&(e.hasUnsavedChanges||e.hasDraft)&&e.editorInstance&&(t.preventDefault(),t.returnValue=""),e.editorInstance&&!e.editorInstance.isDestroyed&&e.collabEnabled)try{const t=e.editorInstance.getHTML();if(t!==W){p();const n=new Blob([JSON.stringify({body:t,_userId:c.userId(),_authToken:l.get("authToken"),expectedVersion:e.documentVersion||null})],{type:"application/json"});navigator.sendBeacon((0,i.Wu)(`/api/v2/collab/document/content-item:${encodeURIComponent(O)}`),n)}}catch(t){try{e.content&&l.set(M+O,JSON.stringify({html:e.content,documentId:O,timestamp:Date.now(),version:e.documentVersion||1,source:"beforeunload_fallback"}))}catch(e){}}}function I(){U("[EditorPocCtrl] Browser is now online"),e.$applyAsync(function(){e.isOffline=!1,m.success(g.CONNECTION_RESTORED),e.hasUnsavedChanges&&m.info(g.SYNCING)})}function E(){p(),e.$applyAsync(function(){e.isOffline=!0,m.warning(g.NO_NETWORK)})}function T(t,n,o){if(!t||"string"!=typeof o||!o.trim())return;const a=e.collabCommentRecoveryDrafts.find(function(e){return e.id===t});a?a.text=o:e.collabCommentRecoveryDrafts.push({id:t,label:n,text:o})}function w(t){return e.collabCommentStoreUnavailable=!0,e.collabCommentStoreMessage=t,Q||(Q=!0,(e.comments||[]).forEach(function(e){e&&e.id&&("string"==typeof e.text&&e.text.trim()&&(e._collabRecoveryText=e.text,T("comment:"+e.id,"Комментарий",e.text)),(e.replies||[]).forEach(function(t,n){t&&"string"==typeof t.text&&t.text.trim()&&T("comment-reply:"+e.id+":"+(t._id||n),"Ответ на комментарий",t.text)}),"string"==typeof e.newReplyText&&e.newReplyText.trim()&&T("comment-reply-draft:"+e.id,"Ответ на комментарий",e.newReplyText))})),e.previewMode&&"function"==typeof e.setEditorMode&&e.setEditorMode("editing"),e.showCommentsSidebar=!0,e.sidebarTab="comments",J&&(r.cancel(J),J=null),K||(K=!0,m.warning(t)),e.$applyAsync(),!0}
1function k(e){return!!(0,o.IR)(e)&&w((0,o.Vj)())}const M="draft_backup_",_=10485760,A=new AbortController;let x=null,P=null,N=null,D=null,R=null;const U="production"!==d?function(){}.bind():function(){};e.content="",e.editorInstance=null,e.selection=null,e.suggestionMode=!1,e.showCommentsSidebar=!0,e.sidebarTab="comments",e.hasUnsavedChanges=!1,e.hasRecoverableDraft=!1,e.draftBackup=null,e.isOffline=!navigator.onLine,e.previewMode=!1,e.showBottomEditButton=!1,e.currentEditorMode="editing",e.currentUser=c.isLoggedIn()?{_id:c.userId(),path:c.userPath(),name:c.userPath()||"Пользователь",avatar:c.userAvatar()}:{_id:"anonymous",name:"Гость"},e.userId=e.currentUser._id;const O=s.search().doc||"poc-test-document",L=u||"wss://discours-collab.fly.dev";e.collabEnabled=c.isLoggedIn(),e.collabServerUrl=e.collabEnabled?L:"",e.collabDocumentName=e.collabEnabled?`content-item:${O}`:"",e.collabToken=e.collabEnabled?`${c.userId()}:${l.get("authToken")}`:"",e.collabStatus=e.collabEnabled?"connecting":"",e.collabCommentStoreUnavailable=!1,e.collabCommentStoreMessage=(0,o.Vj)(),e.collabCommentRecoveryDrafts=[],e.DISCOURS_ENV=d;let B=!1;e.onCollabSynced=function(){U("[EditorPocCtrl] Collaboration synced with server"),e.collabStatus="synced",B&&(B=!1,m.success(g.CONNECTION_RESTORED))},e.onCollabDisconnect=function(){e.collabStatus="disconnected",B||(B=!0,m.warning(g.CONNECTION_LOST),p())},e.onCollabConnect=function(){U("[EditorPocCtrl] Collaboration connected to",e.collabServerUrl),U("[EditorPocCtrl] Document:",e.collabDocumentName),U("[EditorPocCtrl] User:",e.currentUser.name),e.collabStatus="connected"},e.onCollabFallback=function(t){switch(e.collabStatus="offline",t){case"connection_timeout":m.warning(g.CONNECTION_FAILED);break;case"sync_timeout":m.warning(g.SYNC_INCOMPLETE);break;case"auth_failed":m.error(g.AUTH_ERROR_OFFLINE);break;case"connection_closed":m.warning(g.CONNECTION_CLOSED);break;default:m.warning(g.OFFLINE_MODE)}e.autoSaveEnabled||(e.autoSaveEnabled=!0,e.startAutoSave()),p()},e.restoreDraftBackup=async function(){if(e.draftBackup&&e.editorInstance)try{U("[EditorPocCtrl] Restoring draft from localStorage");const{sanitizeBeforeSetContent:t}=await Promise.resolve().then(n.bind(n,35282));if(e.$$destroyed)return;e.editorInstance.commands.setContent(t(e.draftBackup.html),!1),e.hasUnsavedChanges=!0,e.hasRecoverableDraft=!1,e.draftBackup=null,e.$applyAsync(),m.success(g.DRAFT_RESTORED)}catch(e){m.error(g.DRAFT_RESTORE_ERROR)}},e.dismissDraftBackup=function(){e.hasRecoverableDraft=!1,e.draftBackup=null,f(),U("[EditorPocCtrl] Draft backup dismissed by user")},U("[EditorPocCtrl] Collaboration settings:",{enabled:e.collabEnabled,serverUrl:e.collabServerUrl,documentName:e.collabDocumentName,userId:e.userId,userName:e.currentUser.name}),e.initialContent=null,e.collabEnabled&&"poc-test-document"!==O&&(U("[EditorPocCtrl] Loading initial content for:",O),fetch(`/api/v2/collab/document/content-item:${encodeURIComponent(O)}`,{headers:{"X-User-Id":c.userId(),"X-Auth-Token":l.get("authToken"),"Content-Type":"application/json"},signal:A.signal}).then(e=>{if(e.ok)return e.json();throw new Error(`API returned ${e.status}`)}).then(t=>{if("success"===t.status&&t.data){U("[EditorPocCtrl] Loaded document:",t.data.title);const n=function(){try{const e=l.get(M+O);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.timestamp>864e5?(l.remove(M+O),null):t}catch(e){return null}}();e.$applyAsync(function(){n&&n.version>=(t.data.version||1)&&(e.hasRecoverableDraft=!0,e.draftBackup=n,U("[EditorPocCtrl] Found recoverable draft from:",new Date(n.timestamp)),m.info(g.UNSAVED_DRAFT_FOUND)),e.initialContent=t.data.body||"",e.documentTitle=t.data.title||"",e.documentVersion=t.data.version||1,e.canEdit=null!=t.data.canDirectEdit?t.data.canDirectEdit:t.data.canEdit})}}).catch(e=>{})),e.comments=[],e.newCommentText="",e.activeCommentId=null,e.suggestions={adds:[],deletes:[],all:[]}
1,e.sampleContent='\n      <h2>Proof of Concept: Коллаборативный редактор</h2>\n      <p>Это <strong>тестовый контент</strong> для проверки работы нового редактора на базе <em>Tiptap</em>.</p>\n      <p>Здесь можно проверить различные функции форматирования:</p>\n      <ul>\n        <li><strong>Жирный</strong> текст</li>\n        <li><em>Курсив</em></li>\n        <li><u>Подчёркивание</u></li>\n        <li>Вложенные <strong>стили <em>форматирования</em></strong></li>\n      </ul>\n      <h3>Кастомные подвёрстки</h3>\n      <ta-sub>\n        <p>Это пример подвёрстки <strong>ta-sub</strong> — серая плашка, которая выделяет важную информацию.</p>\n        <p>Подвёрстка может содержать несколько абзацев и форматирование.</p>\n      </ta-sub>\n      <p>После подвёрстки продолжается обычный текст статьи.</p>\n      <blockquote>\n        <p>Это обычная цитата (blockquote) — также должна корректно парситься и отображаться.</p>\n      </blockquote>\n      <h3>Ссылки и нумерованные списки</h3>\n      <p>Текст со <a href="https://discours.io" target="_blank">ссылкой на Дискурс</a> и другим форматированием.</p>\n      <ol>\n        <li>Первый пункт нумерованного списка</li>\n        <li>Второй пункт с <strong>жирным</strong> текстом</li>\n        <li>Третий пункт со <a href="https://example.com">ссылкой</a></li>\n      </ol>\n      <h3>Тестирование коллаборации</h3>\n      <p>Выделите любой фрагмент текста и нажмите кнопку "Комментарий" чтобы добавить комментарий на полях.</p>\n      <p>Включите "Режим предложений" и попробуйте редактировать текст — ваши правки будут отмечены для проверки автором.</p>\n    ',e.content=e.sampleContent,e.execCommand=function(t,o){if(!e.editorInstance)return;const a=e.editorInstance;switch(t){case"bold":a.smartToggleFormat?a.smartToggleFormat("bold"):a.chain().focus().toggleBold().run();break;case"italic":a.smartToggleFormat?a.smartToggleFormat("italic"):a.chain().focus().toggleItalic().run();break;case"underline":a.smartToggleFormat?a.smartToggleFormat("underline"):a.chain().focus().toggleUnderline().run();break;case"strike":a.smartToggleFormat?a.smartToggleFormat("strike"):a.chain().focus().toggleStrike().run();break;case"h2":a.chain().focus().toggleHeading({level:2}).run();break;case"h3":a.chain().focus().toggleHeading({level:3}).run();break;case"bulletList":a.chain().focus().toggleBulletList().run();break;case"orderedList":a.chain().focus().toggleOrderedList().run();break;case"blockquote":(async()=>{try{const t=a.state.selection.from,o=a.state.selection.to;let i,r;if(R)i=R.wrapperManager,r=R.pmState;else{const[e,t]=await Promise.all([n.e(929).then(n.bind(n,99159)),n.e(272).then(n.bind(n,75783))]);R={wrapperManager:e,pmState:t},i=e,r=t}if(e.$$destroyed||!a.view||a.isDestroyed)return;try{const e=a.state.doc.content.size,n=Math.min(Math.max(0,t),e),i=Math.min(Math.max(n,o),e);if(a.state.selection.from!==n||a.state.selection.to!==i){const e=a.state.tr,t=r.TextSelection.create(e.doc,n,i);e.setSelection(t),a.view.dispatch(e)}}catch(e){}i.toggleWrapperWithExclusion(a,"blockquote",(e,t)=>{})}catch(e){m.error(g.FORMATTING_ERROR)}})();break;case"taSub":a.chain().focus().toggleTaSub().run();break;case"undo":a.chain().focus().undo().run();break;case"redo":a.chain().focus().redo().run();break;case"link":{const e=a.getAttributes("link").href,t=!!e;Promise.all([n.e(753),n.e(68)]).then(n.bind(n,2260)).then(n=>
1{n.openLinkInlineEditor({initialUrl:e||"",showRemove:t,tiptapEditor:a,onSave:e=>{a.chain().focus().extendMarkRange("link").setLink({href:e}).run()},onRemove:()=>{a.chain().focus().unsetLink().run()},onCancel:()=>{a.chain().focus().run()}})}).catch(e=>{m.error(g.LINK_EDITOR_ERROR)});break}case"unlink":a.chain().focus().unsetLink().run()}e.$applyAsync(function(){e.updateToolbarState()})},e.isActive=function(t,n){if(!e.editorInstance)return!1;const o=e.editorInstance;switch(t){case"bold":return o.isActive("bold");case"italic":return o.isActive("italic");case"underline":return o.isActive("underline");case"strike":return o.isActive("strike");case"h2":return o.isActive("heading",{level:2});case"h3":return o.isActive("heading",{level:3});case"bulletList":return o.isActive("bulletList");case"orderedList":return o.isActive("orderedList");case"blockquote":return o.isActive("blockquote");case"taSub":return o.isActive("taSub");case"link":return o.isActive("link");default:return!1}},e.updateToolbarState=function(){e.$applyAsync()},e.onSelectionChange=function(t){e.selection=t,e.updateSuggestionsListDebounced()},e.canAddComment=function(){return!e.collabCommentStoreUnavailable&&e.selection&&e.selection.hasSelection},e.addComment=function(){if(!e.canAddComment()||!e.editorInstance)return;const n="comment_"+Date.now()+"_"+Math.random().toString(36).substring(2,11),o=e.selection.selectedText;e.editorInstance.chain().focus().setComment(n).run();const a={id:n,text:"",quotedText:o,author:e.currentUser,createdAt:new Date,resolved:!1,replies:[],editing:!0,_isNewComment:!0,_originalText:""};e.saveCommentToYMap(a),e.comments.push(a),e.activeCommentId=n,x=t(function(){x=null;const e=document.querySelector(".comment-item.editing textarea");e&&e.focus()},100)},e.saveComment=function(t){e.collabCommentStoreUnavailable||(t.text.trim()?(t.editing=!1,e.activeCommentId=null,delete t._isNewComment,delete t._originalText,delete t._collabRecoveryText,e.saveCommentToYMap(t),U("[EditorPocCtrl] Comment saved:",t)):e.removeComment(t))},e.cancelComment=function(t){t._isNewComment&&!t.text.trim()?h(t):(t._isNewComment||void 0===t._originalText||e.collabCommentStoreUnavailable&&t.text.trim()?e.collabCommentStoreUnavailable&&"string"==typeof t.text&&t.text.trim()&&(t._collabRecoveryText=t.text):t.text=t._originalText,t.editing=!1,e.activeCommentId=null)},e.editComment=function(t){e.collabCommentStoreUnavailable||(t._isNewComment=!1,t._originalText=t.text,t.editing=!0,e.activeCommentId=t.id)},e.removeComment=function(t){e.collabCommentStoreUnavailable||h(t)},e.resolveComment=function(t){e.collabCommentStoreUnavailable||(t.resolved=!0,e.editorInstance&&e.editorInstance.commands.resolveComment(t.id),e.saveCommentToYMap(t))},e.unresolveComment=function(t){e.collabCommentStoreUnavailable||(t.resolved=!1,e.editorInstance&&e.editorInstance.commands.unresolveComment(t.id),e.saveCommentToYMap(t))},e.scrollToComment=function(t){if(!e.editorInstance)return;const{doc:n}=e.editorInstance.state;n.descendants((n,o)=>{if(n.marks&&n.marks.find(e=>"comment"===e.type.name&&e.attrs.commentId===t.id)){e.editorInstance.commands.setTextSelection({from:o,to:o+n.nodeSize});const t=document.querySelector(".tiptap-editor-content");if(t){const e=window.getSelection();if(e.rangeCount>0){const n=e.getRangeAt(0).getBoundingClientRect();t.scrollTo({top:n.top-100,behavior:"smooth"})}}return!1}})},e.addReply=function(t,n){e.collabCommentStoreUnavailable||n&&n.trim()&&(t.replies.push({text:n,author:{_id:e.currentUser._id,name:e.currentUser.name,path:e.currentUser.path},createdAt:(new Date).toISOString()}),t.newReplyText="",e.saveCommentToYMap(t))},e.previewPost=null;let F=null;window.addEventListener("resize",C,{passive:!0}),e.$on("$destroy",function(){window.removeEventListener("resize",C),F&&(clearTimeout(F),F=null)}),e.togglePreviewMode=function(){e.previewMode=!e.previewMode,e.previewMode?(e.previewPost=b(),e.showCommentsSidebar=!1,v()):(e.previewPost=null,e.showBottomEditButton=!1),e.editorInstance&&e.editorInstance.setEditable(!e.previewMode),e.currentEditorMode=e.previewMode?"preview":e.suggestionMode?"suggesting":"editing",U("[EditorPocCtrl] Preview mode:",e.previewMode)},e.setEditorMode=function(t){switch(e.currentEditorMode=t,t){case"preview":e.previewMode=!0,e.suggestionMode=!1,e.previewPost=b(),e.editorInstance&&(e.editorInstance.setE
1ditable(!1),e.editorInstance.setSuggestionMode(!1)),e.showCommentsSidebar=!1,v();break;case"editing":e.previewMode=!1,e.previewPost=null,e.showBottomEditButton=!1,e.suggestionMode=!1,e.editorInstance&&(e.editorInstance.setEditable(!0),e.editorInstance.setSuggestionMode(!1));break;case"suggesting":e.previewMode=!1,e.previewPost=null,e.showBottomEditButton=!1,e.suggestionMode=!0,e.editorInstance&&(e.editorInstance.setEditable(!0),e.editorInstance.setSuggestionMode(!0))}U("[EditorPocCtrl] Editor mode set to:",t)},e.onEditorModeChange=function(t){e.setEditorMode(t)},e.toggleSuggestionMode=function(){e.suggestionMode=!e.suggestionMode,e.currentEditorMode=e.suggestionMode?"suggesting":"editing",e.editorInstance&&e.editorInstance.setSuggestionMode(e.suggestionMode)};let j=null,q=null;e.updateSuggestionsList=function(){q&&(t.cancel(q),q=null),S()},e.updateSuggestionsListDebounced=function(){q&&t.cancel(q),q=t(()=>{q=null,S()},150)},e.acceptSuggestion=function(t){e.editorInstance&&("add"===t.type?e.editorInstance.commands.acceptSuggestionAdd(t.suggestionId):e.editorInstance.commands.acceptSuggestionDelete(t.suggestionId),e.updateSuggestionsList())},e.rejectSuggestion=function(t){e.editorInstance&&("add"===t.type?e.editorInstance.commands.rejectSuggestionAdd(t.suggestionId):e.editorInstance.commands.rejectSuggestionDelete(t.suggestionId),e.updateSuggestionsList())},e.acceptAllSuggestions=function(){e.suggestions.all.forEach(t=>{e.acceptSuggestion(t)})},e.rejectAllSuggestions=function(){e.suggestions.all.forEach(t=>{e.rejectSuggestion(t)})},e.toggleSidebar=function(){e.showCommentsSidebar=!e.showCommentsSidebar},e.retryConnection=function(){const e=document.querySelector("tiptap-editor");if(e){const t=angular.element(e).isolateScope();if(t&&"function"==typeof t.retryCollabConnection)return void t.retryCollabConnection()}window.location.reload()},e.inviteModalOpen=!1,e.openInviteModal=function(){e.inviteModalOpen=!0},e.onInvitesChanged=function(t){window.DISCOURS_DEBUG&&U("[EditorPocCtrl] Invites changed:",t?t.length:0),e.inviteCount=t?t.length:0,e.acceptedInviteCount=t?t.filter(function(e){return"accepted"===e.status}).length:0},e.loadSampleContent=function(){e.content=e.sampleContent},e.clearContent=function(){e.content="<p></p>",e.comments=[],e.suggestions={adds:[],deletes:[],all:[]}},e.getHTML=function(){e.editorInstance&&U("[EditorPocCtrl] Current HTML:",e.editorInstance.getHTML())};let H=null,V=null,Y=!1;const z=e.$watch("editorInstance",function(o){if(!o||Y)return;Y=!0,z&&z(),U("[EditorPocCtrl] Tiptap editor initialized"),e.updateSuggestionsList();const a=document.getElementById("toc-nav-container");a&&Promise.all([n.e(753),n.e(68)]).then(n.bind(n,75511)).then(({TocNavigation:t})=>{e.tocNavigation=new t(o,a,{collapsed:!0,title:"Оглавление"}),U("[EditorPocCtrl] TOC Navigation initialized")}
1).catch(e=>{}),e.collabEnabled&&(o.isCollaborative&&o.isCollaborative()&&(V=o.getCommentsMap(),e.syncCommentsFromYMap(V),H=t=>{e.$applyAsync(function(){e.syncCommentsFromYMap(V)})},V.observe(H),U("[EditorPocCtrl] Subscribed to collaborative comments")),N=t(function(){N=null,e.startAutoSave()},5e3),D=t(function(){D=null,e.startCommentsSync(),e.loadCommentsFromMongo().then(t=>{if(0===e.comments.length&&t.length>0&&e.editorInstance){const n=e.editorInstance.getCommentsMap();t.forEach(e=>{n.set(e.commentId,{text:e.text,quotedText:e.quotedText,author:e.author,createdAt:e.createdAt instanceof Date?e.createdAt.toISOString():e.createdAt,resolved:e.resolved,replies:e.replies||[]})}),U("[EditorPocCtrl] Loaded",t.length,"comments from MongoDB to Y.Map")}}).catch(function(e){})},3e3))});e.syncCommentsFromYMap=function(t){const n=[],o=new Set;t.forEach((t,a)=>{o.add(a);const i="object"==typeof t?t:JSON.parse(t),r=e.comments.find(e=>e.id===a),s=r&&e.collabCommentStoreUnavailable?r._collabRecoveryText:void 0;n.push({id:a,text:void 0!==s?s:r&&r.editing?r.text:i.text||"",quotedText:i.quotedText||"",author:i.author||{name:"Unknown"},createdAt:i.createdAt?new Date(i.createdAt):new Date,resolved:i.resolved||!1,replies:i.replies||[],editing:!!r&&r.editing,newReplyText:r?r.newReplyText:"",_collabRecoveryText:s,_isNewComment:!!r&&r._isNewComment,_originalText:r?r._originalText:void 0})}),(e.comments||[]).forEach(function(e){e&&!o.has(e.id)&&((e.editing||e._collabRecoveryText)&&T("comment:"+e.id,"Комментарий",e._collabRecoveryText||e.text),T("comment-reply-draft:"+e.id,"Ответ на комментарий",e.newReplyText))}),n.sort((e,t)=>e.createdAt-t.createdAt),e.comments=n},e.saveCommentToYMap=function(t){e.editorInstance&&e.editorInstance.isCollaborative()&&e.editorInstance.getCommentsMap().set(t.id,{text:t.text,quotedText:t.quotedText,author:{_id:t.author._id,name:t.author.name,path:t.author.path},createdAt:t.createdAt instanceof Date?t.createdAt.toISOString():t.createdAt,resolved:t.resolved,replies:t.replies})},e.removeCommentFromYMap=function(t){e.editorInstance&&e.editorInstance.isCollaborative()&&e.editorInstance.getCommentsMap().delete(t)},e.isSaving=!1,e.lastSavedAt=null,e.autoSaveEnabled=!0,e.autoSaveInterval=3e4,e.saveError=null;let X=null,W="";e.saveDocument=function(){if(!e.editorInstance||!e.collabEnabled)return Promise.resolve(!1);const t=e.editorInstance.getHTML(),n=new Blob([t]).size,o=n/_;if(n>_){const t=(n/1048576).toFixed(2);return m.error(g.CONTENT_TOO_LARGE(t)),e.saveError="size_limit",Promise.resolve(!1)}if(o>=.8&&!e._sizeWarningShown){const t=(n/1048576).toFixed(2),a=(100*o).toFixed(0);m.warning(g.CONTENT_SIZE_WARNING(t,a)),e._sizeWarningShown=!0}else o<.8&&(e._sizeWarningShown=!1);if(t===W)return U("[EditorPocCtrl] Content unchanged, skipping save"),Promise.resolve(!0);e.isSaving=!0,e.saveError=null;const a=`/api/v2/collab/document/content-item:${encodeURIComponent(O)}`;return fetch(a,{method:"PUT",headers:{"X-User-Id":c.userId(),"X-Auth-Token":l.get("authToken"),"Content-Type":"application/json",[i.NP]:i.iv},body:JSON.stringify({body:t,title:e.documentTitle}),signal:A.signal}).then(async e=>{if(!e.ok){const t=await e.json().catch(()=>({})),n=new Error(t.data&&t.data.message||t.message||`API returned ${e.status}`);throw n.status=e.status,n}return e.json()}).then(n=>{if("success"===n.status)return W=t,e.$applyAsync(function(){e.isSaving=!1,e.lastSavedAt=new Date,e.hasUnsavedChanges=!1,e.hasDraft=!0,e.draftVersion=n.data.draftVersion,e.saveError=null,U("[EditorPocCtrl] Draft saved, draftVersion:",n.data.draftVersion)}),f(),!0;throw new Error(n.data&&n.data.message||n.message||"Save failed")}).catch(t=>("AbortError"===t.name||(p(),e.$applyAsync(function(){e.isSaving=!1,e.saveError="error"})),!1))},e.isPublishing=!1,e.hasDraft=!1,e.publishDocument=function(){if(!e.editorInstance||!e.collabEnabled)return Promise.resolve(!1);const t=e.editorInstance.getHTML(),n=new Blob([t]).size;if(n>_){const e=(n/1048576).toFixed(2);return m.error(g.CONTENT_PUBLISH_TOO_LARGE(e)),Promise.resolve(!1)}if(e.hasUnsavedChanges)return e.saveDocument().then(()=>e.publishDocument());e.isPublishing=!0;const o=`/api/v2/collab/document/content-item:${encodeURIComponent(O)}/publish`;return fetch(o,{method:"POST",headers:{"X-User-Id":c.userId(),"X-Auth-Token":l.get("authToken"),"Content-Type":"application/json",[i.NP]:i.iv},body:JSON.stringify({}),signal:A.signal}).then(async e=>{if(!e.ok){const t=await e.json().catch(()=>({})),n=new Error(t.data&&t.data.message||t.message||`API returned ${e.status}`);throw n.status=e.status,n}return e.json()}).then(t=>{if("success"===t.status)return e.$applyAsync(function(){e.isPublishing=!1,e.hasDraft=!1,e.documentVersion=t.data.version,m.success(g.CONTENT_PUBLISHED),U("[EditorPocCtrl] Document published, version:",t.data.version)}),!0;throw new Error(t.data&&t.data.message||t.message||"Publish failed")}
1).catch(t=>("AbortError"===t.name||e.$applyAsync(function(){e.isPublishing=!1,m.error(g.CONTENT_PUBLISH_ERROR(t.message))}),!1))},e.startAutoSave=function(){X&&r.cancel(X),e.autoSaveEnabled&&e.collabEnabled&&(X=r(function(){if(e.editorInstance&&!e.isSaving)try{e.saveDocument()}catch(e){}},e.autoSaveInterval),U("[EditorPocCtrl] Autosave started, interval:",e.autoSaveInterval))},e.stopAutoSave=function(){X&&(r.cancel(X),X=null,U("[EditorPocCtrl] Autosave stopped"))},e.$on("$destroy",function(){U("[EditorPocCtrl] Cleaning up resources...");try{e.tocNavigation&&(e.tocNavigation.destroy(),e.tocNavigation=null)}catch(e){}try{A.abort()}catch(e){}try{q&&(t.cancel(q),q=null),x&&(t.cancel(x),x=null),P&&(t.cancel(P),P=null),N&&(t.cancel(N),N=null),D&&(t.cancel(D),D=null)}catch(e){}try{e.stopAutoSave()}catch(e){}try{e.stopCommentsSync()}catch(e){}if(H&&V&&"function"==typeof V.unobserve)try{V.unobserve(H),U("[EditorPocCtrl] Unsubscribed from comments observer")}catch(e){}try{window.removeEventListener("beforeunload",y),window.removeEventListener("online",I),window.removeEventListener("offline",E)}catch(e){}if(e.comments.length>0&&e.collabEnabled)try{e.syncCommentsToMongo()}catch(e){}if(e.editorInstance&&e.collabEnabled)try{e.saveDocument()}catch(e){}}),window.addEventListener("beforeunload",y),window.addEventListener("online",I),window.addEventListener("offline",E);let J=null,G=null,K=!1,Q=!1;e.loadCommentsFromMongo=function(){return e.collabEnabled&&e.collabDocumentName?fetch(`/api/v2/collab/comments/content-item:${encodeURIComponent(O)}`,{headers:{"X-User-Id":c.userId(),"X-Auth-Token":l.get("authToken"),"Content-Type":"application/json"},signal:A.signal}).then(e=>e.json().then(t=>({response:e,body:t}))).then(({response:e,body:t})=>{if(!e.ok){if(k(t))return[];throw new Error(`API returned ${e.status}`)}return"success"===t.status?(U("[EditorPocCtrl] Loaded comments from MongoDB:",t.data.length),t.data):[]}).catch(e=>[]):Promise.resolve([])},e.syncCommentsToMongo=function(){if(!e.editorInstance||!e.collabEnabled||e.collabCommentStoreUnavailable)return Promise.resolve(!1);const t=e.comments.map(e=>({commentId:e.id,text:e.text,quotedText:e.quotedText,resolved:e.resolved,replies:e.replies||[]})),n=JSON.stringify(t);return n===G?Promise.resolve(!0):fetch(`/api/v2/collab/comments/content-item:${encodeURIComponent(O)}`,{method:"PUT",headers:{"X-User-Id":c.userId(),"X-Auth-Token":l.get("authToken"),"Content-Type":"application/json"},body:JSON.stringify({comments:t}),signal:A.signal}).then(e=>e.json().then(t=>({ok:e.ok,status:e.status,body:t}))).then(({ok:e,status:t,body:a})=>!(!e&&k(a))&&(e||404!==t?e&&"success"===a.status?(G=n,void 0!==d&&0===d.indexOf("development")&&U("[EditorPocCtrl] Comments synced to MongoDB:",a.data.synced),!0):("partial"===a.status||Number.isInteger(t)||(0,o.Ld)(a),!1):(w((0,o.e)()),!1))).catch(e=>!1)},e.addCommentWithSync=function(t){return e.collabEnabled&&e.collabDocumentName&&!e.collabCommentStoreUnavailable?fetch(`/api/v2/collab/comments/content-item:${encodeURIComponent(O)}`,{method:"POST",headers:{"X-User-Id":c.userId(),"X-Auth-Token":l.get("authToken"),"Content-Type":"application/json"},body:JSON.stringify({commentId:t.id,text:t.text,quotedText:t.quotedText}),signal:A.signal}).then(e=>e.json().then(t=>({ok:e.ok,body:t}))).then(({ok:e,body:t})=>!(!e&&k(t)||!e||"success"!==t.status||(U("[EditorPocCtrl] Comment added to MongoDB:",t.data._id),0))).catch(e=>!1):Promise.resolve(!1)},e.startCommentsSync=function(){e.collabCommentStoreUnavailable||(J&&r.cancel(J),J=r(function(){e.comments.length>0&&!e.collabCommentStoreUnavailable&&e.syncCommentsToMongo()},6e4),U("[EditorPocCtrl] Comments sync started, interval:",6e4))},e.stopCommentsSync=function(){J&&(r.cancel(J),J=null)}}]),n(53320),n(6929),n(28015);const r={modules:["discours.pages","discours.directives","discours.components","discours.templates"]}},31455(e,t,n){function o({schedule:e,cancel:t,retry:n,exhausted:o,limit:a=3,delay:i=2e3}){function r(){c&&(t(c),c=null)}let s=0,c=null,l=!1,d=!1;return{failed:()=>(l||d||(r(),s+=1,s>=a?(d=!0,o()):c=e(()=>{c=null,l||n()},i)),s),reset(){r(),s=0,d=!1}
1,cancelPending:r,destroy(){l=!0,r()}}}n.d(t,{Q:()=>o})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.