Skip to content
Snippets Groups Projects
Commit 13095b1c authored by hendrik.donath's avatar hendrik.donath
Browse files

Fixed text annotation not showing and not working on mobile devices

parent 691e0cdc
No related branches found
No related tags found
No related merge requests found
...@@ -6322,13 +6322,15 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6322,13 +6322,15 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
var input=void 0; var input=void 0;
var pos = void 0; var pos = void 0;
var _textSize=void 0; var _textSize=void 0;
var _textColor=void 0;/** var _textColor=void 0;
var svg=void 0;
var rect=void 0;/**
* Handle document.mouseup event * Handle document.mouseup event
* *
* *
* @param {Event} e The DOM event to handle * @param {Event} e The DOM event to handle
*/function handleDocumentMouseup(e){ // betrifft textbox */function handleDocumentMouseup(e){ // betrifft textbox
if(input||!(0,_utils.findSVGAtPoint)(e.clientX,e.clientY)){ if(input||!(svg=(0,_utils.findSVGAtPoint)(e.clientX,e.clientY))){
return; return;
} }
let scrollTop = window.pageYOffset; let scrollTop = window.pageYOffset;
...@@ -6345,10 +6347,14 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6345,10 +6347,14 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
input.addEventListener('keyup',handleInputKeyup); input.addEventListener('keyup',handleInputKeyup);
document.body.appendChild(input); document.body.appendChild(input);
input.focus(); input.focus();
rect=svg.getBoundingClientRect();
pos = {x: e.clientX, y: e.clientY }; pos = {x: e.clientX, y: e.clientY };
}/** }
/**
* Handle input.blur event * Handle input.blur event
*/function handleInputBlur(){saveText();}/** */function handleInputBlur(){
saveText();
}/**
* Handle input.keyup event * Handle input.keyup event
* *
* @param {Event} e The DOM event to handle * @param {Event} e The DOM event to handle
...@@ -6360,14 +6366,14 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6360,14 +6366,14 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
var clientX=parseInt(pos.x,10); var clientX=parseInt(pos.x,10);
//text size additional to y to render the text right under the mouse click //text size additional to y to render the text right under the mouse click
var clientY=parseInt(pos.y,10); var clientY=parseInt(pos.y,10);
var svg=(0,_utils.findSVGAtPoint)(clientX,clientY); //var svg=(0,_utils.findSVGAtPoint)(clientX,clientY);
if(!svg){ if(!svg){
return{v:void 0}; return{v:void 0};
} }
var _getMetadata=(0,_utils.getMetadata)(svg); var _getMetadata=(0,_utils.getMetadata)(svg);
var documentId=_getMetadata.documentId; var documentId=_getMetadata.documentId;
var pageNumber=_getMetadata.pageNumber; var pageNumber=_getMetadata.pageNumber;
var rect=svg.getBoundingClientRect();
var annotation=Object.assign({type:'textbox',size:_textSize,color:_textColor,content:input.value.trim()},(0,_utils.scaleDown)(svg,{x:(0,_utils.roundDigits)(clientX-rect.left,4),y:(0,_utils.roundDigits)(clientY-rect.top,4),width:(0,_utils.roundDigits)(input.offsetWidth,4),height:(0,_utils.roundDigits)(input.offsetHeight,4)})); var annotation=Object.assign({type:'textbox',size:_textSize,color:_textColor,content:input.value.trim()},(0,_utils.scaleDown)(svg,{x:(0,_utils.roundDigits)(clientX-rect.left,4),y:(0,_utils.roundDigits)(clientY-rect.top,4),width:(0,_utils.roundDigits)(input.offsetWidth,4),height:(0,_utils.roundDigits)(input.offsetHeight,4)}));
_PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId,pageNumber,annotation) _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId,pageNumber,annotation)
.then(function(annotation){ .then(function(annotation){
...@@ -6394,9 +6400,22 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6394,9 +6400,22 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
* @param {String} textColor The color of the text * @param {String} textColor The color of the text
*/function setText(){var textSize=arguments.length<=0||arguments[0]===undefined?12:arguments[0];var textColor=arguments.length<=1||arguments[1]===undefined?'000000':arguments[1];_textSize=parseInt(textSize,10);_textColor=textColor;}/** */function setText(){var textSize=arguments.length<=0||arguments[0]===undefined?12:arguments[0];var textColor=arguments.length<=1||arguments[1]===undefined?'000000':arguments[1];_textSize=parseInt(textSize,10);_textColor=textColor;}/**
* Enable text behavior * Enable text behavior
*/function enableText(){if(_enabled){return;}_enabled=true;document.getElementById('content-wrapper').classList.add('cursor-text');document.addEventListener('mouseup',handleDocumentMouseup);}/** */function enableText(){
if(_enabled){
return;
}
_enabled=true;
document.getElementById('content-wrapper').classList.add('cursor-text');
document.addEventListener('mouseup',handleDocumentMouseup);
}/**
* Disable text behavior * Disable text behavior
*/function disableText(){if(!_enabled){return;}_enabled=false;document.getElementById('content-wrapper').classList.remove('cursor-text');document.removeEventListener('mouseup',handleDocumentMouseup);} */function disableText(){
if(!_enabled){return;
}
_enabled=false;
document.getElementById('content-wrapper').classList.remove('cursor-text');
document.removeEventListener('mouseup',handleDocumentMouseup);
}
/***/}, /***/},
/* 34 */ /* 34 */
/***/function(module,exports,__webpack_require__){ /***/function(module,exports,__webpack_require__){
......
...@@ -870,3 +870,8 @@ header, section, footer, aside, nav, main, article, figure { ...@@ -870,3 +870,8 @@ header, section, footer, aside, nav, main, article, figure {
.path-mod-pdfannotator .pdfannotator-statistic #chart-container { .path-mod-pdfannotator .pdfannotator-statistic #chart-container {
min-height: 500px; min-height: 500px;
} }
.toolbaritem .pdfannotator_text {
display: inline-block;
visibility: visible;
}
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
{{#usestudenttextbox}} {{#usestudenttextbox}}
<span class="toolbaritem"> <span class="toolbaritem">
<button class="text" type="button" title="{{# str }} text, pdfannotator {{/ str }}" data-tooltype="text">{{# pix }}text_color_picker,pdfannotator, {{# str }} text, pdfannotator {{/ str }} {{/ pix}}</button> <button class="pdfannotator_text text" type="button" title="{{# str }} text, pdfannotator {{/ str }}" data-tooltype="text">{{# pix }}text_color_picker,pdfannotator, {{# str }} text, pdfannotator {{/ str }} {{/ pix}}</button>
<select class="text-size"></select> <select class="text-size"></select>
<div class="text-color"></div> <div class="text-color"></div>
</span> </span>
......
...@@ -25,6 +25,6 @@ ...@@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->component = 'mod_pdfannotator'; // Full name of the plugin (used for diagnostics). $plugin->component = 'mod_pdfannotator'; // Full name of the plugin (used for diagnostics).
$plugin->version = 2021030505; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2021031902; // The current module version (Date: YYYYMMDDXX).
$plugin->release = 'PDF Annotator v1.4 release 4'; $plugin->release = 'PDF Annotator v1.4 release 4';
$plugin->requires = 2016112900; // Requires this Moodle version. $plugin->requires = 2016112900; // Requires this Moodle version.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment