@weavy/uikit-react 13.0.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +24 -0
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/Chat.d.ts +1 -1
- package/dist/cjs/types/components/Messages.d.ts +3 -1
- package/dist/cjs/types/hooks/useConversations.d.ts +1 -1
- package/dist/cjs/types/hooks/useMutateMessage.d.ts +1 -1
- package/dist/cjs/types/hooks/useMutateRead.d.ts +1 -0
- package/dist/cjs/types/types/Chat.d.ts +1 -0
- package/dist/cjs/types/types/Message.d.ts +2 -0
- package/dist/cjs/types/types/types.d.ts +47 -4
- package/dist/cjs/types/ui/Spinner.d.ts +2 -1
- package/dist/css/weavy-chat.css +1540 -954
- package/dist/css/weavy-messenger.css +1901 -1298
- package/dist/css/weavy.css +1696 -1093
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/Chat.d.ts +1 -1
- package/dist/esm/types/components/Messages.d.ts +3 -1
- package/dist/esm/types/hooks/useConversations.d.ts +1 -1
- package/dist/esm/types/hooks/useMutateMessage.d.ts +1 -1
- package/dist/esm/types/hooks/useMutateRead.d.ts +1 -0
- package/dist/esm/types/types/Chat.d.ts +1 -0
- package/dist/esm/types/types/Message.d.ts +2 -0
- package/dist/esm/types/types/types.d.ts +47 -4
- package/dist/esm/types/ui/Spinner.d.ts +2 -1
- package/dist/index.d.ts +2 -1
- package/package.json +2 -2
- package/src/client/WeavyClient.ts +12 -17
- package/src/components/Attachment.tsx +5 -5
- package/src/components/Chat.tsx +6 -5
- package/src/components/Conversation.tsx +26 -20
- package/src/components/ConversationBadge.tsx +7 -5
- package/src/components/ConversationForm.tsx +1 -1
- package/src/components/ConversationList.tsx +59 -11
- package/src/components/ConversationListItem.tsx +71 -54
- package/src/components/FileBrowser.tsx +53 -50
- package/src/components/MeetingCard.tsx +35 -13
- package/src/components/Meetings.tsx +1 -1
- package/src/components/Message.tsx +41 -41
- package/src/components/Messages.tsx +61 -60
- package/src/components/Messenger.tsx +7 -2
- package/src/components/NewConversation.tsx +1 -1
- package/src/components/PdfViewer.tsx +5 -5
- package/src/components/Preview.tsx +2 -2
- package/src/components/Reactions.tsx +11 -5
- package/src/components/SearchUsers.tsx +19 -9
- package/src/components/SeenBy.tsx +13 -7
- package/src/components/Typing.tsx +11 -12
- package/src/contexts/UserContext.tsx +1 -1
- package/src/contexts/WeavyContext.tsx +3 -3
- package/src/hooks/useConversations.ts +15 -5
- package/src/hooks/useMutateMessage.ts +1 -5
- package/src/hooks/useMutateRead.ts +5 -3
- package/src/hooks/usePresence.ts +2 -3
- package/src/hooks/useReactions.ts +11 -12
- package/src/scss/theme/_alert.scss +61 -63
- package/src/scss/theme/_appbar.scss +105 -30
- package/src/scss/theme/_avatar.scss +23 -28
- package/src/scss/theme/_badge.scss +26 -18
- package/src/scss/theme/_buttons.scss +107 -52
- package/src/scss/theme/_card.scss +102 -4
- package/src/scss/theme/_checkbox.scss +16 -20
- package/src/scss/theme/_code-vscode-dark.scss +3 -3
- package/src/scss/theme/_code-vscode-light.scss +3 -3
- package/src/scss/theme/_code.scss +0 -2
- package/src/scss/theme/_comment-editor-cm.scss +97 -0
- package/src/scss/theme/_comment-editor.scss +129 -0
- package/src/scss/theme/_comments.scss +66 -0
- package/src/scss/theme/_content.scss +33 -5
- package/src/scss/theme/_conversations.scss +19 -78
- package/src/scss/theme/_dropdown.scss +102 -15
- package/src/scss/theme/_embed.scss +135 -0
- package/src/scss/theme/_facepile.scss +11 -0
- package/src/scss/theme/_filebrowser.scss +1 -1
- package/src/scss/theme/_files.scss +76 -47
- package/src/scss/theme/_grid.scss +8 -0
- package/src/scss/theme/_icons.scss +155 -19
- package/src/scss/theme/_image-grid.scss +7 -10
- package/src/scss/theme/_input.scss +160 -0
- package/src/scss/theme/_item.scss +169 -0
- package/src/scss/theme/_list.scss +57 -0
- package/src/scss/theme/_meeting.scss +11 -0
- package/src/scss/theme/_message-editor-cm.scss +95 -0
- package/src/scss/theme/_message-editor.scss +65 -19
- package/src/scss/theme/_messages.scss +51 -105
- package/src/scss/theme/_meta.scss +12 -0
- package/src/scss/theme/_overlays.scss +31 -76
- package/src/scss/theme/_pager.scss +5 -1
- package/src/scss/theme/_pane.scss +13 -2
- package/src/scss/theme/_panels.scss +33 -28
- package/src/scss/theme/_picker-list.scss +5 -3
- package/src/scss/theme/_placeholder.scss +19 -0
- package/src/scss/theme/_poll.scss +49 -0
- package/src/scss/theme/_post-editor-cm.scss +100 -0
- package/src/scss/theme/_post-editor.scss +127 -0
- package/src/scss/theme/_post.scss +83 -0
- package/src/scss/theme/_preview-code.scss +11 -2
- package/src/scss/theme/_preview-embed.scss +8 -2
- package/src/scss/theme/_preview-image.scss +8 -26
- package/src/scss/theme/_preview-media.scss +1 -0
- package/src/scss/theme/_preview-pdf.scss +10 -15
- package/src/scss/theme/_preview.scss +57 -79
- package/src/scss/theme/_reactions.scss +48 -17
- package/src/scss/theme/_sheet.scss +59 -0
- package/src/scss/theme/_sidebar.scss +86 -0
- package/src/scss/theme/_spinner.scss +11 -7
- package/src/scss/theme/_tab.scss +72 -0
- package/src/scss/theme/_tables.scss +70 -23
- package/src/scss/theme/_toasts.scss +56 -26
- package/src/scss/theme/_type.scss +41 -0
- package/src/scss/theme/{mixins → base}/_backdrop.scss +0 -0
- package/src/scss/theme/{bootstrap/mixins → base}/_breakpoints.scss +9 -0
- package/src/scss/theme/base/_colors.scss +315 -0
- package/src/scss/theme/base/_md.scss +19 -0
- package/src/scss/theme/base/_palette.scss +130 -0
- package/src/scss/theme/{mixins → base}/_position.scss +5 -5
- package/src/scss/theme/base/_reboot.scss +51 -0
- package/src/scss/theme/base/_scroll.scss +180 -0
- package/src/scss/theme/base/_svg.scss +49 -0
- package/src/scss/theme/base/_text.scss +23 -0
- package/src/scss/theme/base/_vars.scss +203 -0
- package/src/scss/theme/{fonts → base/fonts}/_fontmapping-roboto.scss +0 -0
- package/src/scss/theme/{fonts → base/fonts}/_fontmapping-segoe-ui.scss +0 -0
- package/src/scss/theme/base/fonts/_index.scss +2 -0
- package/src/scss/weavy-chat.scss +10 -4
- package/src/scss/weavy-messenger.scss +37 -21
- package/src/types/Chat.ts +2 -1
- package/src/types/Message.ts +3 -1
- package/src/types/types.ts +56 -5
- package/src/ui/Icon.tsx +1 -1
- package/src/ui/Spinner.tsx +3 -2
- package/src/utils/infiniteScroll.js +11 -2
- package/src/utils/postal-parent.js +398 -0
- package/src/utils/promise.js +187 -0
- package/src/utils/scrollbarDetection.js +68 -9
- package/src/utils/utils.js +547 -0
- package/src/scss/theme/_attachments.scss +0 -74
- package/src/scss/theme/_cm-editor.scss +0 -42
- package/src/scss/theme/_colors.scss +0 -520
- package/src/scss/theme/_config.scss +0 -6
- package/src/scss/theme/_inputs.scss +0 -28
- package/src/scss/theme/_nav.scss +0 -52
- package/src/scss/theme/_palette.scss +0 -165
- package/src/scss/theme/_preview-icon.scss +0 -41
- package/src/scss/theme/_reboot.scss +0 -41
- package/src/scss/theme/_root.scss +0 -2
- package/src/scss/theme/_scroll.scss +0 -55
- package/src/scss/theme/_search.scss +0 -68
- package/src/scss/theme/_turbo.scss +0 -17
- package/src/scss/theme/_variables.scss +0 -139
- package/src/scss/theme/bootstrap/_accordion.scss +0 -146
- package/src/scss/theme/bootstrap/_alert.scss +0 -71
- package/src/scss/theme/bootstrap/_badge.scss +0 -38
- package/src/scss/theme/bootstrap/_breadcrumb.scss +0 -40
- package/src/scss/theme/bootstrap/_button-group.scss +0 -142
- package/src/scss/theme/bootstrap/_buttons.scss +0 -186
- package/src/scss/theme/bootstrap/_card.scss +0 -234
- package/src/scss/theme/bootstrap/_carousel.scss +0 -229
- package/src/scss/theme/bootstrap/_close.scss +0 -40
- package/src/scss/theme/bootstrap/_containers.scss +0 -41
- package/src/scss/theme/bootstrap/_dropdown.scss +0 -248
- package/src/scss/theme/bootstrap/_forms.scss +0 -9
- package/src/scss/theme/bootstrap/_functions.scss +0 -302
- package/src/scss/theme/bootstrap/_grid.scss +0 -33
- package/src/scss/theme/bootstrap/_helpers.scss +0 -10
- package/src/scss/theme/bootstrap/_images.scss +0 -42
- package/src/scss/theme/bootstrap/_list-group.scss +0 -191
- package/src/scss/theme/bootstrap/_maps.scss +0 -54
- package/src/scss/theme/bootstrap/_mixins.scss +0 -43
- package/src/scss/theme/bootstrap/_modal.scss +0 -237
- package/src/scss/theme/bootstrap/_nav.scss +0 -172
- package/src/scss/theme/bootstrap/_navbar.scss +0 -276
- package/src/scss/theme/bootstrap/_offcanvas.scss +0 -143
- package/src/scss/theme/bootstrap/_pagination.scss +0 -109
- package/src/scss/theme/bootstrap/_placeholders.scss +0 -51
- package/src/scss/theme/bootstrap/_popover.scss +0 -196
- package/src/scss/theme/bootstrap/_progress.scss +0 -59
- package/src/scss/theme/bootstrap/_reboot.scss +0 -610
- package/src/scss/theme/bootstrap/_root.scss +0 -73
- package/src/scss/theme/bootstrap/_spinners.scss +0 -85
- package/src/scss/theme/bootstrap/_tables.scss +0 -164
- package/src/scss/theme/bootstrap/_toasts.scss +0 -70
- package/src/scss/theme/bootstrap/_tooltip.scss +0 -120
- package/src/scss/theme/bootstrap/_transitions.scss +0 -27
- package/src/scss/theme/bootstrap/_type.scss +0 -106
- package/src/scss/theme/bootstrap/_utilities.scss +0 -647
- package/src/scss/theme/bootstrap/_variables.scss +0 -1633
- package/src/scss/theme/bootstrap/forms/_floating-labels.scss +0 -74
- package/src/scss/theme/bootstrap/forms/_form-check.scss +0 -175
- package/src/scss/theme/bootstrap/forms/_form-control.scss +0 -194
- package/src/scss/theme/bootstrap/forms/_form-range.scss +0 -91
- package/src/scss/theme/bootstrap/forms/_form-select.scss +0 -71
- package/src/scss/theme/bootstrap/forms/_form-text.scss +0 -11
- package/src/scss/theme/bootstrap/forms/_input-group.scss +0 -129
- package/src/scss/theme/bootstrap/forms/_labels.scss +0 -36
- package/src/scss/theme/bootstrap/forms/_validation.scss +0 -12
- package/src/scss/theme/bootstrap/helpers/_clearfix.scss +0 -3
- package/src/scss/theme/bootstrap/helpers/_color-bg.scss +0 -10
- package/src/scss/theme/bootstrap/helpers/_colored-links.scss +0 -12
- package/src/scss/theme/bootstrap/helpers/_position.scss +0 -36
- package/src/scss/theme/bootstrap/helpers/_ratio.scss +0 -26
- package/src/scss/theme/bootstrap/helpers/_stacks.scss +0 -15
- package/src/scss/theme/bootstrap/helpers/_stretched-link.scss +0 -15
- package/src/scss/theme/bootstrap/helpers/_text-truncation.scss +0 -7
- package/src/scss/theme/bootstrap/helpers/_visually-hidden.scss +0 -8
- package/src/scss/theme/bootstrap/helpers/_vr.scss +0 -8
- package/src/scss/theme/bootstrap/mixins/_alert.scss +0 -15
- package/src/scss/theme/bootstrap/mixins/_backdrop.scss +0 -14
- package/src/scss/theme/bootstrap/mixins/_banner.scss +0 -9
- package/src/scss/theme/bootstrap/mixins/_border-radius.scss +0 -78
- package/src/scss/theme/bootstrap/mixins/_box-shadow.scss +0 -18
- package/src/scss/theme/bootstrap/mixins/_buttons.scss +0 -70
- package/src/scss/theme/bootstrap/mixins/_caret.scss +0 -64
- package/src/scss/theme/bootstrap/mixins/_clearfix.scss +0 -9
- package/src/scss/theme/bootstrap/mixins/_color-scheme.scss +0 -7
- package/src/scss/theme/bootstrap/mixins/_container.scss +0 -11
- package/src/scss/theme/bootstrap/mixins/_deprecate.scss +0 -10
- package/src/scss/theme/bootstrap/mixins/_forms.scss +0 -152
- package/src/scss/theme/bootstrap/mixins/_gradients.scss +0 -47
- package/src/scss/theme/bootstrap/mixins/_grid.scss +0 -151
- package/src/scss/theme/bootstrap/mixins/_image.scss +0 -16
- package/src/scss/theme/bootstrap/mixins/_list-group.scss +0 -24
- package/src/scss/theme/bootstrap/mixins/_lists.scss +0 -7
- package/src/scss/theme/bootstrap/mixins/_pagination.scss +0 -10
- package/src/scss/theme/bootstrap/mixins/_reset-text.scss +0 -17
- package/src/scss/theme/bootstrap/mixins/_resize.scss +0 -6
- package/src/scss/theme/bootstrap/mixins/_table-variants.scss +0 -24
- package/src/scss/theme/bootstrap/mixins/_text-truncate.scss +0 -8
- package/src/scss/theme/bootstrap/mixins/_transition.scss +0 -26
- package/src/scss/theme/bootstrap/mixins/_utilities.scss +0 -97
- package/src/scss/theme/bootstrap/mixins/_visually-hidden.scss +0 -29
- package/src/scss/theme/bootstrap/utilities/_api.scss +0 -47
- package/src/scss/theme/bootstrap/vendor/_rfs.scss +0 -354
- package/src/scss/theme/bs/_badge.scss +0 -20
- package/src/scss/theme/bs/_buttons.scss +0 -185
- package/src/scss/theme/bs/_dropdown.scss +0 -86
- package/src/scss/theme/bs/_forms.scss +0 -161
- package/src/scss/theme/bs/_list-group.scss +0 -73
- package/src/scss/theme/bs/_tables.scss +0 -46
- package/src/scss/theme/fonts/_index.scss +0 -2
- package/src/scss/theme/mixins/_palette.scss +0 -165
- package/src/scss/theme/mixins/_scrollbar.scss +0 -110
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { isPlainObject, eqObjects, S4 } from './utils';
|
|
2
|
+
import WeavyPromise from './promise';
|
|
3
|
+
|
|
4
|
+
//console.debug("postal.js", self.name);
|
|
5
|
+
|
|
6
|
+
function WeavyPostal(options) {
|
|
7
|
+
|
|
8
|
+
var weavyPostal = this;
|
|
9
|
+
|
|
10
|
+
this.timeout = options && options.timeout || 2000;
|
|
11
|
+
|
|
12
|
+
var inQueue = [];
|
|
13
|
+
var messageListeners = [];
|
|
14
|
+
var contentWindows = new Set();
|
|
15
|
+
var contentWindowsByWeavyId = new Map();
|
|
16
|
+
var contentWindowOrigins = new WeakMap();
|
|
17
|
+
var contentWindowNames = new WeakMap();
|
|
18
|
+
var contentWindowWeavyIds = new WeakMap();
|
|
19
|
+
var contentWindowDomain = new WeakMap();
|
|
20
|
+
|
|
21
|
+
var _whenLeader = new WeavyPromise();
|
|
22
|
+
var _isLeader = null;
|
|
23
|
+
|
|
24
|
+
var _origin = extractOrigin(window.location.href);
|
|
25
|
+
|
|
26
|
+
function extractOrigin(url) {
|
|
27
|
+
var extractOrigin = null;
|
|
28
|
+
try {
|
|
29
|
+
extractOrigin = /^((?:https?:\/\/[^/]+)|(?:file:\/\/))\/?/.exec(url)[1]
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error("Unable to resolve location origin. Make sure you are using http, https or file protocol and have a valid location URL.");
|
|
32
|
+
}
|
|
33
|
+
return extractOrigin;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function distributeMessage(e, fromFrame) {
|
|
37
|
+
var fromSelf = e.source === window && e.origin === _origin;
|
|
38
|
+
fromFrame ||= contentWindowOrigins.has(e.source) && e.origin === contentWindowOrigins.get(e.source);
|
|
39
|
+
|
|
40
|
+
if (fromSelf || fromFrame) {
|
|
41
|
+
|
|
42
|
+
var genericDistribution = !e.data.weavyId || e.data.weavyId === true;
|
|
43
|
+
|
|
44
|
+
if (fromFrame && !e.data.windowName) {
|
|
45
|
+
e.data.windowName = contentWindowNames.get(e.source);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var messageName = e.data.name;
|
|
49
|
+
if (messageName === "distribute") {
|
|
50
|
+
if (_isLeader) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
e.data.name = e.data.distributeName;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//console.debug("message from", fromSelf && "self" || fromParent && "parent" || fromFrame && "frame " + e.data.windowName, e.data.name);
|
|
57
|
+
|
|
58
|
+
messageListeners.forEach(function (listener) {
|
|
59
|
+
var matchingName = listener.name === messageName || listener.name === "message";
|
|
60
|
+
var genericListener = listener.selector === null;
|
|
61
|
+
var matchingWeavyId = listener.selector === e.data.weavyId;
|
|
62
|
+
var matchingDataSelector = isPlainObject(listener.selector) && eqObjects(listener.selector, e.data, true);
|
|
63
|
+
|
|
64
|
+
if (matchingName && (genericDistribution || genericListener || matchingWeavyId || matchingDataSelector)) {
|
|
65
|
+
|
|
66
|
+
listener.handler(e, e.data);
|
|
67
|
+
|
|
68
|
+
if (listener.once) {
|
|
69
|
+
off(listener.name, listener.selector, listener.handler);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
window.addEventListener("message", function (e) {
|
|
77
|
+
if (e.data.name && e.data.weavyId !== undefined) {
|
|
78
|
+
if (e.data.weavyMessageId && e.data.name !== "message-receipt" && e.data.name !== "unready") {
|
|
79
|
+
console.debug("sending message receipt", e.data.weavyMessageId, e.data.name)
|
|
80
|
+
try {
|
|
81
|
+
e.source.postMessage({ name: "message-receipt", weavyId: e.data.weavyId, weavyMessageId: e.data.weavyMessageId }, e.origin);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error("could not post back message-receipt to source");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
switch (e.data.name) {
|
|
88
|
+
case "register-child":
|
|
89
|
+
if (!contentWindowWeavyIds.has(e.source)) {
|
|
90
|
+
console.warn("register-child: contentwindow not pre-registered");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (contentWindowOrigins.get(e.source) !== e.origin) {
|
|
94
|
+
console.error("register-child: " + contentWindowNames.get(e.source) + " has invalid origin", e.origin);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
var weavyId = contentWindowWeavyIds.get(e.source);
|
|
100
|
+
var contentWindowName = contentWindowNames.get(e.source);
|
|
101
|
+
|
|
102
|
+
if (contentWindowName) {
|
|
103
|
+
e.source.postMessage({
|
|
104
|
+
name: "register-window",
|
|
105
|
+
windowName: contentWindowName,
|
|
106
|
+
weavyId: weavyId || true,
|
|
107
|
+
}, e.origin);
|
|
108
|
+
}
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.error("could not register frame window", weavyId, contentWindowName, e);
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
case "ready":
|
|
114
|
+
if (contentWindowsByWeavyId.has(e.data.weavyId) && contentWindowNames.has(e.source) && contentWindowsByWeavyId.get(e.data.weavyId).get(contentWindowNames.get(e.source))) {
|
|
115
|
+
contentWindowDomain.set(e.source, e.origin);
|
|
116
|
+
distributeMessage(e);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
break;
|
|
120
|
+
case "unready":
|
|
121
|
+
// Source window does no longer exist at this point
|
|
122
|
+
if (contentWindowsByWeavyId.has(e.data.weavyId)) {
|
|
123
|
+
distributeMessage(e, true);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
if (e.source === window || contentWindowsByWeavyId.size) {
|
|
129
|
+
distributeMessage(e);
|
|
130
|
+
} else {
|
|
131
|
+
inQueue.push(e);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
function on(name, selector, handler) {
|
|
140
|
+
if (typeof arguments[1] === "function") {
|
|
141
|
+
// omit weavyId argument
|
|
142
|
+
handler = arguments[1];
|
|
143
|
+
selector = null;
|
|
144
|
+
}
|
|
145
|
+
messageListeners.push({ name: name, handler: handler, selector: selector });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function one(name, selector, handler) {
|
|
149
|
+
if (typeof arguments[1] === "function") {
|
|
150
|
+
// omit weavyId argument
|
|
151
|
+
handler = arguments[1];
|
|
152
|
+
selector = null;
|
|
153
|
+
}
|
|
154
|
+
messageListeners.push({ name: name, handler: handler, selector: selector, once: true });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function off(name, selector, handler) {
|
|
158
|
+
if (typeof arguments[1] === "function") {
|
|
159
|
+
// omit weavyId argument
|
|
160
|
+
handler = arguments[1];
|
|
161
|
+
selector = null;
|
|
162
|
+
}
|
|
163
|
+
messageListeners = messageListeners.filter(function (listener) {
|
|
164
|
+
var nameMatch = name === listener.name;
|
|
165
|
+
var handlerMatch = handler === listener.handler;
|
|
166
|
+
var stringSelectorMatch = typeof selector === "string" && selector === listener.selector;
|
|
167
|
+
var plainObjectMatch = isPlainObject(selector) && eqObjects(selector, listener.selector);
|
|
168
|
+
var offMatch = nameMatch && handlerMatch && (selector === null || stringSelectorMatch || plainObjectMatch);
|
|
169
|
+
return !(offMatch);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sends the id of a frame to the frame content scripts, so that the frame gets aware of which id it has.
|
|
175
|
+
* The frame needs to have a unique name attribute.
|
|
176
|
+
*
|
|
177
|
+
* @category panels
|
|
178
|
+
* @param {string} weavyId - The id of the group or entity which the contentWindow belongs to.
|
|
179
|
+
* @param {Window} contentWindow - The frame window to send the data to.
|
|
180
|
+
*/
|
|
181
|
+
function registerContentWindow(contentWindow, contentWindowName, weavyId, contentOrigin) {
|
|
182
|
+
try {
|
|
183
|
+
if (!contentWindowName) {
|
|
184
|
+
console.error("registerContentWindow() No valid contentWindow to register, must be a window and have a name.");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
} catch (e) {
|
|
188
|
+
console.error("registerContentWindow() cannot access contentWindowName")
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (contentWindow.self) {
|
|
192
|
+
contentWindow = contentWindow.self;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (!weavyId || weavyId === "true") {
|
|
196
|
+
weavyId = true;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (!contentWindowsByWeavyId.has(weavyId)) {
|
|
200
|
+
contentWindowsByWeavyId.set(weavyId, new Map());
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
contentWindowsByWeavyId.get(weavyId).set(contentWindowName, contentWindow);
|
|
204
|
+
contentWindows.add(contentWindow);
|
|
205
|
+
contentWindowNames.set(contentWindow, contentWindowName);
|
|
206
|
+
contentWindowWeavyIds.set(contentWindow, weavyId);
|
|
207
|
+
contentWindowOrigins.set(contentWindow, contentOrigin);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function unregisterWeavyId(weavyId) {
|
|
211
|
+
if (contentWindowsByWeavyId.has(weavyId)) {
|
|
212
|
+
contentWindowsByWeavyId.get(weavyId).forEach(function (contentWindow, contentWindowName) {
|
|
213
|
+
unregisterContentWindow(contentWindowName, weavyId);
|
|
214
|
+
});
|
|
215
|
+
contentWindowsByWeavyId.get(weavyId)
|
|
216
|
+
contentWindowsByWeavyId.delete(weavyId);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function unregisterContentWindow(windowName, weavyId) {
|
|
221
|
+
if (contentWindowsByWeavyId.has(weavyId)) {
|
|
222
|
+
if (contentWindowsByWeavyId.get(weavyId).has(windowName)) {
|
|
223
|
+
var contentWindow = contentWindowsByWeavyId.get(weavyId).get(windowName);
|
|
224
|
+
try {
|
|
225
|
+
contentWindows.delete(contentWindow);
|
|
226
|
+
contentWindowNames.delete(contentWindow);
|
|
227
|
+
contentWindowWeavyIds.delete(contentWindow);
|
|
228
|
+
contentWindowOrigins.delete(contentWindow);
|
|
229
|
+
} catch (e) { /* no need to delete contentwindow */ }
|
|
230
|
+
}
|
|
231
|
+
contentWindowsByWeavyId.get(weavyId).delete(windowName);
|
|
232
|
+
if (contentWindowsByWeavyId.get(weavyId).size === 0) {
|
|
233
|
+
try {
|
|
234
|
+
contentWindowsByWeavyId.delete(weavyId);
|
|
235
|
+
} catch (e) { /* no need to delete weavyId */ }
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function whenPostMessage(contentWindow, message, transfer) {
|
|
241
|
+
var whenReceipt = new WeavyPromise();
|
|
242
|
+
|
|
243
|
+
if (transfer === null) {
|
|
244
|
+
// Chrome does not allow transfer to be null
|
|
245
|
+
transfer = undefined;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
var toSelf = contentWindow === window.self;
|
|
249
|
+
var origin = toSelf ? extractOrigin(window.location.href) : contentWindowOrigins.get(contentWindow);
|
|
250
|
+
var validWindow = toSelf || contentWindow && origin === contentWindowDomain.get(contentWindow)
|
|
251
|
+
|
|
252
|
+
if (validWindow) {
|
|
253
|
+
if (!message.weavyMessageId) {
|
|
254
|
+
message.weavyMessageId = S4() + S4();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
queueMicrotask(() => {
|
|
258
|
+
console.debug("whenPostMessage", message.name, message.weavyMessageId);
|
|
259
|
+
|
|
260
|
+
var messageWatchdog = setTimeout(function () {
|
|
261
|
+
if (whenReceipt.state() === "pending") {
|
|
262
|
+
whenReceipt.reject(new Error("postMessage() receipt timed out: " + message.weavyMessageId + ", " + message.name));
|
|
263
|
+
}
|
|
264
|
+
}, weavyPostal.timeout || 2000);
|
|
265
|
+
|
|
266
|
+
on("message-receipt", { weavyId: message.weavyId, weavyMessageId: message.weavyMessageId }, function () {
|
|
267
|
+
console.debug("message-receipt received", message.weavyMessageId, message.name);
|
|
268
|
+
clearTimeout(messageWatchdog);
|
|
269
|
+
whenReceipt.resolve();
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
try {
|
|
273
|
+
contentWindow.postMessage(message, origin, transfer);
|
|
274
|
+
} catch (e) {
|
|
275
|
+
whenReceipt.reject(e);
|
|
276
|
+
}
|
|
277
|
+
})
|
|
278
|
+
} else {
|
|
279
|
+
whenReceipt.reject(new Error("postMessage() Invalid window origin: " + origin + ", " + message.name));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return whenReceipt();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function postToChildren(message, transfer) {
|
|
286
|
+
if (typeof message !== "object" || !message.name) {
|
|
287
|
+
console.error("postToChildren() Invalid message format", message);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (transfer === null) {
|
|
292
|
+
// Chrome does not allow transfer to be null
|
|
293
|
+
transfer = undefined;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
message.distributeName = message.name;
|
|
297
|
+
message.name = "distribute";
|
|
298
|
+
message.weavyId = message.weavyId || true;
|
|
299
|
+
|
|
300
|
+
contentWindows.forEach(function (contentWindow) {
|
|
301
|
+
if (contentWindowOrigins.get(contentWindow) === contentWindowDomain.get(contentWindow)) {
|
|
302
|
+
try {
|
|
303
|
+
contentWindow.postMessage(message, contentWindowOrigins.get(contentWindow), transfer);
|
|
304
|
+
} catch (e) {
|
|
305
|
+
console.warn("postToChildren() could not distribute message to " + contentWindowNames.get(contentWindow))
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function postToFrame(windowName, weavyId, message, transfer) {
|
|
313
|
+
if (typeof message !== "object" || !message.name) {
|
|
314
|
+
console.error("postToFrame() Invalid message format", message);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
var contentWindow;
|
|
319
|
+
try {
|
|
320
|
+
contentWindow = contentWindowsByWeavyId.get(weavyId).get(windowName);
|
|
321
|
+
} catch (e) {
|
|
322
|
+
console.error("postToFrame() Window not registered", weavyId, windowName);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
message.weavyId = weavyId;
|
|
326
|
+
|
|
327
|
+
return whenPostMessage(contentWindow, message, transfer);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function postToSelf(message, transfer) {
|
|
331
|
+
if (typeof message !== "object" || !message.name) {
|
|
332
|
+
console.error("postToSelf() Invalid message format", message);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
message.weavyId = message.weavyId || true;
|
|
337
|
+
|
|
338
|
+
return whenPostMessage(window.self, message, transfer);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function postToSource(e, message, transfer) {
|
|
342
|
+
if (e.source && e.data.weavyId !== undefined) {
|
|
343
|
+
var fromSelf = e.source === window.self && e.origin === _origin;
|
|
344
|
+
var fromFrame = contentWindowOrigins.has(e.source) && e.origin === contentWindowOrigins.get(e.source);
|
|
345
|
+
|
|
346
|
+
if (transfer === null) {
|
|
347
|
+
// Chrome does not allow transfer to be null
|
|
348
|
+
transfer = undefined;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (fromSelf || fromFrame) {
|
|
352
|
+
message.weavyId = e.data.weavyId;
|
|
353
|
+
|
|
354
|
+
try {
|
|
355
|
+
e.source.postMessage(message, e.origin, transfer);
|
|
356
|
+
} catch (e) {
|
|
357
|
+
console.error("postToSource() Could not post message back to source");
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function setLeader() {
|
|
364
|
+
if (_whenLeader.state() === "pending") {
|
|
365
|
+
console.debug("Is leader");
|
|
366
|
+
_isLeader = true;
|
|
367
|
+
_whenLeader.resolve(_isLeader);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function init() {
|
|
372
|
+
setLeader();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
this.on = on;
|
|
376
|
+
this.one = one;
|
|
377
|
+
this.off = off;
|
|
378
|
+
this.registerContentWindow = registerContentWindow;
|
|
379
|
+
this.unregisterContentWindow = unregisterContentWindow;
|
|
380
|
+
this.unregisterAll = unregisterWeavyId;
|
|
381
|
+
this.postToFrame = postToFrame;
|
|
382
|
+
this.postToSelf = postToSelf;
|
|
383
|
+
this.postToSource = postToSource;
|
|
384
|
+
this.postToChildren = postToChildren;
|
|
385
|
+
this.whenLeader = function () { return _whenLeader(); };
|
|
386
|
+
|
|
387
|
+
Object.defineProperty(this, "isLeader", {
|
|
388
|
+
get: function () { return _isLeader; }
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
init();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
export default new WeavyPostal();
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// This event is handled using same-origin script policy
|
|
2
|
+
window.addEventListener("unhandledrejection", function (e) {
|
|
3
|
+
if (e.promise.weavy) {
|
|
4
|
+
//console.debug("Uncaught (in weavy promise)", e.reason);
|
|
5
|
+
e.preventDefault();
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Unifying wrapper for deferred promises.
|
|
11
|
+
* Works both as a traditional promise and a deferred promise.
|
|
12
|
+
* Use promise.reset() to replace the promise with a new promise.
|
|
13
|
+
* Use the promise as a function (or via .promise()) to return the actual promise.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Traditional style promise
|
|
17
|
+
* new WeavyPromise(function(resolve, reject) {
|
|
18
|
+
* resolve()
|
|
19
|
+
* }).then(function() {
|
|
20
|
+
* console.log("resolved");
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // jQuery deferred style promise
|
|
25
|
+
* var myPromise = new WeavyPromise();
|
|
26
|
+
*
|
|
27
|
+
* // as variable
|
|
28
|
+
* myPromise.then(function() {
|
|
29
|
+
* console.log("resolved")
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // or as function()
|
|
33
|
+
* myPromise().then(function() {
|
|
34
|
+
* console.log("resolved")
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* myPromise.resolve();
|
|
38
|
+
*
|
|
39
|
+
* @class WeavyPromise
|
|
40
|
+
* @classdesc Unified promises that can be reset
|
|
41
|
+
* @param {function} executor - Function to be executed while constructing the promise
|
|
42
|
+
* @returns {Promise} - A function that acts as the deferred or returns the promise when called
|
|
43
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises}
|
|
44
|
+
**/
|
|
45
|
+
function WeavyPromiseWrapper (executor) {
|
|
46
|
+
var promise, state = "pending";
|
|
47
|
+
var WeavyPromise = function WeavyPromise() { return promise };
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns the native promise.
|
|
51
|
+
* Equal to calling the WeavyPromise as a function.
|
|
52
|
+
* Return the native promise in public methods to avoid unintended promise resolving or rejecting.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* var myPromise = new WeavyPromise();
|
|
56
|
+
*
|
|
57
|
+
* myPromise() === mypromise.promise();
|
|
58
|
+
*
|
|
59
|
+
**/
|
|
60
|
+
WeavyPromise.promise = WeavyPromise.bind(WeavyPromise);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Gets the state of the promise
|
|
64
|
+
* - "pending"
|
|
65
|
+
* - "resolved"
|
|
66
|
+
* - "rejected"
|
|
67
|
+
*
|
|
68
|
+
* @name WeavyPromise#state
|
|
69
|
+
* @function
|
|
70
|
+
**/
|
|
71
|
+
WeavyPromise.state = function () {
|
|
72
|
+
return state;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Resets the promise so that it can be resolved or rejected again.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* var myPromise = new WeavyPromise();
|
|
80
|
+
*
|
|
81
|
+
* myPromise.resolve(123);
|
|
82
|
+
* myPromise.reset();
|
|
83
|
+
*
|
|
84
|
+
* myPromise.then(function(num) {
|
|
85
|
+
* console.log("the number is", num); // 456
|
|
86
|
+
* });
|
|
87
|
+
* myPromise.resolve(456);
|
|
88
|
+
*
|
|
89
|
+
* @name WeavyPromise#reset
|
|
90
|
+
* @function
|
|
91
|
+
**/
|
|
92
|
+
(WeavyPromise.reset = function () {
|
|
93
|
+
var resolve, reject;
|
|
94
|
+
|
|
95
|
+
state = "pending";
|
|
96
|
+
|
|
97
|
+
promise = new Promise(function (_resolve, _reject) {
|
|
98
|
+
resolve = function () { state = "resolved"; _resolve.apply(this, arguments); };
|
|
99
|
+
reject = function () { state = "rejected"; _reject.apply(this, arguments); };
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
promise.weavy = true;
|
|
103
|
+
|
|
104
|
+
WeavyPromise.resolve = function () {
|
|
105
|
+
resolve.apply(promise, arguments);
|
|
106
|
+
return WeavyPromise;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
WeavyPromise.reject = function () {
|
|
110
|
+
reject.apply(promise, arguments);
|
|
111
|
+
return WeavyPromise;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (typeof executor === "function") {
|
|
115
|
+
executor(resolve, reject);
|
|
116
|
+
}
|
|
117
|
+
return WeavyPromise;
|
|
118
|
+
})();
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Wrapper for Promise.prototype.then
|
|
122
|
+
**/
|
|
123
|
+
WeavyPromise.then = function () {
|
|
124
|
+
promise = promise.then.apply(promise, arguments);
|
|
125
|
+
promise.weavy = true;
|
|
126
|
+
return WeavyPromise;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Wrapper for Promise.prototype.catch
|
|
131
|
+
**/
|
|
132
|
+
WeavyPromise.catch = function () {
|
|
133
|
+
promise = promise.catch.apply(promise, arguments);
|
|
134
|
+
promise.weavy = true;
|
|
135
|
+
return WeavyPromise;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Wrapper for Promise.prototype.finally
|
|
140
|
+
**/
|
|
141
|
+
WeavyPromise.finally = function () {
|
|
142
|
+
promise = promise.finally.apply(promise, arguments);
|
|
143
|
+
promise.weavy = true;
|
|
144
|
+
return WeavyPromise;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
return WeavyPromise;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Return an instantly resolved WeavyPromise
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* function doSomething() {
|
|
155
|
+
* return WeavyPromise.resolve(1234);
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
* @name WeavyPromise.resolve
|
|
159
|
+
* @function
|
|
160
|
+
* @param {any} value
|
|
161
|
+
*/
|
|
162
|
+
WeavyPromiseWrapper.resolve = function (value) {
|
|
163
|
+
var promise = WeavyPromiseWrapper();
|
|
164
|
+
promise.resolve(value);
|
|
165
|
+
return promise;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Return an instantly rejected WeavyPromise
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* function doSomething() {
|
|
173
|
+
* return WeavyPromise.reject({ errorcode: 404 });
|
|
174
|
+
* }
|
|
175
|
+
*
|
|
176
|
+
* @name WeavyPromise.reject
|
|
177
|
+
* @function
|
|
178
|
+
* @param {any} value
|
|
179
|
+
*/
|
|
180
|
+
WeavyPromiseWrapper.reject = function (value) {
|
|
181
|
+
var promise = WeavyPromiseWrapper();
|
|
182
|
+
promise.reject(value);
|
|
183
|
+
return promise;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export default WeavyPromiseWrapper;
|
|
187
|
+
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import throttle from "lodash.throttle";
|
|
2
|
+
|
|
1
3
|
// SCROLLBAR DETECTION
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -26,23 +28,80 @@ export function checkScrollbar(entries) {
|
|
|
26
28
|
console.warn("scrollbar detection failed", e);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
31
|
+
|
|
32
|
+
return scrollbarClassnameTarget.classList.contains("wy-scrollbars");
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
/**
|
|
32
36
|
* Creates a scrollbar detection element and starts observing it.
|
|
33
37
|
*/
|
|
34
|
-
export
|
|
38
|
+
export function detectScrollbars() {
|
|
35
39
|
// insert scrollbar detection element
|
|
36
|
-
var
|
|
40
|
+
var scrollCheckElement = document.getElementById("wy-scrollbar-detection");
|
|
37
41
|
|
|
38
|
-
if (!
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
document.documentElement.insertBefore(
|
|
42
|
+
if (!scrollCheckElement) {
|
|
43
|
+
scrollCheckElement = document.createElement("aside");
|
|
44
|
+
scrollCheckElement.id = "wy-scrollbar-detection";
|
|
45
|
+
scrollCheckElement.className = "wy-scrollbar-detection";
|
|
46
|
+
document.documentElement.insertBefore(scrollCheckElement, document.body);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
return new Promise((resolve) => {
|
|
50
|
+
var scrollObserver = new ResizeObserver((entries) => {
|
|
51
|
+
let hasScrollbars = checkScrollbar(entries);
|
|
52
|
+
resolve(hasScrollbars);
|
|
53
|
+
});
|
|
54
|
+
scrollObserver.observe(scrollCheckElement);
|
|
55
|
+
})
|
|
47
56
|
}
|
|
48
57
|
|
|
58
|
+
/**
|
|
59
|
+
* The callback function for the scrollbar adjustments observer.
|
|
60
|
+
*
|
|
61
|
+
* @param {ResizeObserverTarget[]} entries
|
|
62
|
+
*/
|
|
63
|
+
export function checkScrollbarAdjust(entries) {
|
|
64
|
+
for (var entry in entries) {
|
|
65
|
+
let target = entries[entry].target;
|
|
66
|
+
let targetStyle = getComputedStyle(target);
|
|
67
|
+
console.log("checking scrollbar adjust", target)
|
|
68
|
+
if (target.dataset.adjustScrollbarTop !== undefined) {
|
|
69
|
+
scrollbarClassnameTarget.style.setProperty('--wy-scrollbar-adjust-top', targetStyle.height);
|
|
70
|
+
}
|
|
71
|
+
if (target.dataset.adjustScrollbarBottom !== undefined) {
|
|
72
|
+
scrollbarClassnameTarget.style.setProperty('--wy-scrollbar-adjust-bottom', targetStyle.height);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Creates a scrollbar adjustment observer.
|
|
79
|
+
*/
|
|
80
|
+
export function detectScrollbarAdjustments() {
|
|
81
|
+
console.log("detect scrollbar adjust");
|
|
82
|
+
var adjustRO = new ResizeObserver(checkScrollbarAdjust);
|
|
83
|
+
|
|
84
|
+
const registerAdjustmentElements = () => {
|
|
85
|
+
console.log("register scrollbar adjust");
|
|
86
|
+
|
|
87
|
+
scrollbarClassnameTarget.style.removeProperty('--wy-scrollbar-adjust-top');
|
|
88
|
+
scrollbarClassnameTarget.style.removeProperty('--wy-scrollbar-adjust-bottom');
|
|
89
|
+
adjustRO.disconnect();
|
|
90
|
+
|
|
91
|
+
if (scrollbarClassnameTarget.classList.contains("wy-scrollbars")) {
|
|
92
|
+
let scrollbarAdjustElements = document.querySelectorAll("[data-adjust-scrollbar-top], [data-adjust-scrollbar-bottom]");
|
|
93
|
+
if (scrollbarAdjustElements) {
|
|
94
|
+
scrollbarAdjustElements.forEach((target) => {
|
|
95
|
+
checkScrollbarAdjust([{ target: target }]);
|
|
96
|
+
adjustRO.observe(target);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
requestAnimationFrame(registerAdjustmentElements);
|
|
103
|
+
setTimeout(registerAdjustmentElements, 5000);
|
|
104
|
+
|
|
105
|
+
var adjustMO = new MutationObserver(throttle(registerAdjustmentElements, 1));
|
|
106
|
+
adjustMO.observe(scrollbarClassnameTarget);
|
|
107
|
+
}
|