Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #14 add audio support #26

Open
wants to merge 119 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
517e1be
feat: showing character display on the editor
SalahAdDin Jul 20, 2024
41dd071
chore: optimizing count display.
SalahAdDin Jul 20, 2024
b7bfa9d
feat: adding Abbreviation extension
SalahAdDin Jul 20, 2024
7b2f5d2
fix: moving extra components out of toolbar
SalahAdDin Jul 21, 2024
160bd06
chore: remove logging function
SalahAdDin Jul 21, 2024
4b6e2f5
chore: remove logs and unused imports
SalahAdDin Jul 21, 2024
3949830
feat: adding tiptap Alert extension
SalahAdDin Jul 24, 2024
284a8fb
chore: adding extension styles and functionality to the editor
SalahAdDin Jul 24, 2024
2136b2a
chore: adding FloatingMenu extension
SalahAdDin Jul 24, 2024
ee74e01
feat: adding Alert toolbar to handle the alert type
SalahAdDin Jul 24, 2024
2d665ab
chore: remove logs and unused imports
SalahAdDin Jul 21, 2024
64dfb20
chore: adding localization to the editor
SalahAdDin Jul 25, 2024
019179b
chore: adding missing literals for titles
SalahAdDin Jul 25, 2024
0ea7156
fix: adding scroll to editor content
SalahAdDin Jul 20, 2024
af6aeb6
chore: adding localization to the editor
SalahAdDin Jul 25, 2024
dd4d9aa
chore: adding missing literals for titles
SalahAdDin Jul 25, 2024
b2e0af0
chore: adding locale strings
SalahAdDin Jul 25, 2024
6096287
chore: adding localization to the editor
SalahAdDin Jul 25, 2024
650c951
chore: adding missing literals for titles
SalahAdDin Jul 25, 2024
37e683a
chore: adding locale literals
SalahAdDin Jul 25, 2024
17a7edd
chore: adding localization to the editor
SalahAdDin Jul 25, 2024
9ec1680
chore: adding missing literals for titles
SalahAdDin Jul 25, 2024
e6c9d1a
chore: adding localization to the editor
SalahAdDin Jul 25, 2024
e7808c8
chore: adding missing literals for titles
SalahAdDin Jul 25, 2024
9ffaf9a
chore: adding locale literals and fixing some
SalahAdDin Jul 25, 2024
a784bb1
chore: adding locale literals
SalahAdDin Jul 25, 2024
2934f8f
Merge pull request #1 from SalahAdDin/fix/editor-scroll
SalahAdDin Aug 13, 2024
76d7c8d
Merge pull request #2 from SalahAdDin/feat/localization
SalahAdDin Aug 13, 2024
83c3988
Merge branch 'main' into feat/extension-abbr
SalahAdDin Aug 13, 2024
cc5681b
Merge pull request #3 from SalahAdDin/feat/extension-abbr
SalahAdDin Aug 13, 2024
eb4cfcc
Merge branch 'main' into fix/dialogs-in-folder
SalahAdDin Aug 13, 2024
73404fd
Merge pull request #4 from SalahAdDin/fix/dialogs-in-folder
SalahAdDin Aug 13, 2024
9d38658
Merge branch 'main' into feat/character-count-display
SalahAdDin Aug 13, 2024
906fa56
Merge pull request #5 from SalahAdDin/feat/character-count-display
SalahAdDin Aug 13, 2024
27b7c14
Merge branch 'main' into feat/extension-alert
SalahAdDin Aug 13, 2024
2c377e3
Merge pull request #6 from SalahAdDin/feat/extension-alert
SalahAdDin Aug 13, 2024
607165a
fix: adding missing ", on es localization file
SalahAdDin Aug 13, 2024
83faff6
Merge pull request #7 from SalahAdDin/feat/extension-alert
SalahAdDin Aug 13, 2024
e0ffea8
fix: using the proper Youtube icon
SalahAdDin Aug 18, 2024
237abc3
fix: adding text align buttons
SalahAdDin Aug 19, 2024
27eb832
chore: add required dependencies for styles
SalahAdDin Aug 19, 2024
e494720
chore: add color processors
SalahAdDin Aug 19, 2024
1de9d27
chore: enable style extensions for the editor
SalahAdDin Aug 19, 2024
f3a5505
feat: add color picker for Color and Highlight
SalahAdDin Aug 19, 2024
68134e0
chore: add new localized literals
SalahAdDin Aug 20, 2024
dc3e08e
fix: follow proper imports on Color Picker
SalahAdDin Aug 20, 2024
f3ce4fc
fix: parse style colour from either rgb or hex rightly
SalahAdDin Aug 20, 2024
27a616d
Merge pull request #8 from SalahAdDin/feat/titap-plugins
SalahAdDin Aug 20, 2024
dac0d8a
chore: add table extension packages
SalahAdDin Aug 21, 2024
3fdafa8
fix: disable color and highlight on empty selection
SalahAdDin Aug 21, 2024
5b4b0cc
chore: add Table extension to editor and toolbar
SalahAdDin Aug 21, 2024
8b33791
chore: add table icons
SalahAdDin Aug 21, 2024
5ce8b3b
chore: add colum and row commands through floating toolbar
SalahAdDin Aug 21, 2024
edf85f9
chore: add table literals
SalahAdDin Aug 21, 2024
6faa6d2
Merge pull request #9 from SalahAdDin/feat/tiptap-table
SalahAdDin Aug 21, 2024
dba4033
Merge branch 'main' into feat/configurable-settings
SalahAdDin Aug 21, 2024
39db5d8
chore: add header row to table when creating
SalahAdDin Aug 21, 2024
6dd3af4
chore: add default settings and their types
SalahAdDin Aug 21, 2024
56d9163
fix: fix literal id in components
SalahAdDin Aug 22, 2024
2035cf4
chore: rename plugin
SalahAdDin Aug 22, 2024
db43641
chore: enable localization for admin
SalahAdDin Aug 22, 2024
54896e1
Merge pull request #10 from SalahAdDin/feat/new-plugin-name
SalahAdDin Aug 22, 2024
8f89a70
Merge branch 'main' into feat/configurable-settings
SalahAdDin Aug 22, 2024
cbc50a5
chore: add configuration logic on server
SalahAdDin Aug 23, 2024
bcae67c
fix: fix default and settings path for components
SalahAdDin Aug 24, 2024
ce01d21
fix: :fire: remove log
SalahAdDin Aug 29, 2024
be59787
refactor: move global utils to a root folder
SalahAdDin Aug 30, 2024
5926b10
fix: improve server workflow for getting configuration
SalahAdDin Aug 30, 2024
4f6d1d1
chore: add api for getting settings in the editor
SalahAdDin Aug 31, 2024
e4eaba4
chore: add abbreviation and alert settings
SalahAdDin Aug 31, 2024
82a7b9c
chore: pass settings to editor, toolbar and block type select
SalahAdDin Aug 31, 2024
a67efaa
chore: add code block to block type
SalahAdDin Aug 31, 2024
2992963
chore: add code to toolbar
SalahAdDin Aug 31, 2024
c229e1b
chore: add styles for code and code block
SalahAdDin Aug 31, 2024
45eb057
refactor: use loglight to handle code block
SalahAdDin Aug 31, 2024
bdc455b
Merge pull request #12 from SalahAdDin/feat/code-extension
SalahAdDin Aug 31, 2024
a47f656
Merge branch 'main' into feat/configurable-settings
SalahAdDin Aug 31, 2024
9878546
chore: handle toolbar and block types by settings
SalahAdDin Aug 31, 2024
3614b5f
chore: add settings page
SalahAdDin Aug 31, 2024
fd0d9fd
chore: remove unused settings and add validations
SalahAdDin Aug 31, 2024
51663af
chore: update locale strings
SalahAdDin Aug 31, 2024
fe78bea
chore: enable save to json
SalahAdDin Aug 31, 2024
ae902b1
fix: remove duplicated item in headings
SalahAdDin Aug 31, 2024
091fa2a
chore: enforce types for heading, text align and list type
SalahAdDin Aug 31, 2024
dc9ed18
fix: parse json string when initializing the editor
SalahAdDin Aug 31, 2024
01f7e67
Merge pull request #11 from SalahAdDin/feat/configurable-settings
SalahAdDin Sep 1, 2024
04b30aa
chore: improve README with right middleware settings
SalahAdDin Aug 31, 2024
05a229a
refactor: use tabler icons as base
SalahAdDin Sep 1, 2024
c48e1ed
fire: replace svg width and height by viewBox and remove extra path
SalahAdDin Sep 1, 2024
52dbce1
chore: improve svg extra icon styles
SalahAdDin Sep 1, 2024
aa5d612
refactor: move types out to admin root
SalahAdDin Sep 13, 2024
5152c83
chore: add types for Media Library Modal
SalahAdDin Sep 13, 2024
3a64c85
chore: add Media Library Dialog
SalahAdDin Sep 13, 2024
b79cb0e
chore: adding image button to toolbar
SalahAdDin Sep 13, 2024
f370429
chore: add media library dialog for picking images
SalahAdDin Sep 13, 2024
3bfcb9b
refactor: handle Dialog Types as const array
SalahAdDin Sep 13, 2024
626eb59
chore: add support for base64 image
SalahAdDin Sep 13, 2024
7e5591e
chore: add localization literals
SalahAdDin Sep 13, 2024
79f3ef7
chore: remove icons
SalahAdDin Sep 13, 2024
a6da027
Merge pull request #13 from SalahAdDin/feat/media-image
SalahAdDin Sep 13, 2024
5035d1a
chore: remove unrequired media type
SalahAdDin Sep 13, 2024
e8a8a2c
chore: add attachment extension and renderers
SalahAdDin Sep 14, 2024
4bb3252
chore: add file setting to editor settings
SalahAdDin Sep 14, 2024
d0454cd
chore: add file button for toolbar
SalahAdDin Sep 14, 2024
b278987
chore: add media helpers
SalahAdDin Sep 14, 2024
6639096
chore: add locale literals
SalahAdDin Sep 14, 2024
681542d
fix: use the right media types
SalahAdDin Sep 14, 2024
b098b43
Merge pull request #14 from SalahAdDin/feat/media-file
SalahAdDin Sep 14, 2024
189c73a
chore: add extension to attachment and handle bulk attachment
SalahAdDin Sep 14, 2024
ffea2ef
chore: add audio Tiptap extension
SalahAdDin Sep 14, 2024
382c3bb
chore: add audio button to toolbar
SalahAdDin Sep 14, 2024
8cc88d5
chore: add settings to enable audio
SalahAdDin Sep 14, 2024
450216d
fix: set the proper name and id properties to audio
SalahAdDin Sep 14, 2024
0c8c5e7
fix: remove "s" to fix the form property
SalahAdDin Sep 14, 2024
da8655f
chore: add empty line for improving readability
SalahAdDin Sep 14, 2024
7332378
refactor: make parsed image as variable
SalahAdDin Sep 14, 2024
7c70c8e
chore: enable audio by settings in toolbar
SalahAdDin Sep 14, 2024
5588d93
chore: add string literals for audio
SalahAdDin Sep 14, 2024
f859dca
chore: small fixes on audio
SalahAdDin Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🛹 Strapi Plugin Rich Text

