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

editor.insert starts unrequired new paragraph #881

Open
TillCity opened this issue Mar 1, 2022 · 0 comments
Open

editor.insert starts unrequired new paragraph #881

TillCity opened this issue Mar 1, 2022 · 0 comments

Comments

@TillCity
Copy link

TillCity commented Mar 1, 2022

I am using SCEditor in a webapp used by authors to create travel guides. One of the features I want to put in is to allow the author to cross reference their guides - i.e. link to one of their other guides from the current one. The individual guides are identified via their unique identifier, referred to as einzig in my code. By dint of much trial and error - and reading other threads here - I have managed to get things (mostly)

Here is my code

sceditor.formats.bbcode.set('guide',
{
tags:{a:{'data-einzig':null}},
allowedChildren:[],
allowEmpty:false,
isSelfClosing:false,
isInline:true,
isHTMLInline:true,
format:(e,c)=>{return[guide einzig=${e.dataset.einzig}]${e.innerHTML}[/guide];},
html:(t,a,c) =>{return ``<a class='guideJump' href='${a.einzig}' data-einzig='${a.einzig}'>${c}</a>``;},
});

sceditor.formats.bbcode.set('url',{format:(e,c)=>{return c;}})

function jumpToGuide(e)
{
const editor = this,
tgt = e.target;
editor.insert([guide einzig='${tgt.dataset.einzig}']Gudie[/guide]);
editor.closeDropDown(true);
e.stopPropagation();
}

where the process of inserting an external guide reference is triggered by the author selecting a guide name from a dropdown in the toolbar (that part of the code not shown here)

Everything works just fine - but for one issue. My call to editor.insert above appears to close the current paragraph, inserts a few <br> tags and new lines for good measure and then starts a new paragarph. Here, for example, is what I get

<p>Betty bought a bit <br /></p>\n<p><a class='guideJump' href='KJQiZBVvqOuC' data-einzig='KJQiZBVvqOuC'>Gudie</a> of butter but the bit of butter was bitter<br /><br /></p>\n

Why is this happening and how can I prevent it? That apart what is with all those unrequired break tags and newline characters?

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

1 participant