Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
f764882b
Commit
f764882b
authored
Jul 26, 2016
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ie & edge mode (not tested)
parent
a1d1ad5f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
11 deletions
+102
-11
common/text_input.js
common/text_input.js
+102
-11
No files found.
common/text_input.js
View file @
f764882b
...
...
@@ -80,9 +80,22 @@
preventDefault
:
function
()
{
this
.
_isDefaultPrevented
=
true
;
},
stopPropagation
:
function
()
{
// nothing
}
};
function
ti_console_log
(
_log
)
{
//console.log(_log);
}
function
ti_console_log2
(
_log
)
{
//console.log(_log);
}
function
CTextInput
(
api
)
{
this
.
Api
=
api
;
...
...
@@ -114,7 +127,7 @@
this
.
debugTexBoxMaxW
=
100
;
this
.
debugTexBoxMaxH
=
20
;
this
.
isDebug
=
fals
e
;
this
.
isDebug
=
tru
e
;
this
.
isSystem
=
false
;
this
.
isShow
=
false
;
}
...
...
@@ -298,6 +311,8 @@
{
if
(
this
.
isDebug
||
this
.
isSystem
)
{
ti_console_log
(
"
ti: show
"
);
document
.
getElementById
(
"
area_id_main
"
).
style
.
zIndex
=
10
;
this
.
HtmlArea
.
style
.
top
=
"
0px
"
;
...
...
@@ -318,6 +333,8 @@
{
if
(
this
.
isDebug
||
this
.
isSystem
)
{
ti_console_log
(
"
ti: unshow
"
);
document
.
getElementById
(
"
area_id_main
"
).
style
.
zIndex
=
0
;
this
.
HtmlArea
.
style
.
top
=
((
-
this
.
HtmlAreaOffset
)
+
"
px
"
);
...
...
@@ -444,6 +461,8 @@
var
_value
=
this
.
HtmlArea
.
value
;
if
(
!
this
.
KeyDownFlag
&&
c_oCompositionState
.
end
==
this
.
compositionState
&&
!
this
.
TextInputAfterComposition
&&
_value
!=
""
)
{
ti_console_log
(
"
ti: external input
"
);
this
.
Api
.
Begin_CompositeInput
();
this
.
checkCompositionData
(
this
.
HtmlArea
.
value
);
this
.
Api
.
Replace_CompositeText
(
this
.
compositionValue
);
...
...
@@ -473,6 +492,8 @@
this
.
Api
.
onKeyDown
(
_e
);
this
.
Api
.
onKeyUp
(
_e
);
}
ti_console_log
(
"
ti: ea space
"
);
}
if
(
!
AscCommon
.
AscBrowser
.
isMozilla
)
...
...
@@ -492,6 +513,7 @@
{
if
(
this
.
IsUseFirstTextInputAfterComposition
)
{
ti_console_log
(
"
ti: first textinput after composition
"
);
this
.
onCompositionEnd
(
e
);
this
.
IsUseFirstTextInputAfterComposition
=
false
;
}
...
...
@@ -582,6 +604,8 @@
var
_fontSelections
=
g_fontApplication
.
g_fontSelections
;
var
_language
=
_fontSelections
.
checkText
(
this
.
HtmlArea
.
value
);
ti_console_log
(
"
ti: detect language -
"
+
_language
);
/*
switch (_language)
{
...
...
@@ -699,6 +723,7 @@
{
if
(
this
.
IsUseFirstTextInputAfterComposition
&&
e
.
keyCode
==
8
||
e
.
keyCode
==
46
)
// del, backspace
{
ti_console_log
(
"
ti: keydown emulate composition end (del/backspace)
"
);
this
.
onCompositionEnd
(
e
,
this
.
HtmlArea
.
value
);
this
.
IsUseFirstTextInputAfterComposition
=
false
;
}
...
...
@@ -756,6 +781,7 @@
{
if
(
this
.
IsUseFirstTextInputAfterComposition
&&
e
.
keyCode
==
8
||
e
.
keyCode
==
46
)
// del, backspace
{
ti_console_log
(
"
ti: keyup emulate composition end (del/backspace)
"
);
this
.
onCompositionEnd
(
e
,
this
.
HtmlArea
.
value
);
this
.
IsUseFirstTextInputAfterComposition
=
false
;
...
...
@@ -827,9 +853,28 @@
if
(
this
.
isSystem
)
return
;
this
.
compositionState
=
c_oCompositionState
.
start
;
ti_console_log2
(
"
begin
"
);
if
(
this
.
compositionState
==
c_oCompositionState
.
end
)
this
.
Api
.
Begin_CompositeInput
();
this
.
compositionState
=
c_oCompositionState
.
start
;
this
.
isFirstCompositionUpdateAfterStart
=
true
;
ti_console_log
(
"
ti: onCompositionStart
"
);
if
(
AscCommon
.
AscBrowser
.
isIE
&&
e
.
target
[
"
msGetInputContext
"
])
{
var
ctx
=
e
.
target
[
"
msGetInputContext
"
]();
if
(
undefined
!=
ctx
[
"
compositionStartOffset
"
]
&&
undefined
!=
ctx
[
"
compositionEndOffset
"
]
&&
ctx
[
"
compositionEndOffset
"
]
>
ctx
[
"
compositionStartOffset
"
])
{
// edge: sometimes send start but not sent update
ti_console_log
(
"
ti: onCompositionStart->onCompositionUpdate
"
);
this
.
onCompositionUpdate
(
e
);
}
}
},
onCompositionUpdate
:
function
(
e
,
isLockTarget
,
_data
,
isFromEnd
)
...
...
@@ -837,6 +882,8 @@
if
(
this
.
isSystem
)
return
;
ti_console_log
(
"
ti: onCompositionUpdate:
"
+
e
.
data
);
var
_old
=
this
.
compositionValue
.
splice
(
0
);
if
(
_data
!=
null
)
...
...
@@ -863,18 +910,28 @@
только не добавляем дату в редактор. А очищаем только на onInput, когда нет композиции
*/
var
_offsetData
=
""
;
if
(
undefined
!==
ctx
[
"
compositionStartOffset
"
])
{
this
.
ieNonCompositionPrefix
=
""
;
if
(
0
<
ctx
[
"
compositionStartOffset
"
])
this
.
ieNonCompositionPrefix
=
this
.
HtmlArea
.
value
.
substr
(
0
,
ctx
[
"
compositionStartOffset
"
]);
ti_console_log
(
"
ti: ieNonCompositionPrefix:
"
+
this
.
ieNonCompositionPrefix
);
if
(
this
.
isFirstCompositionUpdateAfterStart
)
{
// нельзя очищать текст HtmlArea на onCompositeEnd, так как может блокироваться следующая композиция
// но тогда может возникать ситуация, когда не сбросилась дата (не пришел onInput не в композиции)
// поэтому первый текст this.ieNonCompositionPrefix после старта копозиции - считаем введенным
this
.
ieNonCompositionPrefixConfirm
=
this
.
ieNonCompositionPrefix
;
ti_console_log
(
"
ti: ieNonCompositionPrefixConfirm1:
"
+
this
.
ieNonCompositionPrefixConfirm
);
}
if
(
ctx
[
"
compositionEndOffset
"
]
>
ctx
[
"
compositionStartOffset
"
])
{
_offsetData
=
this
.
HtmlArea
.
value
.
substr
(
ctx
[
"
compositionStartOffset
"
],
ctx
[
"
compositionEndOffset
"
]
-
ctx
[
"
compositionStartOffset
"
]);
ti_console_log
(
"
ti: msContext offsetData:
"
+
_offsetData
);
}
if
(
this
.
ieNonCompositionPrefix
!=
this
.
ieNonCompositionPrefixConfirm
)
...
...
@@ -882,18 +939,27 @@
var
_newConfirm
=
this
.
ieNonCompositionPrefix
.
substr
(
this
.
ieNonCompositionPrefixConfirm
.
length
);
this
.
ieNonCompositionPrefixConfirm
=
this
.
ieNonCompositionPrefix
;
ti_console_log
(
"
ti: ieNonCompositionPrefixConfirm2:
"
+
this
.
ieNonCompositionPrefixConfirm
);
if
(
true
!==
isFromEnd
)
if
(
true
!==
isFromEnd
||
_offsetData
!=
""
)
{
ti_console_log
(
"
ti: emulateCompositeConfirm:
"
+
_newConfirm
);
this
.
checkCompositionData
(
_newConfirm
);
ti_console_log2
(
"
replace:
"
+
this
.
compositionValue
);
this
.
Api
.
Replace_CompositeText
(
this
.
compositionValue
);
ti_console_log2
(
"
end
"
);
this
.
Api
.
End_CompositeInput
();
ti_console_log2
(
"
begin
"
);
this
.
Api
.
Begin_CompositeInput
();
}
}
}
if
(
AscCommon
.
AscBrowser
.
isIE
&&
e
.
data
==
""
)
this
.
checkCompositionData
(
_offsetData
);
else
this
.
checkCompositionData
(
e
.
data
);
}
}
...
...
@@ -926,6 +992,7 @@
_old
=
this
.
Api
.
Get_CursorPosInCompositeText
();
_max
=
this
.
Api
.
Get_MaxCursorPosInCompositeText
();
}
ti_console_log2
(
"
replace:
"
+
this
.
compositionValue
);
this
.
Api
.
Replace_CompositeText
(
this
.
compositionValue
);
if
(
_isNeedSavePos
)
{
...
...
@@ -954,6 +1021,8 @@
if
(
this
.
isSystem
)
return
;
ti_console_log
(
"
ti: onCompositionEnd
"
);
if
(
!
this
.
IsUseFirstTextInputAfterComposition
&&
this
.
isWaitFirstTextInputEvent
(
e
))
{
// always data == ""
...
...
@@ -961,11 +1030,33 @@
return
;
}
ti_console_log
(
"
ti: onCompositionEnd -> onCompositionUpdate
"
);
this
.
onCompositionUpdate
(
e
,
false
,
_data
,
true
);
this
.
Api
.
Set_CursorPosInCompositeText
(
1000
);
// max
this
.
clear
(
true
);
ti_console_log2
(
"
end
"
);
if
(
AscCommon
.
AscBrowser
.
isIE
&&
e
.
target
[
"
msGetInputContext
"
])
{
var
ctx
=
e
.
target
[
"
msGetInputContext
"
]();
if
(
undefined
!=
ctx
[
"
compositionStartOffset
"
]
&&
undefined
!=
ctx
[
"
compositionEndOffset
"
]
&&
ctx
[
"
compositionEndOffset
"
]
>
ctx
[
"
compositionStartOffset
"
])
{
// edge: не натуральный end!!!
this
.
compositionState
=
c_oCompositionState
.
process
;
return
;
}
else
{
this
.
Api
.
End_CompositeInput
();
}
}
else
{
this
.
Api
.
End_CompositeInput
();
}
this
.
unlockTarget
();
this
.
TextInputAfterComposition
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment