UNPKG

@ckeditor/ckeditor5-basic-styles

Version:

Basic styles feature for CKEditor 5.

5 lines • 15.1 kB
!function(t){const e=t.en=t.en||{};e.dictionary=Object.assign(e.dictionary||{},{Bold:"Bold","Bold text":"Bold text",Code:"Code",Italic:"Italic","Italic text":"Italic text","Move out of an inline code style":"Move out of an inline code style",Strikethrough:"Strikethrough","Strikethrough text":"Strikethrough text",Subscript:"Subscript",Superscript:"Superscript",Underline:"Underline","Underline text":"Underline text"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})), /*! * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md. */(()=>{var t={163:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},237:t=>{"use strict";t.exports=CKEditor5.dll},305:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var i="",n=void 0!==e[5];return e[4]&&(i+="@supports (".concat(e[4],") {")),e[2]&&(i+="@media ".concat(e[2]," {")),n&&(i+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),i+=t(e),n&&(i+="}"),e[2]&&(i+="}"),e[4]&&(i+="}"),i}).join("")},e.i=function(t,i,n,r,s){"string"==typeof t&&(t=[[null,t,void 0]]);var o={};if(n)for(var a=0;a<this.length;a++){var c=this[a][0];null!=c&&(o[c]=!0)}for(var u=0;u<t.length;u++){var l=[].concat(t[u]);n&&o[l[0]]||(void 0!==s&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=s),i&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=i):l[2]=i),r&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=r):l[4]="".concat(r)),e.push(l))}},e}},311:(t,e,i)=>{t.exports=i(237)("./src/ui.js")},355:(t,e,i)=>{t.exports=i(237)("./src/icons.js")},404:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var n=i(792),r=i.n(n),s=i(305),o=i.n(s)()(r());o.push([t.id,".ck-content code{background-color:hsla(0,0%,78%,.3);border-radius:2px;padding:.15em}.ck.ck-editor__editable .ck-code_selected{background-color:hsla(0,0%,78%,.5)}",""]);const a=o},424:t=>{"use strict";var e={};t.exports=function(t,i){var n=function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}e[t]=i}return e[t]}(t);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},517:t=>{"use strict";t.exports=function(t,e){Object.keys(e).forEach(function(i){t.setAttribute(i,e[i])})}},719:t=>{"use strict";var e=[];function i(t){for(var i=-1,n=0;n<e.length;n++)if(e[n].identifier===t){i=n;break}return i}function n(t,n){for(var s={},o=[],a=0;a<t.length;a++){var c=t[a],u=n.base?c[0]+n.base:c[0],l=s[u]||0,d="".concat(u," ").concat(l);s[u]=l+1;var g=i(d),m={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==g)e[g].references++,e[g].updater(m);else{var p=r(m,n);n.byIndex=a,e.splice(a,0,{identifier:d,updater:p,references:1})}o.push(d)}return o}function r(t,e){var i=e.domAPI(e);i.update(t);return function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;i.update(t=e)}else i.remove()}}t.exports=function(t,r){var s=n(t=t||[],r=r||{});return function(t){t=t||[];for(var o=0;o<s.length;o++){var a=i(s[o]);e[a].references--}for(var c=n(t,r),u=0;u<s.length;u++){var l=i(s[u]);0===e[l].references&&(e[l].updater(),e.splice(l,1))}s=c}}},782:(t,e,i)=>{t.exports=i(237)("./src/core.js")},783:(t,e,i)=>{t.exports=i(237)("./src/engine.js")},792:t=>{"use strict";t.exports=function(t){return t[1]}},834:(t,e,i)=>{t.exports=i(237)("./src/typing.js")},863:t=>{"use strict";var e,i=(e=[],function(t,i){return e[t]=i,e.filter(Boolean).join("\n")});function n(t,e,n,r){var s;if(n)s="";else{s="",r.supports&&(s+="@supports (".concat(r.supports,") {")),r.media&&(s+="@media ".concat(r.media," {"));var o=void 0!==r.layer;o&&(s+="@layer".concat(r.layer.length>0?" ".concat(r.layer):""," {")),s+=r.css,o&&(s+="}"),r.media&&(s+="}"),r.supports&&(s+="}")}if(t.styleSheet)t.styleSheet.cssText=i(e,s);else{var a=document.createTextNode(s),c=t.childNodes;c[e]&&t.removeChild(c[e]),c.length?t.insertBefore(a,c[e]):t.appendChild(a)}}var r={singleton:null,singletonCounter:0};t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=r.singletonCounter++,i=r.singleton||(r.singleton=t.insertStyleElement(t));return{update:function(t){n(i,e,!1,t)},remove:function(t){n(i,e,!0,t)}}}}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var s=e[n]={id:n,exports:{}};return t[n](s,s.exports,i),s.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";i.r(n),i.d(n,{AttributeCommand:()=>r,Bold:()=>g,BoldEditing:()=>o,BoldUI:()=>d,Code:()=>O,CodeEditing:()=>h,CodeUI:()=>C,Italic:()=>U,ItalicEditing:()=>N,ItalicUI:()=>M,Strikethrough:()=>_,StrikethroughEditing:()=>K,StrikethroughUI:()=>V,Subscript:()=>D,SubscriptEditing:()=>q,SubscriptUI:()=>H,Superscript:()=>Q,SuperscriptEditing:()=>z,SuperscriptUI:()=>J,Underline:()=>et,UnderlineEditing:()=>Y,UnderlineUI:()=>tt,_getBasicStylesButtonCreator:()=>u});var t=i(782),e=i(783);class r extends t.Command{attributeKey;constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const i=this.editor.model,n=i.document.selection,r=void 0===t.forceValue?!this.value:t.forceValue;i.change(t=>{if(n.isCollapsed)r?t.setSelectionAttribute(this.attributeKey,!0):t.removeSelectionAttribute(this.attributeKey);else{const s=i.schema.getValidRanges(n.getRanges(),this.attributeKey,{includeEmptyRanges:!0});for(const i of s){let n=i,s=this.attributeKey;i.isCollapsed&&(n=i.start.parent,s=e.ModelDocumentSelection._getStoreAttributeKey(this.attributeKey)),r?t.setAttribute(s,r,n):t.removeAttribute(s,n)}}})}_getValueFromFirstAllowedNode(){const t=this.editor.model,e=t.schema,i=t.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const t of i.getRanges())for(const i of t.getItems())if(e.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}const s="bold";class o extends t.Plugin{static get pluginName(){return"BoldEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:s}),t.model.schema.setAttributeProperties(s,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:s,view:"strong",upcastAlso:["b",t=>{const e=t.getStyle("font-weight");return e&&("bold"==e||Number(e)>=600)?{name:!0,styles:["font-weight"]}:null}]}),t.commands.add(s,new r(t,s)),t.keystrokes.set("CTRL+B",s),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Bold text"),keystroke:"CTRL+B"}]})}}var a=i(355),c=i(311);function u({editor:t,commandName:e,plugin:i,icon:n,label:r,keystroke:s}){return o=>{const a=t.commands.get(e),u=new o(t.locale);return u.set({label:r,icon:n,keystroke:s,isToggleable:!0}),u.bind("isEnabled").to(a,"isEnabled"),u.bind("isOn").to(a,"value"),u instanceof c.MenuBarMenuListItemButtonView?u.set({role:"menuitemcheckbox"}):u.set({tooltip:!0}),i.listenTo(u,"execute",()=>{t.execute(e),t.editing.view.focus()}),u}}const l="bold";class d extends t.Plugin{static get pluginName(){return"BoldUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,i=u({editor:t,commandName:l,plugin:this,icon:a.IconBold,label:e("Bold"),keystroke:"CTRL+B"});t.ui.componentFactory.add(l,()=>i(c.ButtonView)),t.ui.componentFactory.add("menuBar:"+l,()=>i(c.MenuBarMenuListItemButtonView))}}class g extends t.Plugin{static get requires(){return[o,d]}static get pluginName(){return"Bold"}static get isOfficialPlugin(){return!0}}var m=i(834);const p="code";class h extends t.Plugin{static get pluginName(){return"CodeEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[m.TwoStepCaretMovement]}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:p}),t.model.schema.setAttributeProperties(p,{isFormatting:!0,copyOnEnter:!1}),t.conversion.attributeToElement({model:p,view:"code"}),t.commands.add(p,new r(t,p)),t.plugins.get(m.TwoStepCaretMovement).registerAttribute(p),(0,m.inlineHighlight)(t,p,"code","ck-code_selected"),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Move out of an inline code style"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}}var f=i(719),b=i.n(f),y=i(863),v=i.n(y),k=i(424),x=i.n(k),I=i(517),w=i.n(I),S=i(163),P=i.n(S),B=i(404),A={attributes:{"data-cke":!0}};A.setAttributes=w(),A.insert=x().bind(null,"head"),A.domAPI=v(),A.insertStyleElement=P();b()(B.A,A);B.A&&B.A.locals&&B.A.locals;const E="code";class C extends t.Plugin{static get pluginName(){return"CodeUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,i=u({editor:t,commandName:E,plugin:this,icon:a.IconCode,label:e("Code")});t.ui.componentFactory.add(E,()=>i(c.ButtonView)),t.ui.componentFactory.add("menuBar:"+E,()=>i(c.MenuBarMenuListItemButtonView))}}class O extends t.Plugin{static get requires(){return[h,C]}static get pluginName(){return"Code"}static get isOfficialPlugin(){return!0}}const T="italic";class N extends t.Plugin{static get pluginName(){return"ItalicEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:T}),t.model.schema.setAttributeProperties(T,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:T,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),t.commands.add(T,new r(t,T)),t.keystrokes.set("CTRL+I",T),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Italic text"),keystroke:"CTRL+I"}]})}}const F="italic";class M extends t.Plugin{static get pluginName(){return"ItalicUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,i=u({editor:t,commandName:F,plugin:this,icon:a.IconItalic,keystroke:"CTRL+I",label:e("Italic")});t.ui.componentFactory.add(F,()=>i(c.ButtonView)),t.ui.componentFactory.add("menuBar:"+F,()=>i(c.MenuBarMenuListItemButtonView))}}class U extends t.Plugin{static get requires(){return[N,M]}static get pluginName(){return"Italic"}static get isOfficialPlugin(){return!0}}const L="strikethrough";class K extends t.Plugin{static get pluginName(){return"StrikethroughEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:L}),t.model.schema.setAttributeProperties(L,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:L,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),t.commands.add(L,new r(t,L)),t.keystrokes.set("CTRL+SHIFT+X","strikethrough"),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Strikethrough text"),keystroke:"CTRL+SHIFT+X"}]})}}const R="strikethrough";class V extends t.Plugin{static get pluginName(){return"StrikethroughUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,i=u({editor:t,commandName:R,plugin:this,icon:a.IconStrikethrough,keystroke:"CTRL+SHIFT+X",label:e("Strikethrough")});t.ui.componentFactory.add(R,()=>i(c.ButtonView)),t.ui.componentFactory.add("menuBar:"+R,()=>i(c.MenuBarMenuListItemButtonView))}}class _ extends t.Plugin{static get requires(){return[K,V]}static get pluginName(){return"Strikethrough"}static get isOfficialPlugin(){return!0}}const j="subscript";class q extends t.Plugin{static get pluginName(){return"SubscriptEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:j}),t.model.schema.setAttributeProperties(j,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:j,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),t.commands.add(j,new r(t,j))}}const $="subscript";class H extends t.Plugin{static get pluginName(){return"SubscriptUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,i=u({editor:t,commandName:$,plugin:this,icon:a.IconSubscript,label:e("Subscript")});t.ui.componentFactory.add($,()=>i(c.ButtonView)),t.ui.componentFactory.add("menuBar:"+$,()=>i(c.MenuBarMenuListItemButtonView))}}class D extends t.Plugin{static get requires(){return[q,H]}static get pluginName(){return"Subscript"}static get isOfficialPlugin(){return!0}}const X="superscript";class z extends t.Plugin{static get pluginName(){return"SuperscriptEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:X}),t.model.schema.setAttributeProperties(X,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:X,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),t.commands.add(X,new r(t,X))}}const G="superscript";class J extends t.Plugin{static get pluginName(){return"SuperscriptUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,i=u({editor:t,commandName:G,plugin:this,icon:a.IconSuperscript,label:e("Superscript")});t.ui.componentFactory.add(G,()=>i(c.ButtonView)),t.ui.componentFactory.add("menuBar:"+G,()=>i(c.MenuBarMenuListItemButtonView))}}class Q extends t.Plugin{static get requires(){return[z,J]}static get pluginName(){return"Superscript"}static get isOfficialPlugin(){return!0}}const W="underline";class Y extends t.Plugin{static get pluginName(){return"UnderlineEditing"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=this.editor.t;t.model.schema.extend("$text",{allowAttributes:W}),t.model.schema.setAttributeProperties(W,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:W,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),t.commands.add(W,new r(t,W)),t.keystrokes.set("CTRL+U","underline"),t.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Underline text"),keystroke:"CTRL+U"}]})}}const Z="underline";class tt extends t.Plugin{static get pluginName(){return"UnderlineUI"}static get isOfficialPlugin(){return!0}init(){const t=this.editor,e=t.locale.t,i=u({editor:t,commandName:Z,plugin:this,icon:a.IconUnderline,label:e("Underline"),keystroke:"CTRL+U"});t.ui.componentFactory.add(Z,()=>i(c.ButtonView)),t.ui.componentFactory.add("menuBar:"+Z,()=>i(c.MenuBarMenuListItemButtonView))}}class et extends t.Plugin{static get requires(){return[Y,tt]}static get pluginName(){return"Underline"}static get isOfficialPlugin(){return!0}}})(),(window.CKEditor5=window.CKEditor5||{}).basicStyles=n})();