Steps to create CKEditor plugin.
- Define and add basic plugin info in hook_ckeditor_plugin_info_alter() in your module file.
File: my_module.module
function my_module_ckeditor_plugin_info_alter(array &$plugins) { $plugins[myplugin] = array( ‘id’ => myplugin, ‘label’ => t(‘My Plugin’), ‘module’ => my_module, ‘class’ => ‘Drupal\my_module\Plugin\CKEditorPlugin\MyPlugin, ‘provider’ => my_module, ); } - Define MyPlugin class which defines plugin, extending CKEditorPluginBase and implementing CKEditorPluginConfigurableInterface. In this plugin class we need to define the following methods:
File: MyPlugin.php
- isInternal – Return is this plugin internal or not.
- getFile – Return absolute path to plugin.js file.
public function getFile() { return drupal_get_path(‘module’, my_module) . ‘/js/plugins/myplugin/plugin.js’; } - getLibraries – Return dependency libraries, so those get loaded.
- getConfig – Return configuration array.
- getButtons – Return button info.
- settingsForm – Defines form for plugin settings, where it can be configured in ‘admin/config/content/formats/manage/full_html’. For example, this form shown below is where we can set the max size, width and height of the image, against which image will be validated when uploading an image.
- Define client side plugin.js. Basic things we need to implement in plugin.js are:
File: js/plugins/myplugin/plugin.js
- Add the new plugin to CKEditor. In beforeInit method we have to define our plugin command and add UI button which in turn triggers our plugin command on click of UI button as follows,
(function ($, Drupal, CKEDITOR) { var myPluginSaveCallback = function(data) { var content = data.image_render; insertContent(content); }; CKEDITOR.plugins.add(‘myplugin’, { icons: ‘imagepopup’, hidpi: true, beforeInit: function (editor) { // Implementation before initializing plugin. editor.addCommand( ‘editmyplugin’, { canUndo: true, exec: function (editor, data) { // Populate existing values of form. var existingValues = {}; // Open dialog form. Drupal.ckeditor.openDialog(editor, Drupal.url(‘my_module/dialog/image/’ + editor.config.drupal.format), existingValues, myPluginSaveCallback, {} ); } }); editor.ui.addButton(‘MyPlugin’, { label: Drupal.t(‘My plugin’), // Note that we use the original image2 command! command: ‘editmyplugin’ }); insertContent = function(html) { editor.insertHtml(html); } }, }); })(jQuery, Drupal, CKEDITOR); - Define routing for the dialog, which points to Form controller.
File: my_module.routing.yml
my_module.image_dialog: path: ‘/my_module/dialog/image/{filter_format}‘ defaults: _form: ‘\Drupal\my_module\Form\EditorImagePopupDialog‘ _title: ‘Upload image‘ options: _theme: ajax_base_page requirements: _entity_access: ‘filter_format.use‘ - Define plugin dialog form and its form submit handler as we normally do in Drupal 8. In addition, on form submit we need to return ajax response command like below
File: my_module\Form\EditorImagePopupDialog
$response->addCommand(new EditorDialogSave($form_state->getValues())); $response->addCommand(new CloseModalDialogCommand()); And whenever edit operation happens we need to populate existingValues json object in plugin.js file, so we can get those values in buildForm with the below line of code.
$image_data = $form_state->getUserInput()[‘editor_object’];
- Add the new plugin to CKEditor. In beforeInit method we have to define our plugin command and add UI button which in turn triggers our plugin command on click of UI button as follows,
Finally configurations.
- Go to ‘admin/config/content/formats’, then click on configure action link for which format this plugin needs to be added.
- In configuration form, we can drag and drop newly created plugin button to CKEditor toolbar.
- Now, save the configuration form.
Bitcoin Blogs 1501
Bitcoin Blogs 1502
Bitcoin Blogs 1503
Bitcoin Blogs 1504
Bitcoin Blogs 1505
Bitcoin Blogs 1506
Bitcoin Blogs 1507
Bitcoin Blogs 1508
Bitcoin Blogs 1509
Bitcoin Blogs 1510
Bitcoin Blogs 1511
Bitcoin Blogs 1512
Bitcoin Blogs 1513
Bitcoin Blogs 1514
Bitcoin Blogs 1515
Bitcoin Blogs 1516
Bitcoin Blogs 1517
Bitcoin Blogs 1518
Bitcoin Blogs 1519
Bitcoin Blogs 1520
Bitcoin Blogs 1521
Bitcoin Blogs 1522
Bitcoin Blogs 1523
Bitcoin Blogs 1524
Bitcoin Blogs 1525
Bitcoin Blogs 1526
Bitcoin Blogs 1527
Bitcoin Blogs 1528
Bitcoin Blogs 1529
Bitcoin Blogs 1530
Bitcoin Blogs 1531
Bitcoin Blogs 1532
Bitcoin Blogs 1533
Bitcoin Blogs 1534
Bitcoin Blogs 1535
Bitcoin Blogs 1536
Bitcoin Blogs 1537
Bitcoin Blogs 1538
Bitcoin Blogs 1539
Bitcoin Blogs 1540
Bitcoin Blogs 1541
Bitcoin Blogs 1542
Bitcoin Blogs 1543
Bitcoin Blogs 1544
Bitcoin Blogs 1545
Bitcoin Blogs 1546
Bitcoin Blogs 1547
Bitcoin Blogs 1548
Bitcoin Blogs 1549
Bitcoin Blogs 1550
Bitcoin Blogs 1551
Bitcoin Blogs 1552
Bitcoin Blogs 1553
Bitcoin Blogs 1554
Bitcoin Blogs 1555
Bitcoin Blogs 1556
Bitcoin Blogs 1557
Bitcoin Blogs 1558
Bitcoin Blogs 1559
Bitcoin Blogs 1560
Bitcoin Blogs 1561
Bitcoin Blogs 1562
Bitcoin Blogs 1563
Bitcoin Blogs 1564
Bitcoin Blogs 1565
Bitcoin Blogs 1566
Bitcoin Blogs 1567
Bitcoin Blogs 1568
Bitcoin Blogs 1569
Bitcoin Blogs 1570
Bitcoin Blogs 1571
Bitcoin Blogs 1572
Bitcoin Blogs 1573
Bitcoin Blogs 1574
Bitcoin Blogs 1575
Bitcoin Blogs 1576
Bitcoin Blogs 1577
Bitcoin Blogs 1578
Bitcoin Blogs 1579
Bitcoin Blogs 1580
Bitcoin Blogs 1581
Bitcoin Blogs 1582
Bitcoin Blogs 1583
Bitcoin Blogs 1584
Bitcoin Blogs 1585
Bitcoin Blogs 1586
Bitcoin Blogs 1587
Bitcoin Blogs 1588
Bitcoin Blogs 1589
Bitcoin Blogs 1590
Bitcoin Blogs 1591
Bitcoin Blogs 1592
Bitcoin Blogs 1593
Bitcoin Blogs 1594
Bitcoin Blogs 1595
Bitcoin Blogs 1596
Bitcoin Blogs 1597
Bitcoin Blogs 1598
Bitcoin Blogs 1599
Bitcoin Blogs 1600
Bitcoin Blogs 1601
Bitcoin Blogs 1602
Bitcoin Blogs 1603
Bitcoin Blogs 1604
Bitcoin Blogs 1605
Bitcoin Blogs 1606
Bitcoin Blogs 1607
Bitcoin Blogs 1608
Bitcoin Blogs 1609
Bitcoin Blogs 1610
Bitcoin Blogs 1611
Bitcoin Blogs 1612
Bitcoin Blogs 1613
Bitcoin Blogs 1614
Bitcoin Blogs 1615
Bitcoin Blogs 1616
Bitcoin Blogs 1617
Bitcoin Blogs 1618
Bitcoin Blogs 1619
Bitcoin Blogs 1620
Bitcoin Blogs 1621
Bitcoin Blogs 1622
Bitcoin Blogs 1623
Bitcoin Blogs 1624
Bitcoin Blogs 1625
Bitcoin Blogs 1626
Bitcoin Blogs 1627
Bitcoin Blogs 1628
Bitcoin Blogs 1629
Bitcoin Blogs 1630
Bitcoin Blogs 1631
Bitcoin Blogs 1632
Bitcoin Blogs 1633
Bitcoin Blogs 1634
Bitcoin Blogs 1635
Bitcoin Blogs 1636
Bitcoin Blogs 1637
Bitcoin Blogs 1638
Bitcoin Blogs 1639
Bitcoin Blogs 1640
Bitcoin Blogs 1641
Bitcoin Blogs 1642
Bitcoin Blogs 1643
Bitcoin Blogs 1644
Bitcoin Blogs 1645
Bitcoin Blogs 1646
Bitcoin Blogs 1647
Bitcoin Blogs 1648
Bitcoin Blogs 1649
Bitcoin Blogs 1650
Bitcoin Blogs 1651
Bitcoin Blogs 1652
Bitcoin Blogs 1653
Bitcoin Blogs 1654
Bitcoin Blogs 1655
Bitcoin Blogs 1656
Bitcoin Blogs 1657
Bitcoin Blogs 1658
Bitcoin Blogs 1659
Bitcoin Blogs 1660
Bitcoin Blogs 1661
Bitcoin Blogs 1662
Bitcoin Blogs 1663
Bitcoin Blogs 1664
Bitcoin Blogs 1665
Bitcoin Blogs 1666
Bitcoin Blogs 1667
Bitcoin Blogs 1668
Bitcoin Blogs 1669
Bitcoin Blogs 1670
Bitcoin Blogs 1671
Bitcoin Blogs 1672
Bitcoin Blogs 1673
Bitcoin Blogs 1674
Bitcoin Blogs 1675
Bitcoin Blogs 1676
Bitcoin Blogs 1677
Bitcoin Blogs 1678
Bitcoin Blogs 1679
Bitcoin Blogs 1680
Bitcoin Blogs 1681
Bitcoin Blogs 1682
Bitcoin Blogs 1683
Bitcoin Blogs 1684
Bitcoin Blogs 1685
Bitcoin Blogs 1686
Bitcoin Blogs 1687
Bitcoin Blogs 1688
Bitcoin Blogs 1689
Bitcoin Blogs 1690
Bitcoin Blogs 1691
Bitcoin Blogs 1692
Bitcoin Blogs 1693
Bitcoin Blogs 1694
Bitcoin Blogs 1695
Bitcoin Blogs 1696
Bitcoin Blogs 1697
Bitcoin Blogs 1698
Bitcoin Blogs 1699
Bitcoin Blogs 1700
Bitcoin Blogs 1701
Bitcoin Blogs 1702
Bitcoin Blogs 1703
Bitcoin Blogs 1704
Bitcoin Blogs 1705
Bitcoin Blogs 1706
Bitcoin Blogs 1707
Bitcoin Blogs 1708
Bitcoin Blogs 1709
Bitcoin Blogs 1710
Bitcoin Blogs 1711
Bitcoin Blogs 1712
Bitcoin Blogs 1713
Bitcoin Blogs 1714
Bitcoin Blogs 1715
Bitcoin Blogs 1716
Bitcoin Blogs 1717
Bitcoin Blogs 1718
Bitcoin Blogs 1719
Bitcoin Blogs 1720
Bitcoin Blogs 1721
Bitcoin Blogs 1722
Bitcoin Blogs 1723
Bitcoin Blogs 1724
Bitcoin Blogs 1725
Bitcoin Blogs 1726
Bitcoin Blogs 1727
Bitcoin Blogs 1728
Bitcoin Blogs 1729
Bitcoin Blogs 1730
Bitcoin Blogs 1731
Bitcoin Blogs 1732
Bitcoin Blogs 1733
Bitcoin Blogs 1734
Bitcoin Blogs 1735
Bitcoin Blogs 1736
Bitcoin Blogs 1737
Bitcoin Blogs 1738
Bitcoin Blogs 1739
Bitcoin Blogs 1740
Bitcoin Blogs 1741
Bitcoin Blogs 1742
Bitcoin Blogs 1743
Bitcoin Blogs 1744
Bitcoin Blogs 1745
Bitcoin Blogs 1746
Bitcoin Blogs 1747
Bitcoin Blogs 1748
Bitcoin Blogs 1749
Bitcoin Blogs 1750
Bitcoin Blogs 1751
Bitcoin Blogs 1752
Bitcoin Blogs 1753
Bitcoin Blogs 1754
Bitcoin Blogs 1755
Bitcoin Blogs 1756
Bitcoin Blogs 1757
Bitcoin Blogs 1758
Bitcoin Blogs 1759
Bitcoin Blogs 1760
Bitcoin Blogs 1761
Bitcoin Blogs 1762
Bitcoin Blogs 1763
Bitcoin Blogs 1764
Bitcoin Blogs 1765
Bitcoin Blogs 1766
Bitcoin Blogs 1767
Bitcoin Blogs 1768
Bitcoin Blogs 1769
Bitcoin Blogs 1770
Bitcoin Blogs 1771
Bitcoin Blogs 1772
Bitcoin Blogs 1773
Bitcoin Blogs 1774
Bitcoin Blogs 1775
Bitcoin Blogs 1776
Bitcoin Blogs 1777
Bitcoin Blogs 1778
Bitcoin Blogs 1779
Bitcoin Blogs 1780
Bitcoin Blogs 1781
Bitcoin Blogs 1782
Bitcoin Blogs 1783
Bitcoin Blogs 1784
Bitcoin Blogs 1785
Bitcoin Blogs 1786
Bitcoin Blogs 1787
Bitcoin Blogs 1788
Bitcoin Blogs 1789
Bitcoin Blogs 1790
Bitcoin Blogs 1791
Bitcoin Blogs 1792
Bitcoin Blogs 1793
Bitcoin Blogs 1794
Bitcoin Blogs 1795
Bitcoin Blogs 1796
Bitcoin Blogs 1797
Bitcoin Blogs 1798
Bitcoin Blogs 1799
Bitcoin Blogs 1800
Bitcoin Blogs 1801
Bitcoin Blogs 1802
Bitcoin Blogs 1803
Bitcoin Blogs 1804
Bitcoin Blogs 1805
Bitcoin Blogs 1806
Bitcoin Blogs 1807
Bitcoin Blogs 1808
Bitcoin Blogs 1809
Bitcoin Blogs 1810
Bitcoin Blogs 1811
Bitcoin Blogs 1812
Bitcoin Blogs 1813
Bitcoin Blogs 1814
Bitcoin Blogs 1815
Bitcoin Blogs 1816
Bitcoin Blogs 1817
Bitcoin Blogs 1818
Bitcoin Blogs 1819
Bitcoin Blogs 1820
Bitcoin Blogs 1821
Bitcoin Blogs 1822
Bitcoin Blogs 1823
Bitcoin Blogs 1824
Bitcoin Blogs 1825
Bitcoin Blogs 1826
Bitcoin Blogs 1827
Bitcoin Blogs 1828
Bitcoin Blogs 1829
Bitcoin Blogs 1830
Bitcoin Blogs 1831
Bitcoin Blogs 1832
Bitcoin Blogs 1833
Bitcoin Blogs 1834
Bitcoin Blogs 1835
Bitcoin Blogs 1836
Bitcoin Blogs 1837
Bitcoin Blogs 1838
Bitcoin Blogs 1839
Bitcoin Blogs 1840
Bitcoin Blogs 1841
Bitcoin Blogs 1842
Bitcoin Blogs 1843
Bitcoin Blogs 1844
Bitcoin Blogs 1845
Bitcoin Blogs 1846
Bitcoin Blogs 1847
Bitcoin Blogs 1848
Bitcoin Blogs 1849
Bitcoin Blogs 1850
Bitcoin Blogs 1851
Bitcoin Blogs 1852
Bitcoin Blogs 1853
Bitcoin Blogs 1854
Bitcoin Blogs 1855
Bitcoin Blogs 1856
Bitcoin Blogs 1857
Bitcoin Blogs 1858
Bitcoin Blogs 1859
Bitcoin Blogs 1860
Bitcoin Blogs 1861
Bitcoin Blogs 1862
Bitcoin Blogs 1863
Bitcoin Blogs 1864
Bitcoin Blogs 1865
Bitcoin Blogs 1866
Bitcoin Blogs 1867
Bitcoin Blogs 1868
Bitcoin Blogs 1869
Bitcoin Blogs 1870
Bitcoin Blogs 1871
Bitcoin Blogs 1872
Bitcoin Blogs 1873
Bitcoin Blogs 1874
Bitcoin Blogs 1875
Bitcoin Blogs 1876
Bitcoin Blogs 1877
Bitcoin Blogs 1878
Bitcoin Blogs 1879
Bitcoin Blogs 1880
Bitcoin Blogs 1881
Bitcoin Blogs 1882
Bitcoin Blogs 1883
Bitcoin Blogs 1884
Bitcoin Blogs 1885
Bitcoin Blogs 1886
Bitcoin Blogs 1887
Bitcoin Blogs 1888
Bitcoin Blogs 1889
Bitcoin Blogs 1890
Bitcoin Blogs 1891
Bitcoin Blogs 1892
Bitcoin Blogs 1893
Bitcoin Blogs 1894
Bitcoin Blogs 1895
Bitcoin Blogs 1896
Bitcoin Blogs 1897
Bitcoin Blogs 1898
Bitcoin Blogs 1899
Bitcoin Blogs 1900
Bitcoin Blogs 1901
Bitcoin Blogs 1902
Bitcoin Blogs 1903
Bitcoin Blogs 1904
Bitcoin Blogs 1905
Bitcoin Blogs 1906
Bitcoin Blogs 1907
Bitcoin Blogs 1908
Bitcoin Blogs 1909
Bitcoin Blogs 1910
Bitcoin Blogs 1911
Bitcoin Blogs 1912
Bitcoin Blogs 1913
Bitcoin Blogs 1914
Bitcoin Blogs 1915
Bitcoin Blogs 1916
Bitcoin Blogs 1917
Bitcoin Blogs 1918
Bitcoin Blogs 1919
Bitcoin Blogs 1920
Bitcoin Blogs 1921
Bitcoin Blogs 1922
Bitcoin Blogs 1923
Bitcoin Blogs 1924
Bitcoin Blogs 1925
Bitcoin Blogs 1926
Bitcoin Blogs 1927
Bitcoin Blogs 1928
Bitcoin Blogs 1929
Bitcoin Blogs 1930
Bitcoin Blogs 1931
Bitcoin Blogs 1932
Bitcoin Blogs 1933
Bitcoin Blogs 1934
Bitcoin Blogs 1935
Bitcoin Blogs 1936
Bitcoin Blogs 1937
Bitcoin Blogs 1938
Bitcoin Blogs 1939
Bitcoin Blogs 1940
Bitcoin Blogs 1941
Bitcoin Blogs 1942
Bitcoin Blogs 1943
Bitcoin Blogs 1944
Bitcoin Blogs 1945
Bitcoin Blogs 1946
Bitcoin Blogs 1947
Bitcoin Blogs 1948
Bitcoin Blogs 1949
Bitcoin Blogs 1950
Bitcoin Blogs 1951
Bitcoin Blogs 1952
Bitcoin Blogs 1953
Bitcoin Blogs 1954
Bitcoin Blogs 1955
Bitcoin Blogs 1956
Bitcoin Blogs 1957
Bitcoin Blogs 1958
Bitcoin Blogs 1959
Bitcoin Blogs 1960
Bitcoin Blogs 1961
Bitcoin Blogs 1962
Bitcoin Blogs 1963
Bitcoin Blogs 1964
Bitcoin Blogs 1965
Bitcoin Blogs 1966
Bitcoin Blogs 1967
Bitcoin Blogs 1968
Bitcoin Blogs 1969
Bitcoin Blogs 1970
Bitcoin Blogs 1971
Bitcoin Blogs 1972
Bitcoin Blogs 1973
Bitcoin Blogs 1974
Bitcoin Blogs 1975
Bitcoin Blogs 1976
Bitcoin Blogs 1977
Bitcoin Blogs 1978
Bitcoin Blogs 1979
Bitcoin Blogs 1980
Bitcoin Blogs 1981
Bitcoin Blogs 1982
Bitcoin Blogs 1983
Bitcoin Blogs 1984
Bitcoin Blogs 1985
Bitcoin Blogs 1986
Bitcoin Blogs 1987
Bitcoin Blogs 1988
Bitcoin Blogs 1989
Bitcoin Blogs 1990
Bitcoin Blogs 1991
Bitcoin Blogs 1992
Bitcoin Blogs 1993
Bitcoin Blogs 1994
Bitcoin Blogs 1995
Bitcoin Blogs 1996
Bitcoin Blogs 1997
Bitcoin Blogs 1998
Bitcoin Blogs 1999
Bitcoin Blogs 2000