Skip to content

Commit 9594175

Browse files
committed
added: Inline Editor and story
1 parent d90eb90 commit 9594175

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

stories/InlineEditor.stories.jsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import InlineEditor from "./InlineEditor";
2+
3+
export default {
4+
title: 'Supercode/InlineEditor',
5+
component: InlineEditor,
6+
parameters: {
7+
layout: 'centered',
8+
},
9+
tags: ['autodocs'],
10+
};
11+
12+
const dummyText = `
13+
<p>Dear John,</p>
14+
<p>This is an open letter to John Doe. So Picture this: you, yes, YOU, have become the unwitting superstar of the developer world. Your name is spreading faster than gossip at a family reunion. But here's the kicker&mdash;you're not involved! Nope, nada, zilch. It's like your name decided to ditch you for a more exciting life in coding.</p>
15+
<p>Now, before you start imagining yourself as the next Elon Musk of programming, let me give you the scoop. Developers from all corners of the globe are using your name in their code as placeholders, variables, or test data. It's like they've formed a secret society where the password is... well, your name.</p>
16+
<p>Think about it: somewhere out there, there's a developer typing away at their keyboard, probably sipping on a lukewarm cup of coffee, and suddenly, your name pops up on their screen. They chuckle, thinking they're oh-so-clever, while you're probably just wondering what on earth is going on.</p>
17+
<p>So, here's the deal: you're now officially a coding legend. Congrats! If you ever decide to switch careers and become a developer, you've got a head start. But until then, just know that your name is making waves in the most unexpected places.</p>
18+
<p>Stay awesome, John Doe, and remember, if you ever need a crash course in coding, you know who to call.</p>
19+
<p>Regards, <br>AI that is going to take all the jobs.</p>
20+
`
21+
export const SupercodePlugin = {
22+
args: {
23+
skin: 'oxide',
24+
value: dummyText
25+
},
26+
argTypes: {
27+
skin: {
28+
options: ['oxide', 'oxide-dark'],
29+
control: { type: 'select' }
30+
}
31+
}
32+
};

stories/InlineEditor.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React, { useRef } from 'react';
2+
import { Editor } from '@tinymce/tinymce-react';
3+
import '../public/tinymce/tinymce.js'
4+
5+
/**
6+
* Supercode utilizes an elegant modal as a fallback when tinymce editor version is below v5 where 'Custom Views' are not supported or editor is set to inline mode.
7+
*/
8+
9+
export default function TinymceEditor({ skin = 'oxide', value}) {
10+
const commonConfiguration = {
11+
skin,
12+
base_url: '/tinymce',
13+
promotion: false,
14+
statusbar: false,
15+
menubar: false,
16+
highlight_on_focus: false,
17+
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }',
18+
}
19+
20+
return (
21+
<div style={{background: 'white', color: ' #283747 ', padding: '1rem', borderRadius: '1rem', maxWidth: '50rem'}}>
22+
<div style={{display: 'flex', gap: '15px'}}>
23+
<h1>Subject: </h1>
24+
<Editor
25+
inline
26+
initialValue={"<h1>An Open letter to John Doe</h1>"}
27+
init={{...commonConfiguration,
28+
plugins: [
29+
'advlist', 'autolink', 'lists', 'link', 'anchor',
30+
'searchreplace', 'visualblocks', 'table', 'help', 'supercode'
31+
],
32+
toolbar: 'undo redo | blocks | ' +
33+
'bold italic forecolor | alignleft aligncenter ' +
34+
'alignright alignjustify | bullist numlist outdent indent | ' +
35+
'supercode',
36+
highlight_on_focus: false,
37+
}}
38+
/>
39+
</div>
40+
<h4>Write your content below</h4>
41+
<div style={{background: ' #eaeded ', padding: '0.5rem', borderRadius: '5px', marginBottom: '1.5rem'}}>
42+
<Editor
43+
inline
44+
initialValue={value ?? "<h1>Hello World</h1><p>This is the initial content of the editor.</p>"}
45+
init={{...commonConfiguration,
46+
plugins: [
47+
'advlist', 'autolink', 'lists', 'link', 'anchor',
48+
'searchreplace', 'visualblocks', 'table', 'help', 'supercode'
49+
],
50+
toolbar: 'undo redo | blocks | ' +
51+
'bold italic forecolor | alignleft aligncenter ' +
52+
'alignright alignjustify | bullist numlist outdent indent | ' +
53+
'supercode',
54+
highlight_on_focus: false,
55+
}}
56+
/>
57+
</div>
58+
</div>
59+
);
60+
}

0 commit comments

Comments
 (0)