Skip to content

Commit

Permalink
can't get editorJs to work
Browse files Browse the repository at this point in the history
  • Loading branch information
brentkulwicki committed Nov 19, 2024
1 parent cd2336c commit 3d3efb9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"@babel/plugin-transform-numeric-separator": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.23.2",
"@babel/types": "^7.23.0",
"@editorjs/link-autocomplete": "^0.1.0",
"@emotion/babel-plugin": "^11.11.0",
"@emotion/jest": "^11.11.0",
"@graphql-codegen/add": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Comments/CommentForm/CommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const CommentForm = ({
<RichTextField
name="body"
label="Comment"
tools={['paragraph', 'delimiter', 'marker', 'list']}
tools={['paragraph', 'delimiter', 'marker', 'list', 'mentions']}
placeholder={placeholder}
helperText={false}
/>
Expand Down
20 changes: 20 additions & 0 deletions src/components/RichText/MentionsTool.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { API } from '@editorjs/editorjs';

class MentionsTool {
private readonly api: API;
private element: HTMLDivElement | null;
constructor({ api }: { api: API }) {
this.api = api;
this.element = null;
}

render() {
this.element = document.createElement('div');
this.element.textContent = "I'm a lil div";
this.element.classList.add(this.api.styles.inlineToolButton);
console.log('divvvvvv');
return this.element;
}
}

export default MentionsTool;

Check warning on line 20 in src/components/RichText/MentionsTool.tsx

View workflow job for this annotation

GitHub Actions / run

Prefer named exports
3 changes: 3 additions & 0 deletions src/components/RichText/editorJsTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import SimpleImage from '@editorjs/simple-image';
import Table from '@editorjs/table';
import Warning from '@editorjs/warning';
import { pick } from 'lodash';
import MentionsTool from './MentionsTool';

const defineTools = <T extends EditorConfig['tools']>(tools: T) => tools;

Expand All @@ -39,6 +40,7 @@ export const EDITOR_JS_TOOLS = defineTools({
marker: Marker,
// checkList: CheckList,
delimiter: Delimiter,
mentions: MentionsTool,
// inlineCode: InlineCode,
// simpleImage: SimpleImage,
});
Expand All @@ -52,4 +54,5 @@ export interface BlockDataMap {
paragraph: { text: string };
header: { text: string; level: 1 | 2 | 3 | 4 | 5 | 6 };
list: { style: 'unordered' | 'ordered'; items: string[] };
mentions: { text: string };
}
10 changes: 10 additions & 0 deletions yarn.lock

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

0 comments on commit 3d3efb9

Please sign in to comment.