[{"data":1,"prerenderedAt":291},["ShallowReactive",2],{"docs:\u002Fen\u002Fdocs\u002Fguides\u002Fcustom-plugin":3},{"id":4,"title":5,"body":6,"description":281,"extension":282,"meta":283,"navigation":286,"path":287,"seo":288,"stem":289,"__hash__":290},"docs_en\u002Fen\u002Fdocs\u002Fguides\u002Fcustom-plugin.md","Your own plugin",{"type":7,"value":8,"toc":275},"minimark",[9,14,18,22,25,29,32,36,50,271],[10,11,13],"h2",{"id":12},"plugin-descriptor","Plugin descriptor",[15,16,17],"p",{},"Provide a unique id, plugin version and apiVersion: 1. setup receives the managed public context. Register commands\u002Fevents\u002FUI through that context rather than touching the editor engine or internal DOM. Duplicate IDs or unavailable plugins are rejected.",[10,19,21],{"id":20},"synchronous-setup","Synchronous setup",[15,23,24],{},"Install resources synchronously and return cleanup for external work that you own. The host also revokes managed subscriptions, commands, forms and status when a plugin is removed or the editor is destroyed. Failed setup releases already installed resources.",[10,26,28],{"id":27},"document-operations","Document operations",[15,30,31],{},"Use the checked public operations and revision-bearing ranges. Avoid silently applying an asynchronous result to a newer document. Plain text replacement is not HTML import; transformations preserve marks and a single undo operation.",[10,33,35],{"id":34},"integration","Integration",[15,37,38,39,44,45,49],{},"usePlugin returns a disposer. executePluginCommand invokes your registered command. removePlugin provides an alternate cleanup path. Test installation, command behavior, removal and destroy. ",[40,41,43],"a",{"href":42},"\u002Fen\u002Fdocs\u002Fplugins\u002Foverview","Plugin contract",", ",[40,46,48],{"href":47},"\u002Fen\u002Fdocs\u002Freference\u002Fmethods","methods",".",[51,52,57],"pre",{"className":53,"code":54,"language":55,"meta":56,"style":56},"language-ts shiki shiki-themes github-dark","import { PLUGIN_API_VERSION } from '@vitext-ru\u002Feditor';\nconst remove = editor.usePlugin({\n  id: 'my-format', version: '1.0.0', apiVersion: PLUGIN_API_VERSION,\n  setup(api) {\n    api.registerCommand('bold', () => api.execute('bold'));\n    api.on('change', event => console.log(event.revision));\n    return () => { \u002F* освободите собственные таймеры *\u002F };\n  }\n});\neditor.executePluginCommand('my-format', 'bold');\nremove();\n","ts","",[58,59,60,83,106,130,146,179,209,230,236,242,262],"code",{"__ignoreMap":56},[61,62,65,69,73,76,80],"span",{"class":63,"line":64},"line",1,[61,66,68],{"class":67},"snl16","import",[61,70,72],{"class":71},"s95oV"," { PLUGIN_API_VERSION } ",[61,74,75],{"class":67},"from",[61,77,79],{"class":78},"sU2Wk"," '@vitext-ru\u002Feditor'",[61,81,82],{"class":71},";\n",[61,84,86,89,93,96,99,103],{"class":63,"line":85},2,[61,87,88],{"class":67},"const",[61,90,92],{"class":91},"sDLfK"," remove",[61,94,95],{"class":67}," =",[61,97,98],{"class":71}," editor.",[61,100,102],{"class":101},"svObZ","usePlugin",[61,104,105],{"class":71},"({\n",[61,107,109,112,115,118,121,124,127],{"class":63,"line":108},3,[61,110,111],{"class":71},"  id: ",[61,113,114],{"class":78},"'my-format'",[61,116,117],{"class":71},", version: ",[61,119,120],{"class":78},"'1.0.0'",[61,122,123],{"class":71},", apiVersion: ",[61,125,126],{"class":91},"PLUGIN_API_VERSION",[61,128,129],{"class":71},",\n",[61,131,133,136,139,143],{"class":63,"line":132},4,[61,134,135],{"class":101},"  setup",[61,137,138],{"class":71},"(",[61,140,142],{"class":141},"s9osk","api",[61,144,145],{"class":71},") {\n",[61,147,149,152,155,157,160,163,166,169,172,174,176],{"class":63,"line":148},5,[61,150,151],{"class":71},"    api.",[61,153,154],{"class":101},"registerCommand",[61,156,138],{"class":71},[61,158,159],{"class":78},"'bold'",[61,161,162],{"class":71},", () ",[61,164,165],{"class":67},"=>",[61,167,168],{"class":71}," api.",[61,170,171],{"class":101},"execute",[61,173,138],{"class":71},[61,175,159],{"class":78},[61,177,178],{"class":71},"));\n",[61,180,182,184,187,189,192,194,197,200,203,206],{"class":63,"line":181},6,[61,183,151],{"class":71},[61,185,186],{"class":101},"on",[61,188,138],{"class":71},[61,190,191],{"class":78},"'change'",[61,193,44],{"class":71},[61,195,196],{"class":141},"event",[61,198,199],{"class":67}," =>",[61,201,202],{"class":71}," console.",[61,204,205],{"class":101},"log",[61,207,208],{"class":71},"(event.revision));\n",[61,210,212,215,218,220,223,227],{"class":63,"line":211},7,[61,213,214],{"class":67},"    return",[61,216,217],{"class":71}," () ",[61,219,165],{"class":67},[61,221,222],{"class":71}," { ",[61,224,226],{"class":225},"sAwPA","\u002F* освободите собственные таймеры *\u002F",[61,228,229],{"class":71}," };\n",[61,231,233],{"class":63,"line":232},8,[61,234,235],{"class":71},"  }\n",[61,237,239],{"class":63,"line":238},9,[61,240,241],{"class":71},"});\n",[61,243,245,248,251,253,255,257,259],{"class":63,"line":244},10,[61,246,247],{"class":71},"editor.",[61,249,250],{"class":101},"executePluginCommand",[61,252,138],{"class":71},[61,254,114],{"class":78},[61,256,44],{"class":71},[61,258,159],{"class":78},[61,260,261],{"class":71},");\n",[61,263,265,268],{"class":63,"line":264},11,[61,266,267],{"class":101},"remove",[61,269,270],{"class":71},"();\n",[272,273,274],"style",{},"html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s9osk, html code.shiki .s9osk{--shiki-default:#FFAB70}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":56,"searchDepth":85,"depth":85,"links":276},[277,278,279,280],{"id":12,"depth":85,"text":13},{"id":20,"depth":85,"text":21},{"id":27,"depth":85,"text":28},{"id":34,"depth":85,"text":35},"A minimal API 1 command with managed resources.","md",{"group":284,"order":285},"Integrations",61,true,"\u002Fen\u002Fdocs\u002Fguides\u002Fcustom-plugin",{"title":5,"description":281},"en\u002Fdocs\u002Fguides\u002Fcustom-plugin","yzUClq48Cfnyo7Nk4RJAaDTzXS9dFAeVDLxhvZs7H9U",1792670389491]