Skip to content

Commit

Permalink
deps(Trix): Move back to official editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Dec 20, 2024
1 parent 83175f4 commit 1b7ad1f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UserProvider from '../components/UserProvider';
import 'react-pdf/dist/esm/Page/TextLayer.css';
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
import 'nprogress/nprogress.css';
import '@opencollective/trix/dist/trix.css';
import 'trix/dist/trix.css';
import '../public/static/styles/app.css';

// config file
Expand Down
10 changes: 6 additions & 4 deletions components/RichTextEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { css } from '@styled-system/css';
import { get, remove } from 'lodash';
import { get } from 'lodash';
import styled from 'styled-components';
import { v4 as uuid } from 'uuid';
import { isURL } from 'validator';
Expand Down Expand Up @@ -272,7 +272,7 @@ export default class RichTextEditor extends React.Component<RichTextEditorProps,

// Load Trix
if (typeof window !== 'undefined') {
this.Trix = require('@opencollective/trix').default; // eslint-disable-line @typescript-eslint/no-var-requires
this.Trix = require('trix').default; // eslint-disable-line @typescript-eslint/no-var-requires
document.addEventListener('trix-before-initialize', this.trixBeforeInitialize);
}
}
Expand Down Expand Up @@ -355,8 +355,10 @@ export default class RichTextEditor extends React.Component<RichTextEditorProps,
trixBeforeInitialize = () => {
this.Trix.config.blockAttributes.heading1 = { tagName: 'h3' };
this.Trix.config.attachments.preview.caption = { name: false, size: false };
remove(this.Trix.config.parser.forbiddenElements, type => type === 'iframe'); // Allow iframes for video embeds
this.Trix.config.parser.allowedAttributes.push('frameborder', 'allowfullscreen');
if (this.props.videoEmbedEnabled) {
this.Trix.config.dompurify.ADD_TAGS = ['iframe']; // Allow iframes for video embeds
this.Trix.config.dompurify.ADD_ATTR = ['allowfullscreen', 'frameborder'];
}
};

trixInitialize = event => {
Expand Down
28 changes: 20 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@hyperwatch/hyperwatch": "4.0.0",
"@icons-pack/react-simple-icons": "^10.0.0",
"@opencollective/taxes": "5.0.0",
"@opencollective/trix": "2.1.6",
"trix": "2.1.11",
"@popperjs/core": "2.11.8",
"@radix-ui/react-accordion": "1.2.1",
"@radix-ui/react-alert-dialog": "1.1.2",
Expand Down
2 changes: 1 addition & 1 deletion pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { WorkspaceProvider } from '../components/WorkspaceProvider';
import 'react-pdf/dist/esm/Page/TextLayer.css';
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
import 'nprogress/nprogress.css';
import '@opencollective/trix/dist/trix.css';
import 'trix/dist/trix.css';
import '../public/static/styles/app.css';
import 'react-lite-youtube-embed/dist/LiteYouTubeEmbed.css';

Expand Down
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"assignees": ["betree"],
"matchPackageNames": [
"@opencollective/taxes",
"@opencollective/trix",
"trix",
"@sentry/**",
"interweave**",
"lottie-react",
Expand Down

0 comments on commit 1b7ad1f

Please sign in to comment.