@40q/40q-cli 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/165.index.js +1 -0
- package/dist/216.index.js +1 -0
- package/dist/284.index.js +1 -0
- package/dist/350.index.js +1 -0
- package/dist/522.index.js +1 -0
- package/dist/62.index.js +2 -0
- package/dist/62.index.js.LICENSE.txt +9 -0
- package/dist/758.index.js +1 -0
- package/dist/index.js.LICENSE.txt +14 -0
- package/dist/resources/scripts/editor/blocks/default/default.block.js +39 -0
- package/dist/resources/scripts/editor/blocks/hello-today/hello-today.block.js +39 -0
- package/dist/resources/scripts/editor/blocks/here-we-go-again/here-we-go-again.block.js +39 -0
- package/dist/resources/scripts/editor/blocks/section-header/section-header.block.js +39 -0
- package/dist/src/commands/Codegen/Generators/GeneratorStrategy.factory.js +11 -0
- package/dist/src/commands/Codegen/Generators/GeneratorStrategy.js +2 -0
- package/dist/src/commands/Codegen/Generators/strategies/BlockGenerator.strategy.js +88 -0
- package/dist/src/commands/Codegen/Prompts/PromptStrategy.factory.js +10 -12
- package/dist/src/commands/Codegen/Prompts/PromptStrategy.js +2 -0
- package/dist/src/commands/Codegen/Prompts/strategies/BlockPrompt.strategy.js +43 -0
- package/dist/src/commands/Codegen/StrategyFactory.js +63 -0
- package/package.json +7 -1
- package/templates/blocks/default/tsx.txt +16 -2
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";exports.id=758,exports.ids=[758],exports.modules={10758:(s,e,r)=>{r.r(e)}};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
3
|
+
* CJS and ESM environments.
|
4
|
+
*
|
5
|
+
* @license
|
6
|
+
* Copyright (c) 2016, Contributors
|
7
|
+
* SPDX-License-Identifier: ISC
|
8
|
+
*/
|
9
|
+
|
10
|
+
/**
|
11
|
+
* @license
|
12
|
+
* Copyright (c) 2016, Contributors
|
13
|
+
* SPDX-License-Identifier: ISC
|
14
|
+
*/
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
+
const i18n_1 = require("@wordpress/i18n");
|
5
|
+
const components_1 = require("@wordpress/components");
|
6
|
+
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
+
/* Block name */
|
8
|
+
exports.name = "by40q/default";
|
9
|
+
/* Block title */
|
10
|
+
exports.title = (0, i18n_1.__)("Default", "40q");
|
11
|
+
/* Block category */
|
12
|
+
exports.category = "text";
|
13
|
+
/* Block attributes */
|
14
|
+
exports.attributes = {
|
15
|
+
title: {
|
16
|
+
type: "string",
|
17
|
+
default: "40Q",
|
18
|
+
},
|
19
|
+
};
|
20
|
+
/* Block edit */
|
21
|
+
const edit = ({ attributes, setAttributes }) => {
|
22
|
+
const { title } = attributes;
|
23
|
+
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
+
return (<>
|
25
|
+
<block_editor_1.InspectorControls>
|
26
|
+
<components_1.PanelBody title={(0, i18n_1.__)("Default Settings")} initialOpen></components_1.PanelBody>
|
27
|
+
</block_editor_1.InspectorControls>
|
28
|
+
|
29
|
+
<div {...blockProps}>
|
30
|
+
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
+
</div>
|
32
|
+
</>);
|
33
|
+
};
|
34
|
+
exports.edit = edit;
|
35
|
+
/* Block save */
|
36
|
+
const save = () => <></>;
|
37
|
+
exports.save = save;
|
38
|
+
/* Block styles */
|
39
|
+
exports.styles = [];
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
+
const i18n_1 = require("@wordpress/i18n");
|
5
|
+
const components_1 = require("@wordpress/components");
|
6
|
+
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
+
/* Block name */
|
8
|
+
exports.name = "by40q/hello-today";
|
9
|
+
/* Block title */
|
10
|
+
exports.title = (0, i18n_1.__)("Hello Today", "40q");
|
11
|
+
/* Block category */
|
12
|
+
exports.category = "text";
|
13
|
+
/* Block attributes */
|
14
|
+
exports.attributes = {
|
15
|
+
title: {
|
16
|
+
type: "string",
|
17
|
+
default: "40Q",
|
18
|
+
},
|
19
|
+
};
|
20
|
+
/* Block edit */
|
21
|
+
const edit = ({ attributes, setAttributes }) => {
|
22
|
+
const { title } = attributes;
|
23
|
+
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
+
return (<>
|
25
|
+
<block_editor_1.InspectorControls>
|
26
|
+
<components_1.PanelBody title={(0, i18n_1.__)("Hello Today Settings")} initialOpen></components_1.PanelBody>
|
27
|
+
</block_editor_1.InspectorControls>
|
28
|
+
|
29
|
+
<div {...blockProps}>
|
30
|
+
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
+
</div>
|
32
|
+
</>);
|
33
|
+
};
|
34
|
+
exports.edit = edit;
|
35
|
+
/* Block save */
|
36
|
+
const save = () => <></>;
|
37
|
+
exports.save = save;
|
38
|
+
/* Block styles */
|
39
|
+
exports.styles = [];
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
+
const i18n_1 = require("@wordpress/i18n");
|
5
|
+
const components_1 = require("@wordpress/components");
|
6
|
+
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
+
/* Block name */
|
8
|
+
exports.name = "by40q/here-we-go-again";
|
9
|
+
/* Block title */
|
10
|
+
exports.title = (0, i18n_1.__)("Here We Go Again", "40q");
|
11
|
+
/* Block category */
|
12
|
+
exports.category = "text";
|
13
|
+
/* Block attributes */
|
14
|
+
exports.attributes = {
|
15
|
+
title: {
|
16
|
+
type: "string",
|
17
|
+
default: "40Q",
|
18
|
+
},
|
19
|
+
};
|
20
|
+
/* Block edit */
|
21
|
+
const edit = ({ attributes, setAttributes }) => {
|
22
|
+
const { title } = attributes;
|
23
|
+
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
+
return (<>
|
25
|
+
<block_editor_1.InspectorControls>
|
26
|
+
<components_1.PanelBody title={(0, i18n_1.__)("Here We Go Again Settings")} initialOpen></components_1.PanelBody>
|
27
|
+
</block_editor_1.InspectorControls>
|
28
|
+
|
29
|
+
<div {...blockProps}>
|
30
|
+
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
+
</div>
|
32
|
+
</>);
|
33
|
+
};
|
34
|
+
exports.edit = edit;
|
35
|
+
/* Block save */
|
36
|
+
const save = () => <></>;
|
37
|
+
exports.save = save;
|
38
|
+
/* Block styles */
|
39
|
+
exports.styles = [];
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.styles = exports.save = exports.edit = exports.attributes = exports.category = exports.title = exports.name = void 0;
|
4
|
+
const i18n_1 = require("@wordpress/i18n");
|
5
|
+
const components_1 = require("@wordpress/components");
|
6
|
+
const block_editor_1 = require("@wordpress/block-editor");
|
7
|
+
/* Block name */
|
8
|
+
exports.name = "by40q/section-header";
|
9
|
+
/* Block title */
|
10
|
+
exports.title = (0, i18n_1.__)("Section Header", "40q");
|
11
|
+
/* Block category */
|
12
|
+
exports.category = "text";
|
13
|
+
/* Block attributes */
|
14
|
+
exports.attributes = {
|
15
|
+
title: {
|
16
|
+
type: "string",
|
17
|
+
default: "40Q",
|
18
|
+
},
|
19
|
+
};
|
20
|
+
/* Block edit */
|
21
|
+
const edit = ({ attributes, setAttributes }) => {
|
22
|
+
const { title } = attributes;
|
23
|
+
const blockProps = (0, block_editor_1.useBlockProps)();
|
24
|
+
return (<>
|
25
|
+
<block_editor_1.InspectorControls>
|
26
|
+
<components_1.PanelBody title={(0, i18n_1.__)("Section Header Settings")} initialOpen></components_1.PanelBody>
|
27
|
+
</block_editor_1.InspectorControls>
|
28
|
+
|
29
|
+
<div {...blockProps}>
|
30
|
+
<block_editor_1.RichText tagName="h2" placeholder={(0, i18n_1.__)("40Q")} value={title} onChange={(title) => setAttributes({ title })}/>
|
31
|
+
</div>
|
32
|
+
</>);
|
33
|
+
};
|
34
|
+
exports.edit = edit;
|
35
|
+
/* Block save */
|
36
|
+
const save = () => <></>;
|
37
|
+
exports.save = save;
|
38
|
+
/* Block styles */
|
39
|
+
exports.styles = [];
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.GeneratorStrategyFactory = void 0;
|
4
|
+
const StrategyFactory_1 = require("../StrategyFactory");
|
5
|
+
class GeneratorStrategyFactory extends StrategyFactory_1.StrategyFactory {
|
6
|
+
constructor() {
|
7
|
+
super(...arguments);
|
8
|
+
this.pattern = 'Generator.strategy';
|
9
|
+
}
|
10
|
+
}
|
11
|
+
exports.GeneratorStrategyFactory = GeneratorStrategyFactory;
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.BlockGenerator = void 0;
|
30
|
+
const fs = __importStar(require("fs"));
|
31
|
+
const path_1 = __importDefault(require("path"));
|
32
|
+
const child_process_1 = require("child_process");
|
33
|
+
const cliRoot_1 = require("../../../../lib/cliRoot");
|
34
|
+
class BlockGenerator {
|
35
|
+
constructor(options) {
|
36
|
+
this.template = '';
|
37
|
+
this.name = '';
|
38
|
+
this.title = '';
|
39
|
+
this.camelCaseName = '';
|
40
|
+
console.log(options);
|
41
|
+
this.template = options.template === '' ? 'default' : options.template;
|
42
|
+
this.name = options.name || 'default';
|
43
|
+
this.camelCaseName = this.toCamelCase(this.name);
|
44
|
+
this.title = this.parseName(this.name);
|
45
|
+
}
|
46
|
+
run() {
|
47
|
+
this.createBlockFolder();
|
48
|
+
this.createBlockFiles();
|
49
|
+
}
|
50
|
+
createBlockFolder() {
|
51
|
+
(0, child_process_1.execSync)(`mkdir -p resources/scripts/editor/blocks/${this.name}`);
|
52
|
+
}
|
53
|
+
createBlockFiles() {
|
54
|
+
var _a, _b;
|
55
|
+
fs.writeFileSync(path_1.default.join(process.cwd(), `resources/scripts/editor/blocks/${this.name}/${this.name}.block.tsx`), this.getTemplate('tsx')
|
56
|
+
.replace(/{{name}}/g, (_a = this.name) !== null && _a !== void 0 ? _a : '')
|
57
|
+
.replace(/{{title}}/g, this.title));
|
58
|
+
fs.writeFileSync(path_1.default.join(process.cwd(), `resources/views/blocks/${this.name}.blade.php`), this.getTemplate('blade'));
|
59
|
+
fs.writeFileSync(path_1.default.join(process.cwd(), `app/Blocks/${this.camelCaseName}.php`), this.getTemplate('php')
|
60
|
+
.replace(/{{name}}/g, (_b = this.name) !== null && _b !== void 0 ? _b : '')
|
61
|
+
.replace(/{{camelCaseName}}/g, this.camelCaseName));
|
62
|
+
}
|
63
|
+
parseName(name) {
|
64
|
+
return name
|
65
|
+
.split('-')
|
66
|
+
.map((word) => {
|
67
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
68
|
+
})
|
69
|
+
.join(' ');
|
70
|
+
}
|
71
|
+
toCamelCase(name) {
|
72
|
+
var _a;
|
73
|
+
return ((_a = name.split('-').reduce((acc, word) => {
|
74
|
+
return acc + word.charAt(0).toUpperCase() + word.slice(1);
|
75
|
+
}, '')) !== null && _a !== void 0 ? _a : '');
|
76
|
+
}
|
77
|
+
getTemplate(name) {
|
78
|
+
try {
|
79
|
+
const cliRoot = (0, cliRoot_1.findCliRoot)(__dirname);
|
80
|
+
const templateFolder = `templates/blocks/${this.template}`;
|
81
|
+
return fs.readFileSync(path_1.default.join(cliRoot, `${templateFolder}/${name}.txt`), 'utf8');
|
82
|
+
}
|
83
|
+
catch (e) {
|
84
|
+
return '';
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
exports.BlockGenerator = BlockGenerator;
|
@@ -1,13 +1,11 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
// }
|
13
|
-
// }
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PromptStrategyFactory = void 0;
|
4
|
+
const StrategyFactory_1 = require("../StrategyFactory");
|
5
|
+
class PromptStrategyFactory extends StrategyFactory_1.StrategyFactory {
|
6
|
+
constructor() {
|
7
|
+
super(...arguments);
|
8
|
+
this.pattern = 'Prompt.strategy';
|
9
|
+
}
|
10
|
+
}
|
11
|
+
exports.PromptStrategyFactory = PromptStrategyFactory;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
16
|
+
const config_1 = require("@/config");
|
17
|
+
class BlockPromptStrategy {
|
18
|
+
prompt() {
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
20
|
+
const templateAnswer = yield inquirer_1.default.prompt([
|
21
|
+
{
|
22
|
+
type: 'list',
|
23
|
+
name: 'template',
|
24
|
+
message: 'Please select a template:',
|
25
|
+
choices: config_1.config.templateChoices.block,
|
26
|
+
default: '',
|
27
|
+
}
|
28
|
+
]);
|
29
|
+
const template = (templateAnswer === null || templateAnswer === void 0 ? void 0 : templateAnswer.template) || '';
|
30
|
+
const answers = yield inquirer_1.default.prompt([
|
31
|
+
{
|
32
|
+
type: 'input',
|
33
|
+
name: 'name',
|
34
|
+
message: 'Please enter a name for the block:',
|
35
|
+
default: template || 'block-name',
|
36
|
+
},
|
37
|
+
]);
|
38
|
+
const name = (answers === null || answers === void 0 ? void 0 : answers.name) || '';
|
39
|
+
return { name, template };
|
40
|
+
});
|
41
|
+
}
|
42
|
+
}
|
43
|
+
exports.default = BlockPromptStrategy;
|
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
32
|
+
});
|
33
|
+
};
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
|
+
};
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
38
|
+
exports.StrategyFactory = void 0;
|
39
|
+
const path_1 = __importDefault(require("path"));
|
40
|
+
class StrategyFactory {
|
41
|
+
constructor() {
|
42
|
+
this.directory = 'strategies';
|
43
|
+
}
|
44
|
+
getStrategyFileName(type) {
|
45
|
+
const camelCaseType = type.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
46
|
+
return `${camelCaseType}${this.pattern}.strategy.ts`;
|
47
|
+
}
|
48
|
+
getStrategy(type) {
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
50
|
+
const strategyFileName = this.getStrategyFileName(type);
|
51
|
+
const strategyFilePath = path_1.default.join(__dirname, this.directory, strategyFileName);
|
52
|
+
try {
|
53
|
+
const strategyModule = yield Promise.resolve(`${strategyFilePath}`).then(s => __importStar(require(s)));
|
54
|
+
return new strategyModule.default();
|
55
|
+
}
|
56
|
+
catch (error) {
|
57
|
+
console.error(`Failed to import strategy '${type}':`, error);
|
58
|
+
return null;
|
59
|
+
}
|
60
|
+
});
|
61
|
+
}
|
62
|
+
}
|
63
|
+
exports.StrategyFactory = StrategyFactory;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@40q/40q-cli",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.12",
|
4
4
|
"description": "40q CLI tool",
|
5
5
|
"main": "index.js",
|
6
6
|
"bin": {
|
@@ -21,9 +21,15 @@
|
|
21
21
|
"url": "https://github.com/40Q/40q-cli.git"
|
22
22
|
},
|
23
23
|
"devDependencies": {
|
24
|
+
"@40q/eslint-config": "^1.0.2",
|
24
25
|
"@types/inquirer": "^8.0.0",
|
25
26
|
"@types/node": "^20.8.7",
|
26
27
|
"@types/yargs": "^17.0.29",
|
28
|
+
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
29
|
+
"@typescript-eslint/parser": "^6.9.1",
|
30
|
+
"eslint": "^8.52.0",
|
31
|
+
"husky": "^8.0.3",
|
32
|
+
"lint-staged": "^15.0.2",
|
27
33
|
"ts-node": "^10.9.1",
|
28
34
|
"typescript": "^5.2.2"
|
29
35
|
},
|
@@ -1,5 +1,9 @@
|
|
1
1
|
import { __ } from "@wordpress/i18n";
|
2
2
|
import { PanelBody } from "@wordpress/components";
|
3
|
+
import {
|
4
|
+
GetBlockAttributeValues,
|
5
|
+
GetSetAttributesFunction,
|
6
|
+
} from "scripts/editor/utils/type-mapping";
|
3
7
|
import {
|
4
8
|
InspectorControls,
|
5
9
|
RichText,
|
@@ -21,10 +25,20 @@ export const attributes = {
|
|
21
25
|
type: "string",
|
22
26
|
default: "40Q",
|
23
27
|
},
|
24
|
-
};
|
28
|
+
} as const;
|
29
|
+
|
30
|
+
/* Block types */
|
31
|
+
type BlockAttributeValues = GetBlockAttributeValues<typeof attributes>;
|
32
|
+
type SetAttributesFunction = GetSetAttributesFunction<typeof attributes>;
|
25
33
|
|
26
34
|
/* Block edit */
|
27
|
-
export const edit = ({
|
35
|
+
export const edit = ({
|
36
|
+
attributes,
|
37
|
+
setAttributes,
|
38
|
+
}: {
|
39
|
+
attributes: BlockAttributeValues;
|
40
|
+
setAttributes: SetAttributesFunction;
|
41
|
+
}) => {
|
28
42
|
const { title } = attributes;
|
29
43
|
|
30
44
|
const blockProps = useBlockProps();
|