### Install Export to PDF via npm Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/plugins/exportpdf/README.md Run this command in your terminal to install the plugin package. ```bash npm i ckeditor4-plugin-exportpdf ``` -------------------------------- ### Verify CKEditor Installation Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/README.md Access the sample index page to confirm that the CKEditor installation is functioning correctly. ```text http:////samples/index.html ``` ```text http://www.example.com/ckeditor/samples/index.html ``` -------------------------------- ### Install via Composer Source: https://github.com/hansschouten/phpagebuilder/blob/master/README.md Run this command in your terminal to add PHPagebuilder as a dependency. ```bash composer require hansschouten/phpagebuilder ``` -------------------------------- ### Full XHTML Compliant Editor Configuration Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/samples/old/xhtmlstyle.html A comprehensive configuration example defining styles, font settings, colors, indentation, and justification classes for full XHTML compliance. ```javascript CKEDITOR.replace( 'editor1', { /* * Style sheet for the contents */ contentsCss: 'assets/outputxhtml/outputxhtml.css', /* * Special allowed content rules for spans used by * font face, size, and color buttons. * * Note: all rules have been written separately so * it was possible to specify required classes. */ extraAllowedContent: 'span(!FontColor1);span(!FontColor2);span(!FontColor3);' + 'span(!FontColor1BG);span(!FontColor2BG);span(!FontColor3BG);' + 'span(!FontComic);span(!FontCourier);span(!FontTimes);' + 'span(!FontSmaller);span(!FontLarger);span(!FontSmall);span(!FontBig);span(!FontDouble)', /* * Core styles. */ coreStyles_bold: { element: 'span', attributes: { 'class': 'Bold' } }, coreStyles_italic: { element: 'span', attributes: { 'class': 'Italic' } }, coreStyles_underline: { element: 'span', attributes: { 'class': 'Underline' } }, coreStyles_strike: { element: 'span', attributes: { 'class': 'StrikeThrough' }, overrides: 'strike' }, coreStyles_subscript: { element: 'span', attributes: { 'class': 'Subscript' }, overrides: 'sub' }, coreStyles_superscript: { element: 'span', attributes: { 'class': 'Superscript' }, overrides: 'sup' }, /* * Font face. */ // List of fonts available in the toolbar combo. Each font definition is // separated by a semi-colon (;). We are using class names here, so each font // is defined by {Combo Label}/{Class Name}. font_names: 'Comic Sans MS/FontComic;Courier New/FontCourier;Times New Roman/FontTimes', // Define the way font elements will be applied to the document. The "span" // element will be used. When a font is selected, the font name defined in the // above list is passed to this definition with the name "Font", being it // injected in the "class" attribute. // We must also instruct the editor to replace span elements that are used to // set the font (Overrides). font_style: { element: 'span', attributes: { 'class': '#(family)' }, overrides: [ { element: 'span', attributes: { 'class': /^Font(?:Comic|Courier|Times)$/ } } ] }, /* * Font sizes. */ fontSize_sizes: 'Smaller/FontSmaller;Larger/FontLarger;8pt/FontSmall;14pt/FontBig;Double Size/FontDouble', fontSize_style: { element: 'span', attributes: { 'class': '#(size)' }, overrides: [ { element: 'span', attributes: { 'class': /^Font(?:Smaller|Larger|Small|Big|Double)$/ } } ] } , /* * Font colors. */ colorButton_enableMore: false, colorButton_colors: 'FontColor1/FF9900,FontColor2/0066CC,FontColor3/F00', colorButton_foreStyle: { element: 'span', attributes: { 'class': '#(color)' }, overrides: [ { element: 'span', attributes: { 'class': /^FontColor(?:1|2|3)$/ } } ] }, colorButton_backStyle: { element: 'span', attributes: { 'class': '#(color)BG' }, overrides: [ { element: 'span', attributes: { 'class': /^FontColor(?:1|2|3)BG$/ } } ] }, /* * Indentation. */ indentClasses: [ 'Indent1', 'Indent2', 'Indent3' ], /* * Paragraph justification. */ justifyClasses: [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyFull' ], /* * Styles combo. */ stylesSet: [ { name: 'Strong Emphasis', element: 'strong' }, { name: 'Emphasis', element: 'em' }, { name: 'Computer Code', element: 'code' }, { name: 'Keyboard Phrase', element: 'kbd' }, { name: 'Sample Text', element: 'samp' }, { name: 'Variable', element: 'var' }, { name: 'Deleted Text', element: 'del' }, { name: 'Inserted Text', element: 'ins' }, { name: 'Cited Work', element: 'cite' }, { name: 'Inline Quotation', element: 'q' } ] }); ``` -------------------------------- ### Basic XHTML Configuration Snippet Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/samples/old/xhtmlstyle.html A minimal example showing how to initialize CKEditor with custom core styles for bold and italic text using span elements. ```javascript CKEDITOR.replace( '_textarea_id_', { contentsCss: 'assets/outputxhtml.css', coreStyles_bold: { element: 'span', attributes: { 'class': 'Bold' } }, coreStyles_italic: { element: 'span', attributes: { 'class': 'Italic' } }, ... }); ``` -------------------------------- ### Register External Plugin Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/plugins/exportpdf/README.md Use the addExternal method to register the plugin when installed via npm. ```javascript CKEDITOR.plugins.addExternal( 'exportpdf', './node_modules/ckeditor4-plugin-exportpdf/' ); ``` -------------------------------- ### Set programmatic data in CKEditor Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/samples/old/datafiltering.html Example of inserting HTML content into the editor programmatically. ```javascript editor.setData( '

