Try the fastest and simplest way to install ONLYOFFICE

Edit option not working

Integration questions/issues

Edit option not working

Postby dandanielw » Tue Feb 02, 2016 8:13 pm

Hi, I finally could use the only office api and integrate this solution to my project, but I'm having the following problem: Even though I set edit permission to true in the json config object, and mode in 'edit' , it doesn't allow me to edit anything. I mean , the document is loaded correctly, now javascript errors in the console, it's just that I try to type and there is just no response, as it should be in view mode. But you can see in my configuration below that the mode is set to edit .

Would you mind taking a look at my config and tell me what it could be?

Thanks in advance

Below is my exact configuration:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link rel="icon" href="./favicon.ico" type="image/x-icon" />
   <title>UVQ - Gestion de Evaluaciones</title>

   <style>
      html {
         height: 100%;
         width: 100%;
      }

      body {
         background: #fff;
         color: #333;
         font-family: Arial, Tahoma,sans-serif;
         font-size: 12px;
         font-weight: normal;
         height: 100%;
         margin: 0;
         overflow-y: hidden;
         padding: 0;
         text-decoration: none;
      }

      form {
         height: 100%;
      }

      div {
         margin: 0;
         padding: 0;
      }
   </style>

   <script type='text/javascript' src='http://172.17.0.1:880/OfficeWeb/apps/api/documents/api.js'></script><script type='text/javascript'>
      var onReady ;
      var onDocumentStateChange ;
      var onRequestEditRights ;
      var onError ;
      var docEditor ;
      var connectEditor ;

        var innerAlert = function (message) {
            if (console && console.log)
                console.log(message);
            ;
        };
      

        onReady = function () {
            innerAlert('Document editor ready');
        };

        onDocumentStateChange = function (event) {
            var title = document.title.replace(/\*$/g, '');
            document.title = title + (event.data ? '*' : '');
        };

        onRequestEditRights = function () {
            if (typeof DocsAPI.DocEditor.version == 'function') {
                var version = DocsAPI.DocEditor.version();
                if ((parseFloat(version) || 0) >= 3) {
                    location.href = location.href.replace(RegExp("action=view\&?", "i"), '');
                    return;
                }
            }
            docEditor.applyEditRights(true);
        };

        onError = function (event) {
            if (console && console.log && event)
                console.log(event.data);
        };

      
         connectEditor = function () {

            docEditor = new DocsAPI.DocEditor('iframeEditor', {
                    width: '100%',
                    height: '100%',

                    type: 'desktop',
                    documentType: 'text',
                    document: {
                        title: 'examenqtHeem.docx',
                        url: 'http://10.26.0.243:3000/guarani/3.10/archivos_examen/examenqtHeem.docx',
                        fileType: '.docx',
                        key: '2557577019',
                        vkey: 'cHJPV0swdWM5V3lXdWZ0QzBXTWNWNndaSnkzYmxBWnhWUjNOZS9oc25ITT0_eyJleHBpcmUiOiJcL0RhdGUoMTQ1NDQ0NjIxNTc3OSlcLyIsImtleSI6IjI1NTc1NzcwMTkiLCJrZXlfaWQiOiIiLCJ1c2VyX2NvdW50IjowLCJpcCI6IjEwLjI2LjAuMjQzIn01',
                  info: {
                     author: 'Me',
                     created: '02.02.16'
                  },
                  permissions: {
                     edit: true,
                     download: true
                  }
               },
               editorConfig: {
                  mode: 'edit',
                  lang: 'es',
                  callbackUrl: 'http://10.26.0.243:3000/ajax_callback_onlyoffice.php?type=track&userAddress=1.1.1.1&fileName=examenqtHeem.docx',
                  embedded: {
                     saveUrl: 'http://10.26.0.243:3000/guarani/3.10/archivos_examen/examenqtHeem.docx',
                     embedUrl: 'http://10.26.0.243:3000/guarani/3.10/archivos_examen/examenqtHeem.docx',
                     shareUrl: 'http://10.26.0.243:3000/guarani/3.10/archivos_examen/examenqtHeem.docx',
                     toolbarDocked: 'top'
                  }
               },
               events: {
                  'onReady': onReady,
                  'onError': onError,
                  'onDocumentStateChange': onDocumentStateChange,
                  'onRequestEditRights': onRequestEditRights
               }
            });
         }; // END_OF:  var connectEditor = function ()

         if (window.addEventListener) {
            window.addEventListener('load', connectEditor);
         } else if (window.attachEvent) {
            window.attachEvent('load', connectEditor);
         }</script>
</head>
<body>
<form id="form1">
   
           <div id='iframeEditor'>
           </div>
      </form>
</body>
</html>

dandanielw
 
Posts: 13
Joined: Mon Dec 14, 2015 5:40 pm

Re: Edit option not working

Postby Dean » Wed Feb 03, 2016 11:14 am

Hello,

Please specify, what ONLYOFFICE Documents Version you're using?

The most preferable solution is to use our latest version of the Document Editors - 3.0 and use the attached config to integrate them.

Latest Document Server version you may find here:

http://sourceforge.net/projects/teamlab ... /binaries/

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link rel="icon" href="./favicon.ico" type="image/x-icon" />
   <title>UVQ - Gestion de Evaluaciones</title>

   <style>
      html {
         height: 100%;
         width: 100%;
      }

      body {
         background: #fff;
         color: #333;
         font-family: Arial, Tahoma,sans-serif;
         font-size: 12px;
         font-weight: normal;
         height: 100%;
         margin: 0;
         overflow-y: hidden;
         padding: 0;
         text-decoration: none;
      }

      form {
         height: 100%;
      }

      div {
         margin: 0;
         padding: 0;
      }
   </style>

   <script type='text/javascript' src='http://172.17.0.1:880/OfficeWeb/apps/api/documents/api.js'></script><script type='text/javascript'>
      var onReady ;
      var onDocumentStateChange ;
      var onRequestEditRights ;
      var onError ;
      var docEditor ;
      var connectEditor ;

        var innerAlert = function (message) {
            if (console && console.log)
                console.log(message);
            ;
        };
     

        onReady = function () {
            innerAlert('Document editor ready');
        };

        onDocumentStateChange = function (event) {
            var title = document.title.replace(/\*$/g, '');
            document.title = title + (event.data ? '*' : '');
        };

        onRequestEditRights = function () {
            if (typeof DocsAPI.DocEditor.version == 'function') {
                var version = DocsAPI.DocEditor.version();
                if ((parseFloat(version) || 0) >= 3) {
                    location.href = location.href.replace(RegExp("action=view\&?", "i"), '');
                    return;
                }
            }
            docEditor.applyEditRights(true);
        };

        onError = function (event) {
            if (console && console.log && event)
                console.log(event.data);
        };

     
         connectEditor = function () {

            docEditor = new DocsAPI.DocEditor('iframeEditor', {
                    width: '100%',
                    height: '100%',

                    type: 'desktop',
                    documentType: 'text',
                    document: {
                        title: 'examenqtHeem.docx',
                        url: 'http://10.26.0.243:3000/guarani/3.10/archivos_examen/examenqtHeem.docx',
                        fileType: 'docx',
                        key: '2557577019',                       
                  info: {
                     author: 'Me',
                     created: '02.02.16'
                  },
                  permissions: {
                     edit: true,
                     download: true
                  }
               },
               editorConfig: {
                  mode: 'edit',
                  lang: 'es',
                  callbackUrl: 'http://10.26.0.243:3000/ajax_callback_onlyoffice.php?type=track&userAddress=1.1.1.1&fileName=examenqtHeem.docx',
                  embedded: {
                     saveUrl: 'http://10.26.0.243:3000/guarani/3.10/archivos_examen/examenqtHeem.docx',
                     embedUrl: 'http://10.26.0.243:3000/guarani/3.10/archivos_examen/examenqtHeem.docx',
                     shareUrl: 'http://10.26.0.243:3000/guarani/3.10/archivos_examen/examenqtHeem.docx',
                     toolbarDocked: 'top'
                  }
               },
               events: {
                  'onReady': onReady,
                  'onError': onError,
                  'onDocumentStateChange': onDocumentStateChange,
                  'onRequestEditRights': onRequestEditRights
               }
            });
         }; // END_OF:  var connectEditor = function ()

         if (window.addEventListener) {
            window.addEventListener('load', connectEditor);
         } else if (window.attachEvent) {
            window.attachEvent('load', connectEditor);
         }</script>