#### A WYSIWYG editor for your rich text fields
A WYSIWYG editor for your rich text fields.

This Strapi plugin replaces the Markdown editor with a visual, easy-to-use text editor.

Expand All @@ -19,7 +19,7 @@ The plugin stores the content in HTML format. When querying content on the front

## Getting Started

#### Install
### Install

```bash
pnpm install strapi-plugin-rich-text
Expand All @@ -30,6 +30,42 @@ pnpm run build

After this, the `Rich Text` plugin should show up in your list of Plugins in the admin panel.

#### Add the following to the webpack config (/src/admin/webpack.config.js)

This is due to tippy.js doesn't have an ES6 module, and a tiptap depencency imports it as such.

```javascript
config.plugins.push(new webpack.NormalModuleReplacementPlugin(
/^tippy\.js$/,
'tippy.js/dist/tippy-bundle.umd.min.js'
))
```

#### Add the following to middlewares config (/config/middlewares.js)

You need to add "frame-src": ["'self'", "www.youtube.com"] to the content security policy to allow embedding YouTube videos in your Strapi editor.

```javascript
export default [
// other policies
{
name: "strapi::security",
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
"connect-src": ["'self'", "http:", "https:"],
"frame-src": ["'self'", "www.youtube.com"],
upgradeInsecureRequests: null,
},
},
},
},
// other policies
];