Hello world!

' ); ``` -------------------------------- ### Enable inline editing via contenteditable Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/samples/old/inlineall.html Example of the HTML attribute required to trigger automatic CKEditor instance creation. ```html
...
``` -------------------------------- ### Initialize Sticky Toolbar and Help Modal Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/samples/toolbarconfigurator/index.html Configures sticky positioning for the editor container and sets up the help modal interaction, including browser-specific compatibility checks for IE8. ```javascript placeholder.setStyle( 'width', element.element.getSize( 'width' ) + 'px' ); placeholder.setStyle( 'height', element.element.getSize( 'height' ) + 'px' ); placeholder.setStyle( 'margin-bottom', element.element.getComputedStyle( 'margin-bottom' ) ); placeholder.setStyle( 'display', element.element.getComputedStyle( 'display' ) ); placeholder.insertAfter( element.element ); this.staticContainer.append( element.element ); this.active.push( element ); } element.isFixed = !element.isFixed; }, shouldBeFixed: function( element ) { if ( element.preventFunc && element.preventFunc() ) { return false; } // If element is already fixed we are checking it's placeholder. var related = ( element.isFixed ? element.placeholder : element.element ), clientRect = related.$.getBoundingClientRect(), staticHeight = this.staticContainer.getSize('height' ), elemHeight = element.element.getSize( 'height' ); if ( element.isFixed ) { return ( clientRect.top + elemHeight < staticHeight ); } else { return ( clientRect.top < staticHeight ); } } }; positionSticky.init(); CKEDITOR.document.getWindow().on( 'scroll', CKEDITOR.tools.eventsBuffer( 100, positionSticky.checkAll, positionSticky ).input ); // Make the toolbar sticky. positionSticky.watch( CKEDITOR.document.findOne( '.editors-container' ) ); // Help button and help-content. ( function() { var helpButton = CKEDITOR.document.getById( 'help' ), helpContent = CKEDITOR.document.getById( 'help-content' ); // Don't show help button on IE8 because it's unsupported by Pico Modal. if ( CKEDITOR.env.ie && CKEDITOR.env.version == 8 ) { helpButton.hide(); } else { // Display help modal when the button is clicked. helpButton.on( 'click', function( evt ) { SF.modal( { // Clone modal content from DOM. content: helpContent.getHtml(), afterCreate: function( modal ) { // Enable modal content button to close the modal. new CKEDITOR.dom.element( modal.modalElem() ).findOne( '.help-content-close' ).once( 'click', modal.close ); } } ).show(); } ); } } )(); } )(); ``` -------------------------------- ### Initialize without Composer Source: https://github.com/hansschouten/phpagebuilder/blob/master/README.md Use this code to manually register the autoloader and initialize the builder if not using Composer. ```php $installationFolder = __DIR__ . '/phpagebuilder'; require_once $installationFolder . '/src/Core/helpers.php'; spl_autoload_register('phpb_autoload'); $config = require __DIR__ . '/config.php'; $builder = new PHPageBuilder\PHPageBuilder($config); $builder->handleRequest(); ``` -------------------------------- ### Initialize CKEditor sample Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/samples/index.html Function call used to initialize the editor instance on the sample page. ```javascript initSample(); ``` -------------------------------- ### Append CKEditor to a Specific Element Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/samples/old/appendto.html Example of appending an editor instance to a div with the ID 'section1' using default configuration. ```javascript // This call can be placed at any point after the // DOM element to append CKEditor to or inside the ``` -------------------------------- ### Initialize and Switch Editor Language Source: https://github.com/hansschouten/phpagebuilder/blob/master/dist/pagebuilder/ckeditor4-full-4.21.0/samples/old/uilanguages.html Handles the creation and destruction of editor instances to apply a new language code dynamically. ```javascript // Set the number of languages. document.getElementById( 'count' ).innerHTML = window.CKEDITOR_LANGS.length; var editor; function createEditor( languageCode ) { if ( editor ) editor.destroy(); // Replace the