ONLYOFFICE / document-editor-react

React component for ONLYOFFICE Document Server
Apache License 2.0
34 stars 7 forks source link

How to use “onRequestUser” #18

Closed likedream11 closed 1 year ago

likedream11 commented 1 year ago

I didn't find 'events_onRequestUsers'

likedream11 commented 1 year ago

好吧,我依靠示例自己封装了个组件,大家也自己封装吧,

aleksandrfedorov97 commented 1 year ago

Hi likedream11, you can pass event to config like so:

var onRequestUsers = function (event) {
    var editor = window.DocEditor.instances[args.id];
    editor.setUsers({
        "c": event.data.c,
        "users": [
            {
                "email": "john@example.com",
                "id": "78e1e841",
                "name": "John Smith"
            },
            {
                "email": "kate@example.com",
                "id": "F89d8069ba2b",
                "name": "Kate Cage"
            }
        ]
    });
  };

<DocumentEditor
    config={{
              events: {
                onRequestUsers: onRequestUsers
              }
    }}
        />
      </div>
  )}

Detailed documentation on this method you can find here (https://api.onlyoffice.com/editors/config/events#onRequestUsers)