fix(mark-range): filtering or setting a mark causes the card size to change
This commit is contained in:
parent
ff01d7efd6
commit
980d4d2b80
|
@ -368,12 +368,12 @@ export const toolbarOptions: ToolbarOptions = {
|
||||||
// {
|
// {
|
||||||
// type: 'button',
|
// type: 'button',
|
||||||
// name: 'orderedlist',
|
// name: 'orderedlist',
|
||||||
// icon: 'orderedlist',
|
// icon: 'ordered-list',
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// type: 'button',
|
// type: 'button',
|
||||||
// name: 'unorderedlist',
|
// name: 'unordered-list',
|
||||||
// icon: 'unorderedlist',
|
// icon: 'unordered-list',
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// type: 'button',
|
// type: 'button',
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
trigger="click"
|
trigger="click"
|
||||||
overlay-class-name="editor-toolbar-popover"
|
overlay-class-name="editor-toolbar-popover"
|
||||||
:arrow-point-at-center="true"
|
:arrow-point-at-center="true"
|
||||||
:placement="isMobile ? 'topRight' : 'bottom'"
|
:placement="isMobile ? 'topRight' : undefined"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div :class="['editor-toolbar', {'editor-toolbar-mobile': isMobile && !popup,
|
<div :class="['editor-toolbar', {'editor-toolbar-mobile': isMobile && !popup,
|
||||||
|
@ -58,7 +58,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getPopupContainer:() => document.querySelector('.editor-toolbar') || document.body
|
getPopupContainer:() => document.querySelector('.data-toolbar-popup-wrapper') || document.querySelector('.editor-toolbar') || document.body
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
@contextmenu="triggerContextMenu"
|
@contextmenu="triggerContextMenu"
|
||||||
>
|
>
|
||||||
<div class="editor-toolbar-content">
|
<div class="editor-toolbar-content">
|
||||||
<am-group v-for="(group,index) in groups" :key="index" :engine="engine" v-bind="group" />
|
<am-group v-for="(group,index) in groups" :key="index" :engine="engine" :popup="popup" v-bind="group" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
/** ------------------- popup ---------------------- **/
|
/** ------------------- popup ---------------------- **/
|
||||||
|
/** ------------------- popup ---------------------- **/
|
||||||
.data-toolbar-popup-wrapper {
|
.data-toolbar-popup-wrapper {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
|
@ -41,4 +42,19 @@
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: 1px solid #dee0e3;
|
border: 1px solid #dee0e3;
|
||||||
box-shadow: 0 4px 8px 0 rgba(31, 35, 41, 0.1);
|
box-shadow: 0 4px 8px 0 rgba(31, 35, 41, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-toolbar-popup-wrapper .editor-toolbar-popover {
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-toolbar-popup-wrapper .editor-toolbar-popover .ant-popover-inner-content {
|
||||||
|
padding: 4px 0;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid #dee0e3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-toolbar-popup-wrapper .editor-toolbar-popover .ant-popover-arrow {
|
||||||
|
display: none;
|
||||||
}
|
}
|
|
@ -29,6 +29,7 @@ export default class Popup {
|
||||||
if (!isMobile) window.addEventListener('scroll', this.onSelect);
|
if (!isMobile) window.addEventListener('scroll', this.onSelect);
|
||||||
window.addEventListener('resize', this.onSelect);
|
window.addEventListener('resize', this.onSelect);
|
||||||
this.#editor.scrollNode?.on('scroll', this.onSelect);
|
this.#editor.scrollNode?.on('scroll', this.onSelect);
|
||||||
|
document.addEventListener('mousedown', this.hide);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelect = () => {
|
onSelect = () => {
|
||||||
|
@ -140,12 +141,19 @@ export default class Popup {
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide = (event?: MouseEvent) => {
|
||||||
|
if (event?.target) {
|
||||||
|
if (
|
||||||
|
$(event.target).closest('.data-toolbar-popup-wrapper').length >
|
||||||
|
0
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.#root.css({
|
this.#root.css({
|
||||||
left: '0px',
|
left: '0px',
|
||||||
top: '-9999px',
|
top: '-9999px',
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.#root.remove();
|
this.#root.remove();
|
||||||
|
@ -157,6 +165,7 @@ export default class Popup {
|
||||||
if (!isMobile) window.removeEventListener('scroll', this.onSelect);
|
if (!isMobile) window.removeEventListener('scroll', this.onSelect);
|
||||||
window.removeEventListener('resize', this.onSelect);
|
window.removeEventListener('resize', this.onSelect);
|
||||||
this.#editor.scrollNode?.off('scroll', this.onSelect);
|
this.#editor.scrollNode?.off('scroll', this.onSelect);
|
||||||
|
document.removeEventListener('mousedown', this.hide);
|
||||||
if (this.#vm) this.#vm.unmount();
|
if (this.#vm) this.#vm.unmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,7 +322,12 @@ const Toolbar: React.FC<ToolbarProps> = ({
|
||||||
>
|
>
|
||||||
<div className="editor-toolbar-content">
|
<div className="editor-toolbar-content">
|
||||||
{data.map((group, index) => (
|
{data.map((group, index) => (
|
||||||
<ToolbarGroup key={index} engine={engine} {...group} />
|
<ToolbarGroup
|
||||||
|
key={index}
|
||||||
|
engine={engine}
|
||||||
|
popup={popup}
|
||||||
|
{...group}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -70,10 +70,10 @@ const ToolbarGroup: React.FC<GroupProps> = ({
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
getPopupContainer={() =>
|
getPopupContainer={() =>
|
||||||
|
document.querySelector('.data-toolbar-popup-wrapper') ||
|
||||||
document.querySelector('.editor-toolbar') ||
|
document.querySelector('.editor-toolbar') ||
|
||||||
document.body
|
document.body
|
||||||
}
|
}
|
||||||
trigger="click"
|
|
||||||
overlayClassName="editor-toolbar-popover"
|
overlayClassName="editor-toolbar-popover"
|
||||||
content={
|
content={
|
||||||
<div
|
<div
|
||||||
|
@ -87,7 +87,7 @@ const ToolbarGroup: React.FC<GroupProps> = ({
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
arrowPointAtCenter
|
arrowPointAtCenter
|
||||||
placement={isMobile ? 'topRight' : 'bottom'}
|
placement={isMobile ? 'topRight' : undefined}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
name="group-popover"
|
name="group-popover"
|
||||||
|
|
|
@ -41,4 +41,19 @@
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: 1px solid #dee0e3;
|
border: 1px solid #dee0e3;
|
||||||
box-shadow: 0 4px 8px 0 rgba(31, 35, 41, 0.1);
|
box-shadow: 0 4px 8px 0 rgba(31, 35, 41, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-toolbar-popup-wrapper .editor-toolbar-popover {
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-toolbar-popup-wrapper .editor-toolbar-popover .ant-popover-inner-content {
|
||||||
|
padding: 4px 0;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid #dee0e3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-toolbar-popup-wrapper .editor-toolbar-popover .ant-popover-arrow {
|
||||||
|
display: none;
|
||||||
}
|
}
|
|
@ -29,6 +29,7 @@ export default class Popup {
|
||||||
if (!isMobile) window.addEventListener('scroll', this.onSelect);
|
if (!isMobile) window.addEventListener('scroll', this.onSelect);
|
||||||
window.addEventListener('resize', this.onSelect);
|
window.addEventListener('resize', this.onSelect);
|
||||||
this.#editor.scrollNode?.on('scroll', this.onSelect);
|
this.#editor.scrollNode?.on('scroll', this.onSelect);
|
||||||
|
document.addEventListener('mousedown', this.hide);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelect = () => {
|
onSelect = () => {
|
||||||
|
@ -146,12 +147,19 @@ export default class Popup {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide = (event?: MouseEvent) => {
|
||||||
|
if (event?.target) {
|
||||||
|
if (
|
||||||
|
$(event.target).closest('.data-toolbar-popup-wrapper').length >
|
||||||
|
0
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.#root.css({
|
this.#root.css({
|
||||||
left: '0px',
|
left: '0px',
|
||||||
top: '-9999px',
|
top: '-9999px',
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.#root.remove();
|
this.#root.remove();
|
||||||
|
@ -163,6 +171,7 @@ export default class Popup {
|
||||||
if (!isMobile) window.removeEventListener('scroll', this.onSelect);
|
if (!isMobile) window.removeEventListener('scroll', this.onSelect);
|
||||||
window.removeEventListener('resize', this.onSelect);
|
window.removeEventListener('resize', this.onSelect);
|
||||||
this.#editor.scrollNode?.off('scroll', this.onSelect);
|
this.#editor.scrollNode?.off('scroll', this.onSelect);
|
||||||
|
document.removeEventListener('mousedown', this.hide);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export type { GroupItemProps };
|
export type { GroupItemProps };
|
||||||
|
|
|
@ -641,7 +641,8 @@ export default class<T extends MarkRangeOptions> extends MarkPlugin<T> {
|
||||||
const container = this.editor.container.clone(value ? false : true);
|
const container = this.editor.container.clone(value ? false : true);
|
||||||
container.css({
|
container.css({
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
top: 0,
|
top: '-999px',
|
||||||
|
width: '100%',
|
||||||
clip: 'rect(0, 0, 0, 0)',
|
clip: 'rect(0, 0, 0, 0)',
|
||||||
});
|
});
|
||||||
$(document.body).append(container);
|
$(document.body).append(container);
|
||||||
|
@ -745,7 +746,8 @@ export default class<T extends MarkRangeOptions> extends MarkPlugin<T> {
|
||||||
if (value) value = Selection.removeTags(value);
|
if (value) value = Selection.removeTags(value);
|
||||||
container.css({
|
container.css({
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
top: 0,
|
top: '-999px',
|
||||||
|
width: '100%',
|
||||||
clip: 'rect(0, 0, 0, 0)',
|
clip: 'rect(0, 0, 0, 0)',
|
||||||
});
|
});
|
||||||
$(document.body).append(container);
|
$(document.body).append(container);
|
||||||
|
|
Loading…
Reference in New Issue