-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/opentiny/fluent-editor into…
… feat-export-quill
- Loading branch information
Showing
8 changed files
with
147 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script setup lang="ts"> | ||
import { onMounted } from 'vue' | ||
import FluentEditor from '@opentiny/fluent-editor' | ||
let editor | ||
onMounted(() => { | ||
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook | ||
import('@opentiny/fluent-editor').then((module) => { | ||
const FluentEditor = module.default | ||
editor = new FluentEditor('#editor-counter-count', { | ||
theme: 'snow', | ||
modules: { | ||
counter: { | ||
count: 2000, | ||
}, | ||
}, | ||
}) | ||
}) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div id="editor-counter-count" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup lang="ts"> | ||
import { onMounted } from 'vue' | ||
import FluentEditor from '@opentiny/fluent-editor' | ||
let editor | ||
onMounted(() => { | ||
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook | ||
import('@opentiny/fluent-editor').then((module) => { | ||
const FluentEditor = module.default | ||
editor = new FluentEditor('#editor', { | ||
theme: 'snow', | ||
modules: { | ||
counter: true, | ||
}, | ||
}) | ||
}) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div id="editor" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import path from 'path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { test, expect } from '@playwright/test' | ||
import path from 'path' | ||
import { fileURLToPath } from 'node:url' | ||
const __filename = fileURLToPath(import.meta.url) | ||
const currentDirectory = path.dirname(__filename); | ||
const currentDirectory = path.dirname(__filename) | ||
const baseUrl = path.dirname(currentDirectory) | ||
|
||
test('image-upload', async ({ page }) => { | ||
await page.goto('http://localhost:5173/fluent-editor/docs/image-upload'); | ||
await page.goto('http://localhost:5173/fluent-editor/docs/image-upload') | ||
|
||
// upload | ||
await page.getByLabel('image').click(); | ||
await page.locator('.ql-toolbar input').setInputFiles(path.join(baseUrl, "public", "logo.png")); | ||
await expect(page.locator('#editor').getByRole('img')).toBeVisible(); | ||
await page.getByLabel('image').first().click() | ||
await page.locator('.ql-toolbar input').setInputFiles(path.join(baseUrl, 'public', 'logo.png')) | ||
await expect(page.locator('#editor').getByRole('img')).toBeVisible() | ||
|
||
// overlay | ||
await page.locator('#editor').getByRole('img').click(); | ||
await expect(page.locator('.blot-formatter__overlay')).toBeVisible(); | ||
await page.locator('#editor').getByRole('img').click() | ||
await expect(page.locator('.blot-formatter__overlay')).toBeVisible() | ||
|
||
// zoom | ||
const move_Distance = 100 | ||
const imageElement = page.locator('#editor').getByRole('img'); | ||
const oldBox = await imageElement.boundingBox() as { x: number, y: number, width: number; height: number; }; | ||
await page.mouse.move(oldBox.x, oldBox.y); | ||
const moveDistance = 100 | ||
const imageElement = page.locator('#editor').getByRole('img') | ||
const oldBox = await imageElement.boundingBox() as { x: number, y: number, width: number, height: number } | ||
await page.mouse.move(oldBox.x, oldBox.y) | ||
await page.mouse.down() | ||
await page.mouse.move(oldBox.x + move_Distance, oldBox.y + move_Distance) | ||
await page.mouse.up(); | ||
const newBox = await imageElement.boundingBox() as { x: number, y: number, width: number; height: number; }; | ||
expect(newBox.width + move_Distance).toEqual(oldBox.width) | ||
expect(newBox.height + move_Distance).toEqual(oldBox.height) | ||
await page.mouse.move(oldBox.x + moveDistance, oldBox.y + moveDistance) | ||
await page.mouse.up() | ||
const newBox = await imageElement.boundingBox() as { x: number, y: number, width: number, height: number } | ||
expect(newBox.width + moveDistance).toEqual(oldBox.width) | ||
expect(newBox.height + moveDistance).toEqual(oldBox.height) | ||
|
||
// remove overlay | ||
await page.mouse.click(newBox.x + newBox.width + 2, newBox.y + newBox.height + 2); | ||
await expect(page.locator('.blot-formatter__overlay')).not.toBeVisible(); | ||
}); | ||
await page.mouse.click(newBox.x + newBox.width + 2, newBox.y + newBox.height + 2) | ||
await expect(page.locator('.blot-formatter__overlay')).not.toBeVisible() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script setup lang="ts"> | ||
import { onMounted } from 'vue' | ||
import FluentEditor from '@opentiny/fluent-editor' | ||
let editor | ||
const TOOLBAR_CONFIG = [ | ||
[{ header: [] }], | ||
['bold', 'italic', 'underline', 'link'], | ||
[{ list: 'ordered' }, { list: 'bullet' }], | ||
['clean'], | ||
['video'], | ||
] | ||
onMounted(() => { | ||
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook | ||
import('@opentiny/fluent-editor').then((module) => { | ||
const FluentEditor = module.default | ||
editor = new FluentEditor('#editor', { | ||
theme: 'snow', | ||
modules: { | ||
toolbar: TOOLBAR_CONFIG, | ||
}, | ||
}) | ||
}) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div id="editor" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 字符统计 | ||
|
||
实时显示编辑器中的字符数。 | ||
|
||
## 基本用法 | ||
|
||
通过配置 `counter` 为 true,可以开启字符统计功能。 | ||
|
||
:::demo src=demos/counter.vue | ||
::: | ||
|
||
## 最大字符数 | ||
|
||
默认最大字符数为 500,通过配置 `count` 属性,可以自定义最大字符数。 | ||
|
||
:::demo src=demos/counter-count.vue | ||
::: | ||
|
||
## API | ||
|
||
`counter` 模块配置项: | ||
|
||
```typescript | ||
interface ICounterOption { | ||
format?: 'text' | 'html' | ||
unit?: 'char' | 'word' | ||
count?: number // 默认为 500 | ||
template?: string | Function | ||
errorTemplate?: string | Function | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 视频 | ||
|
||
通过配置工具栏按钮 `video`,可以开启插入视频功能。 | ||
|
||
测试视频链接:[https://media.w3.org/2010/05/sintel/trailer.mp4](https://media.w3.org/2010/05/sintel/trailer.mp4) | ||
|
||
:::demo src=demos/video.vue | ||
::: |