1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 01:34:31 +02:00

Add PR #38 which adds an edit-link-text feature to ProcessPageEditLink, via @rolandtoth

This commit is contained in:
rolandtoth
2021-05-12 15:47:39 -04:00
committed by Ryan Cramer
parent 79b952753c
commit 108ee2384a
5 changed files with 39 additions and 9 deletions

View File

@@ -172,6 +172,13 @@
modalUrl += '&anchors[]=' + encodeURIComponent(anchors[n].id);
}
}
// set link text
var linkText = ($existingLink && $existingLink.text().length) ? $existingLink.text() : selectionText;
if(nodeName !== 'img' && linkText.length) {
modalUrl += '&text=' + encodeURIComponent(linkText);
}
// labels
var insertLinkLabel = ProcessWire.config.InputfieldCKEditor.pwlink.label;
@@ -184,7 +191,10 @@
var $i = $iframe.contents();
var $a = jQuery(jQuery("#link_markup", $i).text());
if($a.attr('href') && $a.attr('href').length) {
$a.html(selectionText);
// $a.html(selectionText);
if(!$a.text().length) {
$a.html(selectionText);
}
var html = jQuery("<div />").append($a).html();
editor.insertHtml(html);
}

File diff suppressed because one or more lines are too long

View File

@@ -21,8 +21,9 @@ $(document).ready(function() {
var $fileSelect = $("#link_page_file");
var $anchorSelect = $("#link_page_anchor");
var $linkPageURL = $("#link_page_url_input");
var $linkPageURL = $("#link_page_url_input");
var $linkText = $("#link_text");
$linkPageURL.val($("#link_page_url").val()); // copy from hidden
function populateFileSelect(selectedPageData) {
@@ -152,7 +153,11 @@ $(document).ready(function() {
var val = $("<div />").text($linkTitle.val()).html();
$link.attr('title', val);
}
if($linkText.length && $linkText.val().length) {
$link.text($linkText.val());
}
var $linkRel = $("#link_rel");
if($linkRel.length && $linkRel.val().length) {
$link.attr('rel', $linkRel.val());
@@ -307,10 +312,12 @@ $(document).ready(function() {
setTimeout(function() {
$linkPageURL.change();
$linkText.change();
}, 250);
$(":input").change(updateLinkPreview);
$("#link_title").keydown(function(event) { updateLinkPreview(); });
$("#link_title").keydown(function(event) { updateLinkPreview(); });
$linkText.keyup(function(event) { updateLinkPreview(); });
// when header is clicked, open up the pageList right away
$(".InputfieldInteger .InputfieldHeader").click(function() {

File diff suppressed because one or more lines are too long

View File

@@ -24,7 +24,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
return array(
'title' => 'Page Edit Link',
'summary' => 'Provides a link capability as used by some Fieldtype modules (like rich text editors).',
'version' => 108,
'version' => 109,
'permanent' => true,
'permission' => 'page-edit',
'icon' => 'link',
@@ -152,6 +152,9 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$currentValue = '';
}
$currentText = $this->wire()->input->get('text');
$currentText = $currentText === null ? '' : $this->wire()->sanitizer->text($currentText);
/** @var InputfieldForm $form */
$form = $this->modules->get("InputfieldForm");
$form->attr('id', 'ProcessPageEditLinkForm');
@@ -163,7 +166,17 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$fieldset = $this->wire(new InputfieldWrapper());
$fieldset->attr('title', $this->_('Link'));
$fieldset->addClass('WireTab');
$form->add($fieldset);
$form->add($fieldset);
if($currentText) {
/** @var InputfieldText $field */
$field = $this->modules->get("InputfieldText");
$field->label = $this->_('Link text');
$field->icon = 'pencil-square';
$field->attr('id+name', 'link_text');
$field->val($currentText);
$fieldset->add($field);
}
/** @var InputfieldPageAutocomplete $field */
$field = $this->modules->get("InputfieldPageAutocomplete");