import{Plugin as a,Command as f}from"@ckeditor/ckeditor5-core";import{IconRemoveFormat as F}from"@ckeditor/ckeditor5-icons";import{ButtonView as h,MenuBarMenuListItemButtonView as b}from"@ckeditor/ckeditor5-ui";import{first as c}from"@ckeditor/ckeditor5-utils";/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const n="removeFormat";class u extends a{static get pluginName(){return"RemoveFormatUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.ui.componentFactory.add(n,()=>{const e=this._createButton(h);return e.set({tooltip:!0}),e}),t.ui.componentFactory.add(`menuBar:${n}`,()=>this._createButton(b))}_createButton(t){const e=this.editor,i=e.locale,s=e.commands.get(n),o=new t(e.locale),r=i.t;return o.set({label:r("Remove Format"),icon:F}),o.bind("isEnabled").to(s,"isEnabled"),this.listenTo(o,"execute",()=>{e.execute(n),e.editing.view.focus()}),o}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class d extends f{_customAttributesHandlers=[];refresh(){const t=this.editor.model;this.isEnabled=!!c(this._getFormattingItems(t.document.selection))}execute(){const t=this.editor.model;t.change(e=>{for(const i of this._getFormattingItems(t.document.selection))if(i.is("selection"))for(const s of this._getFormattingAttributes(i))e.removeSelectionAttribute(s);else{const s=e.createRangeOn(i);for(const o of this._getFormattingAttributes(i))this._removeFormatting(o,i,s,e)}})}registerCustomAttribute(t,e){this._customAttributesHandlers.push({isFormatting:t,removeFormatting:e})}_removeFormatting(t,e,i,s){let o=!1;for(const{isFormatting:r,removeFormatting:g}of this._customAttributesHandlers)r(t,e)&&(g(t,i,s),o=!0);o||s.removeAttribute(t,i)}*_getFormattingItems(t){const e=this.editor.model,i=e.schema,s=o=>!!c(this._getFormattingAttributes(o));for(const o of t.getRanges())for(const r of o.getItems())i.isBlock(r)&&o.end.isTouching(e.createPositionAt(r,0))||s(r)&&(yield r);for(const o of t.getSelectedBlocks())s(o)&&(yield o);s(t)&&(yield t)}*_getFormattingAttributes(t){const e=this.editor.model.schema;for(const[i]of t.getAttributes()){for(const{isFormatting:o}of this._customAttributesHandlers)o(i,t)&&(yield i);const s=e.getAttributeProperties(i);s&&s.isFormatting&&(yield i)}}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class l extends a{static get pluginName(){return"RemoveFormatEditing"}static get licenseFeatureCode(){return"RF"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){const t=this.editor;t.commands.add("removeFormat",new d(t))}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class v extends a{static get requires(){return[l,u]}static get pluginName(){return"RemoveFormat"}static get isOfficialPlugin(){return!0}}export{v as RemoveFormat,d as RemoveFormatCommand,l as RemoveFormatEditing,u as RemoveFormatUI};