```

#### Configuration

| What | How |
Expand All @@ -50,10 +86,8 @@ This project includes an exemplary Strapi installation, which you can use to tes

You can start the development server via `pnpm dev` and access the Strapi admin with the following user credentials:

```
E-Mail Address: [email protected]
Password: dummyAdmin123
```
> E-Mail Address: [email protected]
> Password: dummyAdmin123

The Strapi admin already contains some playgrounds to test the editor.

Expand Down
8 changes: 6 additions & 2 deletions apps/strapi/.strapi/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
import usersPermissions from "@strapi/plugin-users-permissions/strapi-admin";
import i18N from "@strapi/plugin-i18n/strapi-admin";
import strapiCloud from "@strapi/plugin-cloud/strapi-admin";
import strapiPluginRichText from "../../node_modules/strapi-plugin-rich-text/strapi-admin";
import richtextEditor from "../../node_modules/strapi-plugin-rich-text/strapi-admin";
import { renderAdmin } from "@strapi/strapi/admin";

import customisations from "../../src/admin/app.tsx";

renderAdmin(document.getElementById("strapi"), {
customisations,

plugins: {
"users-permissions": usersPermissions,
i18n: i18N,
"strapi-cloud": strapiCloud,
"strapi-plugin-rich-text": strapiPluginRichText,
"richtext-editor": richtextEditor,
},
});
4 changes: 3 additions & 1 deletion apps/strapi/config/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export default [
contentSecurityPolicy: {
useDefaults: true,
directives: {
"frame-src": ["'self'", "https://www.youtube.com"],
"connect-src": ["'self'", "http:", "https:"],
"frame-src": ["'self'", "www.youtube.com"],
upgradeInsecureRequests: null,
},
},
},
Expand Down
9 changes: 8 additions & 1 deletion apps/strapi/config/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
export default {
"strapi-plugin-rich-text": {
"richtext-editor": {
enabled: true,
resolve: "./node_modules/strapi-plugin-rich-text",
config: {
headings: ["h2", "h3", "h4", "h5", "h6"],
other: {
wordcount: true,
saveJson: true,
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
// 'cs',
// 'de',
// 'dk',
// 'es',
"es",
// 'he',
// 'id',
// 'it',
Expand All @@ -22,14 +22,14 @@ export default {
// 'sk',
// 'sv',
// 'th',
// 'tr',
"tr",
// 'uk',
// 'vi',
// 'zh-Hans',
// 'zh',
],
},
bootstrap(app) {
console.log(app);
bootstrap(/* app */) {
// console.log(app);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { IconButton, IconButtonGroup } from "@strapi/design-system/IconButton";
import {
CheckCircle,
CrossCircle,
ExclamationMarkCircle,
Information,
// WarningCircle,
} from "@strapi/icons";
import { Editor, FloatingMenu } from "@tiptap/react";
import { useIntl } from "react-intl";

import { StyledToolbar } from "./StyledToolbar.styles";

export default function AlertToolbar({ editor }: { editor: Editor }) {
const { formatMessage } = useIntl();

return (
<FloatingMenu
editor={editor}
tippyOptions={{ duration: 100 }}
pluginKey="alertToolbar"
shouldShow={({ editor, state }) => {
const { selection } = state;
const { $anchor } = selection;
const isRootDepth = $anchor.depth === 1;

return isRootDepth && editor.isEditable && editor.isActive("alert");
}}
>
<StyledToolbar>
<IconButtonGroup>
<IconButton
icon={<CrossCircle />}
label={formatMessage({
id: "rich-text.editor.toolbar.button.danger",
defaultMessage: "Danger",
})}
onClick={() =>
editor.chain().focus().toggleAlert({ type: "danger" }).run()
}
disabled={
!editor
.can()
.chain()
.focus()
.toggleAlert({ type: "danger" })
.run()
}
className={
editor.isActive("alert", { type: "danger" }) ? "is-active" : ""
}
/>
<IconButton
icon={<Information />}
label={formatMessage({
id: "rich-text.editor.toolbar.button.info",
defaultMessage: "Information",
})}
onClick={() =>
editor.chain().focus().toggleAlert({ type: "info" }).run()
}
disabled={
!editor.can().chain().focus().toggleAlert({ type: "info" }).run()
}
className={
editor.isActive("alert", { type: "info" }) ? "is-active" : ""
}
/>
<IconButton
icon={<CheckCircle />}
label={formatMessage({
id: "rich-text.editor.toolbar.button.success",
defaultMessage: "Success",
})}
onClick={() =>
editor.chain().focus().toggleAlert({ type: "success" }).run()
}
disabled={
!editor
.can()
.chain()
.focus()
.toggleAlert({ type: "success" })
.run()
}
className={
editor.isActive("alert", { type: "success" }) ? "is-active" : ""
}
/>
<IconButton
icon={
// <WarningCircle />
<ExclamationMarkCircle />
}
label={formatMessage({
id: "rich-text.editor.toolbar.button.warning",
defaultMessage: "Warning",
})}
onClick={() =>
editor.chain().focus().toggleAlert({ type: "warning" }).run()
}
disabled={
!editor
.can()
.chain()
.focus()
.toggleAlert({ type: "warning" })
.run()
}
className={
editor.isActive("alert", { type: "warning" }) ? "is-active" : ""
}
/>
</IconButtonGroup>
</StyledToolbar>
</FloatingMenu>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import styled from "styled-components";
import { FILE_EXTENSION_COLORS } from "../../../lib/media";

export const StyledAttachment = styled("div")`
display: flex;
justify-content: space-between;
padding: 1rem;
border-radius: 0.75rem;
border: 1px solid ${({ theme }) => theme.colors.neutral200};
border-style: solid;
align-items: center;
gap: 0.8rem;

