2.0.106 • Published 4 years ago

wix-comments-ooi v2.0.106

Weekly downloads
1
License
UNLICENSED
Repository
-
Last release
4 years ago

Comments-wix-ooi

Overview

Comments is a component that runs within an out of IFrame TPA, the TPA is required to provide a number of properties in order to run comments. Some of the properties need to be passed from wixCodeAPI which is available in the viewerScript, See viewerScript section. TPA can implement more than one instance of Comments, instances can be distinguished by the entityID property.

Setup

npm install wix-comments-ooi

Comments Component:

<WixCommentsOoi
               compId
               biToken
               uid
               appInstanceId
               locale
               entityID
               triggerShareMode
               buildShareURL
               viewSharedComment
               isMobile
               styleConverter
               appHeight
               signedInstance
               appDefinitionId
               editorMode
               wixCodeApiParams
               settings
               triggerScroll
               memberAuth
               commentsPreLoader
           />

Properties

propNamepropTypedefaultValueisRequireddescription
isMobilebooltruetrueIf the app is open in mobile
settingsobjectdefault settingsfalseConfiguration of the app Settings. See table below
styleConverterobject-trueStyle of the site
localestring'en'falseThe current site language
wixCodeApiParamsobject-trueObject with params from wixCodeApi. See more info
commentsPreLoaderobject-falseObject with the preLoad comments for SSR. See more info
memberAuthfunction-trueA function that checks if the User is logged in & in-Community before invoking the callback,memberAuth(arguments, callback). See more info
signedInstancestring-trueThe current signedInstance
appDefinitionIdstring-trueThe appDefinitionId
compIdstring-trueThe current compId
biTokenstring-trueThe current biToken
uidstring-trueThe current uid
appInstanceIdstring-trueThe current appInstanceId
entityIDstring-truea GUID that is unique per site
buildShareURLfunction-falsea function that gets called with two parameters: commentsId, entityId. should return a URL of the site with the provided comment data to be shared buildShareURL(commentId, entityId)
viewSharedCommentobject-truean object that contains the id and the entityID of the comment than needs to be viewed - if provided, Comments enters share mode
triggerShareModefunction-trueThis function gets called when the app enters/exits share mode with one boolean parameter
triggerScrollfunction-trueFunction that gets bool and freeze/unfreeze page scroll. triggerScroll(bool)
editorModeboolfalsefalseif the app is in editor mode

ViewerScript

Comments requires some properties to be passed from the viewerScript, They can be acquired like this: 1. import WixCodeApiManager from wix-comments-ooi

