editor.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if (typeof $('#' + sEditorId).froalaEditor !== 'function')
  13. return;
  14. $('#' + sEditorId).froalaEditor('html.insert', sHtml, false);
  15. }
  16. function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses)
  17. {
  18. if ('undefined' == typeof(sClasses))
  19. sClasses = '';
  20. bx_editor_insert_html(sEditorId, sImgId, '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />');
  21. }
  22. function bx_editor_remove_img (aEditorIds, aMarkers)
  23. {
  24. for (var i = 0; i < aEditorIds.length; i++) {
  25. var eEditor = $('#' + aEditorIds[i]).parent();
  26. // delete images in html editor
  27. for (var k = 0; k < aMarkers.length; k++) {
  28. var jFiles = eEditor.find(aMarkers[k]);
  29. jFiles.each(function () {
  30. $(this).remove();
  31. });
  32. }
  33. }
  34. }
  35. function bx_editor_on_init (sEditorId)
  36. {
  37. if (typeof glOnInitEditor !== 'undefined' && glOnInitEditor instanceof Array) {
  38. for (var i = 0; i < glOnInitEditor.length; i++)
  39. if (typeof glOnInitEditor[i] === "function")
  40. glOnInitEditor[i](sEditorId);
  41. }
  42. }
  43. function bx_editor_on_space_enter (sEditorId)
  44. {
  45. if (typeof glBxEditorOnSpaceEnterTimer !== 'undefined')
  46. clearTimeout(glBxEditorOnSpaceEnterTimer);
  47. glBxEditorOnSpaceEnterTimer = setTimeout(function () {
  48. glBxEditorOnSpaceEnterTimer = undefined;
  49. if (typeof glOnSpaceEnterInEditor !== 'undefined' && glOnSpaceEnterInEditor instanceof Array) {
  50. for (var i = 0; i < glOnSpaceEnterInEditor.length; i++)
  51. if (typeof glOnSpaceEnterInEditor[i] === "function")
  52. glOnSpaceEnterInEditor[i]($(sEditorId).froalaEditor('html.get'), sEditorId);
  53. }
  54. }, 800);
  55. }
  56. function bx_editor_get_htmleditable (sEditorSelector)
  57. {
  58. if (!$(sEditorSelector).size())
  59. return false;
  60. return $(sEditorSelector).data('froala.editor').el;
  61. }
  62. function bx_editor_remove_all (oElement)
  63. {
  64. }
  65. /** @} */