diff --git a/packages/mirinae/src/components.ts b/packages/mirinae/src/components.ts index f74a14c7ec..30dc6104b0 100644 --- a/packages/mirinae/src/components.ts +++ b/packages/mirinae/src/components.ts @@ -76,7 +76,7 @@ export { default as PSearch } from './controls/search/search/PSearch.vue'; export { default as PSelectButton } from './controls/select-button/PSelectButton.vue'; export { default as PSelectCard } from './controls/select-card/PSelectCard.vue'; export { default as PSelectStatus } from './controls/select-status/PSelectStatus.vue'; -export { default as PTextEditor } from './controls/text-editor/PTextEditor.vue'; +export { default as PCodeEditor } from './controls/code-editor/PCodeEditor.vue'; export { default as PTextarea } from './controls/textarea/PTextarea.vue'; export { default as PSlider } from './controls/slider/PSlider.vue'; export { default as PToolbox } from './controls/toolbox/PToolbox.vue'; diff --git a/packages/mirinae/src/controls/code-editor/PCodeEditor.mdx b/packages/mirinae/src/controls/code-editor/PCodeEditor.mdx new file mode 100644 index 0000000000..a5315f99b4 --- /dev/null +++ b/packages/mirinae/src/controls/code-editor/PCodeEditor.mdx @@ -0,0 +1,58 @@ +{/* PCodeEditor.mdx */} + +import { Canvas, Meta, Controls } from '@storybook/blocks'; + +import * as PCodeEditorStories from './PCodeEditor.stories'; + + + + +# Code Editor +
+
+ + +## Basic +
+
+ + +
+
+ +## Loading +
+
+ + +
+
+ +## Highlight Lines +
+
+ + +
+
+ +## Change Code +
+
+ + +
+
+ +## Auto Reformat on Code Change (string only) +
+
+ + +
+
+ + +## Playground + + diff --git a/packages/mirinae/src/controls/text-editor/PTextEditor.stories.ts b/packages/mirinae/src/controls/code-editor/PCodeEditor.stories.ts similarity index 78% rename from packages/mirinae/src/controls/text-editor/PTextEditor.stories.ts rename to packages/mirinae/src/controls/code-editor/PCodeEditor.stories.ts index 9993678f99..37694bd125 100644 --- a/packages/mirinae/src/controls/text-editor/PTextEditor.stories.ts +++ b/packages/mirinae/src/controls/code-editor/PCodeEditor.stories.ts @@ -4,40 +4,41 @@ import type { Meta, StoryObj } from '@storybook/vue'; import type { ComponentProps } from 'vue-component-type-helpers'; import PButton from '@/controls/buttons/button/PButton.vue'; -import { getJsonObject } from '@/controls/text-editor/mock'; +import { getJsonObject } from '@/controls/code-editor/mock'; import { - getTextEditorArgs, getTextEditorParameters, getTextEditorArgTypes, sampleCode, -} from '@/controls/text-editor/story-helper'; + getCodeEditorArgs, getCodeEditorParameters, getCodeEditorArgTypes, sampleCode, +} from '@/controls/code-editor/story-helper'; -import PTextEditor from './PTextEditor.vue'; +import PCodeEditor from './PCodeEditor.vue'; -type PTextEditorPropsAndCustomArgs = ComponentProps; -const meta : Meta = { - title: 'Controls/Text Editor', - component: PTextEditor, +type PCodeEditorPropsAndCustomArgs = ComponentProps; + +const meta : Meta = { + title: 'Controls/Code Editor', + component: PCodeEditor, argTypes: { - ...getTextEditorArgTypes(), + ...getCodeEditorArgTypes(), }, parameters: { - ...getTextEditorParameters(), + ...getCodeEditorParameters(), }, args: { - ...getTextEditorArgs(), + ...getCodeEditorArgs(), }, }; export default meta; -type Story = StoryObj; +type Story = StoryObj; const Template: Story = { render: (args, { argTypes }) => ({ props: Object.keys(argTypes), - components: { PTextEditor }, + components: { PCodeEditor }, template: `
- ({ - components: { PTextEditor }, + components: { PCodeEditor }, template: `
- +
`, setup() { @@ -69,10 +70,10 @@ export const Basic: Story = { export const Loading: Story = { render: () => ({ - components: { PTextEditor, PButton }, + components: { PCodeEditor, PButton }, template: `
- + Load Code!
`, @@ -100,10 +101,10 @@ export const Loading: Story = { export const HighlightLines: Story = { render: () => ({ - components: { PTextEditor }, + components: { PCodeEditor }, template: `
- +
`, setup() { @@ -119,10 +120,10 @@ export const HighlightLines: Story = { export const ChangeCode: Story = { render: () => ({ - components: { PTextEditor }, + components: { PCodeEditor }, template: `
- +
`, @@ -143,10 +144,10 @@ export const ChangeCode: Story = { export const AutoReformatonCodeChangeStringOnly: Story = { render: () => ({ - components: { PTextEditor, PButton }, + components: { PCodeEditor, PButton }, template: `
- + Change Code & Reformat (default) Change Code & Do not Reformat Automatically

This feature works only when the code prop's type is string

diff --git a/packages/mirinae/src/controls/text-editor/PTextEditor.vue b/packages/mirinae/src/controls/code-editor/PCodeEditor.vue similarity index 98% rename from packages/mirinae/src/controls/text-editor/PTextEditor.vue rename to packages/mirinae/src/controls/code-editor/PCodeEditor.vue index f7984b3f9b..5726ca44b2 100644 --- a/packages/mirinae/src/controls/text-editor/PTextEditor.vue +++ b/packages/mirinae/src/controls/code-editor/PCodeEditor.vue @@ -5,7 +5,7 @@ * */ /** - * PTextEditor can get any types, + * PCodeEditor can get any types, * CodeMirror can get String ONLY */ import { @@ -183,7 +183,7 @@ const textareaRef = toRef(state, 'textareaRef'); - +
@@ -257,7 +257,7 @@ export const MenuSlot: Story = { export const ItemSlots: Story = { render: () => ({ props: Object.keys(getContextMenuArgTypes()), - components: { PContextMenu, PI, PTextEditor }, + components: { PContextMenu, PI, PCodeEditor }, template: `
@@ -278,7 +278,7 @@ export const ItemSlots: Story = {
{{slotProps}}
- +
@@ -302,7 +302,7 @@ export const ItemSlots: Story = { export const HeaderSlots: Story = { render: () => ({ props: Object.keys(getContextMenuArgTypes()), - components: { PContextMenu, PI, PTextEditor }, + components: { PContextMenu, PI, PCodeEditor }, template: `
@@ -323,7 +323,7 @@ export const HeaderSlots: Story = {
{{slotProps}}
- +
@@ -367,7 +367,7 @@ export const BottomSlot: Story = { export const SearchSlots: Story = { render: () => ({ props: Object.keys(getContextMenuArgTypes()), - components: { PContextMenu, PEmpty, PTextEditor }, + components: { PContextMenu, PEmpty, PCodeEditor }, template: `
@@ -420,7 +420,7 @@ export const ItemsHeightFixed: Story = { export const HighlightTermAndItemTextListSlot: Story = { render: () => ({ props: Object.keys(getContextMenuArgTypes()), - components: { PContextMenu, PTextEditor }, + components: { PContextMenu, PCodeEditor }, template: `

highlight term: 'o'

@@ -432,7 +432,7 @@ export const HighlightTermAndItemTextListSlot: Story = {

The last item's Slot Props for item-text-list slot with highlight term: 'o'

- +