Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are many formatting errors in BBcode #963

Open
sulaiman0dawod opened this issue May 6, 2024 · 6 comments
Open

There are many formatting errors in BBcode #963

sulaiman0dawod opened this issue May 6, 2024 · 6 comments

Comments

@sulaiman0dawod
Copy link

  1. When you select text and click for example the alignment icon (center-right-left), each line of text is formatted, and the entire selected text is supposed to be formatted.
    2
    With the source
    3

Also on the Bold button
1
Each line has BBcode added to it, not all at once
1 05

  1. Remove Formatting does not work
    Clicked
    4
    With the source
    5

These errors must be fixed 😑
3. Undo buttons must be added Without installing any plugin or relying on keyboard buttons

@sulaiman0dawod

This comment was marked as duplicate.

@sulaiman0dawod
Copy link
Author

All errors have been resolved by me 👌
If anyone wants solutions, He can Mention me
OR
add New topic In Forum official PBBoard technical support
https://pbboard.info/forums/f43

@Sw0rdf1sh1
Copy link

Hey @sulaiman0dawod would love to see those changes for bbcode. Have some issues with the [url] functionality. Regards Fabian

@sulaiman0dawod
Copy link
Author

Hi Fabian - @Sw0rdf1sh1
Here are the modifications I made:
Open these files
1-minified/sceditor.min.js
2-minified/formats/bbcode.js
Copy all the code and then format code JavaScript code Using this tool on the site
https://beautifytools.com/javascript-validator.php

In the sceditor.min.js file
Find:
exec: "justifycenter",
And replace it:

				exec: function() {
					this.wysiwygEditorInsertHtml("<div align='center'>", "</div>")
				},

Find:
exec: "justifyright",
And replace it:

				exec: function() {
					this.wysiwygEditorInsertHtml("<div align='right'>", "</div>")
				},

Find:
exec: "justifyleft",
And replace it:

				exec: function() {
					this.wysiwygEditorInsertHtml("<div align='left'>", "</div>")
				},

Find:
exec: "justifyfull",
And replace it:

				exec: function() {
					this.wysiwygEditorInsertHtml("<div align='justify'>", "</div>")
				},

In the bbcode.js file
Find:

		function c(t, e) {
			for (var n, r, i, l, o, a, s = "", u = function(t) {
					return !1 !== (!t || (void 0 !== t.isHtmlInline ? t.isHtmlInline : t.isInline))
				}; 0 < t.length;)
				if (n = t.shift()) {
					if (n.type === E) a = n.children[n.children.length - 1] || {}, r = x[n.name], l = e && u(r), i = c(n.children, !1), a = r && r.html ? (u(r) || !u(x[a.name]) || r.isPreFormatted || r.skipLastLineBreak || (i += "<br />"), w(r.html) ? r.html.call(m, n, n.attrs, i) : (n.attrs[0] = i, k(r.html, n.attrs))) : n.val + i + (n.closing ? n.closing.val : "");
					else {
						if (n.type === I) {
							if (!e) {
								s += "<br />";
								continue
							}
							o || (s += "<div>"), s += "<br />", t.length || (s += "<br />"), s += "</div>\n", o = !1;
							continue
						}
						l = e, a = f(n.val, !0)
					}
					l && !o ? (s += "<div>", o = !0) : !l && o && (s += "</div>\n", o = !1), s += a
				}
			return o && (s += "</div>\n"), s
		}

And replace it:

		function c(t, e) {
			for (var n, r, i, l, o, a, s = "", u = function(t) {
					return !1 !== (!t || (void 0 !== t.isHtmlInline ? t.isHtmlInline : t.isInline))
				}; 0 < t.length;)
				if (n = t.shift()) {
					if (n.type === E) a = n.children[n.children.length - 1] || {}, r = x[n.name], l = e && u(r), i = c(n.children, !1), a = r && r.html ? (u(r) || !u(x[a.name]) || r.isPreFormatted || r.skipLastLineBreak || (i += "<br />"), w(r.html) ? r.html.call(m, n, n.attrs, i) : (n.attrs[0] = i, k(r.html, n.attrs))) : n.val + i + (n.closing ? n.closing.val : "");
					else {
						if (n.type === I) {
							if (!e) {
								s += "<br />";
								continue
							}
							o || (s += "<ddiv>"), s += "<br />", t.length || (s += "<br />"), s += "</ddiv>\n", o = !1;
							continue
						}
						l = e, a = f(n.val, !0)
					}
					l && !o ? (s += "<ddiv>", o = !0) : !l && o && (s += "</ddiv>\n", o = !1), s += a
				}
			return o && (s += "</ddiv>\n"), s
		}

that's it.

The results are excellent

Example of centering all text with empty lines
98

previewing the source 👌
99

This includes all other BBcodes. (Bold - Italic - [u] - [s] ...)

@Sw0rdf1sh1
Copy link

Hey @sulaiman0dawod,

thank your very much for your detailled instructions on how to fix this bbcode.js for the sceditor. I will adapt my settings and adjust some [url] & [url=https://...]Text[/url], because these aren't working properly for me.

@sulaiman0dawod
Copy link
Author

sulaiman0dawod commented May 13, 2024

I did not notice any errors in the [url] It works well
[url=https://...]Text[/url]

Check the following codes in your editor whether they are similar or not
in the file: sceditor.min.js
Make sure the Insert a link code matches this

				exec: function(e) {
					var n = this;
					Pe.link._dropDown(n, e, function(e, t) {
						t || !n.getRangeHelper().selectedHtml() ? n.wysiwygEditorInsertHtml('<a href="' + ze(e) + '">' + ze(t || e) + "</a>") : n.execCommand("createlink", e)
					})
				},
				tooltip: "Insert a link"
			},

and in the file: bbcode.js
Make sure the link code matches this

			link: {
				txtExec: function(t, n) {
					var r = this;
					l("link")._dropDown(r, t, function(t, e) {
						r.insertText("[url=" + t + "]" + (e || n || t) + "[/url]")
					})
				}
			},

If the problem is not resolved, please attach the editor files

  • bbcode.js
  • sceditor.min.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants