From 28f27bb41b74f7578bdae96c2ec5bf4adde4b1d5 Mon Sep 17 00:00:00 2001 From: Martin Zimandl Date: Mon, 31 Oct 2022 14:19:21 +0100 Subject: [PATCH 1/4] fixed manatee version for release 16 branch --- dockerfiles/Dockerfile.kontext | 2 +- dockerfiles/Dockerfile.kontext-cypress | 2 +- dockerfiles/Dockerfile.kontext-dev | 2 +- dockerfiles/Dockerfile.rqworker | 2 +- dockerfiles/Dockerfile.ws | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dockerfiles/Dockerfile.kontext b/dockerfiles/Dockerfile.kontext index 29aecb1068..912f12ed3f 100644 --- a/dockerfiles/Dockerfile.kontext +++ b/dockerfiles/Dockerfile.kontext @@ -1,4 +1,4 @@ -FROM czcorpus/kontext-manatee:latest +FROM czcorpus/kontext-manatee:2.167.10 SHELL ["/bin/bash", "--login", "-c"] RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash diff --git a/dockerfiles/Dockerfile.kontext-cypress b/dockerfiles/Dockerfile.kontext-cypress index a00f265254..0df0992b00 100644 --- a/dockerfiles/Dockerfile.kontext-cypress +++ b/dockerfiles/Dockerfile.kontext-cypress @@ -1,4 +1,4 @@ -FROM czcorpus/kontext-manatee:latest +FROM czcorpus/kontext-manatee:2.167.10 SHELL ["/bin/bash", "--login", "-c"] RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash diff --git a/dockerfiles/Dockerfile.kontext-dev b/dockerfiles/Dockerfile.kontext-dev index b253068260..0207e8707e 100644 --- a/dockerfiles/Dockerfile.kontext-dev +++ b/dockerfiles/Dockerfile.kontext-dev @@ -1,4 +1,4 @@ -FROM czcorpus/kontext-manatee:latest +FROM czcorpus/kontext-manatee:2.167.10 SHELL ["/bin/bash", "--login", "-c"] RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash diff --git a/dockerfiles/Dockerfile.rqworker b/dockerfiles/Dockerfile.rqworker index cccca3275f..4e22f4ad0e 100644 --- a/dockerfiles/Dockerfile.rqworker +++ b/dockerfiles/Dockerfile.rqworker @@ -1,4 +1,4 @@ -FROM czcorpus/kontext-manatee:latest +FROM czcorpus/kontext-manatee:2.167.10 RUN mkdir /var/log/rq WORKDIR /opt/kontext diff --git a/dockerfiles/Dockerfile.ws b/dockerfiles/Dockerfile.ws index 8c8878b872..c515e3894b 100644 --- a/dockerfiles/Dockerfile.ws +++ b/dockerfiles/Dockerfile.ws @@ -1,4 +1,4 @@ -FROM czcorpus/kontext-manatee:latest +FROM czcorpus/kontext-manatee:2.167.10 RUN pip3 install --upgrade pip && pip3 install aiohttp From 0f7a449d00fdd0b76fe8329ff4c26b654f86a9ca Mon Sep 17 00:00:00 2001 From: Martin Zimandl Date: Mon, 31 Oct 2022 14:20:19 +0100 Subject: [PATCH 2/4] fix handling composition mode in query inputs --- public/files/js/views/cqlEditor.tsx | 36 ++++++++++++++++++++++- public/files/js/views/query/richInput.tsx | 35 +++++++++++++--------- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/public/files/js/views/cqlEditor.tsx b/public/files/js/views/cqlEditor.tsx index cf335436b3..4d458cecd8 100644 --- a/public/files/js/views/cqlEditor.tsx +++ b/public/files/js/views/cqlEditor.tsx @@ -65,6 +65,7 @@ interface CQLEditorCoreState { queries:{[sourceId:string]:AdvancedQuery|SimpleQuery}|unknown; // pquery block -> query downArrowTriggersHistory:{[sourceId:string]:boolean}; cqlEditorMessages:{[sourceId:string]:Array}; + compositionModeOn:boolean; } @@ -151,10 +152,12 @@ export function init(dispatcher:IActionDispatcher, he:Kontext.ComponentHelpers, this.inputKeyDownHandler = this.inputKeyDownHandler.bind(this); this.ffKeyDownHandler = this.ffKeyDownHandler.bind(this); this.handleSelect = this.handleSelect.bind(this); + this.handleCompositionStart = this.handleCompositionStart.bind(this); + this.handleCompositionEnd = this.handleCompositionEnd.bind(this); this.contentEditable = new ContentEditable(this.props.inputRef); } - private handleInputChange() { + private newInputDispatch() { const [rawAnchorIdx, rawFocusIdx] = this.contentEditable.getRawSelection(); const query = this.contentEditable.extractText(); @@ -171,6 +174,35 @@ export function init(dispatcher:IActionDispatcher, he:Kontext.ComponentHelpers, }); } + private handleInputChange() { + if (!this.props.compositionModeOn) { + this.newInputDispatch(); + } + } + + private handleCompositionStart() { + dispatcher.dispatch({ + name: Actions.SetCompositionMode.name, + payload: { + formType: this.props.formType, + status: true + } + }); + } + + private handleCompositionEnd() { + dispatcher.dispatch({ + name: Actions.SetCompositionMode.name, + payload: { + formType: this.props.formType, + status: false + } + }); + // Chrome performs onCompositionEnd action after inputChange + // we have to dispatch new state here + this.newInputDispatch(); + } + private findLinkParent(elm:HTMLElement):HTMLElement { let curr = elm; while (curr !== this.props.inputRef.current) { @@ -361,6 +393,8 @@ export function init(dispatcher:IActionDispatcher, he:Kontext.ComponentHelpers, contentEditable={true} spellCheck={false} onInput={(evt) => this.handleInputChange()} + onCompositionStart={this.handleCompositionStart} + onCompositionEnd={this.handleCompositionEnd} onClick={this.handleEditorClick} className="cql-input" ref={this.props.inputRef} diff --git a/public/files/js/views/query/richInput.tsx b/public/files/js/views/query/richInput.tsx index c6cedc125c..8ea4fdf340 100644 --- a/public/files/js/views/query/richInput.tsx +++ b/public/files/js/views/query/richInput.tsx @@ -81,22 +81,26 @@ export function init( this.handleCompositionEnd = this.handleCompositionEnd.bind(this); } + private newInputDispatch(evt:React.ChangeEvent|React.CompositionEvent) { + const [rawAnchorIdx, rawFocusIdx] = this.contentEditable.getRawSelection(); + const query = this.contentEditable.extractText(); + dispatcher.dispatch({ + name: Actions.QueryInputSetQuery.name, + payload: { + formType: this.props.formType, + sourceId: this.props.sourceId, + query, + rawAnchorIdx, + rawFocusIdx, + insertRange: null + } + }); + } + private handleInputChange(evt:React.ChangeEvent) { if (!this.props.compositionModeOn) { - const [rawAnchorIdx, rawFocusIdx] = this.contentEditable.getRawSelection(); - const query = this.contentEditable.extractText(); - dispatcher.dispatch({ - name: Actions.QueryInputSetQuery.name, - payload: { - formType: this.props.formType, - sourceId: this.props.sourceId, - query, - rawAnchorIdx, - rawFocusIdx, - insertRange: null - } - }); + this.newInputDispatch(evt); } } @@ -238,7 +242,7 @@ export function init( }); } - private handleCompositionEnd() { + private handleCompositionEnd(evt:React.CompositionEvent) { dispatcher.dispatch({ name: Actions.SetCompositionMode.name, payload: { @@ -246,6 +250,9 @@ export function init( status: false } }); + // Chrome performs onCompositionEnd action after inputChange + // we have to dispatch new state here + this.newInputDispatch(evt); } componentDidUpdate(prevProps:RichInputProps & QueryFormModelState, _:unknown) { From 18a281e65dd17d8dbae354f5caf9ac7fcf1aa011 Mon Sep 17 00:00:00 2001 From: Martin Zimandl Date: Mon, 31 Oct 2022 15:12:28 +0100 Subject: [PATCH 3/4] add composition mode to pquery inputs --- public/files/js/models/pquery/common.ts | 9 ++++++--- public/files/js/models/pquery/form.ts | 11 +++++++++++ public/files/js/models/query/filter.ts | 1 - 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/public/files/js/models/pquery/common.ts b/public/files/js/models/pquery/common.ts index ffd795bd5f..ce7fe95ea5 100644 --- a/public/files/js/models/pquery/common.ts +++ b/public/files/js/models/pquery/common.ts @@ -144,6 +144,7 @@ export interface PqueryFormModelState { structAttrs:Array; paramsVisible:boolean; posRangeNotSupported:boolean; // for structural attributes pos range makes no sense + compositionModeOn:boolean; } /** @@ -192,7 +193,7 @@ export function newModelState( type: 'specification', maxNonMatchingRatio: Kontext.newFormValue('0', true) }, - type: 'partial-query' + type: 'partial-query', } ), 2 @@ -222,7 +223,8 @@ export function newModelState( attrs, structAttrs, paramsVisible: true, - posRangeNotSupported: defaultAttr.includes('.') + posRangeNotSupported: defaultAttr.includes('.'), + compositionModeOn: false, }; } @@ -465,7 +467,8 @@ export function storedQueryToModel( attrs, structAttrs, paramsVisible: true, - posRangeNotSupported: sq.attr.includes('.') + posRangeNotSupported: sq.attr.includes('.'), + compositionModeOn: false, } } diff --git a/public/files/js/models/pquery/form.ts b/public/files/js/models/pquery/form.ts index d64bfb35f8..f9f4280763 100644 --- a/public/files/js/models/pquery/form.ts +++ b/public/files/js/models/pquery/form.ts @@ -234,6 +234,17 @@ export class PqueryFormModel extends StatefulModel impleme } ); + this.addActionHandler( + QueryActions.SetCompositionMode, + action => { + this.changeState( + state => { + state.compositionModeOn = action.payload.status; + } + ) + } + ); + this.addActionHandler( QueryActions.QueryInputMoveCursor.name, action => { diff --git a/public/files/js/models/query/filter.ts b/public/files/js/models/query/filter.ts index ecfbbc3a52..4c704d741c 100644 --- a/public/files/js/models/query/filter.ts +++ b/public/files/js/models/query/filter.ts @@ -33,7 +33,6 @@ import { Actions } from './actions'; import { Actions as ConcActions } from '../concordance/actions'; import { Actions as MainMenuActions } from '../mainMenu/actions'; import * as PluginInterfaces from '../../types/plugins'; -import { TextTypesModel } from '../textTypes/main'; import { AjaxConcResponse } from '../concordance/common'; import { QueryType, AnyQuery, AdvancedQuery, SimpleQuery, parseSimpleQuery } from './query'; import { highlightSyntaxStatic } from '../cqleditor/parser'; From 4658f3453bf6b1f9bf087d13a72c69f74ae74ab5 Mon Sep 17 00:00:00 2001 From: Martin Zimandl Date: Tue, 1 Nov 2022 10:28:51 +0100 Subject: [PATCH 4/4] another composition mode fix --- public/files/js/views/cqlEditor.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/public/files/js/views/cqlEditor.tsx b/public/files/js/views/cqlEditor.tsx index 4d458cecd8..1fbd250065 100644 --- a/public/files/js/views/cqlEditor.tsx +++ b/public/files/js/views/cqlEditor.tsx @@ -339,16 +339,18 @@ export function init(dispatcher:IActionDispatcher, he:Kontext.ComponentHelpers, } private handleSelect() { - const [anchorIdx, focusIdx] = this.contentEditable.getRawSelection(); - dispatcher.dispatch({ - name: Actions.QueryInputSelectText.name, - payload: { - sourceId: this.props.sourceId, - formType: this.props.formType, - anchorIdx, - focusIdx - } - }); + if (!this.props.compositionModeOn) { + const [anchorIdx, focusIdx] = this.contentEditable.getRawSelection(); + dispatcher.dispatch({ + name: Actions.QueryInputSelectText.name, + payload: { + sourceId: this.props.sourceId, + formType: this.props.formType, + anchorIdx, + focusIdx + } + }); + } } componentDidUpdate(prevProps, prevState) {