| Server IP : 54.94.228.101 / Your IP : 172.28.20.13 Web Server : Apache System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/vinumday2_0/public/plugins/@ckeditor/ckeditor5-ui/src/icon/ |
Upload File : |
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/* global DOMParser */
/**
* @module ui/icon/iconview
*/
import View from '../view';
import '../../theme/components/icon/icon.css';
/**
* The icon view class.
*
* @extends module:ui/view~View
*/
export default class IconView extends View {
/**
* @inheritDoc
*/
constructor() {
super();
const bind = this.bindTemplate;
/**
* The SVG source of the icon.
*
* @observable
* @member {String} #content
*/
this.set( 'content', '' );
/**
* This attribute specifies the boundaries to which the
* icon content should stretch.
*
* @observable
* @default '0 0 20 20'
* @member {String} #viewBox
*/
this.set( 'viewBox', '0 0 20 20' );
/**
* The fill color of the child `path.ck-icon__fill`.
*
* @observable
* @default ''
* @member {String} #fillColor
*/
this.set( 'fillColor', '' );
this.setTemplate( {
tag: 'svg',
ns: 'http://www.w3.org/2000/svg',
attributes: {
class: [
'ck',
'ck-icon'
],
viewBox: bind.to( 'viewBox' )
}
} );
}
/**
* @inheritDoc
*/
render() {
super.render();
this._updateXMLContent();
this._colorFillPaths();
// This is a hack for lack of innerHTML binding.
// See: https://github.com/ckeditor/ckeditor5-ui/issues/99.
this.on( 'change:content', () => {
this._updateXMLContent();
this._colorFillPaths();
} );
this.on( 'change:fillColor', () => {
this._colorFillPaths();
} );
}
/**
* Updates the {@link #element} with the value of {@link #content}.
*
* @private
*/
_updateXMLContent() {
if ( this.content ) {
const parsed = new DOMParser().parseFromString( this.content.trim(), 'image/svg+xml' );
const svg = parsed.querySelector( 'svg' );
const viewBox = svg.getAttribute( 'viewBox' );
if ( viewBox ) {
this.viewBox = viewBox;
}
this.element.innerHTML = '';
while ( svg.childNodes.length > 0 ) {
this.element.appendChild( svg.childNodes[ 0 ] );
}
}
}
/**
* Fills all child `path.ck-icon__fill` with the `#fillColor`.
*
* @private
*/
_colorFillPaths() {
if ( this.fillColor ) {
this.element.querySelectorAll( '.ck-icon__fill' ).forEach( path => {
path.style.fill = this.fillColor;
} );
}
}
}