-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #811
- Loading branch information
Showing
27 changed files
with
785 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/api-headless-cms/src/handler/plugins/graphqlFields/richText.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { CmsModelFieldToGraphQLPlugin } from "@webiny/api-headless-cms/types"; | ||
|
||
const plugin: CmsModelFieldToGraphQLPlugin = { | ||
name: "cms-model-field-to-graphql-rich-text", | ||
type: "cms-model-field-to-graphql", | ||
fieldType: "rich-text", | ||
read: { | ||
createTypeField({ field }) { | ||
const localeArg = "(locale: String)"; | ||
return `${field.fieldId}${localeArg}: JSON`; | ||
}, | ||
createGetFilters({ field }) { | ||
return `${field.fieldId}: JSON`; | ||
}, | ||
createResolver({ field }) { | ||
return (instance, args) => { | ||
return instance[field.fieldId].value(args.locale); | ||
}; | ||
} | ||
}, | ||
manage: { | ||
createResolver({ field }) { | ||
return instance => { | ||
return instance[field.fieldId]; | ||
}; | ||
}, | ||
createTypeField({ field }) { | ||
return field.fieldId + ": CmsJSON"; | ||
}, | ||
createInputField({ field }) { | ||
return field.fieldId + ": CmsJSONInput"; | ||
} | ||
} | ||
}; | ||
|
||
export default plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/api-headless-cms/src/handler/plugins/modelFields/richText.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CmsModelFieldToCommodoFieldPlugin } from "@webiny/api-headless-cms/types"; | ||
import { withFields, object } from "@webiny/commodo"; | ||
import { i18nField } from "./i18nFields"; | ||
|
||
const plugin: CmsModelFieldToCommodoFieldPlugin = { | ||
name: "cms-model-field-to-commodo-field-rich-text", | ||
type: "cms-model-field-to-commodo-field", | ||
fieldType: "rich-text", | ||
dataModel({ model, field, validation, context }) { | ||
withFields({ | ||
[field.fieldId]: i18nField({ field: object({ validation }), context }) | ||
})(model); | ||
}, | ||
searchModel({ model, field, validation }) { | ||
withFields({ | ||
[field.fieldId]: object({ validation }) | ||
})(model); | ||
} | ||
}; | ||
|
||
export default plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/app-headless-cms/src/admin/plugins/fieldRenderers/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import number from "./number"; | ||
import text from "./text"; | ||
import longText from "./longText"; | ||
import richText from "./richText"; | ||
import boolean from "./boolean"; | ||
import dateTime from "./dateTime"; | ||
|
||
export default [number, text, longText, boolean, dateTime]; | ||
export default [number, text, longText, richText, boolean, dateTime]; |
3 changes: 3 additions & 0 deletions
3
packages/app-headless-cms/src/admin/plugins/fieldRenderers/richText/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import richTextInput from "./richTextInput"; | ||
|
||
export default [richTextInput] |
52 changes: 52 additions & 0 deletions
52
packages/app-headless-cms/src/admin/plugins/fieldRenderers/richText/richTextInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from "react"; | ||
import { CmsEditorFieldRendererPlugin } from "@webiny/app-headless-cms/types"; | ||
import { I18NValue } from "@webiny/app-i18n/components"; | ||
import { i18n } from "@webiny/app/i18n"; | ||
|
||
import I18NRichTextEditor from "@webiny/app-i18n/admin/components/I18NRichTextEditor"; | ||
import numberedListPlugins from "@webiny/app-i18n/admin/plugins/richTextEditor/numberedList"; | ||
import bulletedListPlugins from "@webiny/app-i18n/admin/plugins/richTextEditor/bulletedList"; | ||
import headingPlugins from "@webiny/app-i18n/admin/plugins/richTextEditor/heading"; | ||
import codePlugins from "@webiny/app-i18n/admin/plugins/richTextEditor/code"; | ||
|
||
const t = i18n.ns("app-headless-cms/admin/fields/text"); | ||
|
||
const richTextPlugins = [ | ||
numberedListPlugins.plugin, | ||
bulletedListPlugins.plugin, | ||
headingPlugins.plugin, | ||
codePlugins.plugin | ||
]; | ||
|
||
const plugin: CmsEditorFieldRendererPlugin = { | ||
type: "cms-editor-field-renderer", | ||
name: "cms-editor-field-renderer-rich-text", | ||
renderer: { | ||
rendererName: "rich-text-input", | ||
name: t`Rich Text Input`, | ||
description: t`Renders a rich text input.`, | ||
canUse({ field }) { | ||
return field.type === "rich-text" && !field.multipleValues && !field.predefinedValues; | ||
}, | ||
render({ field, getBind }) { | ||
const Bind = getBind(); | ||
|
||
return ( | ||
<Bind> | ||
{bind => ( | ||
<I18NRichTextEditor | ||
{...bind} | ||
onChange={bind.onChange} | ||
label={I18NValue({ value: field.label })} | ||
placeholder={I18NValue({ value: field.placeholderText })} | ||
description={I18NValue({ value: field.helpText })} | ||
plugins={richTextPlugins} | ||
/> | ||
)} | ||
</Bind> | ||
); | ||
} | ||
} | ||
}; | ||
|
||
export default plugin; |
1 change: 1 addition & 0 deletions
1
packages/app-headless-cms/src/admin/plugins/fields/icons/notes-black-24px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/app-headless-cms/src/admin/plugins/fields/icons/title-black-24px.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/app-headless-cms/src/admin/plugins/fields/richText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from "react"; | ||
import { ReactComponent as NotesIcon } from "./icons/notes-black-24px.svg"; | ||
import { Grid, Cell } from "@webiny/ui/Grid"; | ||
import { I18NInput } from "@webiny/app-i18n/admin/components"; | ||
import { CmsEditorFieldTypePlugin } from "@webiny/app-headless-cms/types"; | ||
import { i18n } from "@webiny/app/i18n"; | ||
const t = i18n.ns("app-headless-cms/admin/fields"); | ||
|
||
const plugin: CmsEditorFieldTypePlugin = { | ||
type: "cms-editor-field-type", | ||
name: "cms-editor-field-type-richText", | ||
field: { | ||
type: "rich-text", | ||
label: t`Rich text`, | ||
description: t`Text formatting with references and media.`, | ||
icon: <NotesIcon />, | ||
allowMultipleValues: false, | ||
allowPredefinedValues: false, | ||
allowIndexes: { | ||
singleValue: false, | ||
multipleValues: false | ||
}, | ||
createField() { | ||
return { | ||
type: this.type, | ||
name: this.name, | ||
validation: [], | ||
settings: { | ||
defaultValue: "" | ||
}, | ||
renderer: { | ||
name: "" | ||
} | ||
}; | ||
}, | ||
renderSettings({ form: { Bind } }) { | ||
return ( | ||
<Grid> | ||
<Cell span={12}> | ||
<Bind name={"placeholderText"}> | ||
<I18NInput | ||
label={t`Placeholder text`} | ||
description={t`Placeholder text (optional)`} | ||
/> | ||
</Bind> | ||
</Cell> | ||
</Grid> | ||
); | ||
} | ||
} | ||
}; | ||
|
||
export default plugin; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
packages/app-i18n/src/admin/assets/icons/format_list_bulleted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions
26
packages/app-i18n/src/admin/assets/icons/format_list_numbered.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.