@ckeditor/ckeditor5-language
Advanced tools
Comparing version 29.1.0 to 29.2.0
@@ -5,2 +5,2 @@ /*! | ||
*/ | ||
window.CKEditor5=window.CKEditor5||{},window.CKEditor5.language=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){e.exports=n(3)("./src/core.js")},function(e,t,n){e.exports=n(3)("./src/ui.js")},function(e,t,n){e.exports=n(3)("./src/utils.js")},function(e,t){e.exports=CKEditor5.dll},function(e,t,n){var r=n(5),o=n(6);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};r(o,a);e.exports=o.locals||{}},function(e,t,n){"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},a=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),i=[];function u(e){for(var t=-1,n=0;n<i.length;n++)if(i[n].identifier===e){t=n;break}return t}function s(e,t){for(var n={},r=[],o=0;o<e.length;o++){var a=e[o],s=t.base?a[0]+t.base:a[0],l=n[s]||0,c="".concat(s," ").concat(l);n[s]=l+1;var d=u(c),g={css:a[1],media:a[2],sourceMap:a[3]};-1!==d?(i[d].references++,i[d].updater(g)):i.push({identifier:c,updater:b(g,t),references:1}),r.push(c)}return r}function l(e){var t=document.createElement("style"),r=e.attributes||{};if(void 0===r.nonce){var o=n.nc;o&&(r.nonce=o)}if(Object.keys(r).forEach((function(e){t.setAttribute(e,r[e])})),"function"==typeof e.insert)e.insert(t);else{var i=a(e.insert||"head");if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(t)}return t}var c,d=(c=[],function(e,t){return c[e]=t,c.filter(Boolean).join("\n")});function g(e,t,n,r){var o=n?"":r.media?"@media ".concat(r.media," {").concat(r.css,"}"):r.css;if(e.styleSheet)e.styleSheet.cssText=d(t,o);else{var a=document.createTextNode(o),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(a,i[t]):e.appendChild(a)}}function f(e,t,n){var r=n.css,o=n.media,a=n.sourceMap;if(o?e.setAttribute("media",o):e.removeAttribute("media"),a&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}var p=null,m=0;function b(e,t){var n,r,o;if(t.singleton){var a=m++;n=p||(p=l(t)),r=g.bind(null,n,a,!1),o=g.bind(null,n,a,!0)}else n=l(t),r=f.bind(null,n,t),o=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=o());var n=s(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var r=0;r<n.length;r++){var o=u(n[r]);i[o].references--}for(var a=s(e,t),l=0;l<n.length;l++){var c=u(n[l]);0===i[c].references&&(i[c].updater(),i.splice(c,1))}n=a}}}},function(e,t){e.exports=".ck-content span[lang]{font-style:italic}"},function(e,t,n){"use strict";n.r(t),n.d(t,"TextPartLanguage",(function(){return c})),n.d(t,"TextPartLanguageEditing",(function(){return u})),n.d(t,"TextPartLanguageUI",(function(){return l}));var r=n(0),o=n(2);function a(e,t){return`${e}:${t=t||Object(o.getLanguageDirection)(e)}`}class i extends r.Command{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"language")}execute({languageCode:e,textDirection:t}={}){const n=this.editor.model,r=n.document.selection,o=!!e&&a(e,t);n.change(e=>{if(r.isCollapsed)o?e.setSelectionAttribute("language",o):e.removeSelectionAttribute("language");else{const t=n.schema.getValidRanges(r.getRanges(),"language");for(const n of t)o?e.setAttribute("language",o,n):e.removeAttribute("language",n)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.getAttribute("language")||!1;for(const e of n.getRanges())for(const n of e.getItems())if(t.checkAttribute(n,"language"))return n.getAttribute("language")||!1;return!1}}class u extends r.Plugin{static get pluginName(){return"TextPartLanguageEditing"}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"language"}),e.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),e.commands.add("textPartLanguage",new i(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>a(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t})=>{if(!e)return;const{languageCode:n,textDirection:r}=function(e){const[t,n]=e.split(":");return{languageCode:t,textDirection:n}}(e);return t.createAttributeElement("span",{lang:n,dir:r})}})}}var s=n(1);n(4);class l extends r.Plugin{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,n=e.config.get("language.textPartLanguage"),r=t("Choose language"),i=t("Remove language"),u=t("Language");e.ui.componentFactory.add("textPartLanguage",t=>{const l=new o.Collection,c={},d=e.commands.get("textPartLanguage");for(const e of n){const t={type:"button",model:new s.Model({label:e.title,languageCode:e.languageCode,textDirection:e.textDirection,withText:!0})},n=a(e.languageCode,e.textDirection);t.model.bind("isOn").to(d,"value",e=>e===n),l.add(t),c[n]=e.title}l.add({type:"separator"}),l.add({type:"button",model:new s.Model({label:i,languageCode:!1,withText:!0})});const g=Object(s.createDropdown)(t);return Object(s.addListToDropdown)(g,l),g.buttonView.set({isOn:!1,withText:!0,tooltip:u}),g.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),g.bind("isEnabled").to(d,"isEnabled"),g.buttonView.bind("label").to(d,"value",e=>c[e]||r),this.listenTo(g,"execute",t=>{d.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()}),g})}}class c extends r.Plugin{static get requires(){return[u,l]}static get pluginName(){return"TextPartLanguage"}}}]); | ||
!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"Choose language":"Choose language",Language:"Language","Remove language":"Remove language"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),window.CKEditor5=window.CKEditor5||{},window.CKEditor5.language=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){e.exports=n(3)("./src/core.js")},function(e,t,n){e.exports=n(3)("./src/ui.js")},function(e,t,n){e.exports=n(3)("./src/utils.js")},function(e,t){e.exports=CKEditor5.dll},function(e,t,n){var o=n(5),r=n(6);"string"==typeof(r=r.__esModule?r.default:r)&&(r=[[e.i,r,""]]);var a={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};o(r,a);e.exports=r.locals||{}},function(e,t,n){"use strict";var o,r=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},a=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),i=[];function u(e){for(var t=-1,n=0;n<i.length;n++)if(i[n].identifier===e){t=n;break}return t}function s(e,t){for(var n={},o=[],r=0;r<e.length;r++){var a=e[r],s=t.base?a[0]+t.base:a[0],l=n[s]||0,c="".concat(s," ").concat(l);n[s]=l+1;var d=u(c),g={css:a[1],media:a[2],sourceMap:a[3]};-1!==d?(i[d].references++,i[d].updater(g)):i.push({identifier:c,updater:b(g,t),references:1}),o.push(c)}return o}function l(e){var t=document.createElement("style"),o=e.attributes||{};if(void 0===o.nonce){var r=n.nc;r&&(o.nonce=r)}if(Object.keys(o).forEach((function(e){t.setAttribute(e,o[e])})),"function"==typeof e.insert)e.insert(t);else{var i=a(e.insert||"head");if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(t)}return t}var c,d=(c=[],function(e,t){return c[e]=t,c.filter(Boolean).join("\n")});function g(e,t,n,o){var r=n?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):o.css;if(e.styleSheet)e.styleSheet.cssText=d(t,r);else{var a=document.createTextNode(r),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(a,i[t]):e.appendChild(a)}}function f(e,t,n){var o=n.css,r=n.media,a=n.sourceMap;if(r?e.setAttribute("media",r):e.removeAttribute("media"),a&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleSheet)e.styleSheet.cssText=o;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(o))}}var p=null,m=0;function b(e,t){var n,o,r;if(t.singleton){var a=m++;n=p||(p=l(t)),o=g.bind(null,n,a,!1),r=g.bind(null,n,a,!0)}else n=l(t),o=f.bind(null,n,t),r=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else r()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=r());var n=s(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var o=0;o<n.length;o++){var r=u(n[o]);i[r].references--}for(var a=s(e,t),l=0;l<n.length;l++){var c=u(n[l]);0===i[c].references&&(i[c].updater(),i.splice(c,1))}n=a}}}},function(e,t){e.exports=".ck-content span[lang]{font-style:italic}"},function(e,t,n){"use strict";n.r(t),n.d(t,"TextPartLanguage",(function(){return c})),n.d(t,"TextPartLanguageEditing",(function(){return u})),n.d(t,"TextPartLanguageUI",(function(){return l}));var o=n(0),r=n(2);function a(e,t){return`${e}:${t=t||Object(r.getLanguageDirection)(e)}`}class i extends o.Command{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"language")}execute({languageCode:e,textDirection:t}={}){const n=this.editor.model,o=n.document.selection,r=!!e&&a(e,t);n.change(e=>{if(o.isCollapsed)r?e.setSelectionAttribute("language",r):e.removeSelectionAttribute("language");else{const t=n.schema.getValidRanges(o.getRanges(),"language");for(const n of t)r?e.setAttribute("language",r,n):e.removeAttribute("language",n)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.getAttribute("language")||!1;for(const e of n.getRanges())for(const n of e.getItems())if(t.checkAttribute(n,"language"))return n.getAttribute("language")||!1;return!1}}class u extends o.Plugin{static get pluginName(){return"TextPartLanguageEditing"}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"language"}),e.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),e.commands.add("textPartLanguage",new i(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>a(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t})=>{if(!e)return;const{languageCode:n,textDirection:o}=function(e){const[t,n]=e.split(":");return{languageCode:t,textDirection:n}}(e);return t.createAttributeElement("span",{lang:n,dir:o})}})}}var s=n(1);n(4);class l extends o.Plugin{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,n=e.config.get("language.textPartLanguage"),o=t("Choose language"),i=t("Remove language"),u=t("Language");e.ui.componentFactory.add("textPartLanguage",t=>{const l=new r.Collection,c={},d=e.commands.get("textPartLanguage");l.add({type:"button",model:new s.Model({label:i,languageCode:!1,withText:!0})}),l.add({type:"separator"});for(const e of n){const t={type:"button",model:new s.Model({label:e.title,languageCode:e.languageCode,textDirection:e.textDirection,withText:!0})},n=a(e.languageCode,e.textDirection);t.model.bind("isOn").to(d,"value",e=>e===n),l.add(t),c[n]=e.title}const g=Object(s.createDropdown)(t);return Object(s.addListToDropdown)(g,l),g.buttonView.set({isOn:!1,withText:!0,tooltip:u}),g.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),g.bind("isEnabled").to(d,"isEnabled"),g.buttonView.bind("label").to(d,"value",e=>c[e]||o),this.listenTo(g,"execute",t=>{d.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()}),g})}}class c extends o.Plugin{static get requires(){return[u,l]}static get pluginName(){return"TextPartLanguage"}}}]); |
{ | ||
"name": "@ckeditor/ckeditor5-language", | ||
"version": "29.1.0", | ||
"version": "29.2.0", | ||
"description": "Text part language feature for CKEditor 5.", | ||
@@ -15,12 +15,12 @@ "keywords": [ | ||
"dependencies": { | ||
"ckeditor5": "^29.1.0" | ||
"ckeditor5": "^29.2.0" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-core": "^29.1.0", | ||
"@ckeditor/ckeditor5-dev-utils": "^25.3.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^29.1.0", | ||
"@ckeditor/ckeditor5-engine": "^29.1.0", | ||
"@ckeditor/ckeditor5-paragraph": "^29.1.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^29.1.0", | ||
"@ckeditor/ckeditor5-ui": "^29.1.0", | ||
"@ckeditor/ckeditor5-core": "^29.2.0", | ||
"@ckeditor/ckeditor5-dev-utils": "^25.4.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^29.2.0", | ||
"@ckeditor/ckeditor5-engine": "^29.2.0", | ||
"@ckeditor/ckeditor5-paragraph": "^29.2.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^29.2.0", | ||
"@ckeditor/ckeditor5-ui": "^29.2.0", | ||
"webpack": "^4.43.0", | ||
@@ -27,0 +27,0 @@ "webpack-cli": "^3.3.11" |
@@ -50,2 +50,16 @@ /** | ||
// Item definition with false `languageCode` will behave as remove lang button. | ||
itemDefinitions.add( { | ||
type: 'button', | ||
model: new Model( { | ||
label: removeTitle, | ||
languageCode: false, | ||
withText: true | ||
} ) | ||
} ); | ||
itemDefinitions.add( { | ||
type: 'separator' | ||
} ); | ||
for ( const option of options ) { | ||
@@ -71,16 +85,2 @@ const def = { | ||
itemDefinitions.add( { | ||
type: 'separator' | ||
} ); | ||
// Item definition with false `languageCode` will behave as remove lang button. | ||
itemDefinitions.add( { | ||
type: 'button', | ||
model: new Model( { | ||
label: removeTitle, | ||
languageCode: false, | ||
withText: true | ||
} ) | ||
} ); | ||
const dropdownView = createDropdown( locale ); | ||
@@ -87,0 +87,0 @@ addListToDropdown( dropdownView, itemDefinitions ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55429
53
Updatedckeditor5@^29.2.0