-
Notifications
You must be signed in to change notification settings - Fork 30
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
base: 6
Are you sure you want to change the base?
Various changes to support TinyMCE moving #300
Conversation
Also adds an optional param for the parent, in case you want to find a button inside a specific element.
d7bb7f6
to
aef2e1c
Compare
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
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.
Important
Multiple commits! Do not squash
Issue