@pubann/textae 14.1.1 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/{textae-14.1.1.js → textae-14.2.0.js} +221 -183
- package/dist/lib/{textae-14.1.1.min.js → textae-14.2.0.min.js} +18 -18
- package/package.json +2 -2
- /package/dist/lib/css/{textae-14.1.1.css → textae-14.2.0.css} +0 -0
- /package/dist/lib/css/{textae-14.1.1.min.css → textae-14.2.0.min.css} +0 -0
|
@@ -58502,7 +58502,7 @@
|
|
|
58502
58502
|
)
|
|
58503
58503
|
} // ./package.json
|
|
58504
58504
|
|
|
58505
|
-
const package_namespaceObject = { rE: '14.
|
|
58505
|
+
const package_namespaceObject = { rE: '14.2.0' } // ./src/lib/component/SettingDialog/EscapeSequence.js
|
|
58506
58506
|
class EscapeSequence {
|
|
58507
58507
|
static escape(str) {
|
|
58508
58508
|
return str
|
|
@@ -58889,11 +58889,10 @@
|
|
|
58889
58889
|
#spanConfig
|
|
58890
58890
|
#functionAvailability
|
|
58891
58891
|
#clipBoard
|
|
58892
|
-
#editModeSwitch
|
|
58893
58892
|
#horizontal
|
|
58894
58893
|
#vertical
|
|
58895
58894
|
#isActive
|
|
58896
|
-
#
|
|
58895
|
+
#currentEditMode
|
|
58897
58896
|
|
|
58898
58897
|
/**
|
|
58899
58898
|
*
|
|
@@ -58909,31 +58908,19 @@
|
|
|
58909
58908
|
functionAvailability,
|
|
58910
58909
|
clipBoard,
|
|
58911
58910
|
menuState,
|
|
58912
|
-
|
|
58913
|
-
editModeSwitch,
|
|
58914
|
-
editMode
|
|
58911
|
+
currentEditMode
|
|
58915
58912
|
) {
|
|
58916
|
-
eventEmitter
|
|
58917
|
-
.
|
|
58918
|
-
if (startUpOptions.isEditMode && hasMultiTracks) {
|
|
58919
|
-
alertify_default().success(
|
|
58920
|
-
'track annotations have been merged to root annotations.'
|
|
58921
|
-
)
|
|
58922
|
-
}
|
|
58923
|
-
|
|
58924
|
-
editModeSwitch.reset()
|
|
58925
|
-
})
|
|
58926
|
-
.on('textae-event.edit-mode.transition', (mode) => {
|
|
58927
|
-
selectionModel.removeAll()
|
|
58913
|
+
eventEmitter.on('textae-event.edit-mode.transition', (mode) => {
|
|
58914
|
+
selectionModel.removeAll()
|
|
58928
58915
|
|
|
58929
|
-
|
|
58930
|
-
|
|
58931
|
-
|
|
58932
|
-
|
|
58933
|
-
|
|
58934
|
-
|
|
58935
|
-
|
|
58936
|
-
|
|
58916
|
+
switch (mode) {
|
|
58917
|
+
case MODE.VIEW:
|
|
58918
|
+
annotationModel.entityInstanceContainer.clarifyLabelOfAll()
|
|
58919
|
+
break
|
|
58920
|
+
default:
|
|
58921
|
+
annotationModel.entityInstanceContainer.declarifyLabelOfAll()
|
|
58922
|
+
}
|
|
58923
|
+
})
|
|
58937
58924
|
|
|
58938
58925
|
this.#editorHTMLElement = editorHTMLElement
|
|
58939
58926
|
this.#eventEmitter = eventEmitter
|
|
@@ -58944,21 +58931,11 @@
|
|
|
58944
58931
|
this.#spanConfig = spanConfig
|
|
58945
58932
|
this.#functionAvailability = functionAvailability
|
|
58946
58933
|
this.#clipBoard = clipBoard
|
|
58947
|
-
this.#editModeSwitch = editModeSwitch
|
|
58948
58934
|
this.#horizontal = new Horizontal(editorHTMLElement, selectionModel)
|
|
58949
58935
|
this.#vertical = new Vertical(editorHTMLElement, selectionModel)
|
|
58950
58936
|
this.#isActive = false
|
|
58951
|
-
this.#
|
|
58952
|
-
|
|
58953
|
-
forwardMethods(this, () => this.#editModeSwitch, [
|
|
58954
|
-
'toViewMode',
|
|
58955
|
-
'toTermEditMode',
|
|
58956
|
-
'toBlockEditMode',
|
|
58957
|
-
'toRelationEditMode',
|
|
58958
|
-
'toTextEditMode',
|
|
58959
|
-
'toggleSimpleMode',
|
|
58960
|
-
'changeModeByShortcut'
|
|
58961
|
-
])
|
|
58937
|
+
this.#currentEditMode = currentEditMode
|
|
58938
|
+
|
|
58962
58939
|
forwardMethods(this, () => this.#clipBoard, [
|
|
58963
58940
|
'copyEntitiesToLocalClipboard',
|
|
58964
58941
|
'copyEntitiesToSystemClipboard',
|
|
@@ -59014,7 +58991,7 @@
|
|
|
59014
58991
|
}
|
|
59015
58992
|
|
|
59016
58993
|
cancelSelect() {
|
|
59017
|
-
this.#
|
|
58994
|
+
this.#currentEditMode.hidePallet()
|
|
59018
58995
|
this.#selectionModel.removeAll()
|
|
59019
58996
|
// Focus the editor for ESC key
|
|
59020
58997
|
this.#editorHTMLElement.focus()
|
|
@@ -59047,36 +59024,36 @@
|
|
|
59047
59024
|
}
|
|
59048
59025
|
|
|
59049
59026
|
selectLeft(shiftKey) {
|
|
59050
|
-
if (this.#
|
|
59051
|
-
this.#
|
|
59027
|
+
if (this.#currentEditMode.isTypeValuesPalletShown) {
|
|
59028
|
+
this.#currentEditMode.selectLeftAttributeTab()
|
|
59052
59029
|
} else {
|
|
59053
59030
|
this.#horizontal.left(shiftKey)
|
|
59054
59031
|
}
|
|
59055
59032
|
}
|
|
59056
59033
|
|
|
59057
59034
|
selectRight(shiftKey) {
|
|
59058
|
-
if (this.#
|
|
59059
|
-
this.#
|
|
59035
|
+
if (this.#currentEditMode.isTypeValuesPalletShown) {
|
|
59036
|
+
this.#currentEditMode.selectRightAttributeTab()
|
|
59060
59037
|
} else {
|
|
59061
59038
|
this.#horizontal.right(shiftKey)
|
|
59062
59039
|
}
|
|
59063
59040
|
}
|
|
59064
59041
|
|
|
59065
59042
|
selectUp() {
|
|
59066
|
-
if (this.#
|
|
59043
|
+
if (this.#currentEditMode.isEditDenotation) {
|
|
59067
59044
|
this.#vertical.up()
|
|
59068
59045
|
}
|
|
59069
59046
|
}
|
|
59070
59047
|
|
|
59071
59048
|
selectDown() {
|
|
59072
|
-
if (this.#
|
|
59049
|
+
if (this.#currentEditMode.isEditDenotation) {
|
|
59073
59050
|
this.#vertical.down()
|
|
59074
59051
|
}
|
|
59075
59052
|
}
|
|
59076
59053
|
|
|
59077
59054
|
applyTextSelectionWithTouchDevice() {
|
|
59078
59055
|
if (this.#isActive) {
|
|
59079
|
-
this.#
|
|
59056
|
+
this.#currentEditMode.applyTextSelectionWithTouchDevice()
|
|
59080
59057
|
}
|
|
59081
59058
|
}
|
|
59082
59059
|
} // ./src/lib/component/enableHTMLElement.js
|
|
@@ -102882,45 +102859,19 @@ data-button-type="${type}">
|
|
|
102882
102859
|
presenter,
|
|
102883
102860
|
persistenceInterface,
|
|
102884
102861
|
functionAvailability,
|
|
102885
|
-
|
|
102862
|
+
currentEditMode,
|
|
102863
|
+
editModeSwitch
|
|
102886
102864
|
) {
|
|
102887
102865
|
this._map = new Map([
|
|
102888
|
-
[
|
|
102889
|
-
|
|
102890
|
-
|
|
102891
|
-
],
|
|
102892
|
-
[
|
|
102893
|
-
|
|
102894
|
-
|
|
102895
|
-
],
|
|
102896
|
-
[
|
|
102897
|
-
'3',
|
|
102898
|
-
(shiftKey) => editMode.current.manipulateAttribute(3, shiftKey)
|
|
102899
|
-
],
|
|
102900
|
-
[
|
|
102901
|
-
'4',
|
|
102902
|
-
(shiftKey) => editMode.current.manipulateAttribute(4, shiftKey)
|
|
102903
|
-
],
|
|
102904
|
-
[
|
|
102905
|
-
'5',
|
|
102906
|
-
(shiftKey) => editMode.current.manipulateAttribute(5, shiftKey)
|
|
102907
|
-
],
|
|
102908
|
-
[
|
|
102909
|
-
'6',
|
|
102910
|
-
(shiftKey) => editMode.current.manipulateAttribute(6, shiftKey)
|
|
102911
|
-
],
|
|
102912
|
-
[
|
|
102913
|
-
'7',
|
|
102914
|
-
(shiftKey) => editMode.current.manipulateAttribute(7, shiftKey)
|
|
102915
|
-
],
|
|
102916
|
-
[
|
|
102917
|
-
'8',
|
|
102918
|
-
(shiftKey) => editMode.current.manipulateAttribute(8, shiftKey)
|
|
102919
|
-
],
|
|
102920
|
-
[
|
|
102921
|
-
'9',
|
|
102922
|
-
(shiftKey) => editMode.current.manipulateAttribute(9, shiftKey)
|
|
102923
|
-
],
|
|
102866
|
+
['1', (shiftKey) => currentEditMode.manipulateAttribute(1, shiftKey)],
|
|
102867
|
+
['2', (shiftKey) => currentEditMode.manipulateAttribute(2, shiftKey)],
|
|
102868
|
+
['3', (shiftKey) => currentEditMode.manipulateAttribute(3, shiftKey)],
|
|
102869
|
+
['4', (shiftKey) => currentEditMode.manipulateAttribute(4, shiftKey)],
|
|
102870
|
+
['5', (shiftKey) => currentEditMode.manipulateAttribute(5, shiftKey)],
|
|
102871
|
+
['6', (shiftKey) => currentEditMode.manipulateAttribute(6, shiftKey)],
|
|
102872
|
+
['7', (shiftKey) => currentEditMode.manipulateAttribute(7, shiftKey)],
|
|
102873
|
+
['8', (shiftKey) => currentEditMode.manipulateAttribute(8, shiftKey)],
|
|
102874
|
+
['9', (shiftKey) => currentEditMode.manipulateAttribute(9, shiftKey)],
|
|
102924
102875
|
[
|
|
102925
102876
|
'a',
|
|
102926
102877
|
() => functionAvailability.isAvailable('redo') && commander.redo()
|
|
@@ -102943,19 +102894,19 @@ data-button-type="${type}">
|
|
|
102943
102894
|
functionAvailability.isAvailable('new entity') &&
|
|
102944
102895
|
presenter.createEntity()
|
|
102945
102896
|
],
|
|
102946
|
-
['f', () =>
|
|
102897
|
+
['f', () => editModeSwitch.changeModeByShortcut()],
|
|
102947
102898
|
[
|
|
102948
102899
|
'i',
|
|
102949
102900
|
() =>
|
|
102950
102901
|
functionAvailability.isAvailable('import') &&
|
|
102951
102902
|
persistenceInterface.importAnnotation()
|
|
102952
102903
|
],
|
|
102953
|
-
['m', () =>
|
|
102904
|
+
['m', () => editModeSwitch.changeModeByShortcut()],
|
|
102954
102905
|
[
|
|
102955
102906
|
'q',
|
|
102956
102907
|
() =>
|
|
102957
102908
|
functionAvailability.isAvailable('pallet') &&
|
|
102958
|
-
|
|
102909
|
+
currentEditMode.showPallet()
|
|
102959
102910
|
],
|
|
102960
102911
|
[
|
|
102961
102912
|
'r',
|
|
@@ -102973,7 +102924,7 @@ data-button-type="${type}">
|
|
|
102973
102924
|
'w',
|
|
102974
102925
|
() =>
|
|
102975
102926
|
functionAvailability.isAvailable('edit properties') &&
|
|
102976
|
-
|
|
102927
|
+
currentEditMode.editProperties()
|
|
102977
102928
|
],
|
|
102978
102929
|
[
|
|
102979
102930
|
'y',
|
|
@@ -103015,15 +102966,16 @@ data-button-type="${type}">
|
|
|
103015
102966
|
persistenceInterface,
|
|
103016
102967
|
menuState,
|
|
103017
102968
|
annotationModel,
|
|
103018
|
-
|
|
102969
|
+
currentEditMode,
|
|
102970
|
+
editModeSwitch
|
|
103019
102971
|
) {
|
|
103020
102972
|
this._map = new Map([
|
|
103021
|
-
['view mode', () =>
|
|
103022
|
-
['term edit mode', () =>
|
|
103023
|
-
['block edit mode', () =>
|
|
103024
|
-
['relation edit mode', () =>
|
|
103025
|
-
['text edit mode', () =>
|
|
103026
|
-
['simple view', () =>
|
|
102973
|
+
['view mode', () => editModeSwitch.toViewMode()],
|
|
102974
|
+
['term edit mode', () => editModeSwitch.toTermEditMode()],
|
|
102975
|
+
['block edit mode', () => editModeSwitch.toBlockEditMode()],
|
|
102976
|
+
['relation edit mode', () => editModeSwitch.toRelationEditMode()],
|
|
102977
|
+
['text edit mode', () => editModeSwitch.toTextEditMode()],
|
|
102978
|
+
['simple view', () => editModeSwitch.toggleSimpleMode()],
|
|
103027
102979
|
['import', () => persistenceInterface.importAnnotation()],
|
|
103028
102980
|
['upload', () => persistenceInterface.uploadAnnotation()],
|
|
103029
102981
|
['undo', () => commander.undo()],
|
|
@@ -103031,23 +102983,23 @@ data-button-type="${type}">
|
|
|
103031
102983
|
['replicate span annotation', () => presenter.replicate()],
|
|
103032
102984
|
[
|
|
103033
102985
|
'create span by touch',
|
|
103034
|
-
() =>
|
|
102986
|
+
() => currentEditMode.createSpanWithTouchDevice()
|
|
103035
102987
|
],
|
|
103036
102988
|
[
|
|
103037
102989
|
'expand span by touch',
|
|
103038
|
-
() =>
|
|
102990
|
+
() => currentEditMode.expandSpanWithTouchDevice()
|
|
103039
102991
|
],
|
|
103040
102992
|
[
|
|
103041
102993
|
'shrink span by touch',
|
|
103042
|
-
() =>
|
|
102994
|
+
() => currentEditMode.shrinkSpanWithTouchDevice()
|
|
103043
102995
|
],
|
|
103044
102996
|
[
|
|
103045
102997
|
'edit text by touch',
|
|
103046
|
-
() =>
|
|
102998
|
+
() => currentEditMode.editTextWithTouchDevice()
|
|
103047
102999
|
],
|
|
103048
103000
|
['new entity', () => presenter.createEntity()],
|
|
103049
|
-
['edit properties', () =>
|
|
103050
|
-
['pallet', () =>
|
|
103001
|
+
['edit properties', () => currentEditMode.editProperties()],
|
|
103002
|
+
['pallet', () => currentEditMode.showPallet()],
|
|
103051
103003
|
['delete', () => presenter.removeSelectedElements()],
|
|
103052
103004
|
['copy', () => presenter.copyEntitiesToLocalClipboard()],
|
|
103053
103005
|
['cut', () => presenter.cutEntitiesToLocalClipboard()],
|
|
@@ -103953,79 +103905,80 @@ data-button-type="${type}">
|
|
|
103953
103905
|
}
|
|
103954
103906
|
} // ./src/lib/Editor/UseCase/EditModeSwitch/index.js
|
|
103955
103907
|
|
|
103908
|
+
// Switches the edit mode to the specified mode or initial state.
|
|
103956
103909
|
class EditModeSwitch {
|
|
103957
103910
|
#editModeState
|
|
103958
|
-
#annotationModel
|
|
103959
103911
|
#startUpOptions
|
|
103960
|
-
#
|
|
103912
|
+
#relationInstanceContainer
|
|
103913
|
+
#hidePalletHandler
|
|
103961
103914
|
|
|
103962
103915
|
/**
|
|
103963
103916
|
*
|
|
103964
103917
|
* @param {import('../../StartUpOptions').default} startUpOptions
|
|
103965
103918
|
*/
|
|
103966
|
-
constructor(
|
|
103967
|
-
|
|
103968
|
-
|
|
103969
|
-
|
|
103970
|
-
|
|
103919
|
+
constructor(
|
|
103920
|
+
startUpOptions,
|
|
103921
|
+
editModeState,
|
|
103922
|
+
relationInstanceContainer,
|
|
103923
|
+
hidePalletHandler
|
|
103924
|
+
) {
|
|
103971
103925
|
this.#startUpOptions = startUpOptions
|
|
103926
|
+
this.#editModeState = editModeState
|
|
103927
|
+
this.#relationInstanceContainer = relationInstanceContainer
|
|
103928
|
+
this.#hidePalletHandler = hidePalletHandler
|
|
103972
103929
|
}
|
|
103973
103930
|
|
|
103974
103931
|
toViewMode() {
|
|
103975
|
-
this
|
|
103932
|
+
this.#hidePalletHandler()
|
|
103976
103933
|
this.#editModeState.toViewMode(this.#editModeState.nextShowRelation)
|
|
103977
103934
|
}
|
|
103978
103935
|
|
|
103979
103936
|
toTermEditMode() {
|
|
103980
|
-
this
|
|
103937
|
+
this.#hidePalletHandler()
|
|
103981
103938
|
this.#editModeState.toTermEditMode(this.#editModeState.nextShowRelation)
|
|
103982
103939
|
}
|
|
103983
103940
|
|
|
103984
103941
|
toBlockEditMode() {
|
|
103985
|
-
this
|
|
103942
|
+
this.#hidePalletHandler()
|
|
103986
103943
|
this.#editModeState.toBlockEditMode(
|
|
103987
103944
|
this.#editModeState.nextShowRelation
|
|
103988
103945
|
)
|
|
103989
103946
|
}
|
|
103990
103947
|
|
|
103991
103948
|
toRelationEditMode() {
|
|
103992
|
-
this
|
|
103949
|
+
this.#hidePalletHandler()
|
|
103993
103950
|
this.#editModeState.toRelationEditMode()
|
|
103994
103951
|
}
|
|
103995
103952
|
|
|
103996
103953
|
toTextEditMode() {
|
|
103997
|
-
this
|
|
103954
|
+
this.#hidePalletHandler()
|
|
103998
103955
|
this.#editModeState.toTextEditMode(this.#editModeState.nextShowRelation)
|
|
103999
103956
|
}
|
|
104000
103957
|
|
|
104001
103958
|
toggleSimpleMode() {
|
|
104002
|
-
this
|
|
103959
|
+
this.#hidePalletHandler()
|
|
104003
103960
|
this.#editModeState.toggleSimpleMode()
|
|
104004
103961
|
}
|
|
104005
103962
|
|
|
104006
103963
|
changeModeByShortcut() {
|
|
104007
|
-
this
|
|
103964
|
+
this.#hidePalletHandler()
|
|
104008
103965
|
this.#editModeState.changeModeByShortcut()
|
|
104009
103966
|
}
|
|
104010
103967
|
|
|
104011
|
-
get isEditDenotation() {
|
|
104012
|
-
return this.#editMode.isEditDenotation
|
|
104013
|
-
}
|
|
104014
|
-
|
|
104015
103968
|
/**
|
|
104016
103969
|
* For an initiation transition on an annotations data loaded.
|
|
104017
103970
|
*/
|
|
104018
103971
|
reset() {
|
|
104019
103972
|
if (this.#startUpOptions.isEditTermMode) {
|
|
104020
103973
|
this.#editModeState.toTermEditMode(
|
|
104021
|
-
this.#
|
|
103974
|
+
this.#relationInstanceContainer.some
|
|
104022
103975
|
)
|
|
104023
103976
|
return
|
|
104024
103977
|
}
|
|
104025
103978
|
|
|
104026
103979
|
if (this.#startUpOptions.isEditBlockMode) {
|
|
104027
103980
|
this.#editModeState.toBlockEditMode(
|
|
104028
|
-
this.#
|
|
103981
|
+
this.#relationInstanceContainer.some
|
|
104029
103982
|
)
|
|
104030
103983
|
return
|
|
104031
103984
|
}
|
|
@@ -104037,30 +103990,12 @@ data-button-type="${type}">
|
|
|
104037
103990
|
|
|
104038
103991
|
if (this.#startUpOptions.isTextEditMode) {
|
|
104039
103992
|
this.#editModeState.toTextEditMode(
|
|
104040
|
-
this.#
|
|
103993
|
+
this.#relationInstanceContainer.some
|
|
104041
103994
|
)
|
|
104042
103995
|
return
|
|
104043
103996
|
}
|
|
104044
103997
|
|
|
104045
|
-
this.#editModeState.toViewMode(
|
|
104046
|
-
this.#annotationModel.relationInstanceContainer.some
|
|
104047
|
-
)
|
|
104048
|
-
}
|
|
104049
|
-
|
|
104050
|
-
hidePallet() {
|
|
104051
|
-
this.#editMode.current.hidePallet()
|
|
104052
|
-
}
|
|
104053
|
-
|
|
104054
|
-
get isTypeValuesPalletShown() {
|
|
104055
|
-
return this.#editMode.current.isPalletShown
|
|
104056
|
-
}
|
|
104057
|
-
|
|
104058
|
-
selectLeftAttributeTab() {
|
|
104059
|
-
this.#editMode.current.pallet.selectLeftAttributeTab()
|
|
104060
|
-
}
|
|
104061
|
-
|
|
104062
|
-
selectRightAttributeTab() {
|
|
104063
|
-
this.#editMode.current.pallet.selectRightAttributeTab()
|
|
103998
|
+
this.#editModeState.toViewMode(this.#relationInstanceContainer.some)
|
|
104064
103999
|
}
|
|
104065
104000
|
} // ./src/lib/Editor/UseCase/EditModeFactory/clearTextSelection.js
|
|
104066
104001
|
|
|
@@ -104963,6 +104898,7 @@ data-button-type="${type}">
|
|
|
104963
104898
|
get isPalletShown() {
|
|
104964
104899
|
return false
|
|
104965
104900
|
}
|
|
104901
|
+
updateSelectedTextOffsets() {}
|
|
104966
104902
|
} // ./src/lib/component/PromiseDialog.js
|
|
104967
104903
|
|
|
104968
104904
|
class PromiseDialog extends Dialog {
|
|
@@ -110176,9 +110112,9 @@ data-button-type="${type}">
|
|
|
110176
110112
|
eventEmitter,
|
|
110177
110113
|
annotationModel,
|
|
110178
110114
|
selectionModel,
|
|
110115
|
+
spanConfig,
|
|
110179
110116
|
commander,
|
|
110180
110117
|
menuState,
|
|
110181
|
-
spanConfig,
|
|
110182
110118
|
mousePoint
|
|
110183
110119
|
) {
|
|
110184
110120
|
super()
|
|
@@ -110467,31 +110403,71 @@ data-button-type="${type}">
|
|
|
110467
110403
|
get #textBox() {
|
|
110468
110404
|
return this.#editorHTMLElement.querySelector('.textae-editor__text-box')
|
|
110469
110405
|
}
|
|
110470
|
-
} // ./src/lib/Editor/UseCase/EditModeFactory/ViewMode.js
|
|
110406
|
+
} // ./src/lib/Editor/UseCase/EditModeFactory/ViewMode/updateSelection/getTextNodeAtOffset.js
|
|
110407
|
+
|
|
110408
|
+
// Get the text node at a specific offset within a root element.
|
|
110409
|
+
// This function traverses the DOM tree to find the text node and its offset.
|
|
110410
|
+
function getTextNodeAtOffset(rootElement, offset) {
|
|
110411
|
+
let currentOffset = 0
|
|
110412
|
+
|
|
110413
|
+
function traverse(node) {
|
|
110414
|
+
for (const child of node.childNodes) {
|
|
110415
|
+
if (child.nodeType === Node.TEXT_NODE) {
|
|
110416
|
+
const textLength = child.textContent.length
|
|
110417
|
+
if (currentOffset + textLength >= offset) {
|
|
110418
|
+
return {
|
|
110419
|
+
node: child,
|
|
110420
|
+
offset: offset - currentOffset
|
|
110421
|
+
}
|
|
110422
|
+
}
|
|
110423
|
+
currentOffset += textLength
|
|
110424
|
+
} else if (child.nodeType === Node.ELEMENT_NODE) {
|
|
110425
|
+
const result = traverse(child)
|
|
110426
|
+
if (result) return result
|
|
110427
|
+
}
|
|
110428
|
+
}
|
|
110429
|
+
return null
|
|
110430
|
+
}
|
|
110431
|
+
|
|
110432
|
+
return traverse(rootElement)
|
|
110433
|
+
} // ./src/lib/Editor/UseCase/EditModeFactory/ViewMode/updateSelection/index.js
|
|
110434
|
+
|
|
110435
|
+
// This function updates the selection in the document based on the provided offsets.
|
|
110436
|
+
function updateSelection(selection, rootElement, begin, end) {
|
|
110437
|
+
const startNode = getTextNodeAtOffset(rootElement, begin)
|
|
110438
|
+
const endNode = getTextNodeAtOffset(rootElement, end)
|
|
110439
|
+
|
|
110440
|
+
const range = document.createRange()
|
|
110441
|
+
range.setStart(startNode.node, startNode.offset)
|
|
110442
|
+
range.setEnd(endNode.node, endNode.offset)
|
|
110443
|
+
|
|
110444
|
+
selection.removeAllRanges()
|
|
110445
|
+
selection.addRange(range)
|
|
110446
|
+
} // ./src/lib/Editor/UseCase/EditModeFactory/ViewMode/index.js
|
|
110471
110447
|
|
|
110472
110448
|
class ViewMode extends EditModeBase {
|
|
110473
110449
|
#editorHTMLElement
|
|
110450
|
+
#eventEmitter
|
|
110474
110451
|
#annotationModel
|
|
110475
110452
|
#selectedTextStartOffset
|
|
110476
110453
|
#selectedTextEndOffset
|
|
110477
|
-
#
|
|
110454
|
+
#spanConfig
|
|
110455
|
+
#menuState
|
|
110478
110456
|
|
|
110479
|
-
constructor(
|
|
110457
|
+
constructor(
|
|
110458
|
+
editorHTMLElement,
|
|
110459
|
+
eventEmitter,
|
|
110460
|
+
annotationModel,
|
|
110461
|
+
spanConfig,
|
|
110462
|
+
menuState
|
|
110463
|
+
) {
|
|
110480
110464
|
super()
|
|
110481
110465
|
|
|
110482
110466
|
this.#editorHTMLElement = editorHTMLElement
|
|
110467
|
+
this.#eventEmitter = eventEmitter
|
|
110483
110468
|
this.#annotationModel = annotationModel
|
|
110484
|
-
|
|
110485
|
-
this.#
|
|
110486
|
-
this.#updateSelectedTextOffsets()
|
|
110487
|
-
|
|
110488
|
-
eventEmitter.emit('textae-event.editor.selected-text.change')
|
|
110489
|
-
})
|
|
110490
|
-
|
|
110491
|
-
document.addEventListener(
|
|
110492
|
-
'selectionchange',
|
|
110493
|
-
this.#updateSelectedTextHandler
|
|
110494
|
-
)
|
|
110469
|
+
this.#spanConfig = spanConfig
|
|
110470
|
+
this.#menuState = menuState
|
|
110495
110471
|
}
|
|
110496
110472
|
|
|
110497
110473
|
get selectedText() {
|
|
@@ -110522,8 +110498,9 @@ data-button-type="${type}">
|
|
|
110522
110498
|
}
|
|
110523
110499
|
}
|
|
110524
110500
|
|
|
110525
|
-
|
|
110501
|
+
updateSelectedTextOffsets() {
|
|
110526
110502
|
const selection = document.getSelection()
|
|
110503
|
+
|
|
110527
110504
|
if (selection && selection.rangeCount > 0) {
|
|
110528
110505
|
const range = selection.getRangeAt(0)
|
|
110529
110506
|
const textBox = this.#editorHTMLElement.querySelector(
|
|
@@ -110534,15 +110511,22 @@ data-button-type="${type}">
|
|
|
110534
110511
|
textBox.contains(range.startContainer) &&
|
|
110535
110512
|
textBox.contains(range.endContainer)
|
|
110536
110513
|
) {
|
|
110537
|
-
this.#
|
|
110538
|
-
this.#
|
|
110539
|
-
|
|
110540
|
-
|
|
110514
|
+
const { begin, end } = this.#annotationModel.getTextSelection(
|
|
110515
|
+
this.#spanConfig,
|
|
110516
|
+
this.#menuState.textSelectionAdjuster
|
|
110517
|
+
)
|
|
110518
|
+
|
|
110519
|
+
updateSelection(selection, textBox, begin, end)
|
|
110520
|
+
|
|
110521
|
+
this.#selectedTextStartOffset = begin
|
|
110522
|
+
this.#selectedTextEndOffset = end
|
|
110541
110523
|
}
|
|
110542
110524
|
} else {
|
|
110543
110525
|
this.#selectedTextStartOffset = undefined
|
|
110544
110526
|
this.#selectedTextEndOffset = undefined
|
|
110545
110527
|
}
|
|
110528
|
+
|
|
110529
|
+
this.#eventEmitter.emit('textae-event.editor.selected-text.change')
|
|
110546
110530
|
}
|
|
110547
110531
|
} // ./src/lib/Editor/UseCase/EditModeFactory/index.js
|
|
110548
110532
|
|
|
@@ -110552,9 +110536,9 @@ data-button-type="${type}">
|
|
|
110552
110536
|
eventEmitter,
|
|
110553
110537
|
annotationModel,
|
|
110554
110538
|
selectionModel,
|
|
110539
|
+
spanConfig,
|
|
110555
110540
|
commander,
|
|
110556
110541
|
menuState,
|
|
110557
|
-
spanConfig,
|
|
110558
110542
|
mousePoint
|
|
110559
110543
|
) {
|
|
110560
110544
|
return new TermEditMode(
|
|
@@ -110562,9 +110546,9 @@ data-button-type="${type}">
|
|
|
110562
110546
|
eventEmitter,
|
|
110563
110547
|
annotationModel,
|
|
110564
110548
|
selectionModel,
|
|
110549
|
+
spanConfig,
|
|
110565
110550
|
commander,
|
|
110566
110551
|
menuState,
|
|
110567
|
-
spanConfig,
|
|
110568
110552
|
mousePoint
|
|
110569
110553
|
)
|
|
110570
110554
|
}
|
|
@@ -110574,6 +110558,7 @@ data-button-type="${type}">
|
|
|
110574
110558
|
eventEmitter,
|
|
110575
110559
|
annotationModel,
|
|
110576
110560
|
selectionModel,
|
|
110561
|
+
spanConfig,
|
|
110577
110562
|
commander,
|
|
110578
110563
|
menuState,
|
|
110579
110564
|
mousePoint
|
|
@@ -110583,6 +110568,7 @@ data-button-type="${type}">
|
|
|
110583
110568
|
eventEmitter,
|
|
110584
110569
|
annotationModel,
|
|
110585
110570
|
selectionModel,
|
|
110571
|
+
spanConfig,
|
|
110586
110572
|
commander,
|
|
110587
110573
|
menuState,
|
|
110588
110574
|
mousePoint
|
|
@@ -110624,12 +110610,24 @@ data-button-type="${type}">
|
|
|
110624
110610
|
)
|
|
110625
110611
|
}
|
|
110626
110612
|
|
|
110627
|
-
static createViewMode(
|
|
110628
|
-
|
|
110613
|
+
static createViewMode(
|
|
110614
|
+
editorHTMLElement,
|
|
110615
|
+
eventEmitter,
|
|
110616
|
+
annotationModel,
|
|
110617
|
+
spanConfig,
|
|
110618
|
+
menuState
|
|
110619
|
+
) {
|
|
110620
|
+
return new ViewMode(
|
|
110621
|
+
editorHTMLElement,
|
|
110622
|
+
eventEmitter,
|
|
110623
|
+
annotationModel,
|
|
110624
|
+
spanConfig,
|
|
110625
|
+
menuState
|
|
110626
|
+
)
|
|
110629
110627
|
}
|
|
110630
|
-
} // ./src/lib/Editor/UseCase/
|
|
110628
|
+
} // ./src/lib/Editor/UseCase/CurrentEditMode.js
|
|
110631
110629
|
|
|
110632
|
-
class
|
|
110630
|
+
class CurrentEditMode {
|
|
110633
110631
|
#editModeState
|
|
110634
110632
|
#termEditMode
|
|
110635
110633
|
#blockEditMode
|
|
@@ -110653,20 +110651,44 @@ data-button-type="${type}">
|
|
|
110653
110651
|
this.#textEditMode = textEditMode
|
|
110654
110652
|
this.#viewMode = viewMode
|
|
110655
110653
|
|
|
110654
|
+
const updateSelectedTextHandler = debounce300(() =>
|
|
110655
|
+
this.#current.updateSelectedTextOffsets()
|
|
110656
|
+
)
|
|
110657
|
+
|
|
110658
|
+
document.addEventListener('selectionchange', updateSelectedTextHandler)
|
|
110659
|
+
|
|
110656
110660
|
eventEmitter
|
|
110657
110661
|
.on('textae-event.editor.relation.click', (event, relation) =>
|
|
110658
|
-
this
|
|
110662
|
+
this.#current.relationClicked(event, relation)
|
|
110659
110663
|
)
|
|
110660
110664
|
.on('textae-event.editor.relation-bollard.click', (_, entity) =>
|
|
110661
|
-
this
|
|
110665
|
+
this.#current.relationBollardClicked(entity)
|
|
110662
110666
|
)
|
|
110667
|
+
|
|
110668
|
+
forwardMethods(this, () => this.#current, [
|
|
110669
|
+
'showPallet',
|
|
110670
|
+
'hidePallet',
|
|
110671
|
+
'selectLeftAttributeTab',
|
|
110672
|
+
'selectRightAttributeTab',
|
|
110673
|
+
'createSpanWithTouchDevice',
|
|
110674
|
+
'expandSpanWithTouchDevice',
|
|
110675
|
+
'shrinkSpanWithTouchDevice',
|
|
110676
|
+
'editTextWithTouchDevice',
|
|
110677
|
+
'applyTextSelectionWithTouchDevice',
|
|
110678
|
+
'editProperties',
|
|
110679
|
+
'manipulateAttribute'
|
|
110680
|
+
])
|
|
110663
110681
|
}
|
|
110664
110682
|
|
|
110665
110683
|
get isEditDenotation() {
|
|
110666
110684
|
return this.#editModeState.currentState === MODE.EDIT_DENOTATION
|
|
110667
110685
|
}
|
|
110668
110686
|
|
|
110669
|
-
get
|
|
110687
|
+
get isTypeValuesPalletShown() {
|
|
110688
|
+
return this.#current.isPalletShown
|
|
110689
|
+
}
|
|
110690
|
+
|
|
110691
|
+
get #current() {
|
|
110670
110692
|
switch (this.#editModeState.currentState) {
|
|
110671
110693
|
case MODE.EDIT_DENOTATION:
|
|
110672
110694
|
return this.#termEditMode
|
|
@@ -110889,10 +110911,10 @@ data-button-type="${type}">
|
|
|
110889
110911
|
|
|
110890
110912
|
class UseCase {
|
|
110891
110913
|
#contextMenu
|
|
110892
|
-
#presenter
|
|
110893
110914
|
#annotationModel
|
|
110894
110915
|
#editModeState
|
|
110895
110916
|
#viewMode
|
|
110917
|
+
#editModeSwitch
|
|
110896
110918
|
|
|
110897
110919
|
/**
|
|
110898
110920
|
*
|
|
@@ -110907,6 +110929,8 @@ data-button-type="${type}">
|
|
|
110907
110929
|
startUpOptions,
|
|
110908
110930
|
selectionModel
|
|
110909
110931
|
) {
|
|
110932
|
+
this.#annotationModel = annotationModel
|
|
110933
|
+
|
|
110910
110934
|
const spanConfig = new SpanConfig()
|
|
110911
110935
|
|
|
110912
110936
|
// Users can edit model only via commands.
|
|
@@ -110958,9 +110982,9 @@ data-button-type="${type}">
|
|
|
110958
110982
|
eventEmitter,
|
|
110959
110983
|
annotationModel,
|
|
110960
110984
|
selectionModel,
|
|
110985
|
+
spanConfig,
|
|
110961
110986
|
commander,
|
|
110962
110987
|
menuState,
|
|
110963
|
-
spanConfig,
|
|
110964
110988
|
mousePoint
|
|
110965
110989
|
)
|
|
110966
110990
|
const blockEditMode = EditModeFactory.createBlockEditMode(
|
|
@@ -110992,10 +111016,12 @@ data-button-type="${type}">
|
|
|
110992
111016
|
const viewMode = EditModeFactory.createViewMode(
|
|
110993
111017
|
editorHTMLElement,
|
|
110994
111018
|
eventEmitter,
|
|
110995
|
-
annotationModel
|
|
111019
|
+
annotationModel,
|
|
111020
|
+
spanConfig,
|
|
111021
|
+
menuState
|
|
110996
111022
|
)
|
|
110997
111023
|
this.#viewMode = viewMode
|
|
110998
|
-
const
|
|
111024
|
+
const currentEditMode = new CurrentEditMode(
|
|
110999
111025
|
editModeState,
|
|
111000
111026
|
termEditMode,
|
|
111001
111027
|
blockEditMode,
|
|
@@ -111006,11 +111032,25 @@ data-button-type="${type}">
|
|
|
111006
111032
|
)
|
|
111007
111033
|
|
|
111008
111034
|
const editModeSwitch = new EditModeSwitch(
|
|
111009
|
-
annotationModel,
|
|
111010
111035
|
startUpOptions,
|
|
111011
111036
|
editModeState,
|
|
111012
|
-
|
|
111037
|
+
annotationModel.relationInstanceContainer,
|
|
111038
|
+
() => currentEditMode.hidePallet()
|
|
111013
111039
|
)
|
|
111040
|
+
eventEmitter.on(
|
|
111041
|
+
'textae-event.annotation-data.all.change',
|
|
111042
|
+
(hasMultiTracks) => {
|
|
111043
|
+
if (startUpOptions.isEditMode && hasMultiTracks) {
|
|
111044
|
+
alertify_default().success(
|
|
111045
|
+
'track annotations have been merged to root annotations.'
|
|
111046
|
+
)
|
|
111047
|
+
}
|
|
111048
|
+
|
|
111049
|
+
editModeSwitch.reset()
|
|
111050
|
+
}
|
|
111051
|
+
)
|
|
111052
|
+
this.#editModeSwitch = editModeSwitch
|
|
111053
|
+
|
|
111014
111054
|
const presenter = new Presenter(
|
|
111015
111055
|
editorHTMLElement,
|
|
111016
111056
|
eventEmitter,
|
|
@@ -111021,12 +111061,8 @@ data-button-type="${type}">
|
|
|
111021
111061
|
functionAvailability,
|
|
111022
111062
|
clipBoard,
|
|
111023
111063
|
menuState,
|
|
111024
|
-
|
|
111025
|
-
editModeSwitch,
|
|
111026
|
-
editMode
|
|
111064
|
+
currentEditMode
|
|
111027
111065
|
)
|
|
111028
|
-
this.#presenter = presenter
|
|
111029
|
-
this.#annotationModel = annotationModel
|
|
111030
111066
|
|
|
111031
111067
|
const remoteResource = new RemoteSource(eventEmitter)
|
|
111032
111068
|
|
|
@@ -111076,7 +111112,8 @@ data-button-type="${type}">
|
|
|
111076
111112
|
persistenceInterface,
|
|
111077
111113
|
menuState,
|
|
111078
111114
|
annotationModel,
|
|
111079
|
-
|
|
111115
|
+
currentEditMode,
|
|
111116
|
+
editModeSwitch
|
|
111080
111117
|
)
|
|
111081
111118
|
|
|
111082
111119
|
// Add the tool bar
|
|
@@ -111135,7 +111172,8 @@ data-button-type="${type}">
|
|
|
111135
111172
|
presenter,
|
|
111136
111173
|
persistenceInterface,
|
|
111137
111174
|
functionAvailability,
|
|
111138
|
-
|
|
111175
|
+
currentEditMode,
|
|
111176
|
+
editModeSwitch
|
|
111139
111177
|
).handle(event)
|
|
111140
111178
|
}
|
|
111141
111179
|
})
|
|
@@ -111161,7 +111199,7 @@ data-button-type="${type}">
|
|
|
111161
111199
|
}
|
|
111162
111200
|
|
|
111163
111201
|
focusDenotation(denotationID) {
|
|
111164
|
-
this.#
|
|
111202
|
+
this.#editModeSwitch.toTermEditMode()
|
|
111165
111203
|
this.#annotationModel.focusDenotation(denotationID)
|
|
111166
111204
|
}
|
|
111167
111205
|
|