Skip to content

Commit

Permalink
doc: complate
Browse files Browse the repository at this point in the history
  • Loading branch information
lovefields committed Aug 28, 2024
1 parent 41f99e5 commit 3dc0db0
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 16 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,5 @@ bun install --frozen-lockfile
### Dev

```
bun run preview
```

### build

```
bun run generate
bun run dev
```
2 changes: 1 addition & 1 deletion assets/scss/_reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ textarea,
select,
button {
color: #333;
font: normal 12px/1.5 "Pretendard", sans-serif;
font: normal 12px/1.6 "Pretendard", sans-serif;
}
input,
textarea,
Expand Down
101 changes: 96 additions & 5 deletions assets/scss/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
.container {
display: flex;
min-height: calc(100vh - 41px);
color: var(--color-text-default);

a {
color: #0000ff;
}

.section {
display: flex;
Expand All @@ -16,14 +21,100 @@
padding: 40px;
}

.page-title {
color: var(--color-text-default);
font-size: 22px;
h1 {
font-size: 26px;
font-weight: bold;
}

.text {
font-size: 14px;
h2 {
font-size: 20px;
font-weight: 500;
}

h3 {
font-size: 16px;
font-weight: 500;
}

p {
font-size: 16px;

code {
padding: 2px 4px;
background: #f1f1f1;
color: #be1b1b;
}
}

.list {
padding-left: 30px;
color: var(--color-text-default);
font-size: 16px;
}

ul {
list-style: disc;

li {
list-style: inherit;
}
}

.--red {
color: var(--color-text-worrying);
}

pre {
padding: 20px;
color: #adbac7;
background: #22272e;

.title,
.title.--class,
.title.--class.--inherited,
.title.--function {
color: #dcbdfb;
}

.attr,
.attribute,
.literal,
.meta,
.number,
.operator,
.selector-attr,
.selector-class,
.selector-id,
.variable {
color: #6cb6ff;
}

.meta .string,
.regexp,
.string {
color: #96d0ff;
}

.name,
.quote,
.selector-pseudo,
.selector-tag {
color: #8ddb8c;
}

.built-in,
.symbol {
color: #f69d50;
}

.doctag,
.keyword,
.meta .keyword,
.template-tag,
.template-variable,
.type,
.variable.--language {
color: #f47067;
}
}
}
1 change: 1 addition & 0 deletions assets/scss/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--color-text-sub: #666;
--color-border: #f3f3f3;
--color-bg: #f9fafc;
--color-text-worrying: #ff0000;

--size-asdie: 200px;
}
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion components/SiteAside.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<aside class="aside">
<NuxtLink class="link" to="/">Intro</NuxtLink>
<NuxtLink class="link">Method</NuxtLink>
<NuxtLink class="link" to="/method">Method</NuxtLink>
<NuxtLink class="link" to="/option">Option</NuxtLink>
</aside>
</template>

Expand Down
65 changes: 63 additions & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
<template>
<div class="section intro-page">
<h1 class="page-title">Intro</h1>
<p class="text">Dragon Editor is</p>
<h1>Intro</h1>

<p>
Dragon Editor made it just because I needed the WYSIWYG Editor to write on my <NuxtLink to="https://dico.me" target="_blank">blog</NuxtLink>.<br />
This module support only Nuxt3.
</p>

<h2>Dependencies</h2>

<ul class="list">
<li><NuxtLink to="https://nuxt.com/modules/pinia" target="_blank">@pinia&#47;nuxt</NuxtLink></li>
</ul>

<h2>Installation</h2>

<p>Install using the package manager you use.</p>

<pre><code>// npm
npm install dragon-editor

// yarn
yarn add dragon-editor

// bun
bun add dragon-editor</code></pre>

<p>If you complate install then set <code>nuxt.config.ts</code></p>

<pre><code><span class="keyword">export</span> <span class="keyword">default</span> <span class="title --function">defineNuxtConfig</span>({
<span class="attr">modules</span>: [<span class="string">"dragon-editor"</span>],
});</code></pre>

<h2>How to use?</h2>

<h3>Edite Page</h3>

<p>You must use <code>&lt;ClientOnly&gt;</code> component.</p>

<pre><code><span class="tag">&lt;<span class="name">template</span>&gt;</span>
<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"editor-area"</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">ClientOnly</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">DragonEditor</span> <span class="attr">ref</span>=<span class="string">"$editor"</span> &#47;&gt;</span>
<span class="tag">&lt;&#47;<span class="keyword">ClientOnly</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">div</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">template</span>&gt;</span>

<span class="tag">&lt;<span class="name">script</span> <span class="attr">setup</span> <span class="attr">lang</span>=<span class="string">"ts"</span>&gt;</span><span class="language-javascript">
<span class="keyword">const</span> $editor = <span class="symbol">ref</span>&lt;<span class="keyword">DragonEditor</span>&gt;();
</span><span class="tag">&lt;&#47;<span class="name">script</span>&gt;</span></code></pre>

<h3>View Page</h3>

<pre><code><span class="tag">&lt;<span class="name">template</span>&gt;</span>
<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"view-area"</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">DragonEditorViewer</span> <span class="attr">:content</span>=<span class="string">"data"</span> &#47;&gt;</span>
<span class="tag">&lt;&#47;<span class="name">div</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">template</span>&gt;</span>

<span class="tag">&lt;<span class="name">script</span> <span class="attr">setup</span> <span class="attr">lang</span>=<span class="string">"ts"</span>&gt;</span><span class="language-javascript">
<span class="keyword">const</span> data = <span class="symbol">ref</span>&lt;<span class="keyword">DEContentData</span>&gt;([]); <span class="comment">&#47;&#47; content data</span>
</span><span class="tag">&lt;&#47;<span class="name">script</span>&gt;</span></code></pre>

<p><NuxtLink to="/method">See Method</NuxtLink></p>
</div>
</template>
77 changes: 77 additions & 0 deletions pages/method.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<template>
<div class="section method-page">
<h1>Method</h1>

<h2>getContentData</h2>

<p>This method return Editor content data.</p>

<pre><code><span class="tag">&lt;<span class="name">template</span>&gt;</span>
<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"editor-area"</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">ClientOnly</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">DragonEditor</span> <span class="attr">ref</span>=<span class="string">"$editor"</span> &#47;&gt;</span>
<span class="tag">&lt;&#47;<span class="keyword">ClientOnly</span>&gt;</span>
<span class="tag">&lt;<span class="name">button</span> @<span class="attr">click</span>=<span class="string">"<span class="symbol">getData</span>()"</span>&gt;</span>Get Data<span class="tag">&lt;&#47;<span class="name">button</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">div</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">template</span>&gt;</span>

<span class="tag">&lt;<span class="name">script</span> <span class="attr">setup</span> <span class="attr">lang</span>=<span class="string">"ts"</span>&gt;</span><span class="language-javascript">
<span class="keyword">const</span> $editor = <span class="symbol">ref</span>&lt;<span class="keyword">DragonEditor</span>&gt;();

<span class="keyword">function</span> <span class="title --function">getData</span>(<span class="params"></span>) {
<span class="variable --language">console</span>.<span class="title --function">log</span>($editor.<span class="property">value</span>.<span class="title --function">getContentData</span>()); <span class="comment">&#47;&#47; return content data (DEContentData type)</span>
}
</span><span class="tag">&lt;&#47;<span class="name">script</span>&gt;</span></code></pre>

<h2>setContentData</h2>

<p>This method change Editor content data.</p>

<pre><code><span class="tag">&lt;<span class="name">template</span>&gt;</span>
<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"editor-area"</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">ClientOnly</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">DragonEditor</span> <span class="attr">ref</span>=<span class="string">"$editor"</span> &#47;&gt;</span>
<span class="tag">&lt;&#47;<span class="keyword">ClientOnly</span>&gt;</span>
<span class="tag">&lt;<span class="name">button</span> @<span class="attr">click</span>=<span class="string">"<span class="symbol">setData</span>()"</span>&gt;</span>Get Data<span class="tag">&lt;&#47;<span class="name">button</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">div</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">template</span>&gt;</span>

<span class="tag">&lt;<span class="name">script</span> <span class="attr">setup</span> <span class="attr">lang</span>=<span class="string">"ts"</span>&gt;</span><span class="language-javascript">
<span class="keyword">const</span> $editor = <span class="symbol">ref</span>&lt;<span class="keyword">DragonEditor</span>&gt;();

<span class="keyword">function</span> <span class="title --function">setData</span>(<span class="params"></span>) {
$editor.<span class="property">value</span>.<span class="title --function">setContentData</span>([...]); <span class="comment">&#47;&#47; use DEContentData type value</span>
}
</span><span class="tag">&lt;&#47;<span class="name">script</span>&gt;</span></code></pre>

<h2>setDecoration</h2>

<p>This method set text node style.</p>

<h2>setTextAlign</h2>

<p>This method set align style in editable element.</p>

<h2>addBlock</h2>

<p>This method adds blocks supported by the editor to the editor.</p>

<h2>addImageBlock</h2>

<p>This method add image block to the editor.</p>

<pre><code>$editor.<span class="property">value</span>.<span class="title --function">addImageBlock</span>({
<span class="attr">src</span>: <span class="built-in">string</span>;
<span class="attr">width</span>: <span class="built-in">number</span>;
<span class="attr">height</span>: <span class="built-in">number</span>;
<span class="attr">classList</span>?: <span class="built-in">string</span>[];
<span class="attr">caption</span>?: <span class="built-in">string</span>;
});</code></pre>

<h2>addCustomBlock</h2>

<p>This method add custom block to the editor.</p>

<pre><code>$editor.<span class="property">value</span>.<span class="title --function">addCustomBlock</span>(<span class="attr">HTML</span>: <span class="built-in">string</span>, <span class="attr">classList</span>: <span class="built-in">string</span>[] = []);</code></pre>
</div>
</template>
24 changes: 24 additions & 0 deletions pages/option.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div class="section option-page">
<h1>Option</h1>

<h2>useMenuBar</h2>

<p>
If you didn't want use default menu bar. You can set <code>useMenuBar</code> option.<br />
Default value is <code>true</code>
</p>

<pre><code><span class="tag">&lt;<span class="name">template</span>&gt;</span>
<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"editor-area"</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">ClientOnly</span>&gt;</span>
<span class="tag">&lt;<span class="keyword">DragonEditor</span> <span class="attr">:useMenuBar</span>="<span class="string">false</span>" <span class="attr">ref</span>=<span class="string">"$editor"</span> &#47;&gt;</span>
<span class="tag">&lt;&#47;<span class="keyword">ClientOnly</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">div</span>&gt;</span>
<span class="tag">&lt;&#47;<span class="name">template</span>&gt;</span>

<span class="tag">&lt;<span class="name">script</span> <span class="attr">setup</span> <span class="attr">lang</span>=<span class="string">"ts"</span>&gt;</span><span class="language-javascript">
<span class="keyword">const</span> $editor = <span class="symbol">ref</span>&lt;<span class="keyword">DragonEditor</span>&gt;();
</span><span class="tag">&lt;&#47;<span class="name">script</span>&gt;</span></code></pre>
</div>
</template>

0 comments on commit 3dc0db0

Please sign in to comment.