Skip to content
Snippets Groups Projects
Commit 44aff6fb authored by Jacob Benz's avatar Jacob Benz
Browse files

Improve handling of lb-tags

parent af80da51
No related branches found
No related tags found
No related merge requests found
...@@ -373,6 +373,21 @@ span[data-mce-bogus] { ...@@ -373,6 +373,21 @@ span[data-mce-bogus] {
text-indent: unset !important; text-indent: unset !important;
} }
*[_tag='lb'] {
display : inline !important;
}
*[_tag='lb']:not(.showTags):before {
content: "\A" !important;
white-space: pre !important;
}
.showTags [_tag='lb']:before {
content: "\A <lb />" !important;
box-shadow: none !important;
padding-left: 0 !important;
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
*[_tag='pb'] { *[_tag='pb'] {
color: black !important; color: black !important;
......
...@@ -281,6 +281,21 @@ span[data-mce-bogus] { ...@@ -281,6 +281,21 @@ span[data-mce-bogus] {
text-indent: unset !important; text-indent: unset !important;
} }
*[_tag='lb'] {
display : inline !important;
}
*[_tag='lb']:not(.showTags):before {
content: "\A" !important;
white-space: pre !important;
}
.showTags [_tag='lb']:before {
content: "\A <lb />" !important;
box-shadow: none !important;
padding-left: 0 !important;
}
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
*[_tag='pb'] { *[_tag='pb'] {
color: black !important; color: black !important;
......
...@@ -377,24 +377,51 @@ export const tinymceWrapperInit = function ({ ...@@ -377,24 +377,51 @@ export const tinymceWrapperInit = function ({
rng.collapse(true); rng.collapse(true);
writer.editor?.selection.setRng(rng); writer.editor?.selection.setRng(rng);
} else { } else {
if (currentNode.getAttribute('_entity') !== 'true') { const curTag = currentNode.getAttribute('_tag')
// exception for entities since the entity parent tag can actually encapsulate several tags if (curTag == "lb")
const currentTag = currentNode.getAttribute('_tag'); {
/* writer.dialogManager.show('message', { // console.log("We ended in lb!")
title: 'No Text Allowed', // get text, that has already been entered
msg: `Text is not allowed in the current tag: ${currentTag}.`, let entered_Text = $(writer.editor?.currentNode).contents().filter(function() {
type: 'error',
});*/
writer.overmindActions.ui.notifyViaSnackbar({
message: `Text is not allowed in the current tag: ${currentTag}.`,
options: { variant: 'error', key: currentTag },
});
}
// remove text that is not allowed
$(writer.editor?.currentNode).contents().filter(function() {
return this.nodeType === 3; return this.nodeType === 3;
}).remove(); })
// console.log(entered_Text.text())
// Copy to position after lb-element
$(writer.editor?.currentNode).after(entered_Text.text())
// get element where to position cursor next
var newCurosorElement;
$(writer.editor?.currentNode).after(function() {
newCurosorElement = this.nextSibling // This is the next (text) sibling of lb
return false
})
// console.log(newCurosorElement)
// remove text on old position
$(writer.editor?.currentNode).contents().filter(function() {
return this.nodeType === 3;
}).remove();
// Move cursor to new position
writer.editor.selection.setCursorLocation(newCurosorElement,entered_Text.text().length) // Position cursor in text sibling of lb at end of inserted text
} else {
if (currentNode.getAttribute('_entity') !== 'true') {
// exception for entities since the entity parent tag can actually encapsulate several tags
const currentTag = currentNode.getAttribute('_tag');
/* writer.dialogManager.show('message', {
title: 'No Text Allowed',
msg: `Text is not allowed in the current tag: ${currentTag}.`,
type: 'error',
});*/
writer.overmindActions.ui.notifyViaSnackbar({
message: `Text is not allowed in the current tag: ${currentTag}.`,
options: { variant: 'error', key: currentTag },
});
}
// remove text that is not allowed
$(writer.editor?.currentNode).contents().filter(function() {
return this.nodeType === 3;
}).remove();
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment