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

Various changes to support TinyMCE moving #300

Draft
wants to merge 2 commits into
base: 6
Choose a base branch
from

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Mar 3, 2025

Important

Multiple commits! Do not squash

Issue

Also adds an optional param for the parent, in case you want to find a
button inside a specific element.
Comment on lines -378 to +391
protected function findNamedButton($title)
public function findNamedButton($title, ?ElementInterface $parent = null)
{
$page = $this->getSession()->getPage();
if ($parent === null) {
$parent = $this->getSession()->getPage();
}
// See https://mathiasbynens.be/notes/css-escapes
$escapedTitle = addcslashes($title ?? '', '!"#$%&\'()*+,-./:;<=>?@[\]^`{|}~');
$matchedEl = null;
$searches = [
['named', ['link_or_button', "'{$title}'"]],
['css', "button[data-text-alternate='{$escapedTitle}']"],
];
foreach ($searches as list($type, $arg)) {
$buttons = $page->findAll($type, $arg);
$buttons = $parent->findAll($type, $arg);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -992 to +993
var editor = jQuery('#$inputFieldId').entwine('ss').getEditor(),
doc = editor.getInstance().getDoc(),
sel = doc.getSelection(),
rng = new Range(),
matched = false;

jQuery(doc).find("$select").each(function() {
if(!matched) {
rng.selectNode(this);
sel.removeAllRanges();
sel.addRange(rng);
matched = true;
}
});
const editor = jQuery('#$inputFieldId').entwine('ss').getEditor();
editor.selectByCssSelector("$select");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TinyMCE-specific logic here was moved into the tinymce module. The selectByCssSelector() function is in admin, and ultimately ends up calling editor-specific functionality.

@GuySartorelli GuySartorelli changed the title ENH Use generic JavaScript for selecting HTML content Various changes to support TinyMCE moving Mar 6, 2025
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

Successfully merging this pull request may close these issues.

1 participant