plugin.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. ( function() {
  6. CKEDITOR.plugins.add( 'iframe', {
  7. requires: 'dialog,fakeobjects',
  8. // jscs:disable maximumLineLength
  9. lang: 'af,ar,az,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,es-mx,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,oc,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%
  10. // jscs:enable maximumLineLength
  11. icons: 'iframe', // %REMOVE_LINE_CORE%
  12. hidpi: true, // %REMOVE_LINE_CORE%
  13. onLoad: function() {
  14. CKEDITOR.addCss( 'img.cke_iframe' +
  15. '{' +
  16. 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +
  17. 'background-position: center center;' +
  18. 'background-repeat: no-repeat;' +
  19. 'border: 1px solid #a9a9a9;' +
  20. 'width: 80px;' +
  21. 'height: 80px;' +
  22. '}'
  23. );
  24. },
  25. init: function( editor ) {
  26. var pluginName = 'iframe',
  27. lang = editor.lang.iframe,
  28. allowed = 'iframe[align,longdesc,tabindex,frameborder,height,name,scrolling,src,title,width]';
  29. if ( editor.plugins.dialogadvtab )
  30. allowed += ';iframe' + editor.plugins.dialogadvtab.allowedContent( { id: 1, classes: 1, styles: 1 } );
  31. CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/iframe.js' );
  32. editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName, {
  33. allowedContent: allowed,
  34. requiredContent: 'iframe'
  35. } ) );
  36. editor.ui.addButton && editor.ui.addButton( 'Iframe', {
  37. label: lang.toolbar,
  38. command: pluginName,
  39. toolbar: 'insert,80'
  40. } );
  41. editor.on( 'doubleclick', function( evt ) {
  42. var element = evt.data.element;
  43. if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'iframe' )
  44. evt.data.dialog = 'iframe';
  45. } );
  46. if ( editor.addMenuItems ) {
  47. editor.addMenuItems( {
  48. iframe: {
  49. label: lang.title,
  50. command: 'iframe',
  51. group: 'image'
  52. }
  53. } );
  54. }
  55. // If the "contextmenu" plugin is loaded, register the listeners.
  56. if ( editor.contextMenu ) {
  57. editor.contextMenu.addListener( function( element ) {
  58. if ( element && element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'iframe' )
  59. return { iframe: CKEDITOR.TRISTATE_OFF };
  60. } );
  61. }
  62. },
  63. afterInit: function( editor ) {
  64. var dataProcessor = editor.dataProcessor,
  65. dataFilter = dataProcessor && dataProcessor.dataFilter;
  66. if ( dataFilter ) {
  67. dataFilter.addRules( {
  68. elements: {
  69. iframe: function( element ) {
  70. return editor.createFakeParserElement( element, 'cke_iframe', 'iframe', true );
  71. }
  72. }
  73. } );
  74. }
  75. }
  76. } );
  77. } )();