@kids-reporter/cms-core
Version:
50 lines (49 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.richTextEditor = void 0;
var _core = require("@keystone-6/core");
var _types = require("@keystone-6/core/types");
const richTextEditor = ({
defaultValue = null,
disabledButtons = [],
...config
}) => meta => {
if (config.isIndexed === 'unique') {
throw Error("isIndexed: 'unique' is not a supported option for field type textEditor");
}
return (0, _types.jsonFieldTypePolyfilledForSQLite)(meta.provider, {
...config,
input: {
create: {
arg: _core.graphql.arg({
type: _core.graphql.JSON
}),
resolve(val) {
return val === undefined ? defaultValue : val;
}
},
update: {
arg: _core.graphql.arg({
type: _core.graphql.JSON
})
}
},
output: _core.graphql.field({
type: _core.graphql.JSON
}),
views: `@kids-reporter/cms-core/lib/custom-fields/rich-text-editor/views/index`,
getAdminMeta: () => ({
defaultValue,
disabledButtons
})
}, {
default: defaultValue === null ? undefined : {
kind: 'literal',
value: JSON.stringify(defaultValue)
},
map: config.db?.map
});
};
exports.richTextEditor = richTextEditor;