changeset 34:20d1f23225fe

fix [url]
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 15 Aug 2022 21:35:44 -0600
parents c23475f3f466
children cd02cd04bc9d
files src/formats/bbcode.js
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
diff -r c23475f3f466 -r 20d1f23225fe src/formats/bbcode.js
--- a/src/formats/bbcode.js	Sun Aug 14 20:36:17 2022 -0600
+++ b/src/formats/bbcode.js	Mon Aug 15 21:35:44 2022 -0600
@@ -198,11 +198,19 @@
 					editor,
 					caller,
 					function (url, text) {
-						editor.insertText(
-							'[url=' + url + ']' +
-								(text || selected || url) +
-							'[/url]'
-						);
+						if(text) {
+							editor.insertText(
+								'[url=' + url + ']' +
+									(text || selected) +
+								'[/url]'
+							);
+						} else {
+							editor.insertText(
+								'[url]' +
+									(selected || url) +
+								'[/url]'
+							);
+						}
 					}
 				);
 			}
@@ -616,7 +624,11 @@
 						content + '[/email]';
 				}
 
-				return '[url=' + url + ']' + content + '[/url]';
+				if( url === content ) {
+					return '[url]' + content + '[/url]';
+				} else {
+					return '[url=' + url + ']' + content + '[/url]';
+				}
 			},
 			html: function (token, attrs, content) {
 				attrs.defaultattr =