๐Ÿ“ Sign Up | ๐Ÿ” Log In

โ† Root | โ†‘ Up

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ ๐Ÿ“„ shadcn/directory/udecode/plate/(plugins)/(marks)/code.cn โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘

title: ไปฃ็ ๆ ผๅผ docs:

  • route: /docs/components/mark-toolbar-button title: ๆ ‡่ฎฐๅทฅๅ…ทๆ ๆŒ‰้’ฎ

<ComponentPreview name="basic-marks-demo" /> <PackageInfo>

ๅŠŸ่ƒฝ็‰นๆ€ง

  • ๆ ผๅผๅŒ–ๅ†…่”ไปฃ็ ็‰‡ๆฎตๅ’ŒๆŠ€ๆœฏๆœฏ่ฏญ
  • ๆ”ฏๆŒๅฟซๆท้”ฎๅฟซ้€Ÿๆ ผๅผๅŒ–
  • ้ป˜่ฎคๆธฒๆŸ“ไธบ <code> HTML ๅ…ƒ็ด 
</PackageInfo>

ๅฅ—ไปถไฝฟ็”จ

<Steps>

ๅฎ‰่ฃ…

ๆœ€ๅฟซๆท็š„ๆ–นๅผๆ˜ฏไฝฟ็”จ BasicMarksKit ๆฅๆทปๅŠ ไปฃ็ ๆ’ไปถ๏ผŒ่ฏฅๅฅ—ไปถๅŒ…ๅซ้ข„้…็ฝฎ็š„ CodePlugin ไปฅๅŠๅ…ถไป–ๅŸบ็ก€ๆ ‡่ฎฐๅŠๅ…ถ Plate UI ็ป„ไปถใ€‚

<ComponentSource name="basic-marks-kit" />
  • CodeLeaf: ๆธฒๆŸ“ๅ†…่”ไปฃ็ ๅ…ƒ็ด 

ๆทปๅŠ ๅฅ—ไปถ

ๅฐ†ๅฅ—ไปถๆทปๅŠ ๅˆฐไฝ ็š„ๆ’ไปถไธญ๏ผš

import { createPlateEditor } from 'platejs/react';
import { BasicMarksKit } from '@/components/editor/plugins/basic-marks-kit';

const editor = createPlateEditor({
  plugins: [
    // ...ๅ…ถไป–ๆ’ไปถ
    ...BasicMarksKit,
  ],
});
</Steps>

ๆ‰‹ๅŠจ้…็ฝฎ

<Steps>

ๅฎ‰่ฃ…

npm install @platejs/basic-nodes

ๆทปๅŠ ๆ’ไปถ

ๅœจๅˆ›ๅปบ็ผ–่พ‘ๅ™จๆ—ถ๏ผŒๅฐ† CodePlugin ๅŒ…ๅซๅˆฐ Plate ๆ’ไปถๆ•ฐ็ป„ไธญใ€‚

import { CodePlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';

const editor = createPlateEditor({
  plugins: [
    // ...ๅ…ถไป–ๆ’ไปถ
    CodePlugin,
  ],
});

้…็ฝฎๆ’ไปถ

ไฝ ๅฏไปฅไธบ CodePlugin ้…็ฝฎ่‡ชๅฎšไน‰็ป„ไปถๅ’Œ้”ฎ็›˜ๅฟซๆท้”ฎใ€‚

import { CodePlugin } from '@platejs/basic-nodes/react';
import { createPlateEditor } from 'platejs/react';
import { CodeLeaf } from '@/components/ui/code-node';

const editor = createPlateEditor({
  plugins: [
    // ...ๅ…ถไป–ๆ’ไปถ
    CodePlugin.configure({
      node: { component: CodeLeaf },
      shortcuts: { toggle: { keys: 'mod+e' } },
    }),
  ],
});
  • node.component: ๆŒ‡ๅฎš CodeLeaf ๆฅๆธฒๆŸ“ๅ†…่”ไปฃ็ ๅ…ƒ็ด 
  • shortcuts.toggle: ๅฎšไน‰็”จไบŽๅˆ‡ๆขไปฃ็ ๆ ผๅผ็š„้”ฎ็›˜ๅฟซๆท้”ฎ

ๆทปๅŠ ๅทฅๅ…ทๆ ๆŒ‰้’ฎ

ไฝ ๅฏไปฅๅœจๅทฅๅ…ทๆ ไธญๆทปๅŠ  MarkToolbarButton ๆฅๅˆ‡ๆขไปฃ็ ๆ ผๅผใ€‚

</Steps>

ๆ’ไปถ

CodePlugin

็”จไบŽๅ†…่”ไปฃ็ ๆ–‡ๆœฌๆ ผๅผๅŒ–็š„ๆ’ไปถใ€‚้ป˜่ฎคๆธฒๆŸ“ไธบ <code> HTML ๅ…ƒ็ด ใ€‚

่ฝฌๆขๆ“ไฝœ

tf.code.toggle

ๅˆ‡ๆขๆ‰€้€‰ๆ–‡ๆœฌ็š„ไปฃ็ ๆ ผๅผใ€‚

โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โ† Root | โ†‘ Up