plugin.min.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * Copyright (c) Tiny Technologies, Inc. All rights reserved.
  3. * Licensed under the LGPL or a commercial license.
  4. * For LGPL see License.txt in the project root for license information.
  5. * For commercial licenses see https://www.tiny.cloud/
  6. *
  7. * Version: 5.10.2 (2021-11-17)
  8. */
  9. !(function () {
  10. 'use strict'
  11. function u(e) {
  12. return e.getParam('pagebreak_split_block', !1)
  13. }
  14. function l(e) {
  15. var a =
  16. '<img src="' +
  17. n.transparentSrc +
  18. '" class="' +
  19. m +
  20. '" data-mce-resize="false" data-mce-placeholder />'
  21. return e ? '<p>' + a + '</p>' : a
  22. }
  23. var e = tinymce.util.Tools.resolve('tinymce.PluginManager'),
  24. n = tinymce.util.Tools.resolve('tinymce.Env'),
  25. m = 'mce-pagebreak'
  26. e.add('pagebreak', function (e) {
  27. var a, n, o, i, t, r
  28. function c() {
  29. return n.execCommand('mcePageBreak')
  30. }
  31. function g() {
  32. return u(o)
  33. }
  34. ;(a = e).addCommand('mcePageBreak', function () {
  35. a.insertContent(l(u(a)))
  36. }),
  37. (n = e).ui.registry.addButton('pagebreak', {
  38. icon: 'page-break',
  39. tooltip: 'Page break',
  40. onAction: c,
  41. }),
  42. n.ui.registry.addMenuItem('pagebreak', {
  43. text: 'Page break',
  44. icon: 'page-break',
  45. onAction: c,
  46. }),
  47. (i = (o = e).getParam('pagebreak_separator', '\x3c!-- pagebreak --\x3e')),
  48. (t = new RegExp(
  49. i.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function (e) {
  50. return '\\' + e
  51. }),
  52. 'gi'
  53. )),
  54. o.on('BeforeSetContent', function (e) {
  55. e.content = e.content.replace(t, l(g()))
  56. }),
  57. o.on('PreInit', function () {
  58. o.serializer.addNodeFilter('img', function (e) {
  59. for (var a, n, t, r = e.length; r--; )
  60. (t = (n = e[r]).attr('class')) &&
  61. -1 !== t.indexOf(m) &&
  62. ((a = n.parent),
  63. o.schema.getBlockElements()[a.name] && g()
  64. ? ((a.type = 3), (a.value = i), (a.raw = !0), n.remove())
  65. : ((n.type = 3), (n.value = i), (n.raw = !0)))
  66. })
  67. }),
  68. (r = e).on('ResolveName', function (e) {
  69. 'IMG' === e.target.nodeName &&
  70. r.dom.hasClass(e.target, m) &&
  71. (e.name = 'pagebreak')
  72. })
  73. })
  74. })()