.file {
display: flex;
gap: 0.75rem;

.filename {
display: flex;
flex-direction: column;
color: ${({ theme }) => theme.colors.neutral900};

span {
color: ${({ theme }) => theme.colors.neutral500};
}
}
}

.options {
> div {
gap: 0.5rem;
button {
border-radius: 0.75rem;
border: none;

svg {
width: 5rem;
height: 5rem;

path {
fill: transparent !important;
}
}

&.neutral {
color: ${({ theme }) => theme.colors.neutral600};
}

&.danger {
color: ${({ theme }) => theme.colors.danger600};
}
}
}
}
`;

export const ExtensionParagraph = styled.p<{
extension: keyof typeof FILE_EXTENSION_COLORS;
}>`
background-color: ${(props) => FILE_EXTENSION_COLORS[props.extension]};
padding: 0.75rem 0.5rem;
border-radius: 0.5rem;
text-transform: uppercase;
color: white;
font-weight: 700;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { ComponentPropsWithRef, ReactNode, forwardRef, Ref } from "react";

import { formatBytes, type TFileExtension } from "../../../lib/media";

import { ExtensionParagraph, StyledAttachment } from "./Attachment.styles";

export interface AttachmentProps extends ComponentPropsWithRef<"div"> {
/**
* Name of resource or Folder
* */
name?: string;
extension?: TFileExtension;
size?: number;
/**
* Actions attachment
* */
options: ReactNode | undefined;
}

export type AttachmentType = AttachmentProps;

const Attachment = forwardRef(
(
{
name = "Attachment Name",
extension = "",
size = 0,
options,
...restProps
}: AttachmentProps,
ref: Ref<HTMLDivElement>
) => {
return (
<StyledAttachment ref={ref} {...restProps}>
<div className="file">
<ExtensionParagraph extension={extension}>
{extension}
</ExtensionParagraph>
<p className="filename text-truncate">
{name}
<span>{formatBytes(size)}</span>
</p>
</div>
{options && <div className="options">{options}</div>}
</StyledAttachment>
);
}
);

Attachment.displayName = "Attachment";

export default Attachment;
Loading