Skip to content

Commit

Permalink
style: fix markdown code style
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxming committed Jan 12, 2025
1 parent e9b8d04 commit 69b8073
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 93 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default antfu(

'no-restricted-globals': 'off',
'eqeqeq': 'off',
'no-new': 'off',
'no-new-func': 'off',
'no-alert': 'off',
'prefer-promise-reject-errors': 'off',
Expand Down
13 changes: 9 additions & 4 deletions packages/docs/fluent-editor/docs/api/fluent-editor-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ FluentEditor 类继承自 Quill 类,包含了 Quill 类的全部静态变量
- 类型

```typescript
Quill.import(path): any
class Quill {
static import(path): any
}
```

- 详细信息
Expand Down Expand Up @@ -51,9 +53,12 @@ const Link = FluentEditor.import('formats/link')
- 类型

```typescript
Quill.register(format: Attributor | BlotDefinintion, supressWarning: boolean = false)
Quill.register(path: string, def: any, supressWarning: boolean = false)
Quill.register(defs: { [path: string]: any }, supressWarning: boolean = false)
class Quill {
static register(format: Attributor | BlotDefinintion, supressWarning: boolean = false): void
static register(path: string, def: any, supressWarning: boolean = false): void
static register(defs: { [path: string]: any }, supressWarning: boolean = false): void
static register(...args: any[]): void
}
```

- 详细信息
Expand Down
16 changes: 11 additions & 5 deletions packages/docs/fluent-editor/docs/api/fluent-editor-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ Fluent Editor 基于 Quill,因此 Fluent Editor 的实例对象包含 Quill

- 类型

```typescript
getModule(name: string): any
```ts
class Quill {
getModule(name: string): any
}
```

- 详细信息
Expand All @@ -43,7 +45,9 @@ const i18n = quill.getModule('i18n')
- 类型

```typescript
getContents(index: number = 0, length: number = remaining): Delta
class Quill {
getContents(index: number = 0, length: number = remaining): Delta
}
```

- 详细信息
Expand All @@ -65,7 +69,9 @@ const delta = editor.getContents()
- 类型

```typescript
setContents(delta: Delta, source: string = 'api'): Delta
class Quill {
setContents(delta: Delta, source: string = 'api'): Delta
}
```

- 详细信息
Expand All @@ -79,7 +85,7 @@ editor.setContents([
{ insert: 'Hello ' },
{ insert: 'World!', attributes: { bold: true } },
{ insert: '\n' },
]);
])
```

- 参考[内容初始化](/docs/demo/set-content)
Expand Down
8 changes: 4 additions & 4 deletions packages/docs/fluent-editor/docs/api/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ export interface FluentEditorOptions extends QuillOptions {
'better-table'?: boolean | BetterTableOptions

// 字符统计模块
counter: boolean | CounterOption
'counter': boolean | CounterOption

// 表情模块
'emoji-toolbar'?: boolean

// 文件上传模块
file?: boolean
'file'?: boolean

// 可编辑公式模块
mathlive: boolean
'mathlive': boolean

// @提醒模块
mention?: boolean | MentionOptions
'mention'?: boolean | MentionOptions
}

// 是否给超链接自动增加协议前缀
Expand Down
24 changes: 12 additions & 12 deletions packages/docs/fluent-editor/docs/modules/header-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ new FluentEditor('#editor', {
'toolbar': {
container: [[{ header: [null, 1, 2, 3, 4, 5, 6] }, 'header-list']],
handlers: {
'header-list': HeaderList.toolbarHandle
}
'header-list': HeaderList.toolbarHandle,
},
},
'header-list': {
container: document.getElementById('directory'), // 指定一个元素来接收头部列表
Expand All @@ -35,16 +35,16 @@ new FluentEditor('#editor', {

## Options 配置

| 名称 | 类型 | 描述 | 默认值 | 是否必选 |
| --------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------- |
| container | `string \| HTMLElement` | 列表容器,字符串必须是元素的id | - | `true` |
| scrollContainer | `string \| HTMLElement` | 编辑器滚动容器,默认是 `quill.root` | - | `false` |
| hideClass | `number` | 列表隐藏时的类名 | `is-hidden` | `false` |
| topOffset | `number \| () => number` | 从顶部的偏移量(单位为 `px` | `0` | `false` |
| 名称 | 类型 | 描述 | 默认值 | 是否必选 |
| --------------- | ------------------------ | ---------------------------------------------------------------------------- | ----------- | -------- |
| container | `string \| HTMLElement` | 列表容器,字符串必须是元素的id | - | `true` |
| scrollContainer | `string \| HTMLElement` | 编辑器滚动容器,默认是 `quill.root` | - | `false` |
| hideClass | `number` | 列表隐藏时的类名 | `is-hidden` | `false` |
| topOffset | `number \| () => number` | 从顶部的偏移量(单位为 `px`| `0` | `false` |
| headerHeight | `number` | 编辑器中的头部高度,这是用于计算头部滚动高亮的,不要使h1和h6之间的高度差过大 | `36` | `false` |
| onBeforeShow | `() => boolean` | 在显示前触发,返回 `true` 将取消显示 | - | `false` |
| onBeforeHide | `() => boolean` | 在隐藏前触发,返回 `true` 将取消隐藏 | - | `false` |
| onItemClick | `(id: string) => void` | 点击列表项时触发,id是头部元素的id | - | `false` |
| onBeforeShow | `() => boolean` | 在显示前触发,返回 `true` 将取消显示 | - | `false` |
| onBeforeHide | `() => boolean` | 在隐藏前触发,返回 `true` 将取消隐藏 | - | `false` |
| onItemClick | `(id: string) => void` | 点击列表项时触发,id是头部元素的id | - | `false` |

## 其他

Expand All @@ -54,7 +54,7 @@ new FluentEditor('#editor', {
new FluentEditor('#editor', {
theme: 'snow',
modules: {
'toolbar': [[{ header: [null, 1, 2, 3, 4, 5, 6] }, 'header-list'],],
'toolbar': [[{ header: [null, 1, 2, 3, 4, 5, 6] }, 'header-list']],
'header-list': {
container: document.getElementById('directory'), // 指定一个元素来接收头部列表
topOffset: () => {
Expand Down
132 changes: 66 additions & 66 deletions packages/docs/fluent-editor/docs/modules/toolbar-tip.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,88 +13,88 @@ npm install quill-toolbar-tip
如果你想使用英文文本,你可以使用导出名为 `defaultToolbarTip` 的默认提示文本。

```ts
import FluentEditor from "@opentiny/fluent-editor";
import QuillToolbarTip, { defaultToolbarTip } from "quill-toolbar-tip";
import "quill-toolbar-tip/dist/index.css";
import FluentEditor from '@opentiny/fluent-editor'
import QuillToolbarTip, { defaultToolbarTip } from 'quill-toolbar-tip'
import 'quill-toolbar-tip/dist/index.css'

FluentEditor.register(
{
[`modules/${QuillToolbarTip.moduleName}`]: QuillToolbarTip,
},
true
);
true,
)

const QuillToolbarTipOption = {
tipTextMap: defaultToolbarTip["en-US"],
};
tipTextMap: defaultToolbarTip['en-US'],
}

const editor = new FluentEditor("#editor", {
theme: "snow",
const editor = new FluentEditor('#editor', {
theme: 'snow',
modules: {
toolbar: [
["bold", "italic"],
[{ list: "ordered" }, { list: "bullet" }],
[{ script: "sub" }, { script: "super" }],
['bold', 'italic'],
[{ list: 'ordered' }, { list: 'bullet' }],
[{ script: 'sub' }, { script: 'super' }],
[{ color: [] }, { background: [] }],
],
[QuillToolbarTip.moduleName]: QuillToolbarTipOption,
},
});
})
```

或者你可以在 `tipTextMap` 中添加文本以在工具提示中显示。键与工具栏格式名称相匹配。

```ts
import QuillToolbarTip from "quill-toolbar-tip";
import "quill-toolbar-tip/dist/index.css";
import QuillToolbarTip from 'quill-toolbar-tip'
import 'quill-toolbar-tip/dist/index.css'

FluentEditor.register(
{
[`modules/${QuillToolbarTip.moduleName}`]: QuillToolbarTip,
},
true
);
true,
)

const QuillToolbarTipOption = {
tipTextMap: {
bold: "Bold",
italic: "Italic",
bold: 'Bold',
italic: 'Italic',
color: {
onShow(target, value) {
return `Font Color${value ? `: ${value}` : ""}`;
return `Font Color${value ? `: ${value}` : ''}`
},
},
background: {
onShow(target, value) {
return `Background Color${value ? `: ${value}` : ""}`;
return `Background Color${value ? `: ${value}` : ''}`
},
},
},
};
}

const editor = new FluentEditor("#editor", {
theme: "snow",
const editor = new FluentEditor('#editor', {
theme: 'snow',
modules: {
toolbar: [
["bold", "italic"],
[{ list: "ordered" }, { list: "bullet" }],
[{ script: "sub" }, { script: "super" }],
['bold', 'italic'],
[{ list: 'ordered' }, { list: 'bullet' }],
[{ script: 'sub' }, { script: 'super' }],
[{ color: [] }, { background: [] }],
],
[QuillToolbarTip.moduleName]: QuillToolbarTipOption,
},
});
})
```

你可以使用 `key:value` 来设置特定的提示。例如,要为项目符号列表设置提示文本“无序列表”,你可以使用 `'list: bullet': 'Unordered List'`

```ts
const QuillToolbarTipOption = {
tipTextMap: {
"list:ordered": "Ordered List",
"list:bullet": "Unordered List",
'list:ordered': 'Ordered List',
'list:bullet': 'Unordered List',
},
};
}
```

你还可以为键设置一个选项,并使用 `onShow` 来计算工具提示的文本。但是,如果你使用了 `onShow` 选项,`msg` / `content` 或字符串值将被忽略。最终显示的文本将是项的值。
Expand All @@ -105,14 +105,14 @@ const QuillToolbarTipOption = {
script: {
onShow(target, value) {
const text = {
sub: "Subscript",
super: "Superscript",
};
return text[value] || null;
sub: 'Subscript',
super: 'Superscript',
}
return text[value] || null
},
},
},
};
}
```

## Options 配置
Expand All @@ -137,26 +137,26 @@ const QuillToolbarTipOption = {
```ts
interface TooltipOptions {
direction:
| "auto"
| "auto-start"
| "auto-end"
| "top"
| "top-start"
| "top-end"
| "bottom"
| "bottom-start"
| "bottom-end"
| "right"
| "right-start"
| "right-end"
| "left"
| "left-start"
| "left-end";
msg: string;
delay: number;
content: HTMLElement;
className: string | string[];
onShow: (target: HTMLElement) => string | HTMLElement | undefined;
| 'auto'
| 'auto-start'
| 'auto-end'
| 'top'
| 'top-start'
| 'top-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'right'
| 'right-start'
| 'right-end'
| 'left'
| 'left-start'
| 'left-end'
msg: string
delay: number
content: HTMLElement
className: string | string[]
onShow: (target: HTMLElement) => string | HTMLElement | undefined
}
```

Expand All @@ -165,37 +165,37 @@ interface TooltipOptions {
这意味着如果你设置了如下选项,最终显示的文本将是 'C'。

```js
const B = document.createElement("span");
B.textContent = "B";
const B = document.createElement('span')
B.textContent = 'B'

tipTextMap = {
color: {
msg: "A",
msg: 'A',
content: B,
onShow() {
return "C";
return 'C'
},
},
};
}
```

`onShow` 的参数 `value` 是工具栏按钮或选择框的当前值。

```ts
interface TooltipItem extends Omit<TooltipOptions, "onShow"> {
onShow: (target: HTMLElement, value: string) => string | HTMLElement;
interface TooltipItem extends Omit<TooltipOptions, 'onShow'> {
onShow: (target: HTMLElement, value: string) => string | HTMLElement
}
```

`defaultTooltipOptions` 如下所示。

```ts
const tooltipDefaultOptions = {
msg: "",
msg: '',
delay: 150,
direction: "top",
direction: 'top',
className: [] as string[],
};
}
```

想了解更多 quill-toolbar-tip 模块的使用说明,请参考:[https://github.com/opentiny/quill-toolbar-tip](https://github.com/opentiny/quill-toolbar-tip)
2 changes: 0 additions & 2 deletions packages/docs/fluent-editor/docs/used-in-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import FluentEditor from '@opentiny/fluent-editor'
import { onMounted } from 'vue'
onMounted(() => {
// eslint-disable-next-line no-new
new FluentEditor('#editor', {
theme: 'snow',
})
Expand Down Expand Up @@ -106,7 +105,6 @@ export class AppComponent {
title = 'my-app'

ngAfterViewInit() {
// eslint-disable-next-line no-new
new FluentEditor('#editor', {
theme: 'snow',
})
Expand Down

0 comments on commit 69b8073

Please sign in to comment.