@ckeditor/ckeditor5-language
Advanced tools
Comparing version 37.1.0 to 38.0.0-rc.0
@@ -5,2 +5,2 @@ !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={})), | ||
* For licensing, see LICENSE.md. | ||
*/(()=>{var e={704:(e,t,n)=>{e.exports=n(79)("./src/core.js")},273:(e,t,n)=>{e.exports=n(79)("./src/ui.js")},209:(e,t,n)=>{e.exports=n(79)("./src/utils.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function n(a){var o=t[a];if(void 0!==o)return o.exports;var i=t[a]={exports:{}};return e[a](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};(()=>{"use strict";n.r(a),n.d(a,{TextPartLanguage:()=>u,TextPartLanguageEditing:()=>r,TextPartLanguageUI:()=>s});var e=n(704),t=n(209);function o(e,n){return`${e}:${n=n||(0,t.getLanguageDirection)(e)}`}class i extends e.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,a=n.document.selection,i=!!e&&o(e,t);n.change((e=>{if(a.isCollapsed)i?e.setSelectionAttribute("language",i):e.removeSelectionAttribute("language");else{const t=n.schema.getValidRanges(a.getRanges(),"language");for(const n of t)i?e.setAttribute("language",i,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 r extends e.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=>o(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},n)=>{if(!e)return;if(!n.item.is("$textProxy")&&!n.item.is("documentSelection"))return;const{languageCode:a,textDirection:o}=function(e){const[t,n]=e.split(":");return{languageCode:t,textDirection:n}}(e);return t.createAttributeElement("span",{lang:a,dir:o})}})}}var g=n(273);class s extends e.Plugin{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,n=e.t,a=e.config.get("language.textPartLanguage"),i=n("Choose language"),r=n("Remove language"),s=n("Language");e.ui.componentFactory.add("textPartLanguage",(n=>{const u=new t.Collection,l={},d=e.commands.get("textPartLanguage");u.add({type:"button",model:new g.Model({label:r,languageCode:!1,withText:!0})}),u.add({type:"separator"});for(const e of a){const t={type:"button",model:new g.Model({label:e.title,languageCode:e.languageCode,textDirection:e.textDirection,withText:!0})},n=o(e.languageCode,e.textDirection);t.model.bind("isOn").to(d,"value",(e=>e===n)),u.add(t),l[n]=e.title}const c=(0,g.createDropdown)(n);return(0,g.addListToDropdown)(c,u),c.buttonView.set({isOn:!1,withText:!0,tooltip:s}),c.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),c.bind("isEnabled").to(d,"isEnabled"),c.buttonView.bind("label").to(d,"value",(e=>e&&l[e]||i)),this.listenTo(c,"execute",(t=>{d.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),c}))}}class u extends e.Plugin{static get requires(){return[r,s]}static get pluginName(){return"TextPartLanguage"}}})(),(window.CKEditor5=window.CKEditor5||{}).language=a})(); | ||
*/(()=>{var e={704:(e,t,a)=>{e.exports=a(79)("./src/core.js")},273:(e,t,a)=>{e.exports=a(79)("./src/ui.js")},209:(e,t,a)=>{e.exports=a(79)("./src/utils.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function a(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,a),i.exports}a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";a.r(n),a.d(n,{TextPartLanguage:()=>u,TextPartLanguageEditing:()=>r,TextPartLanguageUI:()=>s});var e=a(704),t=a(209);function o(e,a){return`${e}:${a=a||(0,t.getLanguageDirection)(e)}`}class i extends e.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 a=this.editor.model,n=a.document.selection,i=!!e&&o(e,t);a.change((e=>{if(n.isCollapsed)i?e.setSelectionAttribute("language",i):e.removeSelectionAttribute("language");else{const t=a.schema.getValidRanges(n.getRanges(),"language");for(const a of t)i?e.setAttribute("language",i,a):e.removeAttribute("language",a)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,a=e.document.selection;if(a.isCollapsed)return a.getAttribute("language")||!1;for(const e of a.getRanges())for(const a of e.getItems())if(t.checkAttribute(a,"language"))return a.getAttribute("language")||!1;return!1}}class r extends e.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=>o(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},a)=>{if(!e)return;if(!a.item.is("$textProxy")&&!a.item.is("documentSelection"))return;const{languageCode:n,textDirection:o}=function(e){const[t,a]=e.split(":");return{languageCode:t,textDirection:a}}(e);return t.createAttributeElement("span",{lang:n,dir:o})}})}}var g=a(273);class s extends e.Plugin{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,a=e.t,n=e.config.get("language.textPartLanguage"),i=a("Choose language"),r=a("Remove language"),s=a("Language");e.ui.componentFactory.add("textPartLanguage",(a=>{const u=new t.Collection,l={},d=e.commands.get("textPartLanguage");u.add({type:"button",model:new g.Model({label:r,languageCode:!1,withText:!0})}),u.add({type:"separator"});for(const e of n){const t={type:"button",model:new g.Model({label:e.title,languageCode:e.languageCode,role:"menuitemradio",textDirection:e.textDirection,withText:!0})},a=o(e.languageCode,e.textDirection);t.model.bind("isOn").to(d,"value",(e=>e===a)),u.add(t),l[a]=e.title}const c=(0,g.createDropdown)(a);return(0,g.addListToDropdown)(c,u,{ariaLabel:s,role:"menu"}),c.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),c.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),c.bind("isEnabled").to(d,"isEnabled"),c.buttonView.bind("label").to(d,"value",(e=>e&&l[e]||i)),this.listenTo(c,"execute",(t=>{d.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),c}))}}class u extends e.Plugin{static get requires(){return[r,s]}static get pluginName(){return"TextPartLanguage"}}})(),(window.CKEditor5=window.CKEditor5||{}).language=n})(); |
{ | ||
"name": "@ckeditor/ckeditor5-language", | ||
"version": "37.1.0", | ||
"version": "38.0.0-rc.0", | ||
"description": "Text part language feature for CKEditor 5.", | ||
@@ -15,12 +15,12 @@ "keywords": [ | ||
"dependencies": { | ||
"ckeditor5": "^37.1.0" | ||
"ckeditor5": "^38.0.0-rc.0" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-core": "^37.1.0", | ||
"@ckeditor/ckeditor5-core": "^38.0.0-rc.0", | ||
"@ckeditor/ckeditor5-dev-utils": "^37.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^37.1.0", | ||
"@ckeditor/ckeditor5-engine": "^37.1.0", | ||
"@ckeditor/ckeditor5-paragraph": "^37.1.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^37.1.0", | ||
"@ckeditor/ckeditor5-ui": "^37.1.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^38.0.0-rc.0", | ||
"@ckeditor/ckeditor5-engine": "^38.0.0-rc.0", | ||
"@ckeditor/ckeditor5-paragraph": "^38.0.0-rc.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^38.0.0-rc.0", | ||
"@ckeditor/ckeditor5-ui": "^38.0.0-rc.0", | ||
"typescript": "^4.8.4", | ||
@@ -27,0 +27,0 @@ "webpack": "^5.58.1", |
@@ -33,3 +33,3 @@ /** | ||
const removeTitle = t('Remove language'); | ||
const dropdownTooltip = t('Language'); | ||
const accessibleLabel = t('Language'); | ||
// Register UI component. | ||
@@ -58,2 +58,3 @@ editor.ui.componentFactory.add('textPartLanguage', locale => { | ||
languageCode: option.languageCode, | ||
role: 'menuitemradio', | ||
textDirection: option.textDirection, | ||
@@ -69,7 +70,12 @@ withText: true | ||
const dropdownView = createDropdown(locale); | ||
addListToDropdown(dropdownView, itemDefinitions); | ||
addListToDropdown(dropdownView, itemDefinitions, { | ||
ariaLabel: accessibleLabel, | ||
role: 'menu' | ||
}); | ||
dropdownView.buttonView.set({ | ||
ariaLabel: accessibleLabel, | ||
ariaLabelledBy: undefined, | ||
isOn: false, | ||
withText: true, | ||
tooltip: dropdownTooltip | ||
tooltip: accessibleLabel | ||
}); | ||
@@ -76,0 +82,0 @@ dropdownView.extendTemplate({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
101106
698
1
+ Added@ckeditor/ckeditor5-clipboard@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-core@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-engine@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-enter@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-paragraph@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-select-all@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-typing@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-ui@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-undo@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-upload@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-utils@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-watchdog@38.1.1(transitive)
+ Added@ckeditor/ckeditor5-widget@38.1.1(transitive)
+ Addedckeditor5@38.1.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcolor-parse@1.4.2(transitive)
+ Addedvanilla-colorful@0.7.2(transitive)
- Removed@ckeditor/ckeditor5-clipboard@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-core@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-engine@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-enter@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-paragraph@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-select-all@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-typing@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-ui@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-undo@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-upload@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-utils@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-watchdog@37.1.0(transitive)
- Removed@ckeditor/ckeditor5-widget@37.1.0(transitive)
- Removedckeditor5@37.1.0(transitive)
Updatedckeditor5@^38.0.0-rc.0