import WixCodeApiManager from 'wix-comments-ooi/dist/src/wixCodeApiManager.js';
  1. then call WixCodeApiManager with the parameters wixCodeApi, appParams, compId :
 let wixCodeApiParams = await WixCodeApiManager(wixCodeApi, appParams, compId); 
  1. This will return an object that contains the necessary parameters for comments, it should be passed via setProps:
      let wixCodeApiParams = await WixCodeApiManager(wixCodeApi, appParams, compId); 
      
      setProps({
            ...,
            wixCodeApiParams
       });
  1. add the same logic to the user.onLogin function:
      wixCodeApi.user.onLogin(() => {
           let wixCodeApiParams = await WixCodeApiManager(wixCodeApi, appParams, compId);
           setProps({
                // other props
                wixCodeApiParams
            });
       }

Settings

An object that contains the settings of Comments. Like how many comments to load/show..

propNamepropTypedefaultValueisRequireddescription
commentsToDisplaynumber1-number of comments to display by default
repliesToDisplaynumber1-number of replies to display by default - next version
textDirectionstring"LTR"-text direction: "RTL" / "LTR"
commentsToLoadOnShowMorenumber5-number of comments to be loaded when clicking show more comments
repliesToLoadOnShowMorenumber5-number of replies to be loaded when clicking show more comments
enableRepliesboolfalse-Enable replies
showCommentsTitlebooltrue-Show/hide "All Comments(n)" title
enableLikesbooltrue-enable/disable likes
enableSharebooltrue-enable/disable share
enablePaddingDesktopboolfalse-enable/disable left & right padding on Comments component (20px)
enablePaddingMobileboolfalse-enable/disable left & right padding on Comments component (20px)
enableDividerbooltrue-enable/disable divider bellow Comments title
showRepliesByDefaultboolfalse-show/hide replies with comments
commentsBox_nonenumber1-Indicates where to show the addCommentBox when there is no comments yet. 1=at top. 2=at bottom. 3=at top & at bottom.
commentsBox_fewnumber1-Indicates where to show the addCommentBox when there is few comments. 1=at top. 2=at bottom. 3=at top & at bottom.
commentsBox_manynumber3-Indicates where to show the addCommentBox when there is many comments. 1=at top. 2=at bottom. 3=at top & at bottom.

Member Auth

The TPA should implement a function called memberAuth and pass it to Comments component via props, the function will check and open login/join-community popups when required, and in case the User is login and in the community then invoke the callback.

In order to perform any action in the Comments Component the User needs to be of the following:

  • Signed-in
  • Part of the community

memberAuth function gets two parameters:

  • arguments
  • callback

Example of how the implement should look like in the TPA:

memberAuth(args, cb) {
    if (!isUserLoggedIn) {
      	showLoginPopup();
    } else {
      if (privateUserFlag) {
        showJoinCommunityPopup();
      } else {
        cb.call(this, ...args);
      }
    }
}

Share functions

Since Comments is not a standalone app, Its the TPA responsibility to build the share URL, and decode it later when users come through it. Comments will enter share mode when it gets the property viewSharedComment. The object should look like this:

viewSharedComment={
            id:  "commentId",
            entityID: "entityId"
        };

When user clicks on share comment, Comments will call the function buildShareURL, the function should return the URL, and Comments will send this URL to the user. User should be able to exit share mode by clicking back to all comments, This will call the function triggerShareMode

Page Scroll

Comments need to freeze the page scrolling in some situations and for that, a function needs to pass to Comments that control the scrolling called triggerScroll(bool). for example:

triggerScroll(status){
       document.querySelector("body").style.overflow = status ? "scroll" : "hidden";
   }

SSR support

Because Comments load his data via API call, the site (TPA) needs to do that before loading Comments component. to display comments data and support SSR with Comments: 1. import CommentsPreLoader from 'wix-comments-ooi/dist/src/commentsPreLoader.js'; 2. call CommentsPreLoader to receve the list of comments to display: let commentsPreLoader = await CommentsPreLoader(signedInstance, token, entityID, numberOfCommentsToLoad); 3. pass the 'commentsPreLoader' to 'WixCommentsOoi' component props.

Example:

import CommentsPreLoader from 'wix-comments-ooi/dist/src/commentsPreLoader.js';

let commentsPreLoader = await CommentsPreLoader(signedInstance, token, entityID, numberOfCommentsToLoad);

<WixCommentsOoi
    ...
    commentsPreLoader={commentsPreLoader}
/>
2.0.106

4 years ago

2.0.105

4 years ago

2.0.104

4 years ago

2.0.103

4 years ago

2.0.102

4 years ago

2.0.101

4 years ago

2.0.100

4 years ago

2.0.99

4 years ago

2.0.98

4 years ago

2.0.97

4 years ago

2.0.96

4 years ago

2.0.95

4 years ago

2.0.94

4 years ago

2.0.93

4 years ago

2.0.89

4 years ago

2.0.91

4 years ago

2.0.92

4 years ago

2.0.90

4 years ago

2.0.88

4 years ago

2.0.87

4 years ago

2.0.86

4 years ago

2.0.85

4 years ago

2.0.84

4 years ago

2.0.83

4 years ago

2.0.82

4 years ago

2.0.81

4 years ago

2.0.80

4 years ago

2.0.79

4 years ago

2.0.78

4 years ago

2.0.77

4 years ago

2.0.76

4 years ago

2.0.75

4 years ago

2.0.74

4 years ago

2.0.73

4 years ago

2.0.72

4 years ago

2.0.71

4 years ago

2.0.70

4 years ago

2.0.69

4 years ago

2.0.68

4 years ago

2.0.67

4 years ago

2.0.66

4 years ago

2.0.65

4 years ago

2.0.64

4 years ago

2.0.63

4 years ago

2.0.62

4 years ago

2.0.61

4 years ago

2.0.60

4 years ago

2.0.59

4 years ago

2.0.58

4 years ago

2.0.57

4 years ago

2.0.55

4 years ago

2.0.56

4 years ago

2.0.54

4 years ago

2.0.49

4 years ago

2.0.53

4 years ago

2.0.51

4 years ago

2.0.52

4 years ago

2.0.50

4 years ago

2.0.48

4 years ago

2.0.47

4 years ago

2.0.46

4 years ago

2.0.45

4 years ago

2.0.44

4 years ago

2.0.42

4 years ago

2.0.43

4 years ago

2.0.41

4 years ago

2.0.40

4 years ago

2.0.39

4 years ago

2.0.38

4 years ago

2.0.37

4 years ago

2.0.35

4 years ago

2.0.36

4 years ago

2.0.34

4 years ago

2.0.33

4 years ago

2.0.32

4 years ago

2.0.31

4 years ago

2.0.30

4 years ago

2.0.29

4 years ago

2.0.27

4 years ago

2.0.28

4 years ago

2.0.26

4 years ago

2.0.25

4 years ago

2.0.24

4 years ago

2.0.22

4 years ago

2.0.23

4 years ago

2.0.21

4 years ago

2.0.20

4 years ago

2.0.19

4 years ago

2.0.18

4 years ago

2.0.17

4 years ago

2.0.16

4 years ago

2.0.15

4 years ago

2.0.14

4 years ago

2.0.13

4 years ago

2.0.12

4 years ago

2.0.11

4 years ago

2.0.10

4 years ago

2.0.9

4 years ago

2.0.7

4 years ago

2.0.8

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.147

4 years ago

1.1.146

4 years ago

1.1.145

4 years ago

1.1.144

4 years ago

1.1.143

4 years ago

1.1.142

4 years ago

1.1.141

4 years ago

1.1.140

4 years ago

1.1.139

4 years ago

1.1.138

4 years ago

1.1.137

4 years ago

1.1.136

4 years ago

1.1.135

4 years ago

1.1.134

4 years ago

1.1.133

4 years ago

1.1.132

4 years ago

1.1.131

4 years ago

1.1.130

4 years ago

1.1.129

4 years ago

1.1.128

4 years ago

1.1.127

4 years ago

1.1.126

4 years ago

1.1.125

4 years ago

1.1.124

4 years ago

1.1.123

4 years ago

1.1.122

4 years ago

1.1.121

4 years ago

1.1.120

4 years ago

1.1.119

4 years ago

1.1.118

4 years ago

1.1.117

4 years ago

1.1.116

4 years ago

1.1.115

4 years ago

1.1.114

4 years ago

1.1.113

4 years ago

1.1.112

4 years ago

1.1.111

4 years ago

1.1.110

4 years ago

1.1.109

4 years ago

1.1.108

4 years ago

1.1.107

4 years ago

1.1.106

4 years ago

1.1.105

4 years ago

1.1.104

4 years ago

1.1.103

4 years ago

1.1.102

4 years ago

1.1.100

4 years ago

1.1.101

4 years ago

1.1.99

4 years ago

1.1.98

4 years ago

1.1.97

4 years ago

1.1.96

4 years ago

1.1.95

4 years ago

1.1.94

4 years ago

1.1.93

4 years ago

1.1.92

4 years ago

1.1.91

4 years ago

1.1.90

4 years ago

1.1.89

4 years ago

1.1.88

4 years ago

1.1.87

4 years ago

1.1.86

4 years ago

1.1.85

4 years ago

1.1.84

4 years ago

1.1.83

4 years ago

1.1.82

4 years ago

1.1.81

4 years ago

1.1.80

4 years ago

1.1.79

4 years ago

1.1.78

4 years ago

1.1.77

4 years ago

1.1.76

4 years ago

1.1.75

4 years ago

1.1.74

4 years ago

1.1.73

4 years ago

1.1.72

4 years ago

1.1.71

4 years ago

1.1.70

4 years ago

1.1.69

4 years ago

1.1.68

4 years ago

1.1.67

4 years ago

1.1.66

4 years ago

1.1.65

4 years ago

1.1.64

4 years ago

1.1.63

4 years ago

1.1.62

4 years ago

1.1.61

4 years ago

1.1.59

4 years ago

1.1.58

4 years ago

1.1.60

4 years ago

1.1.57

4 years ago

1.1.56

4 years ago

1.1.55

4 years ago

1.1.54

4 years ago

1.1.53

4 years ago

1.1.52

4 years ago

1.1.51

4 years ago

1.1.50

4 years ago

1.1.49

4 years ago

1.1.48

4 years ago

1.1.47

4 years ago

1.1.45

4 years ago

1.1.46

4 years ago

1.1.44

4 years ago

1.1.43

4 years ago

1.1.41

4 years ago

1.1.42

4 years ago

1.1.40

4 years ago

1.1.38

4 years ago

1.1.39

4 years ago

1.1.37

4 years ago

1.1.36

4 years ago

1.1.35

4 years ago

1.1.34

4 years ago

1.1.33

4 years ago

1.1.32

4 years ago

1.1.31

4 years ago

1.1.30

4 years ago

1.1.29

4 years ago

1.1.28

4 years ago

1.1.27

4 years ago

1.1.26

4 years ago

1.1.25

4 years ago

1.1.24

4 years ago

1.1.19

4 years ago

1.1.23

4 years ago

1.1.22

4 years ago

1.1.21

4 years ago

1.1.20

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.16

4 years ago

1.1.15

4 years ago

1.1.14

4 years ago

1.0.213

4 years ago

1.1.12

4 years ago

1.1.13

4 years ago

1.1.11

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.10

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.212

4 years ago

1.0.211

4 years ago

1.0.210

4 years ago

1.0.209

4 years ago

1.0.208

4 years ago

1.0.207

4 years ago

1.0.206

4 years ago

1.0.205

4 years ago

1.0.204

4 years ago

1.0.203

4 years ago

1.0.202

4 years ago

1.0.201

4 years ago

1.0.200

4 years ago

1.0.199

4 years ago

1.0.198

4 years ago

1.0.197

4 years ago

1.0.196

4 years ago

1.0.195

4 years ago

1.0.194

4 years ago

1.0.193

4 years ago

1.0.192

4 years ago

1.0.191

4 years ago

1.0.190

4 years ago

1.0.189

4 years ago

1.0.188

4 years ago

1.0.187

4 years ago

1.0.186

4 years ago

1.0.185

4 years ago

1.0.183

4 years ago

1.0.184

4 years ago

1.0.182

4 years ago

1.0.181

4 years ago

1.0.180

4 years ago

1.0.179

4 years ago

1.0.178

4 years ago

1.0.177

4 years ago

1.0.176

4 years ago

1.0.175

4 years ago

1.0.174

4 years ago

1.0.173

4 years ago

1.0.172

4 years ago

1.0.171

4 years ago

1.0.170

4 years ago

1.0.169

4 years ago

1.0.168

4 years ago

1.0.167

4 years ago

1.0.166

4 years ago

1.0.165

4 years ago

1.0.164

4 years ago

1.0.163

4 years ago

1.0.162

4 years ago

1.0.161

4 years ago

1.0.160

4 years ago

1.0.159

4 years ago

1.0.158

4 years ago

1.0.156

4 years ago

1.0.157

4 years ago

1.0.155

4 years ago

1.0.154

4 years ago

1.0.153

4 years ago

1.0.152

4 years ago

1.0.151

4 years ago

1.0.150

4 years ago

1.0.149

4 years ago

1.0.148

4 years ago

1.0.147

4 years ago

1.0.146

4 years ago

1.0.145

4 years ago

1.0.143

4 years ago

1.0.144

4 years ago

1.0.142

4 years ago

1.0.141

4 years ago

1.0.140

4 years ago

1.0.139

4 years ago

1.0.138

4 years ago

1.0.137

4 years ago

1.0.136

4 years ago

1.0.135

4 years ago

1.0.134

4 years ago

1.0.133

4 years ago

1.0.132

4 years ago

1.0.131

4 years ago

1.0.130

4 years ago

1.0.129

4 years ago

1.0.128

4 years ago

1.0.127

4 years ago

1.0.126

4 years ago

1.0.125

5 years ago

1.0.124

5 years ago

1.0.123

5 years ago

1.0.122

5 years ago

1.0.121

5 years ago

1.0.120

5 years ago

1.0.119

5 years ago

1.0.118

5 years ago

1.0.117

5 years ago

1.0.116

5 years ago

1.0.115

5 years ago

1.0.114

5 years ago

1.0.113

5 years ago

1.0.112

5 years ago

1.0.111

5 years ago

1.0.110

5 years ago

1.0.109

5 years ago

1.0.108

5 years ago

1.0.107

5 years ago

1.0.106

5 years ago

1.0.105

5 years ago

1.0.104

5 years ago

1.0.103

5 years ago

1.0.102

5 years ago

1.0.101

5 years ago

1.0.100

5 years ago

1.0.99

5 years ago

1.0.98

5 years ago

1.0.97

5 years ago

1.0.96

5 years ago

1.0.95

5 years ago

1.0.94

5 years ago

1.0.93

5 years ago

1.0.92

5 years ago

1.0.91

5 years ago

1.0.90

5 years ago

1.0.89

5 years ago

1.0.88

5 years ago

1.0.87

5 years ago

1.0.86

5 years ago

1.0.85

5 years ago

1.0.84

5 years ago

1.0.83

5 years ago

1.0.82

5 years ago

1.0.81

5 years ago

1.0.80

5 years ago

1.0.79

5 years ago

1.0.78

5 years ago

1.0.77

5 years ago

1.0.76

5 years ago

1.0.75

5 years ago

1.0.74

5 years ago

1.0.73

5 years ago

1.0.72

5 years ago

1.0.71

5 years ago

1.0.70

5 years ago

1.0.69

5 years ago

1.0.68

5 years ago

1.0.67

5 years ago

1.0.66

5 years ago

1.0.65

5 years ago

1.0.64

5 years ago

1.0.63

5 years ago

1.0.62

5 years ago

1.0.61

5 years ago

1.0.60

5 years ago

1.0.59

5 years ago

1.0.58

5 years ago

1.0.57

5 years ago

1.0.56

5 years ago

1.0.55

5 years ago

1.0.54

5 years ago

1.0.53

5 years ago

1.0.52

5 years ago

1.0.51

5 years ago

1.0.50

5 years ago

1.0.49

5 years ago

1.0.48

5 years ago

1.0.47

5 years ago

1.0.46

5 years ago

1.0.45

5 years ago

1.0.44

5 years ago

1.0.43

5 years ago

1.0.42

5 years ago

1.0.41

5 years ago

1.0.40

5 years ago

1.0.39

5 years ago

1.0.38

5 years ago

1.0.37

5 years ago

1.0.36

5 years ago

1.0.35

5 years ago

1.0.34

5 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago