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
1b109e14
Commit
1b109e14
authored
Jun 09, 2016
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ввод иероглифов - правильное место курсора
parent
d9860e44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
8 deletions
+93
-8
common/apiBase.js
common/apiBase.js
+7
-0
common/text_input.js
common/text_input.js
+86
-8
No files found.
common/apiBase.js
View file @
1b109e14
...
...
@@ -117,6 +117,8 @@
this
.
pluginsManager
=
null
;
this
.
isLockTargetUpdate
=
false
;
return
this
;
}
...
...
@@ -227,6 +229,11 @@
baseEditorsApi
.
prototype
.
asc_IsFocus
=
function
(
bIsNaturalFocus
)
{
};
// target pos
baseEditorsApi
.
prototype
.
asc_LockTargetUpdate
=
function
(
isLock
)
{
this
.
isLockTargetUpdate
=
isLock
;
};
// Просмотр PDF
baseEditorsApi
.
prototype
.
isPdfViewer
=
function
()
{
...
...
common/text_input.js
View file @
1b109e14
...
...
@@ -21,6 +21,7 @@
this
.
HtmlAreaOffset
=
60
;
this
.
Listener
=
null
;
this
.
LockerTargetTimer
=
-
1
;
this
.
KeyDownFlag
=
false
;
}
...
...
@@ -67,21 +68,29 @@
var
oThis
=
this
;
this
.
HtmlArea
[
"
onkeydown
"
]
=
function
(
e
)
{
return
oThis
.
onKeyDown
(
e
);
};
this
.
HtmlArea
[
"
onkeypress
"
]
=
function
(
e
)
{
return
oThis
.
onKeyPress
(
e
);
};
this
.
HtmlArea
[
"
onkeyup
"
]
=
function
(
e
)
{
return
oThis
.
onKeyUp
(
e
);
};
this
.
HtmlArea
[
"
oninput
"
]
=
function
(
e
)
{
return
oThis
.
onInput
(
e
);
};
//this.HtmlArea["oncompositionstart"] = function(e) { return oThis.onCompositionStart(e); };
//this.HtmlArea["oncompositionupdate"] = function(e) { return oThis.onCompositionUpdate(e); };
//this.HtmlArea["oncompositionend"] = function(e) { return oThis.onCompositionEnd(e); };
this
.
HtmlArea
.
addEventListener
(
"
compositionstart
"
,
function
(
e
)
{
return
oThis
.
onCompositionStart
(
e
);
},
false
);
this
.
HtmlArea
.
addEventListener
(
"
compositionupdate
"
,
function
(
e
)
{
return
oThis
.
onCompositionUpdate
(
e
);
},
false
);
this
.
HtmlArea
.
addEventListener
(
"
compositionend
"
,
function
(
e
)
{
return
oThis
.
onCompositionEnd
(
e
);
},
false
);
this
.
Listener
=
this
.
Api
.
WordControl
.
m_oLogicDocument
;
if
(
false
)
{
// DEBUG_MODE
this
.
HtmlAreaOffset
=
0
;
this
.
HtmlArea
.
style
.
top
=
"
0px
"
;
this
.
HtmlArea
.
style
.
color
=
"
black
"
;
this
.
HtmlDiv
.
style
.
zIndex
=
5
;
this
.
HtmlDiv
.
style
.
width
=
"
200px
"
;
}
// TODO:
setInterval
(
function
(){
oThis
.
HtmlArea
.
focus
();
if
(
oThis
.
Api
.
asc_IsFocus
())
oThis
.
HtmlArea
.
focus
();
},
10
);
},
...
...
@@ -97,14 +106,20 @@
clear
:
function
()
{
this
.
compositionValue
=
""
;
this
.
compositionValue
=
[]
;
this
.
compositionState
=
c_oCompositionState
.
end
;
this
.
HtmlArea
.
value
=
""
;
},
onInput
:
function
(
e
)
{
// none
if
(
AscCommon
.
AscBrowser
.
isMozilla
)
{
if
(
c_oCompositionState
.
process
==
this
.
compositionState
)
{
this
.
checkTargetPosition
();
}
}
},
onKeyDown
:
function
(
e
)
...
...
@@ -120,6 +135,48 @@
return
this
.
Api
.
WordControl
.
onKeyPress
(
e
);
},
onKeyUp
:
function
(
e
)
{
if
(
c_oCompositionState
.
end
==
this
.
compositionState
)
return
this
.
Api
.
WordControl
.
onKeyUp
(
e
);
if
(
AscCommon
.
AscBrowser
.
isChrome
||
AscCommon
.
AscBrowser
.
isSafari
||
AscCommon
.
AscBrowser
.
isIE
)
{
this
.
checkTargetPosition
();
}
},
checkTargetPosition
:
function
()
{
var
_offset
=
this
.
HtmlArea
.
selectionEnd
;
_offset
-=
(
this
.
HtmlArea
.
value
.
length
-
this
.
compositionValue
.
length
);
this
.
Listener
.
Set_CursorPosInCompositeText
(
_offset
);
this
.
unlockTarget
();
},
lockTarget
:
function
()
{
if
(
-
1
!=
this
.
LockerTargetTimer
)
clearTimeout
(
this
.
LockerTargetTimer
);
this
.
Api
.
asc_LockTargetUpdate
(
true
);
var
oThis
=
this
;
this
.
LockerTargetTimer
=
setTimeout
(
function
(){
oThis
.
unlockTarget
();
},
1000
);
},
unlockTarget
:
function
()
{
if
(
-
1
!=
this
.
LockerTargetTimer
)
clearTimeout
(
this
.
LockerTargetTimer
);
this
.
LockerTargetTimer
=
-
1
;
this
.
Api
.
asc_LockTargetUpdate
(
false
);
},
onCompositionStart
:
function
(
e
)
{
if
(
!
this
.
Listener
)
...
...
@@ -131,13 +188,34 @@
onCompositionUpdate
:
function
(
e
)
{
var
_old
=
this
.
compositionValue
.
splice
(
0
);
this
.
checkCompositionData
(
e
.
data
);
this
.
Listener
.
Replace_CompositeText
(
this
.
compositionValue
);
var
_isEqual
=
(
_old
.
length
==
this
.
compositionValue
.
length
);
if
(
_isEqual
)
{
var
_len
=
this
.
compositionValue
.
length
;
for
(
var
i
=
0
;
i
<
_len
;
i
++
)
{
if
(
_old
[
i
]
!=
this
.
compositionValue
[
i
])
{
_isEqual
=
false
;
break
;
}
}
}
this
.
lockTarget
();
if
(
!
_isEqual
)
this
.
Listener
.
Replace_CompositeText
(
this
.
compositionValue
);
this
.
compositionState
=
c_oCompositionState
.
process
;
},
onCompositionEnd
:
function
(
e
)
{
this
.
Listener
.
Set_CursorPosInCompositeText
(
1000
);
// max
this
.
clear
();
this
.
Listener
.
End_CompositeInput
();
},
...
...
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