diff --git a/.browserslistrc b/.browserslistrc index c71c8b9c7..03696bd42 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,11 +1 @@ -# https://github.com/browserslist/browserslist#readme - ->= 0.5% -last 2 major versions -not dead -Chrome >= 60 -Firefox >= 60 -Firefox ESR -iOS >= 12 -Safari >= 12 -not Explorer <= 11 +extends browserslist-config-nk diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 078e56515..000000000 --- a/.eslintrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": [ - "eslint-config-nk" - ], - "globals": { - "wp": true - }, - "settings": { - "react": { - "pragma": "wp" - } - }, - "rules": { - "react/prefer-stateless-function": "off", - "react/prop-types": "off" - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..87d69583f --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,15 @@ +module.exports = { + extends: ['eslint-config-nk'], + globals: { + wp: true, + }, + settings: { + react: { + pragma: 'wp', + }, + }, + rules: { + 'react/prefer-stateless-function': 'off', + 'react/prop-types': 'off', + }, +}; diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 459882ddb..03faccb1a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: push: tags: - - "v*" + - 'v*' jobs: deploy: @@ -22,12 +22,12 @@ jobs: run: npm install - name: Run Production Task - run: npm run production + run: npm run build:prod - name: WordPress Plugin Deploy uses: nk-o/action-wordpress-plugin-deploy@master env: SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} SVN_USERNAME: ${{ secrets.SVN_USERNAME }} - SOURCE_DIR: dist/lazy-blocks/ + SOURCE_DIR: dist-zip/lazy-blocks/ SLUG: lazy-blocks diff --git a/.gitignore b/.gitignore index e7ae90136..d58521d0d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,9 @@ .sass-cache .publish .idea -/dist +/dist-zip /vendor /node_modules -/src/languages/* npm-debug.log .phpcs.xml phpcs.xml diff --git a/src/LICENSE.txt b/LICENSE.txt similarity index 100% rename from src/LICENSE.txt rename to LICENSE.txt diff --git a/README.md b/README.md index 7c4512072..537ff67b7 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ ### Building +- `npm run dev` to run build and start files watcher - `npm run build` to run build -- `npm run watch` to run build and start files watcher -- `npm run production` to run build and prepare zip files for production +- `npm run build:prod` to run build and prepare zip files for production ### Linting diff --git a/src/assets/_variables.scss b/assets/_variables.scss similarity index 81% rename from src/assets/_variables.scss rename to assets/_variables.scss index 8db5b78f6..4fc924cc8 100644 --- a/src/assets/_variables.scss +++ b/assets/_variables.scss @@ -2,8 +2,8 @@ * WordPress. */ /* stylelint-disable-next-line scss/at-import-partial-extension */ -@import "../../node_modules/@wordpress/base-styles/colors.native"; -@import "../../node_modules/@wordpress/base-styles/variables"; +@import "../node_modules/@wordpress/base-styles/colors.native"; +@import "../node_modules/@wordpress/base-styles/variables"; $radius: 3px !default; $radius_large: 4px !default; diff --git a/src/assets/admin/style.scss b/assets/admin/style.scss similarity index 100% rename from src/assets/admin/style.scss rename to assets/admin/style.scss diff --git a/src/assets/admin/templates/index.js b/assets/admin/templates/index.js similarity index 90% rename from src/assets/admin/templates/index.js rename to assets/admin/templates/index.js index 1d789f76c..b34254b15 100644 --- a/src/assets/admin/templates/index.js +++ b/assets/admin/templates/index.js @@ -87,15 +87,15 @@ function UpdateEditor() { const templateLockOptions = [ { - label: __('None', '@@text_domain'), + label: __('None', 'lazy-blocks'), value: '', }, { - label: __('Prevent all operations', '@@text_domain'), + label: __('Prevent all operations', 'lazy-blocks'), value: 'all', }, { - label: __('Prevent inserting new blocks, but allows moving existing ones', '@@text_domain'), + label: __('Prevent inserting new blocks, but allows moving existing ones', 'lazy-blocks'), value: 'insert', }, ]; @@ -108,9 +108,9 @@ function UpdateEditor() { .filter( (post) => post.viewable && - post.slug !== 'lazyblocks' && - post.slug !== 'lazyblocks_templates' && - post.slug !== 'attachment' + 'lazyblocks' !== post.slug && + 'lazyblocks_templates' !== post.slug && + 'attachment' !== post.slug ) .forEach((post) => { let { label } = post; @@ -144,12 +144,12 @@ function UpdateEditor() { return ( { diff --git a/src/assets/admin/templates/style.scss b/assets/admin/templates/style.scss similarity index 100% rename from src/assets/admin/templates/style.scss rename to assets/admin/templates/style.scss diff --git a/src/assets/admin/tools/index.js b/assets/admin/tools/index.js similarity index 100% rename from src/assets/admin/tools/index.js rename to assets/admin/tools/index.js diff --git a/src/assets/admin/tools/style.scss b/assets/admin/tools/style.scss similarity index 100% rename from src/assets/admin/tools/style.scss rename to assets/admin/tools/style.scss diff --git a/src/assets/admin/tools/tools.js b/assets/admin/tools/tools.js similarity index 87% rename from src/assets/admin/tools/tools.js rename to assets/admin/tools/tools.js index c29632e15..431e00b8c 100644 --- a/src/assets/admin/tools/tools.js +++ b/assets/admin/tools/tools.js @@ -89,18 +89,18 @@ export default function Templates() { clipboard.writeText(getPHPStringCode(type)); - if (typeLabel === 'Blocks') { + if ('Blocks' === typeLabel) { setCopiedBlocks(true); - } else if (typeLabel === 'Templates') { + } else if ('Templates' === typeLabel) { setCopiedTemplates(true); } clearTimeout(copiedTimeouts.current[typeLabel]); copiedTimeouts.current[typeLabel] = setTimeout(() => { - if (typeLabel === 'Blocks') { + if ('Blocks' === typeLabel) { setCopiedBlocks(false); - } else if (typeLabel === 'Templates') { + } else if ('Templates' === typeLabel) { setCopiedTemplates(false); } }, 350); @@ -116,21 +116,21 @@ export default function Templates() {
{ const newDisabled = {}; // disable all - if (Object.keys(disabledStates[`disabled${typeLabel}`]).length === 0) { + if (0 === Object.keys(disabledStates[`disabled${typeLabel}`]).length) { data[type].forEach((item) => { newDisabled[item.data.id] = true; }); } - if (typeLabel === 'Blocks') { + if ('Blocks' === typeLabel) { setDisabledBlocks(newDisabled); - } else if (typeLabel === 'Templates') { + } else if ('Templates' === typeLabel) { setDisabledTemplates(newDisabled); } }} @@ -144,7 +144,7 @@ export default function Templates() { label={ // eslint-disable-next-line react/jsx-wrap-multilines - {type === 'blocks' ? ( + {'blocks' === type ? ( {item.data.icon && /^dashicons/.test(item.data.icon) ? ( @@ -173,13 +173,13 @@ export default function Templates() { if (isSelected && !newDisabled[item.data.id]) { newDisabled[item.data.id] = true; - } else if (!isSelected && typeof newDisabled[item.data.id] !== 'undefined') { + } else if (!isSelected && 'undefined' !== typeof newDisabled[item.data.id]) { delete newDisabled[item.data.id]; } - if (typeLabel === 'Blocks') { + if ('Blocks' === typeLabel) { setDisabledBlocks(newDisabled); - } else if (typeLabel === 'Templates') { + } else if ('Templates' === typeLabel) { setDisabledTemplates(newDisabled); } }} @@ -206,7 +206,7 @@ export default function Templates() { copyPHPStringCode(type); }} > - {__('Copy to Clipboard', '@@text_domain')} + {__('Copy to Clipboard', 'lazy-blocks')} {copiedStates[`copied${typeLabel}`] ? : ''}
@@ -218,21 +218,21 @@ export default function Templates() { disabled={nothingSelected} href={getDownloadJSONUrl(type)} > - {__('Export JSON', '@@text_domain')} + {__('Export JSON', 'lazy-blocks')} {/* eslint-disable-next-line react/button-has-type */} )} @@ -247,7 +247,7 @@ export default function Templates() {

- {__('Export Blocks', '@@text_domain')} + {__('Export Blocks', 'lazy-blocks')}

{data.blocks && data.blocks.length ? (
@@ -267,7 +267,7 @@ export default function Templates() {

- {__('Export Templates', '@@text_domain')} + {__('Export Templates', 'lazy-blocks')}

{data.templates && data.templates.length ? (
@@ -289,7 +289,7 @@ export default function Templates() {

- {__('Import', '@@text_domain')} + {__('Import', 'lazy-blocks')}

@@ -307,9 +307,7 @@ export default function Templates() {

{/* eslint-disable-next-line react/button-has-type */} - +
diff --git a/src/assets/components/block-slug/editor.scss b/assets/components/block-slug/editor.scss similarity index 100% rename from src/assets/components/block-slug/editor.scss rename to assets/components/block-slug/editor.scss diff --git a/src/assets/components/block-slug/index.js b/assets/components/block-slug/index.js similarity index 100% rename from src/assets/components/block-slug/index.js rename to assets/components/block-slug/index.js diff --git a/src/assets/components/box/editor.scss b/assets/components/box/editor.scss similarity index 100% rename from src/assets/components/box/editor.scss rename to assets/components/box/editor.scss diff --git a/src/assets/components/box/index.js b/assets/components/box/index.js similarity index 100% rename from src/assets/components/box/index.js rename to assets/components/box/index.js diff --git a/src/assets/components/code-editor/editor.scss b/assets/components/code-editor/editor.scss similarity index 100% rename from src/assets/components/code-editor/editor.scss rename to assets/components/code-editor/editor.scss diff --git a/src/assets/components/code-editor/index.js b/assets/components/code-editor/index.js similarity index 100% rename from src/assets/components/code-editor/index.js rename to assets/components/code-editor/index.js diff --git a/src/assets/components/copied/editor.scss b/assets/components/copied/editor.scss similarity index 100% rename from src/assets/components/copied/editor.scss rename to assets/components/copied/editor.scss diff --git a/src/assets/components/copied/index.js b/assets/components/copied/index.js similarity index 84% rename from src/assets/components/copied/index.js rename to assets/components/copied/index.js index 7a43da764..d73cd89f2 100644 --- a/src/assets/components/copied/index.js +++ b/assets/components/copied/index.js @@ -5,6 +5,6 @@ const { __ } = wp.i18n; export default function Copied({ children }) { return ( -
{children || __('Copied!', '@@text_domain')}
+
{children || __('Copied!', 'lazy-blocks')}
); } diff --git a/src/assets/components/document-tabs/editor.scss b/assets/components/document-tabs/editor.scss similarity index 100% rename from src/assets/components/document-tabs/editor.scss rename to assets/components/document-tabs/editor.scss diff --git a/src/assets/components/document-tabs/index.js b/assets/components/document-tabs/index.js similarity index 85% rename from src/assets/components/document-tabs/index.js rename to assets/components/document-tabs/index.js index e86ccbdfd..6aa6c38cc 100644 --- a/src/assets/components/document-tabs/index.js +++ b/assets/components/document-tabs/index.js @@ -33,7 +33,7 @@ export default function DocumentTabs({ children }) { function activateTab(name) { globalActiveTab = name; - if (name === 'block') { + if ('block' === name) { clearSelectedControl(); } else { selectControl('NO_CONTROL_ID_JUST_SELECT_TAB'); @@ -51,11 +51,11 @@ export default function DocumentTabs({ children }) { activateTab('block'); }} className={`components-button edit-post-sidebar__panel-tab ${ - activeTab === 'block' ? 'is-active' : '' + 'block' === activeTab ? 'is-active' : '' }`} - aria-label={__('Block', '@@text_domain')} + aria-label={__('Block', 'lazy-blocks')} > - {__('Block', '@@text_domain')} + {__('Block', 'lazy-blocks')}
  • @@ -65,11 +65,11 @@ export default function DocumentTabs({ children }) { activateTab('control'); }} className={`components-button edit-post-sidebar__panel-tab ${ - activeTab === 'control' ? 'is-active' : '' + 'control' === activeTab ? 'is-active' : '' }`} - aria-label={__('Control', '@@text_domain')} + aria-label={__('Control', 'lazy-blocks')} > - {__('Control', '@@text_domain')} + {__('Control', 'lazy-blocks')}
  • diff --git a/src/assets/components/icon-picker/editor.scss b/assets/components/icon-picker/editor.scss similarity index 100% rename from src/assets/components/icon-picker/editor.scss rename to assets/components/icon-picker/editor.scss diff --git a/src/assets/components/icon-picker/index.js b/assets/components/icon-picker/index.js similarity index 94% rename from src/assets/components/icon-picker/index.js rename to assets/components/icon-picker/index.js index 0f2fedca9..c514ff9f9 100644 --- a/src/assets/components/icon-picker/index.js +++ b/assets/components/icon-picker/index.js @@ -60,10 +60,10 @@ function IconPickerDropdown(props) { render: ( setSearch(searchVal)} - placeholder={__('Type to Search...', '@@text_domain')} + placeholder={__('Type to Search...', 'lazy-blocks')} autoComplete="off" /> @@ -74,7 +74,7 @@ function IconPickerDropdown(props) { Object.keys(icons).forEach((categoryName) => { const categoryIcons = icons[categoryName]; const showCategory = - typeof hiddenCategories[categoryName] !== 'undefined' + 'undefined' !== typeof hiddenCategories[categoryName] ? hiddenCategories[categoryName] : true; const searchString = search.toLowerCase(); @@ -84,7 +84,7 @@ function IconPickerDropdown(props) { .filter((iconName) => { if ( !searchString || - (searchString && iconName.indexOf(searchString.toLowerCase()) > -1) + (searchString && -1 < iconName.indexOf(searchString.toLowerCase())) ) { return true; } @@ -189,7 +189,7 @@ function IconPickerDropdown(props) { allIcons.forEach((icon, i) => { currentIcons.push(icon); - if (currentIcons.length === 3 || allIcons.length === i + 1) { + if (3 === currentIcons.length || allIcons.length === i + 1) { rows.push({ key: 'icons', render:
    {currentIcons}
    , @@ -201,10 +201,10 @@ function IconPickerDropdown(props) { }); // No icons. - if (rows.length === 1) { + if (1 === rows.length) { rows.push({ key: 'icons', - render: __('No icons found.', '@@text_domain'), + render: __('No icons found.', 'lazy-blocks'), }); } @@ -274,7 +274,7 @@ export default function IconPicker({ value, onChange, label }) { onChange={onChange} value={value} renderToggle={({ isOpen, onToggle }) => ( - + {/* We need this
    just because Tooltip don't work without it */}
    @@ -52,7 +52,7 @@ export default function ConstructorBlock() { {(tabData) => { // Selected control settings. - if (tabData.name === 'control') { + if ('control' === tabData.name) { return ; } @@ -60,10 +60,10 @@ export default function ConstructorBlock() { return ( - + - + diff --git a/src/assets/editor-constructor/block/index.js b/assets/editor-constructor/block/index.js similarity index 89% rename from src/assets/editor-constructor/block/index.js rename to assets/editor-constructor/block/index.js index de4a358e5..7bca9e48d 100644 --- a/src/assets/editor-constructor/block/index.js +++ b/assets/editor-constructor/block/index.js @@ -15,7 +15,7 @@ const { __ } = wp.i18n; * Constructor block */ registerBlockType('lzb-constructor/main', { - title: __('Blocks Constructor', '@@text_domain'), + title: __('Blocks Constructor', 'lazy-blocks'), category: 'design', supports: { html: false, diff --git a/src/assets/editor-constructor/block/save.js b/assets/editor-constructor/block/save.js similarity index 100% rename from src/assets/editor-constructor/block/save.js rename to assets/editor-constructor/block/save.js diff --git a/src/assets/editor-constructor/boxes/code-preview/editor.scss b/assets/editor-constructor/boxes/code-preview/editor.scss similarity index 100% rename from src/assets/editor-constructor/boxes/code-preview/editor.scss rename to assets/editor-constructor/boxes/code-preview/editor.scss diff --git a/src/assets/editor-constructor/boxes/code-preview/index.js b/assets/editor-constructor/boxes/code-preview/index.js similarity index 96% rename from src/assets/editor-constructor/boxes/code-preview/index.js rename to assets/editor-constructor/boxes/code-preview/index.js index 8fcfb1b20..3f57c6620 100644 --- a/src/assets/editor-constructor/boxes/code-preview/index.js +++ b/assets/editor-constructor/boxes/code-preview/index.js @@ -109,7 +109,7 @@ export default function CodePreview(props) { } if (error) { - if (errorCode === 'lazy_block_no_render_callback') { + if ('lazy_block_no_render_callback' === errorCode) { setCodePreview(''); } else { setCodePreview(`
    ${response}
    `); @@ -123,7 +123,7 @@ export default function CodePreview(props) { return; } - setCodePreview(__('Error: Could not generate the preview.', '@@text_domain')); + setCodePreview(__('Error: Could not generate the preview.', 'lazy-blocks')); }); }; @@ -154,7 +154,7 @@ export default function CodePreview(props) { return (
    -

    {__('Preview', '@@text_domain')}

    +

    {__('Preview', 'lazy-blocks')}

    ${2}\nsnippet iframe.\n\t${3}\nsnippet iframe#\n\t${3}\nsnippet img\n\t${2}${3}\nsnippet img.\n\t${3}${4}\nsnippet img#\n\t${3}${4}\nsnippet input\n\t${5}\nsnippet input.\n\t${6}\nsnippet input:text\n\t${4}\nsnippet input:submit\n\t${4}\nsnippet input:hidden\n\t${4}\nsnippet input:button\n\t${4}\nsnippet input:image\n\t${5}\nsnippet input:checkbox\n\t${3}\nsnippet input:radio\n\t${3}\nsnippet input:color\n\t${4}\nsnippet input:date\n\t${4}\nsnippet input:datetime\n\t${4}\nsnippet input:datetime-local\n\t${4}\nsnippet input:email\n\t${4}\nsnippet input:file\n\t${4}\nsnippet input:month\n\t${4}\nsnippet input:number\n\t${4}\nsnippet input:password\n\t${4}\nsnippet input:range\n\t${4}\nsnippet input:reset\n\t${4}\nsnippet input:search\n\t${4}\nsnippet input:time\n\t${4}\nsnippet input:url\n\t${4}\nsnippet input:week\n\t${4}\nsnippet ins\n\t${1}\nsnippet kbd\n\t${1}\nsnippet keygen\n\t${1}\nsnippet label\n\t\nsnippet label:i\n\t\n\t${7}\nsnippet label:s\n\t\n\t\nsnippet legend\n\t${1}\nsnippet legend+\n\t${1}\nsnippet li\n\t
  • ${1}
  • \nsnippet li.\n\t
  • ${2}
  • \nsnippet li+\n\t
  • ${1}
  • \n\tli+${2}\nsnippet lia\n\t
  • ${1}
  • \nsnippet lia+\n\t
  • ${1}
  • \n\tlia+${3}\nsnippet link\n\t${5}\nsnippet link:atom\n\t${2}\nsnippet link:css\n\t${4}\nsnippet link:favicon\n\t${2}\nsnippet link:rss\n\t${2}\nsnippet link:touch\n\t${2}\nsnippet map\n\t\n\t\t${2}\n\t\nsnippet map.\n\t\n\t\t${3}\n\t\nsnippet map#\n\t\n\t\t${5}${6}\n\t${7}\nsnippet mark\n\t${1}\nsnippet menu\n\t\n\t\t${1}\n\t\nsnippet menu:c\n\t\n\t\t${1}\n\t\nsnippet menu:t\n\t\n\t\t${1}\n\t\nsnippet meta\n\t${3}\nsnippet meta:compat\n\t${3}\nsnippet meta:refresh\n\t${3}\nsnippet meta:utf\n\t${3}\nsnippet meter\n\t${1}\nsnippet nav\n\t\nsnippet nav.\n\t\nsnippet nav#\n\t\nsnippet noscript\n\t\nsnippet object\n\t\n\t\t${3}\n\t${4}\n# Embed QT Movie\nsnippet movie\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t${6}\nsnippet ol\n\t
      \n\t\t${1}\n\t
    \nsnippet ol.\n\t
      \n\t\t${2}\n\t
    \nsnippet ol+\n\t
      \n\t\t
    1. ${1}
    2. \n\t\tli+${2}\n\t
    \nsnippet opt\n\t\nsnippet opt+\n\t\n\topt+${3}\nsnippet optt\n\t\nsnippet optgroup\n\t\n\t\t\n\t\topt+${3}\n\t\nsnippet output\n\t${1}\nsnippet p\n\t

    ${1}

    \nsnippet param\n\t${3}\nsnippet pre\n\t
    \n\t\t${1}\n\t
    \nsnippet progress\n\t${1}\nsnippet q\n\t${1}\nsnippet rp\n\t${1}\nsnippet rt\n\t${1}\nsnippet ruby\n\t\n\t\t${1}\n\t\nsnippet s\n\t${1}\nsnippet samp\n\t\n\t\t${1}\n\t\nsnippet script\n\t