mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 06:04:29 +00:00
Add plugin for testing custom fields
This commit is contained in:
parent
5aad18547b
commit
1c556a0845
@ -28,4 +28,8 @@ module.exports = () => ({
|
||||
testConf: 3,
|
||||
},
|
||||
},
|
||||
mycustomfields: {
|
||||
enabled: true,
|
||||
resolve: `./src/plugins/mycustomfields`,
|
||||
},
|
||||
});
|
||||
|
||||
3
examples/getstarted/src/plugins/mycustomfields/README.md
Normal file
3
examples/getstarted/src/plugins/mycustomfields/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Strapi plugin mycustomfield
|
||||
|
||||
A quick description of mycustomfield.
|
||||
@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import Puzzle from '@strapi/icons/Puzzle';
|
||||
|
||||
const ColorPickerIcon = () => <Puzzle />;
|
||||
|
||||
export default ColorPickerIcon;
|
||||
@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
const ColorPickerInput = () => {
|
||||
return <div>TODO: Color Picker Input Component</div>;
|
||||
};
|
||||
|
||||
export default ColorPickerInput;
|
||||
@ -0,0 +1,49 @@
|
||||
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
||||
import pluginId from './pluginId';
|
||||
// TODO: Uncomment for EXPANSION-235
|
||||
//import ColorPickerIcon from './components/ColorPicker/ColorPickerIcon';
|
||||
|
||||
export default {
|
||||
register(app) {
|
||||
// TODO: Uncomment for EXPANSION-235
|
||||
// app.customFields.register({
|
||||
// name: 'color',
|
||||
// pluginId: 'color-picker',
|
||||
// type: 'text',
|
||||
// icon: ColorPickerIcon,
|
||||
// intlLabel: {
|
||||
// id: 'color-picker.color.label',
|
||||
// defaultMessage: 'Color',
|
||||
// },
|
||||
// intlDescription: {
|
||||
// id: 'color-picker.color.description',
|
||||
// defaultMessage: 'Select any color',
|
||||
// },
|
||||
// components: {
|
||||
// Input: async () => import(/* webpackChunkName: "input-component" */ './components/ColorPicker/ColorPickerInput'),
|
||||
// },
|
||||
// });
|
||||
},
|
||||
bootstrap(app) {},
|
||||
async registerTrads({ locales }) {
|
||||
const importedTrads = await Promise.all(
|
||||
locales.map(locale => {
|
||||
return import(`./translations/${locale}.json`)
|
||||
.then(({ default: data }) => {
|
||||
return {
|
||||
data: prefixPluginTranslations(data, pluginId),
|
||||
locale,
|
||||
};
|
||||
})
|
||||
.catch(() => {
|
||||
return {
|
||||
data: {},
|
||||
locale,
|
||||
};
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
return Promise.resolve(importedTrads);
|
||||
},
|
||||
};
|
||||
@ -0,0 +1,5 @@
|
||||
const pluginPkg = require('../../package.json');
|
||||
|
||||
const pluginId = pluginPkg.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, '');
|
||||
|
||||
module.exports = pluginId;
|
||||
@ -0,0 +1 @@
|
||||
{}
|
||||
@ -0,0 +1 @@
|
||||
{}
|
||||
@ -0,0 +1,5 @@
|
||||
import pluginId from '../pluginId';
|
||||
|
||||
const getTrad = id => `${pluginId}.${id}`;
|
||||
|
||||
export default getTrad;
|
||||
25
examples/getstarted/src/plugins/mycustomfields/package.json
Normal file
25
examples/getstarted/src/plugins/mycustomfields/package.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "mycustomfield",
|
||||
"version": "0.0.0",
|
||||
"description": "This is the description of the plugin.",
|
||||
"strapi": {
|
||||
"name": "mycustomfield",
|
||||
"description": "Description of Mycustomfield plugin",
|
||||
"kind": "plugin",
|
||||
"displayName": "Mycustomfield"
|
||||
},
|
||||
"dependencies": {},
|
||||
"author": {
|
||||
"name": "A Strapi developer"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "A Strapi developer"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.19.1 <=16.x.x",
|
||||
"npm": ">=6.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const register = require('./register');
|
||||
|
||||
module.exports = {
|
||||
register,
|
||||
};
|
||||
@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = ({ strapi }) => {
|
||||
console.log('Running register in customfields plugin');
|
||||
// TODO: Uncomment for EXPANSION-234
|
||||
// strapi.customFields.register({
|
||||
// name: 'color',
|
||||
// plugin: 'color-picker',
|
||||
// type: 'text',
|
||||
// });
|
||||
};
|
||||
@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./admin/src').default;
|
||||
@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./server');
|
||||
Loading…
x
Reference in New Issue
Block a user