editor.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup Froala Froala editor integration
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. function bx_editor_insert_html (sEditorId, sImgId, sHtml)
  11. {
  12. var oEditor = $('#' + sEditorId).data('froala-instance');
  13. if (typeof oEditor !== 'object')
  14. return;
  15. oEditor.html.insert(sHtml, false);
  16. }
  17. function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses)
  18. {
  19. if ('undefined' == typeof(sClasses))
  20. sClasses = '';
  21. bx_editor_insert_html(sEditorId, sImgId, '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />');
  22. }
  23. function bx_editor_remove_img (aEditorIds, aMarkers)
  24. {
  25. for (var i = 0; i < aEditorIds.length; i++) {
  26. var eEditor = $('#' + aEditorIds[i]).parent();
  27. // delete images in html editor
  28. for (var k = 0; k < aMarkers.length; k++) {
  29. var jFiles = eEditor.find(aMarkers[k]);
  30. jFiles.each(function () {
  31. $(this).remove();
  32. });
  33. }
  34. }
  35. }
  36. function bx_editor_on_init (sEditorId)
  37. {
  38. if (typeof glOnInitEditor !== 'undefined' && glOnInitEditor instanceof Array) {
  39. for (var i = 0; i < glOnInitEditor.length; i++)
  40. if (typeof glOnInitEditor[i] === "function")
  41. glOnInitEditor[i](sEditorId);
  42. }
  43. }
  44. function bx_editor_on_space_enter (sEditorId)
  45. {
  46. if (typeof glBxEditorOnSpaceEnterTimer !== 'undefined')
  47. clearTimeout(glBxEditorOnSpaceEnterTimer);
  48. glBxEditorOnSpaceEnterTimer = setTimeout(function () {
  49. glBxEditorOnSpaceEnterTimer = undefined;
  50. if (typeof glOnSpaceEnterInEditor !== 'undefined' && glOnSpaceEnterInEditor instanceof Array) {
  51. for (var i = 0; i < glOnSpaceEnterInEditor.length; i++) {
  52. if (typeof glOnSpaceEnterInEditor[i] === "function") {
  53. var oEditor = $(sEditorId).data('froala-instance');
  54. glOnSpaceEnterInEditor[i](oEditor.html.get(), sEditorId);
  55. }
  56. }
  57. }
  58. }, 800);
  59. }
  60. function bx_editor_get_htmleditable (sEditorSelector)
  61. {
  62. if (!$(sEditorSelector).size())
  63. return false;
  64. var oEditor = $(sEditorSelector).data('froala-instance');
  65. return oEditor.el;
  66. }
  67. function bx_editor_remove_all (oElement)
  68. {
  69. }
  70. /** @} */