update: toolbar popup

This commit is contained in:
yanmao 2021-12-29 11:39:11 +08:00
parent 1b98363e75
commit 19021ffdd7
4 changed files with 86 additions and 2 deletions

View File

@ -86,6 +86,7 @@ import {
ToolbarComponent, ToolbarComponent,
fontFamilyDefaultData, fontFamilyDefaultData,
} from '@aomao/toolbar'; } from '@aomao/toolbar';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import Loading from '../loading'; import Loading from '../loading';
import Empty from 'antd/es/empty'; import Empty from 'antd/es/empty';
@ -309,6 +310,86 @@ export const lineHeightOptions: LineHeightOptions = {
}; };
export const pluginConfig: Record<string, PluginOptions> = { export const pluginConfig: Record<string, PluginOptions> = {
[ToolbarPlugin.pluginName]: {
// popup: {
// items: [
// ['undo', 'redo'],
// {
// icon: 'text',
// items: [
// 'bold',
// 'italic',
// 'strikethrough',
// 'underline',
// 'fontsize',
// 'fontcolor',
// 'backcolor',
// 'moremark',
// ],
// },
// [
// {
// type: 'button',
// name: 'image-uploader',
// icon: 'image',
// },
// 'link',
// 'tasklist',
// 'heading',
// ],
// {
// icon: 'more',
// items: [
// {
// type: 'button',
// name: 'video-uploader',
// icon: 'video',
// },
// {
// type: 'button',
// name: 'file-uploader',
// icon: 'attachment',
// },
// {
// type: 'button',
// name: 'table',
// icon: 'table',
// },
// {
// type: 'button',
// name: 'math',
// icon: 'math',
// },
// {
// type: 'button',
// name: 'codeblock',
// icon: 'codeblock',
// },
// {
// type: 'button',
// name: 'orderedlist',
// icon: 'orderedlist',
// },
// {
// type: 'button',
// name: 'unorderedlist',
// icon: 'unorderedlist',
// },
// {
// type: 'button',
// name: 'hr',
// icon: 'hr',
// },
// {
// type: 'button',
// name: 'quote',
// icon: 'quote',
// },
// ],
// },
// ]
// }
},
[Table.pluginName]: tableOptions, [Table.pluginName]: tableOptions,
[MarkRange.pluginName]: markRangeOptions, [MarkRange.pluginName]: markRangeOptions,
[Italic.pluginName]: italicOptions, [Italic.pluginName]: italicOptions,

View File

@ -6,6 +6,8 @@ import {
fontfamily, fontfamily,
} from './config'; } from './config';
import ToolbarPlugin, { ToolbarComponent } from './plugin'; import ToolbarPlugin, { ToolbarComponent } from './plugin';
import type { ToolbarOptions } from './plugin';
import type { ToolbarProps, GroupItemProps, ToolbarItemProps } from './types';
Toolbar.install = (app: App) => { Toolbar.install = (app: App) => {
app.component(Toolbar.name, Toolbar); app.component(Toolbar.name, Toolbar);
@ -19,3 +21,4 @@ export {
fontFamilyDefaultData, fontFamilyDefaultData,
fontfamily, fontfamily,
}; };
export type { ToolbarOptions, ToolbarProps, GroupItemProps, ToolbarItemProps };

View File

@ -1,9 +1,10 @@
import { fontFamilyDefaultData, fontfamily } from './config/toolbar'; import { fontFamilyDefaultData, fontfamily } from './config/toolbar';
import ToolbarPlugin, { ToolbarComponent } from './plugin'; import ToolbarPlugin, { ToolbarComponent } from './plugin';
import type { ToolbarOptions } from './plugin';
import Toolbar from './Toolbar'; import Toolbar from './Toolbar';
import type { ToolbarProps, GroupItemProps, ToolbarItemProps } from './Toolbar'; import type { ToolbarProps, GroupItemProps, ToolbarItemProps } from './Toolbar';
import './index.css'; import './index.css';
export default Toolbar; export default Toolbar;
export { ToolbarPlugin, ToolbarComponent, fontFamilyDefaultData, fontfamily }; export { ToolbarPlugin, ToolbarComponent, fontFamilyDefaultData, fontfamily };
export type { ToolbarProps, GroupItemProps, ToolbarItemProps }; export type { ToolbarProps, GroupItemProps, ToolbarItemProps, ToolbarOptions };

View File

@ -63,7 +63,6 @@ export default class Popup {
let rootRect: DOMRect | undefined = undefined; let rootRect: DOMRect | undefined = undefined;
this.showContent(() => { this.showContent(() => {
rootRect = this.#root.get<HTMLElement>()?.getBoundingClientRect(); rootRect = this.#root.get<HTMLElement>()?.getBoundingClientRect();
console.log(rootRect);
if (!rootRect) { if (!rootRect) {
this.hide(); this.hide();
return; return;