fix: text shape blur issue

pull/6489/head
Peng Xiao 2022-08-23 14:49:28 +08:00
parent 62e962a4b4
commit 328e9b5a6c
3 changed files with 36 additions and 3 deletions

View File

@ -30,11 +30,12 @@ import { LogseqContext } from '~lib/logseq-context'
export const contextBarActionTypes = [
// Order matters
'Edit',
'ResetBounds',
'Swatch',
'NoFill',
'ResetBounds',
'StrokeType',
'ScaleLevel',
// 'TextStyle',
'YoutubeLink',
'LogseqPortalViewMode',
'ArrowMode',
@ -81,7 +82,6 @@ const EditAction = observer(() => {
type="button"
onClick={() => {
app.api.editShape(shape)
app.api.zoomToSelection()
if (shape.props.type === 'logseq-portal') {
let uuid = shape.props.pageId
if (shape.props.blockType === 'P') {
@ -378,6 +378,37 @@ const ArrowModeAction = observer(() => {
)
})
// const TextStyleAction = observer(() => {
// const app = useApp<Shape>()
// const shapes = filterShapeByAction<TextShape>(
// app.selectedShapesArray,
// 'TextStyle'
// )
// const StrokeTypeOptions: ToggleGroupInputOption[] = [
// {
// value: 'bold',
// icon: 'bold',
// },
// {
// value: 'italic',
// icon: 'italic',
// },
// ]
// const bold = shapes.every(s => s.props.fontWeight > 500 ?)
// const italic = shapes.every(s => s.props.fontStyle === 'italic')
// const value = [startValue ? 'start' : null, endValue ? 'end' : null].filter(isNonNullable)
// return (
// <ToggleInput className="tl-contextbar-button" pressed={noFill} onPressedChange={handleChange}>
// {noFill ? <TablerIcon name="eye-off" /> : <TablerIcon name="eye" />}
// </ToggleInput>
// )
// })
contextBarActionMapping.set('Edit', EditAction)
contextBarActionMapping.set('ResetBounds', ResetBoundsAction)
contextBarActionMapping.set('LogseqPortalViewMode', LogseqPortalViewModeAction)
@ -388,6 +419,7 @@ contextBarActionMapping.set('NoFill', NoFillAction)
contextBarActionMapping.set('Swatch', SwatchAction)
contextBarActionMapping.set('StrokeType', StrokeTypeAction)
contextBarActionMapping.set('ArrowMode', ArrowModeAction)
// contextBarActionMapping.set('TextStyle', TextStyleAction)
const getContextBarActionTypes = (type: ShapeType) => {
return (shapeMapping[type] ?? []).filter(isNonNullable)

View File

@ -485,6 +485,7 @@ export class TLApp<
}
readonly clearEditingShape = (): this => {
this.selectedTool.transition('idle')
return this.setEditingShape()
}

View File

@ -19,7 +19,7 @@ export class EditingShapeState<
onExit = () => {
this.app.persist()
this.app.clearEditingShape()
this.app.setEditingShape()
// Blur all inputs when exit idle
document.querySelectorAll<HTMLElement>('input,textarea').forEach(el => el.blur())