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
f0d5a7aa
Commit
f0d5a7aa
authored
Oct 17, 2017
by
Oleg Korshul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multiplugins scheme
parent
d5984bf1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
487 additions
and
289 deletions
+487
-289
common/Drawings/WorkEvents.js
common/Drawings/WorkEvents.js
+4
-6
common/apiBase.js
common/apiBase.js
+1
-5
common/editorscommon.js
common/editorscommon.js
+2
-3
common/plugins.js
common/plugins.js
+472
-266
common/scroll.js
common/scroll.js
+4
-6
common/text_input.js
common/text_input.js
+1
-1
word/api.js
word/api.js
+3
-2
No files found.
common/Drawings/WorkEvents.js
View file @
f0d5a7aa
...
...
@@ -106,9 +106,8 @@
if
(
window
.
captureEvents
)
window
.
captureEvents
(
Event
.
MOUSEDOWN
|
Event
.
MOUSEUP
);
var
_frame
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_frame
)
_frame
.
style
.
pointerEvents
=
"
none
"
;
if
(
window
.
g_asc_plugins
)
window
.
g_asc_plugins
.
disablePointerEvents
();
/*
var parent = window;
...
...
@@ -140,9 +139,8 @@
if
(
window
.
releaseEvents
)
window
.
releaseEvents
(
Event
.
MOUSEMOVE
);
var
_frame
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_frame
)
_frame
.
style
.
pointerEvents
=
""
;
if
(
window
.
g_asc_plugins
)
window
.
g_asc_plugins
.
enablePointerEvents
();
/*
var parent = window;
...
...
common/apiBase.js
View file @
f0d5a7aa
...
...
@@ -1251,11 +1251,7 @@
if
(
!
this
.
pluginsManager
)
return
;
var
_pluginData
=
new
Asc
.
CPluginData
();
_pluginData
.
setAttribute
(
"
type
"
,
"
enableMouseEvent
"
);
_pluginData
.
setAttribute
(
"
isEnabled
"
,
isEnable
);
this
.
pluginsManager
.
sendMessage
(
_pluginData
);
this
.
pluginsManager
.
onEnableMouseEvents
(
isEnable
);
};
baseEditorsApi
.
prototype
[
"
pluginMethod_GetFontList
"
]
=
function
()
...
...
common/editorscommon.js
View file @
f0d5a7aa
...
...
@@ -1227,9 +1227,8 @@
}
else
if
(
data
.
type
===
"
onExternalPluginMessage
"
)
{
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
event
.
data
,
"
*
"
);
if
(
window
.
g_asc_plugins
)
window
.
g_asc_plugins
.
sendToAllPlugins
(
event
.
data
);
}
}
catch
(
err
)
{
...
...
common/plugins.js
View file @
f0d5a7aa
...
...
@@ -80,103 +80,244 @@
function
CPluginsManager
(
api
)
{
this
.
plugins
=
[];
this
.
current
=
null
;
this
.
currentInit
=
false
;
this
.
currentVariation
=
0
;
this
.
systemPlugins
=
[];
this
.
runnedPluginsMap
=
{};
// guid => { iframeId: "", currentVariation: 0, currentInit: false, isSystem: false, startData: {}, closeAttackTimer: -1, methodReturnAsync: false }
this
.
pluginsMap
=
{};
// guid => { isSystem: false }
this
.
path
=
"
../../../../sdkjs-plugins/
"
;
this
.
api
=
null
;
this
.
systemPath
=
""
;
this
.
api
=
api
;
this
[
"
api
"
]
=
this
.
api
;
this
.
startData
=
null
;
this
.
runAndCloseData
=
null
;
this
.
closeAttackTimer
=
-
1
;
// защита от плагитнов, которые не закрываются
this
.
isNoSystemPluginsOnlyOne
=
true
;
this
.
guidAsyncMethod
=
""
;
this
.
methodReturnAsync
=
false
;
this
.
sendsToInterface
=
{}
;
}
CPluginsManager
.
prototype
=
{
register
:
function
(
basePath
,
plugins
)
register
:
function
(
basePath
,
plugins
)
{
this
.
path
=
basePath
;
for
(
var
i
=
0
;
i
<
plugins
.
length
;
i
++
)
this
.
plugins
.
push
(
plugins
[
i
]);
{
var
guid
=
plugins
[
i
].
guid
;
if
(
this
.
runnedPluginsMap
[
guid
])
{
// не меняем запущенный
continue
;
}
else
if
(
this
.
pluginsMap
[
guid
])
{
// заменяем новым
for
(
var
j
=
0
;
j
<
this
.
plugins
.
length
;
j
++
)
{
if
(
this
.
plugins
[
j
].
guid
==
guid
)
{
this
.
plugins
[
j
]
=
plugins
[
i
];
break
;
}
}
}
else
{
this
.
plugins
.
push
(
plugins
[
i
]);
this
.
pluginsMap
[
guid
]
=
{
isSystem
:
false
};
}
}
},
r
un
:
function
(
guid
,
variation
,
data
)
r
egisterSystem
:
function
(
basePath
,
plugins
)
{
if
(
null
!=
this
.
current
)
this
.
systemPath
=
basePath
;
for
(
var
i
=
0
;
i
<
plugins
.
length
;
i
++
)
{
if
(
this
.
current
.
guid
!=
guid
)
var
guid
=
plugins
[
i
].
guid
;
// системные не обновляем
if
(
this
.
pluginsMap
[
guid
])
{
this
.
runAndCloseData
=
{};
this
.
runAndCloseData
.
guid
=
guid
;
this
.
runAndCloseData
.
variation
=
variation
;
this
.
runAndCloseData
.
data
=
data
;
continue
;
}
// закрываем
this
.
buttonClick
(
-
1
);
this
.
systemPlugins
.
push
(
plugins
[
i
]);
this
.
pluginsMap
[
guid
]
=
{
isSystem
:
true
};
}
},
// pointer events methods -------------------
enablePointerEvents
:
function
()
{
for
(
var
guid
in
this
.
runnedPluginsMap
)
{
var
_frame
=
document
.
getElementById
(
this
.
runnedPluginsMap
[
guid
].
frameId
);
if
(
_frame
)
_frame
.
style
.
pointerEvents
=
""
;
}
},
disablePointerEvents
:
function
()
{
for
(
var
guid
in
this
.
runnedPluginsMap
)
{
var
_frame
=
document
.
getElementById
(
this
.
runnedPluginsMap
[
guid
].
frameId
);
if
(
_frame
)
_frame
.
style
.
pointerEvents
=
"
none
"
;
}
},
// ------------------------------------------
checkRunnedFrameId
:
function
(
id
)
{
for
(
var
guid
in
this
.
runnedPluginsMap
)
{
if
(
this
.
runnedPluginsMap
[
guid
].
frameId
==
id
)
return
true
;
}
return
false
;
},
sendToAllPlugins
:
function
(
data
)
{
for
(
var
guid
in
this
.
runnedPluginsMap
)
{
var
_frame
=
document
.
getElementById
(
this
.
runnedPluginsMap
[
guid
].
frameId
);
if
(
_frame
)
_iframe
.
contentWindow
.
postMessage
(
data
,
"
*
"
);
}
},
getPluginByGuid
:
function
(
guid
)
{
if
(
undefined
===
this
.
pluginsMap
[
guid
])
return
null
;
var
_array
=
(
this
.
pluginsMap
[
guid
].
isSystem
)
?
this
.
systemPlugins
:
this
.
plugins
;
for
(
var
i
=
_array
.
length
-
1
;
i
>=
0
;
i
--
)
{
if
(
_array
[
i
].
guid
==
guid
)
return
_array
[
i
];
}
return
null
;
},
run
:
function
(
guid
,
variation
,
data
,
isNoUse_isNoSystemPluginsOnlyOne
)
{
if
(
this
.
runAndCloseData
)
// run only on close!!!
return
;
if
(
this
.
pluginsMap
[
guid
]
===
undefined
)
return
;
var
plugin
=
this
.
getPluginByGuid
(
guid
);
if
(
!
plugin
)
return
;
var
isSystem
=
this
.
pluginsMap
[
guid
].
isSystem
;
var
isRunned
=
(
this
.
runnedPluginsMap
[
guid
]
!==
undefined
)
?
true
:
false
;
if
(
isRunned
)
{
// запуск запущенного => закрытие
this
.
close
(
guid
);
return
false
;
}
for
(
var
i
=
0
;
i
<
this
.
plugins
.
length
;
i
++
)
if
((
isNoUse_isNoSystemPluginsOnlyOne
!==
true
)
&&
!
isSystem
&&
this
.
isNoSystemPluginsOnlyOne
)
{
if
(
this
.
plugins
[
i
].
guid
==
guid
)
// смотрим, есть ли запущенный несистемный плагин
var
guidOther
=
""
;
for
(
var
i
in
this
.
runnedPluginsMap
)
{
this
.
current
=
this
.
plugins
[
i
];
break
;
if
(
this
.
pluginsMap
[
i
]
&&
!
this
.
pluginsMap
[
i
].
isSystem
)
{
guidOther
=
i
;
break
;
}
}
}
if
(
this
.
current
==
null
)
return
false
;
if
(
guidOther
!=
""
)
{
// стопим текущий, а после закрытия - стартуем новый.
this
.
runAndCloseData
=
{};
this
.
runAndCloseData
.
guid
=
guid
;
this
.
runAndCloseData
.
variation
=
variation
;
this
.
runAndCloseData
.
data
=
data
;
this
.
close
(
guidOther
);
return
;
}
}
this
.
currentVariation
=
Math
.
min
(
variation
,
this
.
current
.
variations
.
length
-
1
);
var
_startData
=
(
data
==
null
||
data
==
""
)
?
new
CPluginData
()
:
data
;
_startData
.
setAttribute
(
"
guid
"
,
guid
);
this
.
correctData
(
_startData
);
this
.
runnedPluginsMap
[
guid
]
=
{
frameId
:
"
iframe_
"
+
guid
,
currentVariation
:
Math
.
min
(
variation
,
plugin
.
variations
.
length
-
1
),
currentInit
:
false
,
isSystem
:
isSystem
,
startData
:
_startData
,
closeAttackTimer
:
-
1
,
methodReturnAsync
:
false
};
this
.
startData
=
(
data
==
null
||
data
==
""
)
?
new
CPluginData
()
:
data
;
this
.
startData
.
setAttribute
(
"
guid
"
,
guid
)
this
.
correctData
(
this
.
startData
);
this
.
show
();
this
.
show
(
guid
);
},
runResize
:
function
(
data
)
{
var
guid
=
data
.
getAttribute
(
"
guid
"
);
for
(
var
i
=
0
;
i
<
this
.
plugins
.
length
;
i
++
)
{
if
(
this
.
plugins
[
i
].
guid
==
guid
)
{
if
(
this
.
plugins
[
i
].
variations
[
0
].
isUpdateOleOnResize
!==
true
)
return
;
}
}
var
plugin
=
this
.
getPluginByGuid
(
guid
);
if
(
true
!==
plugin
.
variations
[
0
].
isUpdateOleOnResize
)
return
;
data
.
setAttribute
(
"
resize
"
,
true
);
return
this
.
run
(
guid
,
0
,
data
);
return
this
.
run
(
guid
,
0
,
data
,
true
);
},
close
:
function
(
)
close
:
function
(
guid
)
{
if
(
this
.
startData
&&
this
.
startData
.
getAttribute
(
"
resize
"
)
===
true
)
var
plugin
=
this
.
getPluginByGuid
(
guid
);
var
runObject
=
this
.
runnedPluginsMap
[
guid
];
if
(
!
plugin
||
!
runObject
)
return
;
if
(
runObject
.
startData
&&
runObject
.
startData
.
getAttribute
(
"
resize
"
)
===
true
)
this
.
endLongAction
();
this
.
startData
=
null
;
runObject
.
startData
=
null
;
if
(
true
)
{
this
.
api
.
sendEvent
(
"
asc_onPluginClose
"
,
this
.
current
,
this
.
currentVariation
);
var
_div
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
this
.
sendsToInterface
[
plugin
.
guid
])
{
this
.
api
.
sendEvent
(
"
asc_onPluginClose
"
,
plugin
,
runObject
.
currentVariation
);
delete
this
.
sendsToInterface
[
plugin
.
guid
];
}
var
_div
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_div
)
_div
.
parentNode
.
removeChild
(
_div
);
}
this
.
current
=
null
;
delete
this
.
runnedPluginsMap
[
guid
];
if
(
this
.
runAndCloseData
)
{
this
.
run
(
this
.
runAndCloseData
.
guid
,
this
.
runAndCloseData
.
variation
,
this
.
runAndCloseData
.
data
)
;
var
_tmp
=
this
.
runAndCloseData
;
this
.
runAndCloseData
=
null
;
this
.
run
(
_tmp
.
guid
,
_tmp
.
variation
,
_tmp
.
data
);
}
},
show
:
function
()
show
:
function
(
guid
)
{
if
(
this
.
startData
.
getAttribute
(
"
resize
"
)
===
true
)
var
plugin
=
this
.
getPluginByGuid
(
guid
);
var
runObject
=
this
.
runnedPluginsMap
[
guid
];
if
(
!
plugin
||
!
runObject
)
return
;
if
(
runObject
.
startData
.
getAttribute
(
"
resize
"
)
===
true
)
this
.
startLongAction
();
if
(
this
.
api
.
WordControl
&&
this
.
api
.
WordControl
.
m_oTimerScrollSelect
!=
-
1
)
...
...
@@ -185,17 +326,18 @@
this
.
api
.
WordControl
.
m_oTimerScrollSelect
=
-
1
;
}
if
(
this
.
current
.
variations
[
this
.
currentVariation
].
isVisual
&&
this
.
startData
.
getAttribute
(
"
resize
"
)
!==
true
)
if
(
plugin
.
variations
[
runObject
.
currentVariation
].
isVisual
&&
runObject
.
startData
.
getAttribute
(
"
resize
"
)
!==
true
)
{
this
.
api
.
sendEvent
(
"
asc_onPluginShow
"
,
this
.
current
,
this
.
currentVariation
);
this
.
api
.
sendEvent
(
"
asc_onPluginShow
"
,
plugin
,
runObject
.
currentVariation
,
runObject
.
frameId
);
this
.
sendsToInterface
[
plugin
.
guid
]
=
true
;
}
else
{
var
ifr
=
document
.
createElement
(
"
iframe
"
);
ifr
.
name
=
"
plugin_iframe
"
;
ifr
.
id
=
"
plugin_iframe
"
;
var
_add
=
this
.
current
.
baseUrl
==
""
?
this
.
path
:
this
.
current
.
baseUrl
;
ifr
.
src
=
_add
+
this
.
current
.
variations
[
this
.
currentVariation
].
url
;
ifr
.
name
=
runObject
.
frameId
;
ifr
.
id
=
runObject
.
frameId
;
var
_add
=
plugin
.
baseUrl
==
""
?
this
.
path
:
plugin
.
baseUrl
;
ifr
.
src
=
_add
+
plugin
.
variations
[
runObject
.
currentVariation
].
url
;
ifr
.
style
.
position
=
AscCommon
.
AscBrowser
.
isIE
?
'
fixed
'
:
"
absolute
"
;
ifr
.
style
.
top
=
'
-100px
'
;
ifr
.
style
.
left
=
'
0px
'
;
...
...
@@ -205,52 +347,79 @@
ifr
.
style
.
zIndex
=
-
1000
;
document
.
body
.
appendChild
(
ifr
);
if
(
this
.
startData
.
getAttribute
(
"
resize
"
)
!==
true
)
this
.
api
.
sendEvent
(
"
asc_onPluginShow
"
,
this
.
current
,
this
.
currentVariation
);
if
(
runObject
.
startData
.
getAttribute
(
"
resize
"
)
!==
true
)
{
this
.
api
.
sendEvent
(
"
asc_onPluginShow
"
,
plugin
,
runObject
.
currentVariation
);
this
.
sendsToInterface
[
plugin
.
guid
]
=
true
;
}
}
this
.
currentInit
=
false
;
runObject
.
currentInit
=
false
;
},
buttonClick
:
function
(
id
)
buttonClick
:
function
(
id
,
guid
)
{
if
(
this
.
closeAttackTimer
!=
-
1
)
if
(
guid
===
undefined
)
{
// old version support
for
(
var
i
in
this
.
runnedPluginsMap
)
{
if
(
this
.
pluginsMap
[
i
])
{
guid
=
i
;
break
;
}
}
}
if
(
undefined
===
guid
)
return
;
var
plugin
=
this
.
getPluginByGuid
(
guid
);
var
runObject
=
this
.
runnedPluginsMap
[
guid
];
if
(
!
plugin
||
!
runObject
)
return
;
if
(
runObject
.
closeAttackTimer
!=
-
1
)
{
clearTimeout
(
this
.
closeAttackTimer
);
this
.
closeAttackTimer
=
-
1
;
clearTimeout
(
runObject
.
closeAttackTimer
);
runObject
.
closeAttackTimer
=
-
1
;
}
if
(
-
1
==
id
)
{
if
(
!
this
.
currentInit
)
if
(
!
runObject
.
currentInit
)
{
window
.
g_asc_plugins
.
close
();
this
.
close
();
this
.
close
(
guid
);
}
// защита от плохого плагина
this
.
closeAttackTimer
=
setTimeout
(
function
()
runObject
.
closeAttackTimer
=
setTimeout
(
function
()
{
window
.
g_asc_plugins
.
close
();
},
5000
);
}
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
var
_iframe
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_iframe
)
{
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
this
.
current
.
guid
);
pluginData
.
setAttribute
(
"
guid
"
,
plugin
.
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
button
"
);
pluginData
.
setAttribute
(
"
button
"
,
""
+
id
);
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
}
},
init
:
function
(
)
init
:
function
(
guid
)
{
if
(
!
this
.
startData
)
var
plugin
=
this
.
getPluginByGuid
(
guid
);
var
runObject
=
this
.
runnedPluginsMap
[
guid
];
if
(
!
plugin
||
!
runObject
||
!
runObject
.
startData
)
return
;
switch
(
this
.
current
.
variations
[
this
.
currentVariation
].
initDataType
)
switch
(
plugin
.
variations
[
runObject
.
currentVariation
].
initDataType
)
{
case
Asc
.
EPluginDataType
.
text
:
{
...
...
@@ -265,7 +434,7 @@
this
.
api
.
asc_CheckCopy
(
text_data
,
1
);
if
(
text_data
.
data
==
null
)
text_data
.
data
=
""
;
this
.
startData
.
setAttribute
(
"
data
"
,
text_data
.
data
);
runObject
.
startData
.
setAttribute
(
"
data
"
,
text_data
.
data
);
break
;
}
case
Asc
.
EPluginDataType
.
html
:
...
...
@@ -281,7 +450,7 @@
this
.
api
.
asc_CheckCopy
(
text_data
,
2
);
if
(
text_data
.
data
==
null
)
text_data
.
data
=
""
;
this
.
startData
.
setAttribute
(
"
data
"
,
text_data
.
data
);
runObject
.
startData
.
setAttribute
(
"
data
"
,
text_data
.
data
);
break
;
}
case
Asc
.
EPluginDataType
.
ole
:
...
...
@@ -291,16 +460,16 @@
}
}
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
var
_iframe
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_iframe
)
{
this
.
startData
.
setAttribute
(
"
type
"
,
"
init
"
);
_iframe
.
contentWindow
.
postMessage
(
this
.
startData
.
serialize
(),
"
*
"
);
runObject
.
startData
.
setAttribute
(
"
type
"
,
"
init
"
);
_iframe
.
contentWindow
.
postMessage
(
runObject
.
startData
.
serialize
(),
"
*
"
);
}
this
.
currentInit
=
true
;
runObject
.
currentInit
=
true
;
},
correctData
:
function
(
pluginData
)
correctData
:
function
(
pluginData
)
{
pluginData
.
setAttribute
(
"
editorType
"
,
this
.
api
.
_editorNameById
());
...
...
@@ -322,6 +491,7 @@
for
(
var
i
=
0
;
i
<
this
.
plugins
.
length
;
i
++
)
_map
[
this
.
plugins
[
i
].
guid
]
=
true
;
var
_new
=
[];
for
(
var
i
=
0
;
i
<
_plugins
.
length
;
i
++
)
{
var
_p
=
new
Asc
.
CPlugin
();
...
...
@@ -330,9 +500,11 @@
if
(
_map
[
_p
.
guid
]
===
true
)
continue
;
this
.
plugins
.
push
(
_p
);
_new
.
push
(
_p
);
}
this
.
register
(
this
.
path
,
_new
);
var
_pluginsInstall
=
{
"
url
"
:
this
.
path
,
"
pluginsData
"
:
[]};
for
(
var
i
=
0
;
i
<
this
.
plugins
.
length
;
i
++
)
{
...
...
@@ -353,55 +525,80 @@
this
.
api
.
sync_EndAction
(
Asc
.
c_oAscAsyncActionType
.
BlockInteraction
,
Asc
.
c_oAscAsyncAction
.
SlowOperation
);
},
sendMessage
:
function
(
pluginData
)
onChangedSelectionData
:
function
(
)
{
if
(
!
this
.
current
)
return
;
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_iframe
)
for
(
var
guid
in
this
.
runnedPluginsMap
)
{
pluginData
.
setAttribute
(
"
guid
"
,
this
.
current
.
guid
);
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
var
plugin
=
this
.
getPluginByGuid
(
guid
);
var
runObject
=
this
.
runnedPluginsMap
[
guid
];
if
(
plugin
&&
plugin
.
variations
[
runObject
.
currentVariation
].
initOnSelectionChanged
===
true
)
{
// re-init
this
.
init
(
guid
);
}
}
},
on
ChangedSelectionData
:
function
()
on
ExternalMouseUp
:
function
()
{
if
(
this
.
current
&&
this
.
current
.
variations
[
this
.
currentVariation
].
initOnSelectionChanged
===
true
)
for
(
var
guid
in
this
.
runnedPluginsMap
)
{
// re-init
this
.
init
();
var
runObject
=
this
.
runnedPluginsMap
[
guid
];
runObject
.
startData
.
setAttribute
(
"
type
"
,
"
onExternalMouseUp
"
);
this
.
correctData
(
runObject
.
startData
);
var
_iframe
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_iframe
)
{
runObject
.
startData
.
setAttribute
(
"
guid
"
,
guid
);
_iframe
.
contentWindow
.
postMessage
(
runObject
.
startData
.
serialize
(),
"
*
"
);
}
}
},
onE
xternalMouseUp
:
function
(
)
onE
nableMouseEvents
:
function
(
isEnable
)
{
if
(
!
this
.
current
||
!
this
.
startData
)
return
;
for
(
var
guid
in
this
.
runnedPluginsMap
)
{
var
runObject
=
this
.
runnedPluginsMap
[
guid
];
this
.
startData
.
setAttribute
(
"
type
"
,
"
onExternalMouseUp
"
);
this
.
correctData
(
this
.
startData
);
this
.
sendMessage
(
this
.
startData
);
var
_pluginData
=
new
Asc
.
CPluginData
();
_pluginData
.
setAttribute
(
"
type
"
,
"
enableMouseEvent
"
);
_pluginData
.
setAttribute
(
"
isEnabled
"
,
isEnable
);
this
.
correctData
(
_pluginData
);
var
_iframe
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_iframe
)
{
_pluginData
.
setAttribute
(
"
guid
"
,
guid
);
_iframe
.
contentWindow
.
postMessage
(
_pluginData
.
serialize
(),
"
*
"
);
}
}
},
onPluginMethodReturn
:
function
(
_return
)
onPluginMethodReturn
:
function
(
guid
,
_return
)
{
if
(
!
this
.
current
)
var
plugin
=
this
.
getPluginByGuid
(
guid
);
var
runObject
=
this
.
runnedPluginsMap
[
guid
];
if
(
!
plugin
||
!
runObject
)
return
;
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
this
.
current
.
guid
);
pluginData
.
setAttribute
(
"
guid
"
,
plugin
.
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
onMethodReturn
"
);
pluginData
.
setAttribute
(
"
methodReturnData
"
,
_return
);
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
var
_iframe
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
},
setPluginMethodReturnAsync
:
function
()
{
this
.
methodReturnAsync
=
true
;
if
(
this
.
runnedPluginsMap
[
this
.
guidAsyncMethod
])
this
.
runnedPluginsMap
[
this
.
guidAsyncMethod
].
methodReturnAsync
=
true
;
return
this
.
guidAsyncMethod
;
}
};
...
...
@@ -410,209 +607,218 @@
function
onMessage
(
event
)
{
if
(
!
window
.
g_asc_plugins
||
!
window
.
g_asc_plugins
.
current
)
if
(
!
window
.
g_asc_plugins
)
return
;
if
(
typeof
(
event
.
data
)
==
"
string
"
)
{
var
pluginData
=
new
CPluginData
();
pluginData
.
deserialize
(
event
.
data
);
if
(
typeof
(
event
.
data
)
!=
"
string
"
)
return
;
var
guid
=
pluginData
.
getAttribute
(
"
guid
"
);
var
pluginData
=
new
CPluginData
();
pluginData
.
deserialize
(
event
.
data
);
if
(
guid
!=
window
.
g_asc_plugins
.
current
.
guid
)
return
;
var
guid
=
pluginData
.
getAttribute
(
"
guid
"
);
var
runObject
=
window
.
g_asc_plugins
.
runnedPluginsMap
[
guid
]
;
var
name
=
pluginData
.
getAttribute
(
"
type
"
);
var
value
=
pluginData
.
getAttribute
(
"
data
"
);
if
(
!
runObject
)
return
;
var
name
=
pluginData
.
getAttribute
(
"
type
"
);
var
value
=
pluginData
.
getAttribute
(
"
data
"
);
if
(
"
initialize_internal
"
==
name
)
{
window
.
g_asc_plugins
.
init
();
}
else
if
(
"
initialize
"
==
name
)
if
(
"
initialize_internal
"
==
name
)
{
window
.
g_asc_plugins
.
init
(
guid
);
}
else
if
(
"
initialize
"
==
name
)
{
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
plugin_init
"
);
pluginData
.
setAttribute
(
"
data
"
,
"
!function(n,e){var i=!1;n.plugin_sendMessage=function(e){n.parent.postMessage(e,
\"
*
\"
)},n.plugin_onMessage=function(t){if(n.Asc.plugin&&
\"
string
\"
==typeof t.data){var s={};try{s=JSON.parse(t.data)}catch(n){s={}}if(s.guid!=n.Asc.plugin.guid)return;var a=s.type;switch(
\"
init
\"
==a&&(n.Asc.plugin.info=s),a){case
\"
init
\"
:n.Asc.plugin.executeCommand=function(e,i){n.Asc.plugin.info.type=e,n.Asc.plugin.info.data=i;var t=
\"\"
;try{t=JSON.stringify(n.Asc.plugin.info)}catch(n){t=JSON.stringify({type:i})}n.plugin_sendMessage(t)},n.Asc.plugin.executeMethod=function(e,i){if(!0===n.Asc.plugin.isWaitMethod)return!1;n.Asc.plugin.isWaitMethod=!0,n.Asc.plugin.info.type=
\"
method
\"
,n.Asc.plugin.info.methodName=e,n.Asc.plugin.info.data=i;var t=
\"\"
;try{t=JSON.stringify(n.Asc.plugin.info)}catch(n){t=JSON.stringify({type:data})}return n.plugin_sendMessage(t),!0},n.Asc.plugin.resizeWindow=function(i,t,s,a,u,c){e==s&&(s=0),e==a&&(a=0),e==u&&(u=0),e==c&&(c=0);var g=JSON.stringify({width:i,height:t,minw:s,minh:a,maxw:u,maxh:c});n.Asc.plugin.info.type=
\"
resize
\"
,n.Asc.plugin.info.data=g;var o=
\"\"
;try{o=JSON.stringify(n.Asc.plugin.info)}catch(n){o=JSON.stringify({type:g})}n.plugin_sendMessage(o)},n.Asc.plugin.init(n.Asc.plugin.info.data);break;case
\"
button
\"
:var u=parseInt(s.button);n.Asc.plugin.button||-1!=u?n.Asc.plugin.button(u):n.Asc.plugin.executeCommand(
\"
close
\"
,
\"\"
);break;case
\"
enableMouseEvent
\"
:i=s.isEnabled,n.Asc.plugin.onEnableMouseEvent&&n.Asc.plugin.onEnableMouseEvent(i);break;case
\"
onExternalMouseUp
\"
:n.Asc.plugin.onExternalMouseUp&&n.Asc.plugin.onExternalMouseUp();break;case
\"
onMethodReturn
\"
:n.Asc.plugin.isWaitMethod=!1,n.Asc.plugin.onMethodReturn&&n.Asc.plugin.onMethodReturn(s.methodReturnData);break;case
\"
onCommandCallback
\"
:n.Asc.plugin.onCommandCallback&&n.Asc.plugin.onCommandCallback();break;case
\"
onExternalPluginMessage
\"
:n.Asc.plugin.onExternalPluginMessage&&s.data&&s.data.type&&n.Asc.plugin.onExternalPluginMessage(s.data)}}},n.onmousemove=function(t){if(i&&n.Asc.plugin&&n.Asc.plugin.executeCommand){var s=e===t.clientX?t.pageX:t.clientX,a=e===t.clientY?t.pageY:t.clientY;n.Asc.plugin.executeCommand(
\"
onmousemove
\"
,JSON.stringify({x:s,y:a}))}},n.onmouseup=function(t){if(i&&n.Asc.plugin&&n.Asc.plugin.executeCommand){var s=e===t.clientX?t.pageX:t.clientX,a=e===t.clientY?t.pageY:t.clientY;n.Asc.plugin.executeCommand(
\"
onmouseup
\"
,JSON.stringify({x:s,y:a}))}},n.plugin_sendMessage(JSON.stringify({guid:n.Asc.plugin.guid,type:
\"
initialize_internal
\"
}))}(window,void 0);
"
);
var
_iframe
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
return
;
}
else
if
(
"
close
"
==
name
||
"
command
"
==
name
)
{
if
(
runObject
.
closeAttackTimer
!=
-
1
)
{
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
plugin_init
"
);
pluginData
.
setAttribute
(
"
data
"
,
"
!function(n,e){var i=!1;n.plugin_sendMessage=function(e){n.parent.postMessage(e,
\"
*
\"
)},n.plugin_onMessage=function(t){if(n.Asc.plugin&&
\"
string
\"
==typeof t.data){var s={};try{s=JSON.parse(t.data)}catch(n){s={}}if(s.guid!=n.Asc.plugin.guid)return;var a=s.type;switch(
\"
init
\"
==a&&(n.Asc.plugin.info=s),a){case
\"
init
\"
:n.Asc.plugin.executeCommand=function(e,i){n.Asc.plugin.info.type=e,n.Asc.plugin.info.data=i;var t=
\"\"
;try{t=JSON.stringify(n.Asc.plugin.info)}catch(n){t=JSON.stringify({type:i})}n.plugin_sendMessage(t)},n.Asc.plugin.executeMethod=function(e,i){if(!0===n.Asc.plugin.isWaitMethod)return!1;n.Asc.plugin.isWaitMethod=!0,n.Asc.plugin.info.type=
\"
method
\"
,n.Asc.plugin.info.methodName=e,n.Asc.plugin.info.data=i;var t=
\"\"
;try{t=JSON.stringify(n.Asc.plugin.info)}catch(n){t=JSON.stringify({type:data})}return n.plugin_sendMessage(t),!0},n.Asc.plugin.resizeWindow=function(i,t,s,a,u,c){e==s&&(s=0),e==a&&(a=0),e==u&&(u=0),e==c&&(c=0);var g=JSON.stringify({width:i,height:t,minw:s,minh:a,maxw:u,maxh:c});n.Asc.plugin.info.type=
\"
resize
\"
,n.Asc.plugin.info.data=g;var o=
\"\"
;try{o=JSON.stringify(n.Asc.plugin.info)}catch(n){o=JSON.stringify({type:g})}n.plugin_sendMessage(o)},n.Asc.plugin.init(n.Asc.plugin.info.data);break;case
\"
button
\"
:var u=parseInt(s.button);n.Asc.plugin.button||-1!=u?n.Asc.plugin.button(u):n.Asc.plugin.executeCommand(
\"
close
\"
,
\"\"
);break;case
\"
enableMouseEvent
\"
:i=s.isEnabled,n.Asc.plugin.onEnableMouseEvent&&n.Asc.plugin.onEnableMouseEvent(i);break;case
\"
onExternalMouseUp
\"
:n.Asc.plugin.onExternalMouseUp&&n.Asc.plugin.onExternalMouseUp();break;case
\"
onMethodReturn
\"
:n.Asc.plugin.isWaitMethod=!1,n.Asc.plugin.onMethodReturn&&n.Asc.plugin.onMethodReturn(s.methodReturnData);break;case
\"
onCommandCallback
\"
:n.Asc.plugin.onCommandCallback&&n.Asc.plugin.onCommandCallback();break;case
\"
onExternalPluginMessage
\"
:n.Asc.plugin.onExternalPluginMessage&&s.data&&s.data.type&&n.Asc.plugin.onExternalPluginMessage(s.data)}}},n.onmousemove=function(t){if(i&&n.Asc.plugin&&n.Asc.plugin.executeCommand){var s=e===t.clientX?t.pageX:t.clientX,a=e===t.clientY?t.pageY:t.clientY;n.Asc.plugin.executeCommand(
\"
onmousemove
\"
,JSON.stringify({x:s,y:a}))}},n.onmouseup=function(t){if(i&&n.Asc.plugin&&n.Asc.plugin.executeCommand){var s=e===t.clientX?t.pageX:t.clientX,a=e===t.clientY?t.pageY:t.clientY;n.Asc.plugin.executeCommand(
\"
onmouseup
\"
,JSON.stringify({x:s,y:a}))}},n.plugin_sendMessage(JSON.stringify({guid:n.Asc.plugin.guid,type:
\"
initialize_internal
\"
}))}(window,void 0);
"
);
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
return
;
clearTimeout
(
runObject
.
closeAttackTimer
);
runObject
.
closeAttackTimer
=
-
1
;
}
else
if
(
"
close
"
==
name
||
"
command
"
==
name
)
{
if
(
window
.
g_asc_plugins
.
closeAttackTimer
!=
-
1
)
{
clearTimeout
(
window
.
g_asc_plugins
.
closeAttackTimer
);
window
.
g_asc_plugins
.
closeAttackTimer
=
-
1
;
}
if
(
value
&&
value
!=
""
)
if
(
value
&&
value
!=
""
)
{
var
_command_callback_send
=
(
"
command
"
==
name
);
try
{
var
_command_callback_send
=
(
"
command
"
==
name
);
try
if
(
pluginData
.
getAttribute
(
"
interface
"
))
{
var
_script
=
"
(function(){ var Api = window.g_asc_plugins.api;
\n
"
+
value
+
"
\n
})();
"
;
eval
(
_script
);
}
else
if
(
pluginData
.
getAttribute
(
"
resize
"
)
||
window
.
g_asc_plugins
.
api
.
asc_canPaste
())
{
if
(
pluginData
.
getAttribute
(
"
interface
"
))
var
oLogicDocument
,
i
;
var
editorId
=
window
.
g_asc_plugins
.
api
.
getEditorId
();
if
(
AscCommon
.
c_oEditorId
.
Word
===
editorId
||
AscCommon
.
c_oEditorId
.
Presentation
===
editorId
)
{
var
_script
=
"
(function(){ var Api = window.g_asc_plugins.api;
\n
"
+
value
+
"
\n
})();
"
;
eval
(
_script
);
oLogicDocument
=
window
.
g_asc_plugins
.
api
.
WordControl
?
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
:
null
;
if
(
AscCommon
.
c_oEditorId
.
Word
===
editorId
){
oLogicDocument
.
LockPanelStyles
();
}
}
else
if
(
pluginData
.
getAttribute
(
"
resize
"
)
||
window
.
g_asc_plugins
.
api
.
asc_canPaste
())
var
_script
=
"
(function(){ var Api = window.g_asc_plugins.api;
\n
"
+
value
+
"
\n
})();
"
;
eval
(
_script
);
if
(
pluginData
.
getAttribute
(
"
recalculate
"
)
==
true
)
{
var
oLogicDocument
,
i
;
var
editorId
=
window
.
g_asc_plugins
.
api
.
getEditorId
();
_command_callback_send
=
false
;
if
(
AscCommon
.
c_oEditorId
.
Word
===
editorId
||
AscCommon
.
c_oEditorId
.
Presentation
===
editorId
)
{
oLogicDocument
=
window
.
g_asc_plugins
.
api
.
WordControl
?
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
:
null
;
if
(
AscCommon
.
c_oEditorId
.
Word
===
editorId
){
oLogicDocument
.
LockPanelStyles
();
var
_fonts
=
oLogicDocument
.
Document_Get_AllFontNames
();
var
_imagesArray
=
oLogicDocument
.
Get_AllImageUrls
();
var
_images
=
{};
for
(
i
=
0
;
i
<
_imagesArray
.
length
;
i
++
)
{
_images
[
_imagesArray
[
i
]]
=
_imagesArray
[
i
];
}
}
var
_script
=
"
(function(){ var Api = window.g_asc_plugins.api;
\n
"
+
value
+
"
\n
})();
"
;
eval
(
_script
);
if
(
pluginData
.
getAttribute
(
"
recalculate
"
)
==
true
)
{
_command_callback_send
=
false
;
if
(
AscCommon
.
c_oEditorId
.
Word
===
editorId
||
AscCommon
.
c_oEditorId
.
Presentation
===
editorId
)
{
oLogicDocument
=
window
.
g_asc_plugins
.
api
.
WordControl
?
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
:
null
;
var
_fonts
=
oLogicDocument
.
Document_Get_AllFontNames
();
var
_imagesArray
=
oLogicDocument
.
Get_AllImageUrls
();
var
_images
=
{};
for
(
i
=
0
;
i
<
_imagesArray
.
length
;
i
++
)
window
.
g_asc_plugins
.
images_rename
=
_images
;
AscCommon
.
Check_LoadingDataBeforePrepaste
(
window
.
g_asc_plugins
.
api
,
_fonts
,
_images
,
function
()
{
_images
[
_imagesArray
[
i
]]
=
_imagesArray
[
i
];
}
window
.
g_asc_plugins
.
images_rename
=
_images
;
AscCommon
.
Check_LoadingDataBeforePrepaste
(
window
.
g_asc_plugins
.
api
,
_fonts
,
_images
,
function
()
if
(
window
.
g_asc_plugins
.
api
.
WordControl
&&
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
&&
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
.
Reassign_ImageUrls
)
{
if
(
window
.
g_asc_plugins
.
api
.
WordControl
&&
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
&&
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
.
Reassign_ImageUrls
)
{
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
.
Reassign_ImageUrls
(
window
.
g_asc_plugins
.
images_rename
);
}
delete
window
.
g_asc_plugins
.
images_rename
;
if
(
AscCommon
.
c_oEditorId
.
Word
===
editorId
)
{
oLogicDocument
.
UnlockPanelStyles
(
true
);
oLogicDocument
.
OnEndLoadScript
();
}
window
.
g_asc_plugins
.
api
.
asc_Recalculate
();
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
onCommandCallback
"
);
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
});
}
else
if
(
AscCommon
.
c_oEditorId
.
Spreadsheet
===
editorId
)
window
.
g_asc_plugins
.
api
.
WordControl
.
m_oLogicDocument
.
Reassign_ImageUrls
(
window
.
g_asc_plugins
.
images_rename
);
}
delete
window
.
g_asc_plugins
.
images_rename
;
if
(
AscCommon
.
c_oEditorId
.
Word
===
editorId
)
{
oLogicDocument
.
UnlockPanelStyles
(
true
);
oLogicDocument
.
OnEndLoadScript
();
}
window
.
g_asc_plugins
.
api
.
asc_Recalculate
();
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
onCommandCallback
"
);
var
runObj
=
window
.
g_asc_plugins
.
runnedPluginsMap
[
guid
];
var
_iframe
=
document
.
getElementById
(
runObj
.
frameId
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
});
}
else
if
(
AscCommon
.
c_oEditorId
.
Spreadsheet
===
editorId
)
{
var
oApi
=
window
.
g_asc_plugins
.
api
;
var
oFonts
=
oApi
.
wbModel
.
_generateFontMap
();
var
aImages
=
oApi
.
wbModel
.
getAllImageUrls
();
var
oImages
=
{};
for
(
i
=
0
;
i
<
aImages
.
length
;
i
++
)
{
var
oApi
=
window
.
g_asc_plugins
.
api
;
var
oFonts
=
oApi
.
wbModel
.
_generateFontMap
();
var
aImages
=
oApi
.
wbModel
.
getAllImageUrls
();
var
oImages
=
{};
for
(
i
=
0
;
i
<
aImages
.
length
;
i
++
)
{
oImages
[
aImages
[
i
]]
=
aImages
[
i
];
}
window
.
g_asc_plugins
.
images_rename
=
oImages
;
AscCommon
.
Check_LoadingDataBeforePrepaste
(
window
.
g_asc_plugins
.
api
,
oFonts
,
oImages
,
function
(){
oApi
.
wbModel
.
reassignImageUrls
(
window
.
g_asc_plugins
.
images_rename
);
delete
window
.
g_asc_plugins
.
images_rename
;
window
.
g_asc_plugins
.
api
.
asc_Recalculate
();
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
onCommandCallback
"
);
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
});
}
}
else
{
if
(
AscCommon
.
c_oEditorId
.
Spreadsheet
===
editorId
)
{
// На asc_canPaste создается точка в истории и startTransaction. Поэтому нужно ее закрыть без пересчета.
window
.
g_asc_plugins
.
api
.
asc_endPaste
();
oImages
[
aImages
[
i
]]
=
aImages
[
i
];
}
window
.
g_asc_plugins
.
images_rename
=
oImages
;
AscCommon
.
Check_LoadingDataBeforePrepaste
(
window
.
g_asc_plugins
.
api
,
oFonts
,
oImages
,
function
(){
oApi
.
wbModel
.
reassignImageUrls
(
window
.
g_asc_plugins
.
images_rename
);
delete
window
.
g_asc_plugins
.
images_rename
;
window
.
g_asc_plugins
.
api
.
asc_Recalculate
();
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
onCommandCallback
"
);
var
runObj
=
window
.
g_asc_plugins
.
runnedPluginsMap
[
guid
];
var
_iframe
=
document
.
getElementById
(
runObj
.
frameId
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
});
}
}
else
{
if
(
AscCommon
.
c_oEditorId
.
Spreadsheet
===
editorId
)
{
// На asc_canPaste создается точка в истории и startTransaction. Поэтому нужно ее закрыть без пересчета.
window
.
g_asc_plugins
.
api
.
asc_endPaste
();
}
}
}
catch
(
err
)
{
}
if
(
_command_callback_send
)
{
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
onCommandCallback
"
);
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
}
}
if
(
"
close
"
==
name
)
}
catch
(
err
)
{
window
.
g_asc_plugins
.
close
();
}
}
else
if
(
"
resize
"
==
name
)
{
var
_sizes
=
JSON
.
parse
(
value
);
window
.
g_asc_plugins
.
api
.
sendEvent
(
"
asc_onPluginResize
"
,
[
_sizes
[
"
width
"
],
_sizes
[
"
height
"
]],
[
_sizes
[
"
minw
"
],
_sizes
[
"
minh
"
]],
[
_sizes
[
"
maxw
"
],
_sizes
[
"
maxh
"
]],
function
()
{
// TODO: send resize end event
});
}
else
if
(
"
onmousemove
"
==
name
)
{
var
_pos
=
JSON
.
parse
(
value
);
window
.
g_asc_plugins
.
api
.
sendEvent
(
"
asc_onPluginMouseMove
"
,
_pos
[
"
x
"
],
_pos
[
"
y
"
]);
}
else
if
(
"
onmouseup
"
==
name
)
{
var
_pos
=
JSON
.
parse
(
value
);
window
.
g_asc_plugins
.
api
.
sendEvent
(
"
asc_onPluginMouseUp
"
,
_pos
[
"
x
"
],
_pos
[
"
y
"
]);
}
else
if
(
"
method
"
==
name
)
{
var
_apiMethodName
=
"
pluginMethod_
"
+
pluginData
.
getAttribute
(
"
methodName
"
);
var
_return
=
undefined
;
if
(
window
.
g_asc_plugins
.
api
[
_apiMethodName
])
_return
=
window
.
g_asc_plugins
.
api
[
_apiMethodName
].
apply
(
window
.
g_asc_plugins
.
api
,
value
);
if
(
!
window
.
g_asc_plugins
.
methodReturnAsync
)
if
(
_command_callback_send
)
{
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
onMethodReturn
"
);
pluginData
.
setAttribute
(
"
methodReturnData
"
,
_return
);
var
_iframe
=
document
.
getElementById
(
"
plugin_iframe
"
);
pluginData
.
setAttribute
(
"
type
"
,
"
onCommandCallback
"
);
var
_iframe
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
}
window
.
g_asc_plugins
.
methodReturnAsync
=
false
;
return
;
}
if
(
"
close
"
==
name
)
{
window
.
g_asc_plugins
.
close
(
guid
);
}
}
else
if
(
"
resize
"
==
name
)
{
var
_sizes
=
JSON
.
parse
(
value
);
window
.
g_asc_plugins
.
api
.
sendEvent
(
"
asc_onPluginResize
"
,
[
_sizes
[
"
width
"
],
_sizes
[
"
height
"
]],
[
_sizes
[
"
minw
"
],
_sizes
[
"
minh
"
]],
[
_sizes
[
"
maxw
"
],
_sizes
[
"
maxh
"
]],
function
()
{
// TODO: send resize end event
});
}
else
if
(
"
onmousemove
"
==
name
)
{
var
_pos
=
JSON
.
parse
(
value
);
window
.
g_asc_plugins
.
api
.
sendEvent
(
"
asc_onPluginMouseMove
"
,
_pos
[
"
x
"
],
_pos
[
"
y
"
]);
}
else
if
(
"
onmouseup
"
==
name
)
{
var
_pos
=
JSON
.
parse
(
value
);
window
.
g_asc_plugins
.
api
.
sendEvent
(
"
asc_onPluginMouseUp
"
,
_pos
[
"
x
"
],
_pos
[
"
y
"
]);
}
else
if
(
"
method
"
==
name
)
{
var
_apiMethodName
=
"
pluginMethod_
"
+
pluginData
.
getAttribute
(
"
methodName
"
);
var
_return
=
undefined
;
window
.
g_asc_plugins
.
guidAsyncMethod
=
guid
;
if
(
window
.
g_asc_plugins
.
api
[
_apiMethodName
])
_return
=
window
.
g_asc_plugins
.
api
[
_apiMethodName
].
apply
(
window
.
g_asc_plugins
.
api
,
value
);
if
(
!
runObject
.
methodReturnAsync
)
{
var
pluginData
=
new
CPluginData
();
pluginData
.
setAttribute
(
"
guid
"
,
guid
);
pluginData
.
setAttribute
(
"
type
"
,
"
onMethodReturn
"
);
pluginData
.
setAttribute
(
"
methodReturnData
"
,
_return
);
var
_iframe
=
document
.
getElementById
(
runObject
.
frameId
);
if
(
_iframe
)
_iframe
.
contentWindow
.
postMessage
(
pluginData
.
serialize
(),
"
*
"
);
}
runObject
.
methodReturnAsync
=
false
;
window
.
g_asc_plugins
.
guidAsyncMethod
=
""
;
return
;
}
}
...
...
common/scroll.js
View file @
f0d5a7aa
...
...
@@ -3067,9 +3067,8 @@ ScrollObject.prototype = {
var
evt
=
e
||
window
.
event
;
// prevent pointer events on all iframes (while only plugin!)
var
_frame
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_frame
)
_frame
.
style
.
pointerEvents
=
""
;
if
(
window
.
g_asc_plugins
)
window
.
g_asc_plugins
.
enablePointerEvents
();
if
(
evt
.
preventDefault
)
evt
.
preventDefault
();
...
...
@@ -3115,9 +3114,8 @@ ScrollObject.prototype = {
var
evt
=
e
||
window
.
event
;
// prevent pointer events on all iframes (while only plugin!)
var
_frame
=
document
.
getElementById
(
"
plugin_iframe
"
);
if
(
_frame
)
_frame
.
style
.
pointerEvents
=
"
none
"
;
if
(
window
.
g_asc_plugins
)
window
.
g_asc_plugins
.
disablePointerEvents
();
// если сделать превент дефолт - перестанет приходить mousemove от window
/*
...
...
common/text_input.js
View file @
f0d5a7aa
...
...
@@ -1784,7 +1784,7 @@
if
(
document
.
activeElement
)
{
var
_id
=
document
.
activeElement
.
id
;
if
(
_id
==
"
area_id
"
||
_id
==
"
plugin_iframe
"
)
if
(
_id
==
"
area_id
"
||
(
window
.
g_asc_plugins
&&
window
.
g_asc_plugins
.
checkRunnedFrameId
(
_id
))
)
return
;
}
...
...
word/api.js
View file @
f0d5a7aa
...
...
@@ -409,6 +409,7 @@
this
.
documents
=
_docs
;
this
.
returnDocuments
=
[];
this
.
current
=
-
1
;
this
.
guid
=
""
;
this
.
start
=
function
()
{
...
...
@@ -417,14 +418,14 @@
this
.
api
.
incrementCounterLongAction
();
if
(
window
.
g_asc_plugins
)
window
.
g_asc_plugins
.
setPluginMethodReturnAsync
();
this
.
guid
=
window
.
g_asc_plugins
.
setPluginMethodReturnAsync
();
this
.
run
();
};
this
.
end
=
function
()
{
if
(
window
.
g_asc_plugins
)
window
.
g_asc_plugins
.
onPluginMethodReturn
(
this
.
returnDocuments
);
window
.
g_asc_plugins
.
onPluginMethodReturn
(
this
.
guid
,
this
.
returnDocuments
);
delete
this
.
api
.
__content_control_worker
;
this
.
api
.
decrementCounterLongAction
();
...
...
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