rtl_ltr_buttons.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
  7. <link rel="stylesheet" href="../../css/froala_editor.css">
  8. <link rel="stylesheet" href="../../css/froala_style.css">
  9. <link rel="stylesheet" href="../../css/plugins/code_view.css">
  10. <link rel="stylesheet" href="../../css/plugins/colors.css">
  11. <link rel="stylesheet" href="../../css/plugins/emoticons.css">
  12. <link rel="stylesheet" href="../../css/plugins/image_manager.css">
  13. <link rel="stylesheet" href="../../css/plugins/image.css">
  14. <link rel="stylesheet" href="../../css/plugins/line_breaker.css">
  15. <link rel="stylesheet" href="../../css/plugins/table.css">
  16. <link rel="stylesheet" href="../../css/plugins/char_counter.css">
  17. <link rel="stylesheet" href="../../css/plugins/video.css">
  18. <link rel="stylesheet" href="../../css/plugins/fullscreen.css">
  19. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.css">
  20. <style>
  21. body {
  22. text-align: center;
  23. }
  24. section {
  25. width: 81%;
  26. margin: auto;
  27. text-align: left;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <section id="editor">
  33. <div id='edit' style="margin-top: 30px;">
  34. <h1>RTL LTR Direction Buttons</h1>
  35. <p>Custom buttons for RTL and LTR to change direction for the current selection.</p>
  36. <img class="fr-fir" src="../../img/photo1.jpg" alt="Old Clock" width="300" />
  37. <p>The rich text editor has full RTL support. Set the <a
  38. href="https://www.froala.com/wysiwyg-editor/v2.0/docs/options#direction" title="direction option"
  39. target="_blank">direction</a> option to rtl and writing in Arabic or Farsi will feel naturally.</p>
  40. <a href="http://froala.com" title="Aenean sed hendrerit" target="_blank">Aenean sed hendrerit</a> velit. Nullam eu
  41. mi dolor. Maecenas et erat risus. Nulla ac auctor diam, non aliquet ante. Fusce ullamcorper, ipsum id tempor
  42. lacinia, sem tellus malesuada libero, quis ornare sem massa in orci. Sed dictum dictum tristique. Proin eros
  43. turpis, ultricies eu sapien eget, ornare rutrum ipsum. Pellentesque eros nisl, ornare nec ipsum sed, aliquet
  44. sollicitudin erat. Nulla tincidunt porta <strong>vehicula.</strong><br />
  45. <table style="width: 60%;">
  46. <tr>
  47. <td style="width: 25%;">testing rtl</td>
  48. <td style="width: 25%;">rtl</td>
  49. <td style="width: 25%;">testing rtl</td>
  50. <td style="width: 25%;">rtl</td>
  51. </tr>
  52. <tr>
  53. <td style="width: 25%;">testing rtl</td>
  54. <td style="width: 25%;">rtl</td>
  55. <td style="width: 25%;">testing rtl</td>
  56. <td style="width: 25%;">rtl</td>
  57. </tr>
  58. </table>
  59. </div>
  60. </section>
  61. <script type="text/javascript"
  62. src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.js"></script>
  63. <script type="text/javascript"
  64. src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/mode/xml/xml.min.js"></script>
  65. <script type="text/javascript" src="../../js/froala_editor.min.js"></script>
  66. <script type="text/javascript" src="../../js/plugins/align.min.js"></script>
  67. <script type="text/javascript" src="../../js/plugins/code_beautifier.min.js"></script>
  68. <script type="text/javascript" src="../../js/plugins/code_view.min.js"></script>
  69. <script type="text/javascript" src="../../js/plugins/colors.min.js"></script>
  70. <script type="text/javascript" src="../../js/plugins/draggable.min.js"></script>
  71. <script type="text/javascript" src="../../js/plugins/emoticons.min.js"></script>
  72. <script type="text/javascript" src="../../js/plugins/font_size.min.js"></script>
  73. <script type="text/javascript" src="../../js/plugins/font_family.min.js"></script>
  74. <script type="text/javascript" src="../../js/plugins/image.min.js"></script>
  75. <script type="text/javascript" src="../../js/plugins/image_manager.min.js"></script>
  76. <script type="text/javascript" src="../../js/plugins/line_breaker.min.js"></script>
  77. <script type="text/javascript" src="../../js/plugins/link.min.js"></script>
  78. <script type="text/javascript" src="../../js/plugins/lists.min.js"></script>
  79. <script type="text/javascript" src="../../js/plugins/paragraph_format.min.js"></script>
  80. <script type="text/javascript" src="../../js/plugins/paragraph_style.min.js"></script>
  81. <script type="text/javascript" src="../../js/plugins/video.min.js"></script>
  82. <script type="text/javascript" src="../../js/plugins/table.min.js"></script>
  83. <script type="text/javascript" src="../../js/plugins/url.min.js"></script>
  84. <script type="text/javascript" src="../../js/plugins/entities.min.js"></script>
  85. <script type="text/javascript" src="../../js/plugins/char_counter.min.js"></script>
  86. <script type="text/javascript" src="../../js/plugins/inline_style.min.js"></script>
  87. <script type="text/javascript" src="../../js/plugins/save.min.js"></script>
  88. <script type="text/javascript" src="../../js/plugins/fullscreen.min.js"></script>
  89. <script type="text/javascript" src="../../js/languages/ro.js"></script>
  90. <script>
  91. (function () {
  92. var changeDirection = function (dir, align) {
  93. this.selection.save()
  94. var elements = this.selection.blocks()
  95. for (var i = 0; i < elements.length; i++) {
  96. var element = elements[i]
  97. if (element != this.$el.get(0)) {
  98. element.style.direction = dir
  99. element.style.textAlign = align
  100. }
  101. }
  102. this.selection.restore()
  103. }
  104. FroalaEditor.DefineIcon('rightToLeft', { NAME: 'long-arrow-left', SVG_KEY: 'undo' })
  105. FroalaEditor.RegisterCommand('rightToLeft', {
  106. title: 'RTL',
  107. focus: true,
  108. undo: true,
  109. refreshAfterCallback: true,
  110. callback: function () {
  111. changeDirection.apply(this, ['rtl', 'right'])
  112. }
  113. })
  114. FroalaEditor.DefineIcon('leftToRight', { NAME: 'long-arrow-right', SVG_KEY: 'redo' })
  115. FroalaEditor.RegisterCommand('leftToRight', {
  116. title: 'LTR',
  117. focus: true,
  118. undo: true,
  119. refreshAfterCallback: true,
  120. callback: function () {
  121. changeDirection.apply(this, ['ltr', 'left'])
  122. }
  123. })
  124. new FroalaEditor("#edit", {
  125. toolbarButtons: [ ['undo', 'redo', 'bold', 'formatOL', 'formatUL'], ['rightToLeft', 'leftToRight'] ]
  126. })
  127. })()
  128. </script>
  129. </body>
  130. </html>