</head>
<body>
<form id="form1">
   
           <div id='iframeEditor'>
           </div>
      </form>
</body>
</html>
Dean
 
Posts: 700
Joined: Tue Sep 30, 2014 11:04 am

Re: Edit option not working

Postby dandanielw » Wed Feb 03, 2016 8:11 pm

Hi Dean,

I'm running onlyoffice-documentserver 3.0.0-99

The strange thing is that if I use the original integration example it works perfectly, but I had to adapt the php a littlebit to the system where I had to embed it in.
But even then, I didn't change the core functions that come with the example, and if you check it out, my html and javascript are practically the same as the one that come with the example, and more important, the resulting JSON object for the docEditor configuration is the same, that's why it's so strange.

Is there anyway i can help you , to help me figure out what the problem is? because everything works fine, it's just that I can't get to edit the document in the editor .

Thanks .
dandanielw
 
Posts: 13
Joined: Mon Dec 14, 2015 5:40 pm

Re: Edit option not working

Postby Dean » Thu Feb 04, 2016 12:12 pm

Hello,

Would you please mind specifying the storage you've downloaded Document Server from?
Dean
 
Posts: 700
Joined: Tue Sep 30, 2014 11:04 am

Re: Edit option not working

Postby dandanielw » Thu Feb 04, 2016 3:51 pm

Yes, I installed it through docker like this :

Code: Select all
sudo docker run -i -t -d -p 880:80 -p 4443:443 --name onlyoffice \
    -v /opt/onlyoffice/Logs:/var/log/onlyoffice  \
    -v /opt/onlyoffice/Data:/var/www/onlyoffice/Data  onlyoffice/documentserver


Oh, and by the way, on another post you answered to me this :

vkey is not necessary and will cause errors like opening viewer instead of editor.


So I thought that maybe vkey was causing the problem, so I commented out all vkey usages (from the PHP requests and from the JSON editor configuration , but it still doesn't let me edit the document.
dandanielw
 
Posts: 13
Joined: Mon Dec 14, 2015 5:40 pm

Re: Edit option not working

Postby Dean » Fri Feb 05, 2016 10:24 am

Please use the config I sent you two posts ago. It works for us.
Dean
 
Posts: 700
Joined: Tue Sep 30, 2014 11:04 am

Re: Edit option not working

Postby dandanielw » Tue Feb 16, 2016 5:02 pm

Hi, I'm sorry but I don't understand: 2 posts ago you sent me an exact copy of the configuration I posted for you to check.

Would you mind telling what are the config variables and anything that would put the editor in "view only" mode ?

as you can see in my config I put

...
permissions: {
edit: true,
download: true
}
},
editorConfig: {
mode: 'edit',
lang: 'es',
...

but that's not working, so there must be something else that is blocking the edit mode apart from the configuration.
dandanielw
 
Posts: 13
Joined: Mon Dec 14, 2015 5:40 pm

Re: Edit option not working

Postby dandanielw » Tue Feb 16, 2016 5:36 pm

OK< it's solved, I just found the error, the problem was that in the configuration in the

document.fileType setting I was prepending a dot before the document extension. I trimmed it and it worked.

Thanks for the help.
dandanielw
 
Posts: 13
Joined: Mon Dec 14, 2015 5:40 pm


Return to API

Who is online

Users browsing this forum: No registered users and 5 guests