remove-format button removes blockcodes
5 posters
Page 1 of 1
remove-format button removes blockcodes
Hello,
I noticed that remove-format button removes blockcodes.
Is it possible to preserve blockcodes (as it preserves blockquotes) by modifying code of SCEditor
I have another question about remove-format function:
The font-size cannot be cleared in one click if it is nested (this is common in web page HTML)
For example, I copied some paragraphs from wikipedia
After first click, there are 28 pairs left
After second click, there are 0 pairs left
Is it possible to clear all font-size in one click
I noticed that remove-format button removes blockcodes.
Is it possible to preserve blockcodes (as it preserves blockquotes) by modifying code of SCEditor
I have another question about remove-format function:
The font-size cannot be cleared in one click if it is nested (this is common in web page HTML)
For example, I copied some paragraphs from wikipedia
- Code:
[size=14]In[/size][size=14] [/size][url=https://en.wikipedia.org/wiki/Physics][size=14]physics[/size][/url][size=14],[/size][size=14] [/size][b][size=14]angular momentum[/size][/b][size=14] [/size][size=14](rarely,[/size][size=14] [/size][b][size=14]moment of momentum[/size][/b][size=14] [/size][size=14]or[/size][size=14] [/size][b][size=14]rotational momentum[/size][/b][size=14]) is the rotational equivalent of[/size][size=14] [/size][url=https://en.wikipedia.org/wiki/Linear_momentum][size=14]linear momentum[/size][/url][size=14]. It is an important quantity in physics because it is a[/size][size=14] [/size][url=https://en.wikipedia.org/wiki/Conservation_law][size=14]conserved quantity[/size][/url][size=14]—the total angular momentum of a closed system remains constant.[/size]
[size=14]In three [url=https://en.wikipedia.org/wiki/Dimensions]dimensions[/url], the angular momentum for a [url=https://en.wikipedia.org/wiki/Point_particle]point particle[/url] is a [url=https://en.wikipedia.org/wiki/Pseudovector]pseudovector[/url] [b]r[/b] × [b]p[/b], the [url=https://en.wikipedia.org/wiki/Cross_product]cross product[/url] of the particle's [url=https://en.wikipedia.org/wiki/Position_vector]position vector[/url] [b]r[/b] (relative to some origin) and its [url=https://en.wikipedia.org/wiki/Momentum_vector]momentum vector[/url]; the latter is [b]p[/b] = [i]m[/i][b]v[/b] in Newtonian mechanics. Unlike momentum, angular momentum depends on where the origin is chosen, since the particle's position is measured from it.[/size]
[size=14]Just as for [url=https://en.wikipedia.org/wiki/Angular_velocity]angular velocity[/url], there are two special types of angular momentum of an object: the [i]spin angular momentum[/i] is the angular momentum about the object's [url=https://en.wikipedia.org/wiki/Centre_of_mass]centre of mass[/url], while the [i]orbital angular momentum[/i] is the angular momentum about a chosen center of rotation. The total angular momentum is the sum of the spin and orbital angular momenta. The orbital angular momentum vector of a point particle is always parallel and directly proportional to its orbital [url=https://en.wikipedia.org/wiki/Angular_velocity]angular velocity[/url] vector [b]ω[/b], where the constant of proportionality depends on both the mass of the particle and its distance from origin. The spin angular momentum vector of a rigid body is proportional but not always parallel to the spin angular velocity vector [b]Ω[/b], making the constant of proportionality a second-rank [url=https://en.wikipedia.org/wiki/Tensor]tensor[/url] rather than a scalar.[/size]
[size=14]Angular momentum is an extensive quantity; i.e. the total angular momentum of any composite system is the sum of the angular momenta of its constituent parts. For a [url=https://en.wikipedia.org/wiki/Continuum_mechanics]continuous[/url] rigid body or a fluid the total angular momentum is the volume integral of angular momentum density (i.e. angular momentum per unit volume in the limit as volume shrinks to zero) over the entire body.[/size]
[size=14]Torque can be defined as the rate of change of angular momentum, analogous to [url=https://en.wikipedia.org/wiki/Force]force[/url]. The net [i]external[/i] torque on any system is always equal to the [i]total[/i] torque on the system; in other words, the sum of all internal torques of any system is always 0 (this is the rotational analogue of [url=https://en.wikipedia.org/wiki/Newton%27s_Third_Law]Newton's Third Law[/url]). Therefore, for a [i]closed[/i] system (where there is no net external torque), the [i]total[/i] torque on the system must be 0, which means that the total angular momentum of the system is constant. The conservation of angular momentum helps explain many observed phenomena, for example the increase in rotational speed of a spinning [url=https://en.wikipedia.org/wiki/Figure_skater]figure skater[/url] as the skater's arms are contracted, the high rotational rates of [url=https://en.wikipedia.org/wiki/Neutron_star]neutron stars[/url], the [url=https://en.wikipedia.org/wiki/Coriolis_effect]Coriolis effect[/url], and the [url=https://en.wikipedia.org/wiki/Precession]precession[/url] of [url=https://en.wikipedia.org/wiki/Gyroscope]gyroscopes[/url]. In general, conservation limits the possible motion of a system but does not uniquely determine it.[/size]
[size=14]In[/size][size=14] [/size][url=https://en.wikipedia.org/wiki/Quantum_mechanics][size=14]quantum mechanics[/size][/url][size=14], angular momentum (like other quantities) is expressed as an[/size][size=14] [/size][url=https://en.wikipedia.org/wiki/Operator_(physics)][size=14]operator[/size][/url][size=14], and its one-dimensional projections have[/size][size=14] [/size][url=https://en.wikipedia.org/wiki/Point_spectrum][size=14]quantized eigenvalues[/size][/url][size=14]. Angular momentum is subject to the[/size][size=14] [/size][url=https://en.wikipedia.org/wiki/Heisenberg_uncertainty_principle][size=14]Heisenberg uncertainty principle[/size][/url][size=14], implying that at any time, only one[/size][size=14] [/size][url=https://en.wikipedia.org/wiki/Vector_projection][size=14]projection[/size][/url][size=14] [/size][size=14](also called "component") can be measured with definite precision; the other two then remain uncertain. Because of this, the axis of rotation of a quantum particle is undefined. Quantum particles[/size][size=14] [/size][i][size=14]do[/size][/i][size=14] [/size][size=14]possess a type of non-orbital angular momentum called "spin", but this angular momentum does not correspond to a spinning motion.[/size][sup][size=12][url=https://en.wikipedia.org/wiki/Angular_momentum#cite_note-1][1][/url][/size][/sup]
After first click, there are 28 pairs left
After second click, there are 0 pairs left
Is it possible to clear all font-size in one click
Re: remove-format button removes blockcodes
All you have to do is only highlight the sections where you want to remove the format. Whatever you highlight should all be removed.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: remove-format button removes blockcodes
Hello,SLGray wrote:All you have to do is only highlight the sections where you want to remove the format. Whatever you highlight should all be removed.
I noticed that if [size] is nested, they can′t be removed in one click.
Re: remove-format button removes blockcodes
It does when I tried.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: remove-format button removes blockcodes
Hello,
If you do not want formatted text, why don't you copy/paste in source mode instead of wysiwyg mode ?
If you do not want formatted text, why don't you copy/paste in source mode instead of wysiwyg mode ?
Re: remove-format button removes blockcodes
Hello,Neptune- wrote:Hello,
If you do not want formatted text, why don't you copy/paste in source mode instead of wysiwyg mode ?
Because I would like to keep links, blockquotes and blockcodes.
Re: remove-format button removes blockcodes
The problem is that it doesn't remove nested [size] in one click, here is a gif: https://ibb.co/YpP0yBzSLGray wrote:It does when I tried.
Re: remove-format button removes blockcodes
Ok, I see what you mean. Usually when I copy and paste from other sites, I edit it before sending it.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
poesia-verses likes this post
Re: remove-format button removes blockcodes
This isn't remove format buttom,
this is remove format buttom
The other buttom Just change the way you see the content of the topic normal to WYSIWYG
That's why the tags disappear
Bockquotes is here:
Only when swinging between the editor's methods, the tags appear,or disappear but being there if you change the form of the editor, do not worry when sending the subject, the quote will appear without problems
this is remove format buttom
The other buttom Just change the way you see the content of the topic normal to WYSIWYG
That's why the tags disappear
Bockquotes is here:
Only when swinging between the editor's methods, the tags appear,or disappear but being there if you change the form of the editor, do not worry when sending the subject, the quote will appear without problems
TonnyKamper likes this post
Re: remove-format button removes blockcodes
Hello,jucarese wrote:This isn't remove format buttom,
this is remove format buttom
...
You may have misunderstand me....
I knew they were two buttons, remove-format and switch-mode. Switch-mode button has no problem, but remove-format button removes codeblocks.
Re: remove-format button removes blockcodes
Next time, try to copy & paste your content to Notepad, then Ctrl+H do replace all [size] bbcode tag to empty
- Code:
[size=14] [/size]
TonnyKamper likes this post
Re: remove-format button removes blockcodes
I think maybe we can modify a little bit of the code of sceditor to function automaticallySarkZKalie wrote:Next time, try to copy & paste your content to Notepad, then Ctrl+H do replace all bbcode tag to empty
- Code:
[size=14] [/size]
Re: remove-format button removes blockcodes
@hbghlyj, I may be able to make such a code. Please explain in detail exactly what you want the remove format button to do, since this topic is already quite long and confusing!
Guest- Guest
Re: remove-format button removes blockcodes
Thanks.Occultist wrote:@hbghlyj, I may be able to make such a code. Please explain in detail exactly what you want the remove format button to do, since this topic is already quite long and confusing!
First, I wish that it will keep all the code tags.
Second, I wish that it will remove all the size tags only in one click (even if they are nested)
Another question about javascript:
I am curious what is the effect of "return true" on the editpost page
Screenshot:
Last edited by hbghlyj on August 24th 2021, 3:28 pm; edited 6 times in total
Re: remove-format button removes blockcodes
By blockcodes you mean the
- Code:
[code][/code]
Guest- Guest
Re: remove-format button removes blockcodes
Yes. The current script will remove all formatted code tags(formatted, not in the original form [code])Occultist wrote:By blockcodes you mean thetags?
- Code:
[code][/code]
Re: remove-format button removes blockcodes
This is a somewhat incomplete code that should do just about what you want:
There are a couple other tags to remove, some css to give the button the right icon, and making sure that it works on all other editors, but first let me know if this works on your forum, and if so far it does what you're expecting it too!
The code should be added to the javascript code management section, as a new code, with whatever name you want, with the placement as "In the topics"(it will probably produce errors on other pages, but that will be taken care of in the final version).
Update:I have edited the code. Now you can place it on all pages!
- Code:
$(function() {
let sceditor = $.sceditor; // get instance of the editor
if (!sceditor) return;
// create a new command
sceditor.command.set("removeformat2", {
exec: function(c) {
// when in wysiwyg; remove [b], [i], [u], [strike] and [font]
let rangeHelper = this.getRangeHelper(); // get the current selection
let newHTML = rangeHelper.selectedHtml().replace(
/\<(b|\/b|i|\/i|u|\/u|strike|\/strike|font size="\d+"|\/font)\>/g,
""
); // remove the formatting from the selection
rangeHelper.insertHTML(newText); // replace the selection with the unformatted text
},
txtExec: function() {
// we are in text mode, so do nothing
},
tooltip: "Remove text formatting",
});
toolbar = toolbar.replace("removeformat", "removeformat2"); // replace the default button with the new one
});
There are a couple other tags to remove, some css to give the button the right icon, and making sure that it works on all other editors, but first let me know if this works on your forum, and if so far it does what you're expecting it too!
The code should be added to the javascript code management section, as a new code, with whatever name you want, with the placement as "In the topics"(it will probably produce errors on other pages, but that will be taken care of in the final version).
Update:I have edited the code. Now you can place it on all pages!
Guest- Guest
Re: remove-format button removes blockcodes
Hello,
It seems that you've made a small mistake: you defined "newHTML" but "newText" is undefined
Also, <font style="font-size: 14px;"> is not removed.
It seems that you've made a small mistake: you defined "newHTML" but "newText" is undefined
Also, <font style="font-size: 14px;"> is not removed.
Re: remove-format button removes blockcodes
Hmm, you're right about the variable name. I thought newHTML made more sense, but forgot to replace it everywhere. Regardless, it looks like you managed to fix that yourself.
I'm not sure what you mean about
. If I write that in text mode, and then switch to wysiwyg mode, it stays as text. The editor itself doesn't seem to produce that kind of html. The default removeformat button doesn't do anything to it either.
I'm not sure what you mean about
|
Guest- Guest
Re: remove-format button removes blockcodes
No, it seems that switching to wysiwyg mode doesn't display HTML effects, you could try "preview" or "send"Occultist wrote:Hmm, you're right about the variable name. I thought newHTML made more sense, but forgot to replace it everywhere. Regardless, it looks like you managed to fix that yourself.
I'm not sure what you mean about. If I write that in text mode, and then switch to wysiwyg mode, it stays as text. The editor itself doesn't seem to produce that kind of html. The default removeformat button doesn't do anything to it either.
- Code:
<font style="font-size: 14px;">
↑ Note that there are 3 huge "a" in the preview zone
font-size, font-family and font-weight affect the font.
Re: remove-format button removes blockcodes
I see. I made a few modifications. Now anything of the form
gets removed:
This has the nice side effect of removing custom fonts as well.
|
- Code:
$(function () {
let sceditor = $.sceditor; // get instance of the editor
if (!sceditor) return;
// create a new command
sceditor.command.set("removeformat2", {
exec: function (c) {
// when in wysiwyg; remove [b], [i], [u], [strike] and [font]
let rangeHelper = this.getRangeHelper(); // get the current selection
let newHTML = rangeHelper
.selectedHtml()
.replace(
/(\<|<)(b|\/b|i|\/i|u|\/u|strike|\/strike|font.+?(?=(>|>))|\/font)(>|>)/g,
""
); // remove the formatting from the selection
rangeHelper.insertHTML(newHTML); // replace the selection with the unformatted text
},
txtExec: function () {
// we are in text mode, so do nothing
},
tooltip: "Remove text formatting",
});
toolbar = toolbar.replace("removeformat", "removeformat2"); // replace the default button with the new one
});
This has the nice side effect of removing custom fonts as well.
Guest- Guest
Re: remove-format button removes blockcodes
Problem solved & topic archived.
|
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Remove button
» Any New Java Script removes Chatbox from Toolbar?
» Can I Remove the similar topics button?
» when using "solved" button, remove reply ability, then add notifier box
» How to remove minus (-) vote button on topic forumotion?
» Any New Java Script removes Chatbox from Toolbar?
» Can I Remove the similar topics button?
» when using "solved" button, remove reply ability, then add notifier box
» How to remove minus (-) vote button on topic forumotion?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum