Content deleted Content added
Polygnotus (talk | contribs) No edit summary |
Polygnotus (talk | contribs) No edit summary |
||
Line 25:
refIdeas: {
type: 'element',
filters: [ 'body.ns-3' ],
Line 33:
icon: 'lightbulb',
title: 'refideas'
} );
button.connect( null, {
Line 39 ⟶ 38:
var text = '{{refideas\n|1=\n}}';
console.log('Button clicked!');
console.log('Context object:', context);
console.log('context.fn exists:', !!context.fn);
console.log('context.fn.encapsulateSelection exists:', !!(context.fn && context.fn.encapsulateSelection));
console.log('context.$textarea exists:', !!context.$textarea);
// Method 1: context.fn.encapsulateSelection
if ( context.fn && context.fn.encapsulateSelection ) {
console.log('Using method 1: context.fn.encapsulateSelection');
context.fn.encapsulateSelection( {
pre: text
} );
} else if ( context.$textarea ) {
// Method 2: Direct textarea manipulation via context
console.log('Using method 2: context.$textarea');
var textarea = context.$textarea[0];
var start = textarea.selectionStart;
Line 55 ⟶ 62:
textarea.focus();
$(textarea).trigger('input');
} else {
// Method 3: Fallback -
console.log('Using method 3: fallback #wpTextbox1');
var $textarea = $('#wpTextbox1');
console.log('Found textarea:', $textarea.length > 0);
if ( $textarea.length ) {
var textarea = $textarea[0];
|