@pnp/sp 2.8.0 → 2.12.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/LICENSE +25 -25
- package/appcatalog/index.d.ts +8 -8
- package/appcatalog/index.js +30 -30
- package/appcatalog/types.d.ts +81 -81
- package/appcatalog/types.d.ts.map +1 -1
- package/appcatalog/types.js +177 -177
- package/appcatalog/types.js.map +1 -1
- package/appcatalog/web.d.ts +16 -16
- package/appcatalog/web.js +6 -6
- package/attachments/index.d.ts +2 -2
- package/attachments/index.js +2 -2
- package/attachments/item.d.ts +12 -12
- package/attachments/item.js +4 -4
- package/attachments/types.d.ts +92 -92
- package/attachments/types.js +240 -240
- package/batch.d.ts +17 -17
- package/batch.js +223 -223
- package/clientside-pages/funcs.d.ts +22 -22
- package/clientside-pages/funcs.js +25 -25
- package/clientside-pages/index.d.ts +2 -2
- package/clientside-pages/index.js +2 -2
- package/clientside-pages/types.d.ts +496 -494
- package/clientside-pages/types.d.ts.map +1 -1
- package/clientside-pages/types.js +1496 -1487
- package/clientside-pages/types.js.map +1 -1
- package/clientside-pages/web.d.ts +41 -41
- package/clientside-pages/web.js +57 -57
- package/column-defaults/folder.d.ts +27 -27
- package/column-defaults/folder.js +82 -82
- package/column-defaults/index.d.ts +3 -3
- package/column-defaults/index.js +2 -2
- package/column-defaults/list.d.ts +19 -19
- package/column-defaults/list.js +198 -198
- package/column-defaults/types.d.ts +21 -21
- package/column-defaults/types.js +1 -1
- package/comments/clientside-page.d.ts +57 -57
- package/comments/clientside-page.d.ts.map +1 -1
- package/comments/clientside-page.js +136 -136
- package/comments/index.d.ts +2 -2
- package/comments/index.js +2 -2
- package/comments/item.d.ts +29 -29
- package/comments/item.js +47 -47
- package/comments/item.js.map +1 -1
- package/comments/types.d.ts +107 -107
- package/comments/types.d.ts.map +1 -1
- package/comments/types.js +145 -145
- package/comments/types.js.map +1 -1
- package/content-types/index.d.ts +4 -4
- package/content-types/index.js +4 -4
- package/content-types/item.d.ts +12 -12
- package/content-types/item.js +4 -4
- package/content-types/list.d.ts +12 -12
- package/content-types/list.js +4 -4
- package/content-types/types.d.ts +107 -107
- package/content-types/types.js +166 -166
- package/content-types/web.d.ts +12 -12
- package/content-types/web.js +4 -4
- package/decorators.d.ts +11 -11
- package/decorators.js +28 -28
- package/features/index.d.ts +3 -3
- package/features/index.js +3 -3
- package/features/site.d.ts +12 -12
- package/features/site.js +4 -4
- package/features/types.d.ts +47 -47
- package/features/types.js +109 -109
- package/features/web.d.ts +12 -12
- package/features/web.js +4 -4
- package/fields/index.d.ts +4 -4
- package/fields/index.js +4 -4
- package/fields/list.d.ts +12 -12
- package/fields/list.js +4 -4
- package/fields/types.d.ts +368 -368
- package/fields/types.js +624 -624
- package/fields/web.d.ts +17 -17
- package/fields/web.js +5 -5
- package/files/folder.d.ts +12 -12
- package/files/folder.js +4 -4
- package/files/index.d.ts +4 -4
- package/files/index.js +4 -4
- package/files/item.d.ts +12 -12
- package/files/item.js +4 -4
- package/files/types.d.ts +421 -421
- package/files/types.js +853 -853
- package/files/types.js.map +1 -1
- package/files/web.d.ts +35 -35
- package/files/web.js +15 -15
- package/folders/index.d.ts +4 -4
- package/folders/index.js +4 -4
- package/folders/item.d.ts +9 -9
- package/folders/item.js +4 -4
- package/folders/list.d.ts +12 -12
- package/folders/list.js +4 -4
- package/folders/types.d.ts +207 -207
- package/folders/types.js +433 -433
- package/folders/types.js.map +1 -1
- package/folders/web.d.ts +39 -39
- package/folders/web.js +15 -15
- package/forms/index.d.ts +2 -2
- package/forms/index.js +2 -2
- package/forms/list.d.ts +9 -9
- package/forms/list.js +4 -4
- package/forms/types.d.ts +35 -35
- package/forms/types.js +41 -41
- package/hubsites/index.d.ts +12 -12
- package/hubsites/index.js +15 -15
- package/hubsites/site.d.ts +26 -26
- package/hubsites/site.js +39 -39
- package/hubsites/types.d.ts +55 -55
- package/hubsites/types.d.ts.map +1 -1
- package/hubsites/types.js +53 -53
- package/hubsites/web.d.ts +21 -21
- package/hubsites/web.js +23 -23
- package/index.d.ts +14 -14
- package/index.js +13 -13
- package/items/index.d.ts +2 -2
- package/items/index.js +2 -2
- package/items/list.d.ts +9 -9
- package/items/list.js +4 -4
- package/items/types.d.ts +226 -226
- package/items/types.js +549 -549
- package/lists/index.d.ts +2 -2
- package/lists/index.js +2 -2
- package/lists/types.d.ts +495 -495
- package/lists/types.js +522 -522
- package/lists/types.js.map +1 -1
- package/lists/web.d.ts +43 -43
- package/lists/web.js +27 -27
- package/navigation/index.d.ts +8 -8
- package/navigation/index.js +14 -14
- package/navigation/types.d.ts +154 -154
- package/navigation/types.js +219 -219
- package/navigation/web.d.ts +13 -13
- package/navigation/web.js +4 -4
- package/odata.d.ts +5 -5
- package/odata.js +90 -90
- package/odata.js.map +1 -1
- package/operations.d.ts +9 -9
- package/operations.js +63 -63
- package/package.json +4 -4
- package/presets/all.d.ts +72 -72
- package/presets/all.js +72 -72
- package/presets/core.d.ts +11 -11
- package/presets/core.js +11 -11
- package/profiles/index.d.ts +7 -7
- package/profiles/index.js +13 -13
- package/profiles/types.d.ts +357 -357
- package/profiles/types.js +454 -454
- package/readme.md +21 -21
- package/regional-settings/content-type.d.ts +7 -7
- package/regional-settings/content-type.js +4 -4
- package/regional-settings/field.d.ts +7 -7
- package/regional-settings/field.js +4 -4
- package/regional-settings/funcs.d.ts +2 -2
- package/regional-settings/funcs.js +8 -8
- package/regional-settings/index.d.ts +6 -6
- package/regional-settings/index.js +6 -6
- package/regional-settings/list.d.ts +7 -7
- package/regional-settings/list.js +4 -4
- package/regional-settings/types.d.ts +111 -111
- package/regional-settings/types.js +159 -159
- package/regional-settings/user-custom-actions.d.ts +7 -7
- package/regional-settings/user-custom-actions.js +4 -4
- package/regional-settings/web.d.ts +12 -12
- package/regional-settings/web.js +7 -7
- package/related-items/index.d.ts +1 -1
- package/related-items/index.js +1 -1
- package/related-items/types.d.ts +76 -76
- package/related-items/types.js +103 -103
- package/related-items/web.d.ts +12 -12
- package/related-items/web.js +9 -9
- package/rest.d.ts +44 -44
- package/rest.js +72 -72
- package/search/index.d.ts +30 -30
- package/search/index.js +25 -25
- package/search/query.d.ts +62 -62
- package/search/query.js +302 -302
- package/search/suggest.d.ts +76 -76
- package/search/suggest.js +66 -66
- package/search/types.d.ts +426 -426
- package/search/types.js +57 -57
- package/security/funcs.d.ts +43 -43
- package/security/funcs.js +142 -142
- package/security/index.d.ts +4 -4
- package/security/index.js +4 -4
- package/security/item.d.ts +7 -7
- package/security/item.js +14 -14
- package/security/list.d.ts +7 -7
- package/security/list.js +14 -14
- package/security/types.d.ts +318 -318
- package/security/types.js +399 -399
- package/security/web.d.ts +9 -9
- package/security/web.js +15 -15
- package/sharepointqueryable.d.ts +135 -135
- package/sharepointqueryable.js +265 -265
- package/sharing/file.d.ts +18 -18
- package/sharing/file.js +116 -116
- package/sharing/folder.d.ts +9 -9
- package/sharing/folder.js +136 -136
- package/sharing/funcs.d.ts +62 -62
- package/sharing/funcs.js +239 -239
- package/sharing/funcs.js.map +1 -1
- package/sharing/index.d.ts +5 -5
- package/sharing/index.js +5 -5
- package/sharing/item.d.ts +16 -16
- package/sharing/item.js +15 -15
- package/sharing/types.d.ts +583 -583
- package/sharing/types.js +113 -113
- package/sharing/web.d.ts +19 -19
- package/sharing/web.js +76 -76
- package/site-designs/index.d.ts +8 -8
- package/site-designs/index.js +14 -14
- package/site-designs/types.d.ts +319 -319
- package/site-designs/types.js +203 -203
- package/site-designs/web.d.ts +25 -25
- package/site-designs/web.js +11 -11
- package/site-groups/index.d.ts +2 -2
- package/site-groups/index.js +2 -2
- package/site-groups/types.d.ts +89 -89
- package/site-groups/types.js +125 -125
- package/site-groups/web.d.ts +40 -40
- package/site-groups/web.js +30 -30
- package/site-scripts/index.d.ts +9 -9
- package/site-scripts/index.js +15 -15
- package/site-scripts/list.d.ts +12 -12
- package/site-scripts/list.js +24 -24
- package/site-scripts/types.d.ts +183 -183
- package/site-scripts/types.js +141 -141
- package/site-scripts/web.d.ts +13 -13
- package/site-scripts/web.js +5 -5
- package/site-users/index.d.ts +2 -2
- package/site-users/index.js +2 -2
- package/site-users/types.d.ts +138 -138
- package/site-users/types.js +122 -122
- package/site-users/web.d.ts +31 -31
- package/site-users/web.js +27 -27
- package/sites/index.d.ts +7 -7
- package/sites/index.js +13 -13
- package/sites/types.d.ts +147 -147
- package/sites/types.js +321 -321
- package/social/index.d.ts +10 -10
- package/social/index.js +13 -13
- package/social/types.d.ts +309 -309
- package/social/types.js +322 -322
- package/sphttpclient.d.ts +18 -18
- package/sphttpclient.js +189 -189
- package/splibconfig.d.ts +22 -22
- package/splibconfig.js +13 -13
- package/sputilities/index.d.ts +7 -7
- package/sputilities/index.js +13 -13
- package/sputilities/types.d.ts +130 -130
- package/sputilities/types.js +118 -118
- package/subscriptions/index.d.ts +2 -2
- package/subscriptions/index.js +2 -2
- package/subscriptions/list.d.ts +13 -13
- package/subscriptions/list.js +4 -4
- package/subscriptions/types.d.ts +54 -54
- package/subscriptions/types.js +111 -111
- package/taxonomy/index.d.ts +7 -7
- package/taxonomy/index.js +13 -13
- package/taxonomy/types.d.ts +200 -200
- package/taxonomy/types.js +347 -347
- package/taxonomy/types.js.map +1 -1
- package/telemetry.d.ts +12 -12
- package/telemetry.js +48 -48
- package/types.d.ts +218 -218
- package/types.js +79 -79
- package/user-custom-actions/index.d.ts +4 -4
- package/user-custom-actions/index.js +4 -4
- package/user-custom-actions/list.d.ts +12 -12
- package/user-custom-actions/list.js +4 -4
- package/user-custom-actions/site.d.ts +12 -12
- package/user-custom-actions/site.js +4 -4
- package/user-custom-actions/types.d.ts +82 -82
- package/user-custom-actions/types.js +93 -93
- package/user-custom-actions/web.d.ts +15 -15
- package/user-custom-actions/web.js +4 -4
- package/utils/escapeQueryStrValue.d.ts +1 -1
- package/utils/escapeQueryStrValue.js +19 -19
- package/utils/extractweburl.d.ts +1 -1
- package/utils/extractweburl.js +15 -15
- package/utils/file-names.d.ts +17 -17
- package/utils/file-names.js +38 -38
- package/utils/metadata.d.ts +5 -5
- package/utils/metadata.js +5 -5
- package/utils/objectToSPKeyValueCollection.d.ts +20 -20
- package/utils/objectToSPKeyValueCollection.js +16 -16
- package/utils/toResourcePath.d.ts +7 -7
- package/utils/toResourcePath.js +6 -6
- package/utils/toabsoluteurl.d.ts +7 -7
- package/utils/toabsoluteurl.js +61 -61
- package/views/index.d.ts +2 -2
- package/views/index.js +2 -2
- package/views/list.d.ts +23 -23
- package/views/list.js +8 -8
- package/views/types.d.ts +140 -140
- package/views/types.js +184 -184
- package/webparts/file.d.ts +15 -15
- package/webparts/file.js +6 -6
- package/webparts/index.d.ts +2 -2
- package/webparts/index.js +2 -2
- package/webparts/types.d.ts +83 -83
- package/webparts/types.js +117 -117
- package/webs/index.d.ts +16 -16
- package/webs/index.js +16 -16
- package/webs/types.d.ts +210 -210
- package/webs/types.js +295 -295
|
@@ -1,1488 +1,1497 @@
|
|
|
1
|
-
import { __awaiter, __decorate, __extends, __generator, __read, __spreadArray } from "tslib";
|
|
2
|
-
import { invokableFactory, body, headers } from "@pnp/odata";
|
|
3
|
-
import { assign, getGUID, hOP, stringIsNullOrEmpty, objectDefinedNotNull, combine, isUrlAbsolute, isArray } from "@pnp/common";
|
|
4
|
-
import { Item } from "../items/types.js";
|
|
5
|
-
import { SharePointQueryable, _SharePointQueryable, SharePointQueryableCollection } from "../sharepointqueryable.js";
|
|
6
|
-
import { metadata } from "../utils/metadata.js";
|
|
7
|
-
import { List } from "../lists/types.js";
|
|
8
|
-
import { odataUrlFrom } from "../odata.js";
|
|
9
|
-
import { Web } from "../webs/types.js";
|
|
10
|
-
import { extractWebUrl } from "../utils/extractweburl.js";
|
|
11
|
-
import { Site } from "../sites/types.js";
|
|
12
|
-
import { spPost } from "../operations.js";
|
|
13
|
-
import { getNextOrder, reindex } from "./funcs.js";
|
|
14
|
-
import "../files/web.js";
|
|
15
|
-
import "../comments/item.js";
|
|
16
|
-
import { tag } from "../telemetry.js";
|
|
17
|
-
/**
|
|
18
|
-
* Page promotion state
|
|
19
|
-
*/
|
|
20
|
-
export var PromotedState;
|
|
21
|
-
(function (PromotedState) {
|
|
22
|
-
/**
|
|
23
|
-
* Regular client side page
|
|
24
|
-
*/
|
|
25
|
-
PromotedState[PromotedState["NotPromoted"] = 0] = "NotPromoted";
|
|
26
|
-
/**
|
|
27
|
-
* Page that will be promoted as news article after publishing
|
|
28
|
-
*/
|
|
29
|
-
PromotedState[PromotedState["PromoteOnPublish"] = 1] = "PromoteOnPublish";
|
|
30
|
-
/**
|
|
31
|
-
* Page that is promoted as news article
|
|
32
|
-
*/
|
|
33
|
-
PromotedState[PromotedState["Promoted"] = 2] = "Promoted";
|
|
34
|
-
})(PromotedState || (PromotedState = {}));
|
|
35
|
-
function initFrom(o, url) {
|
|
36
|
-
return ClientsidePage(extractWebUrl(o.toUrl()), url).configureFrom(o);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Represents the data and methods associated with client side "modern" pages
|
|
40
|
-
*/
|
|
41
|
-
var _ClientsidePage = /** @class */ (function (_super) {
|
|
42
|
-
__extends(_ClientsidePage, _super);
|
|
43
|
-
/**
|
|
44
|
-
* PLEASE DON'T USE THIS CONSTRUCTOR DIRECTLY, thank you 🐇
|
|
45
|
-
*/
|
|
46
|
-
function _ClientsidePage(baseUrl, path, json, noInit, sections, commentsDisabled) {
|
|
47
|
-
if (noInit === void 0) { noInit = false; }
|
|
48
|
-
if (sections === void 0) { sections = []; }
|
|
49
|
-
if (commentsDisabled === void 0) { commentsDisabled = false; }
|
|
50
|
-
var _this = _super.call(this, baseUrl, path) || this;
|
|
51
|
-
_this.json = json;
|
|
52
|
-
_this.sections = sections;
|
|
53
|
-
_this.commentsDisabled = commentsDisabled;
|
|
54
|
-
_this._bannerImageDirty = false;
|
|
55
|
-
_this._bannerImageThumbnailUrlDirty = false;
|
|
56
|
-
// ensure we have a good url to build on for the pages api
|
|
57
|
-
if (typeof baseUrl === "string") {
|
|
58
|
-
_this.data.parentUrl = "";
|
|
59
|
-
_this.data.url = combine(extractWebUrl(baseUrl), path);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
_this.assign(initFrom(baseUrl, null), path);
|
|
63
|
-
}
|
|
64
|
-
// set a default page settings slice
|
|
65
|
-
_this._pageSettings = { controlType: 0, pageSettingsSlice: { isDefaultDescription: true, isDefaultThumbnail: true } };
|
|
66
|
-
// set a default layout part
|
|
67
|
-
_this._layoutPart = _ClientsidePage.getDefaultLayoutPart();
|
|
68
|
-
if (typeof json !== "undefined" && !noInit) {
|
|
69
|
-
_this.fromJSON(json);
|
|
70
|
-
}
|
|
71
|
-
return _this;
|
|
72
|
-
}
|
|
73
|
-
_ClientsidePage.getDefaultLayoutPart = function () {
|
|
74
|
-
return {
|
|
75
|
-
dataVersion: "1.4",
|
|
76
|
-
description: "Title Region Description",
|
|
77
|
-
id: "cbe7b0a9-3504-44dd-a3a3-0e5cacd07788",
|
|
78
|
-
instanceId: "cbe7b0a9-3504-44dd-a3a3-0e5cacd07788",
|
|
79
|
-
properties: {
|
|
80
|
-
authorByline: [],
|
|
81
|
-
authors: [],
|
|
82
|
-
layoutType: "FullWidthImage",
|
|
83
|
-
showPublishDate: false,
|
|
84
|
-
showTopicHeader: false,
|
|
85
|
-
textAlignment: "Left",
|
|
86
|
-
title: "",
|
|
87
|
-
topicHeader: "",
|
|
88
|
-
},
|
|
89
|
-
reservedHeight: 280,
|
|
90
|
-
serverProcessedContent: { htmlStrings: {}, searchablePlainTexts: {}, imageSources: {}, links: {} },
|
|
91
|
-
title: "Title area",
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
Object.defineProperty(_ClientsidePage.prototype, "pageLayout", {
|
|
95
|
-
get: function () {
|
|
96
|
-
return this.json.PageLayoutType;
|
|
97
|
-
},
|
|
98
|
-
set: function (value) {
|
|
99
|
-
this.json.PageLayoutType = value;
|
|
100
|
-
},
|
|
101
|
-
enumerable: false,
|
|
102
|
-
configurable: true
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(_ClientsidePage.prototype, "bannerImageUrl", {
|
|
105
|
-
get: function () {
|
|
106
|
-
return this.json.BannerImageUrl;
|
|
107
|
-
},
|
|
108
|
-
set: function (value) {
|
|
109
|
-
this.setBannerImage(value);
|
|
110
|
-
},
|
|
111
|
-
enumerable: false,
|
|
112
|
-
configurable: true
|
|
113
|
-
});
|
|
114
|
-
Object.defineProperty(_ClientsidePage.prototype, "thumbnailUrl", {
|
|
115
|
-
get: function () {
|
|
116
|
-
return this._pageSettings.pageSettingsSlice.isDefaultThumbnail ? this.json.BannerImageUrl : this.json.BannerThumbnailUrl;
|
|
117
|
-
},
|
|
118
|
-
set: function (value) {
|
|
119
|
-
this.json.BannerThumbnailUrl = value;
|
|
120
|
-
this._bannerImageThumbnailUrlDirty = true;
|
|
121
|
-
this._pageSettings.pageSettingsSlice.isDefaultThumbnail = false;
|
|
122
|
-
},
|
|
123
|
-
enumerable: false,
|
|
124
|
-
configurable: true
|
|
125
|
-
});
|
|
126
|
-
Object.defineProperty(_ClientsidePage.prototype, "topicHeader", {
|
|
127
|
-
get: function () {
|
|
128
|
-
return objectDefinedNotNull(this.json.TopicHeader) ? this.json.TopicHeader : "";
|
|
129
|
-
},
|
|
130
|
-
set: function (value) {
|
|
131
|
-
this.json.TopicHeader = value;
|
|
132
|
-
this._layoutPart.properties.topicHeader = value;
|
|
133
|
-
if (stringIsNullOrEmpty(value)) {
|
|
134
|
-
this.showTopicHeader = false;
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
enumerable: false,
|
|
138
|
-
configurable: true
|
|
139
|
-
});
|
|
140
|
-
Object.defineProperty(_ClientsidePage.prototype, "title", {
|
|
141
|
-
get: function () {
|
|
142
|
-
return this._layoutPart.properties.title;
|
|
143
|
-
},
|
|
144
|
-
set: function (value) {
|
|
145
|
-
this.json.Title = value;
|
|
146
|
-
this._layoutPart.properties.title = value;
|
|
147
|
-
},
|
|
148
|
-
enumerable: false,
|
|
149
|
-
configurable: true
|
|
150
|
-
});
|
|
151
|
-
Object.defineProperty(_ClientsidePage.prototype, "reservedHeight", {
|
|
152
|
-
get: function () {
|
|
153
|
-
return this._layoutPart.reservedHeight;
|
|
154
|
-
},
|
|
155
|
-
set: function (value) {
|
|
156
|
-
this._layoutPart.reservedHeight = value;
|
|
157
|
-
},
|
|
158
|
-
enumerable: false,
|
|
159
|
-
configurable: true
|
|
160
|
-
});
|
|
161
|
-
Object.defineProperty(_ClientsidePage.prototype, "description", {
|
|
162
|
-
get: function () {
|
|
163
|
-
return this.json.Description;
|
|
164
|
-
},
|
|
165
|
-
set: function (value) {
|
|
166
|
-
if (!stringIsNullOrEmpty(value) && value.length > 255) {
|
|
167
|
-
throw Error("Modern Page description is limited to 255 chars.");
|
|
168
|
-
}
|
|
169
|
-
this.json.Description = value;
|
|
170
|
-
if (!hOP(this._pageSettings, "htmlAttributes")) {
|
|
171
|
-
this._pageSettings.htmlAttributes = [];
|
|
172
|
-
}
|
|
173
|
-
if (this._pageSettings.htmlAttributes.indexOf("modifiedDescription") < 0) {
|
|
174
|
-
this._pageSettings.htmlAttributes.push("modifiedDescription");
|
|
175
|
-
}
|
|
176
|
-
this._pageSettings.pageSettingsSlice.isDefaultDescription = false;
|
|
177
|
-
},
|
|
178
|
-
enumerable: false,
|
|
179
|
-
configurable: true
|
|
180
|
-
});
|
|
181
|
-
Object.defineProperty(_ClientsidePage.prototype, "layoutType", {
|
|
182
|
-
get: function () {
|
|
183
|
-
return this._layoutPart.properties.layoutType;
|
|
184
|
-
},
|
|
185
|
-
set: function (value) {
|
|
186
|
-
this._layoutPart.properties.layoutType = value;
|
|
187
|
-
},
|
|
188
|
-
enumerable: false,
|
|
189
|
-
configurable: true
|
|
190
|
-
});
|
|
191
|
-
Object.defineProperty(_ClientsidePage.prototype, "headerTextAlignment", {
|
|
192
|
-
get: function () {
|
|
193
|
-
return this._layoutPart.properties.textAlignment;
|
|
194
|
-
},
|
|
195
|
-
set: function (value) {
|
|
196
|
-
this._layoutPart.properties.textAlignment = value;
|
|
197
|
-
},
|
|
198
|
-
enumerable: false,
|
|
199
|
-
configurable: true
|
|
200
|
-
});
|
|
201
|
-
Object.defineProperty(_ClientsidePage.prototype, "showTopicHeader", {
|
|
202
|
-
get: function () {
|
|
203
|
-
return this._layoutPart.properties.showTopicHeader;
|
|
204
|
-
},
|
|
205
|
-
set: function (value) {
|
|
206
|
-
this._layoutPart.properties.showTopicHeader = value;
|
|
207
|
-
},
|
|
208
|
-
enumerable: false,
|
|
209
|
-
configurable: true
|
|
210
|
-
});
|
|
211
|
-
Object.defineProperty(_ClientsidePage.prototype, "showPublishDate", {
|
|
212
|
-
get: function () {
|
|
213
|
-
return this._layoutPart.properties.showPublishDate;
|
|
214
|
-
},
|
|
215
|
-
set: function (value) {
|
|
216
|
-
this._layoutPart.properties.showPublishDate = value;
|
|
217
|
-
},
|
|
218
|
-
enumerable: false,
|
|
219
|
-
configurable: true
|
|
220
|
-
});
|
|
221
|
-
Object.defineProperty(_ClientsidePage.prototype, "hasVerticalSection", {
|
|
222
|
-
get: function () {
|
|
223
|
-
return this.sections.findIndex(function (s) { return s.layoutIndex === 2; }) > -1;
|
|
224
|
-
},
|
|
225
|
-
enumerable: false,
|
|
226
|
-
configurable: true
|
|
227
|
-
});
|
|
228
|
-
Object.defineProperty(_ClientsidePage.prototype, "authorByLine", {
|
|
229
|
-
get: function () {
|
|
230
|
-
if (isArray(this._layoutPart.properties.authorByline) && this._layoutPart.properties.authorByline.length > 0) {
|
|
231
|
-
return this._layoutPart.properties.authorByline[0];
|
|
232
|
-
}
|
|
233
|
-
return null;
|
|
234
|
-
},
|
|
235
|
-
enumerable: false,
|
|
236
|
-
configurable: true
|
|
237
|
-
});
|
|
238
|
-
Object.defineProperty(_ClientsidePage.prototype, "verticalSection", {
|
|
239
|
-
get: function () {
|
|
240
|
-
if (this.hasVerticalSection) {
|
|
241
|
-
return this.addVerticalSection();
|
|
242
|
-
}
|
|
243
|
-
return null;
|
|
244
|
-
},
|
|
245
|
-
enumerable: false,
|
|
246
|
-
configurable: true
|
|
247
|
-
});
|
|
248
|
-
/**
|
|
249
|
-
* Add a section to this page
|
|
250
|
-
*/
|
|
251
|
-
_ClientsidePage.prototype.addSection = function () {
|
|
252
|
-
var section = new CanvasSection(this, getNextOrder(this.sections), 1);
|
|
253
|
-
this.sections.push(section);
|
|
254
|
-
return section;
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* Add a section to this page
|
|
258
|
-
*/
|
|
259
|
-
_ClientsidePage.prototype.addVerticalSection = function () {
|
|
260
|
-
// we can only have one vertical section so we find it if it exists
|
|
261
|
-
var sectionIndex = this.sections.findIndex(function (s) { return s.layoutIndex === 2; });
|
|
262
|
-
if (sectionIndex > -1) {
|
|
263
|
-
return this.sections[sectionIndex];
|
|
264
|
-
}
|
|
265
|
-
var section = new CanvasSection(this, getNextOrder(this.sections), 2);
|
|
266
|
-
this.sections.push(section);
|
|
267
|
-
return section;
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* Loads this instance from the appropriate JSON data
|
|
271
|
-
*
|
|
272
|
-
* @param pageData JSON data to load (replaces any existing data)
|
|
273
|
-
*/
|
|
274
|
-
_ClientsidePage.prototype.fromJSON = function (pageData) {
|
|
275
|
-
this.json = pageData;
|
|
276
|
-
var canvasControls = JSON.parse(pageData.CanvasContent1);
|
|
277
|
-
var layouts = JSON.parse(pageData.LayoutWebpartsContent);
|
|
278
|
-
if (layouts && layouts.length > 0) {
|
|
279
|
-
this._layoutPart = layouts[0];
|
|
280
|
-
}
|
|
281
|
-
this.setControls(canvasControls);
|
|
282
|
-
return this;
|
|
283
|
-
};
|
|
284
|
-
/**
|
|
285
|
-
* Loads this page's content from the server
|
|
286
|
-
*/
|
|
287
|
-
_ClientsidePage.prototype.load = function () {
|
|
288
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
289
|
-
var item, pageData;
|
|
290
|
-
return __generator(this, function (_a) {
|
|
291
|
-
switch (_a.label) {
|
|
292
|
-
case 0: return [4 /*yield*/, this.getItem("Id", "CommentsDisabled")];
|
|
293
|
-
case 1:
|
|
294
|
-
item = _a.sent();
|
|
295
|
-
return [4 /*yield*/, SharePointQueryable(this, "_api/sitepages/pages(" + item.Id + ")")()];
|
|
296
|
-
case 2:
|
|
297
|
-
pageData = _a.sent();
|
|
298
|
-
this.commentsDisabled = item.CommentsDisabled;
|
|
299
|
-
return [2 /*return*/, this.fromJSON(pageData)];
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Persists the content changes (sections, columns, and controls) [does not work with batching]
|
|
306
|
-
*
|
|
307
|
-
* @param publish If true the page is published, if false the changes are persisted to SharePoint but not published [Default: true]
|
|
308
|
-
*/
|
|
309
|
-
_ClientsidePage.prototype.save = function (publish) {
|
|
310
|
-
if (publish === void 0) { publish = true; }
|
|
311
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
312
|
-
var previewPartialUrl, serverRelativePath, imgInfo_1, webUrl_1, web, batch, f, saveBody, bannerImageUrlValue, updater, r;
|
|
313
|
-
return __generator(this, function (_a) {
|
|
314
|
-
switch (_a.label) {
|
|
315
|
-
case 0:
|
|
316
|
-
if (this.json.Id === null) {
|
|
317
|
-
throw Error("The id for this page is null. If you want to create a new page, please use ClientSidePage.Create");
|
|
318
|
-
}
|
|
319
|
-
previewPartialUrl = "_layouts/15/getpreview.ashx";
|
|
320
|
-
if (!(this._bannerImageDirty && !this.bannerImageUrl.includes(previewPartialUrl))) return [3 /*break*/, 2];
|
|
321
|
-
serverRelativePath = this.bannerImageUrl;
|
|
322
|
-
web = Web(extractWebUrl(this.toUrl())).configureFrom(this);
|
|
323
|
-
batch = web.createBatch();
|
|
324
|
-
web.getFileByServerRelativePath(serverRelativePath.replace(/%20/ig, " "))
|
|
325
|
-
.select("ListId", "WebId", "UniqueId", "Name", "SiteId").inBatch(batch)().then(function (r1) { return imgInfo_1 = r1; });
|
|
326
|
-
web.select("Url").inBatch(batch)().then(function (r2) { return webUrl_1 = r2.Url; });
|
|
327
|
-
// we know the .then calls above will run before execute resolves, ensuring the vars are set
|
|
328
|
-
return [4 /*yield*/, batch.execute()];
|
|
329
|
-
case 1:
|
|
330
|
-
// we know the .then calls above will run before execute resolves, ensuring the vars are set
|
|
331
|
-
_a.sent();
|
|
332
|
-
f = SharePointQueryable(webUrl_1, previewPartialUrl);
|
|
333
|
-
f.query.set("guidSite", "" + imgInfo_1.SiteId);
|
|
334
|
-
f.query.set("guidWeb", "" + imgInfo_1.WebId);
|
|
335
|
-
f.query.set("guidFile", "" + imgInfo_1.UniqueId);
|
|
336
|
-
this.bannerImageUrl = f.toUrlAndQuery();
|
|
337
|
-
if (!objectDefinedNotNull(this._layoutPart.serverProcessedContent)) {
|
|
338
|
-
this._layoutPart.serverProcessedContent = {};
|
|
339
|
-
}
|
|
340
|
-
this._layoutPart.serverProcessedContent.imageSources = { imageSource: serverRelativePath };
|
|
341
|
-
if (!objectDefinedNotNull(this._layoutPart.serverProcessedContent.customMetadata)) {
|
|
342
|
-
this._layoutPart.serverProcessedContent.customMetadata = {};
|
|
343
|
-
}
|
|
344
|
-
this._layoutPart.serverProcessedContent.customMetadata.imageSource = {
|
|
345
|
-
listId: imgInfo_1.ListId,
|
|
346
|
-
siteId: imgInfo_1.SiteId,
|
|
347
|
-
uniqueId: imgInfo_1.UniqueId,
|
|
348
|
-
webId: imgInfo_1.WebId,
|
|
349
|
-
};
|
|
350
|
-
this._layoutPart.properties.webId = imgInfo_1.WebId;
|
|
351
|
-
this._layoutPart.properties.siteId = imgInfo_1.SiteId;
|
|
352
|
-
this._layoutPart.properties.listId = imgInfo_1.ListId;
|
|
353
|
-
this._layoutPart.properties.uniqueId = imgInfo_1.UniqueId;
|
|
354
|
-
_a.label = 2;
|
|
355
|
-
case 2:
|
|
356
|
-
if (!!this.json.IsPageCheckedOutToCurrentUser) return [3 /*break*/, 4];
|
|
357
|
-
return [4 /*yield*/, spPost(initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/checkoutpage"))];
|
|
358
|
-
case 3:
|
|
359
|
-
_a.sent();
|
|
360
|
-
_a.label = 4;
|
|
361
|
-
case 4:
|
|
362
|
-
saveBody = Object.assign(metadata("SP.Publishing.SitePage"), {
|
|
363
|
-
AuthorByline: this.json.AuthorByline || [],
|
|
364
|
-
CanvasContent1: this.getCanvasContent1(),
|
|
365
|
-
Description: this.description,
|
|
366
|
-
LayoutWebpartsContent: this.getLayoutWebpartsContent(),
|
|
367
|
-
Title: this.title,
|
|
368
|
-
TopicHeader: this.topicHeader,
|
|
369
|
-
BannerImageUrl: this.bannerImageUrl
|
|
370
|
-
});
|
|
371
|
-
if (this._bannerImageDirty || this._bannerImageThumbnailUrlDirty) {
|
|
372
|
-
bannerImageUrlValue = this._bannerImageThumbnailUrlDirty ? this.thumbnailUrl : this.bannerImageUrl;
|
|
373
|
-
saveBody = assign(saveBody, {
|
|
374
|
-
BannerImageUrl: bannerImageUrlValue,
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
updater = initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/savepage");
|
|
378
|
-
return [4 /*yield*/, spPost(updater, headers({ "if-match": "*" }, body(saveBody)))];
|
|
379
|
-
case 5:
|
|
380
|
-
_a.sent();
|
|
381
|
-
r = true;
|
|
382
|
-
if (!publish) return [3 /*break*/, 7];
|
|
383
|
-
return [4 /*yield*/, spPost(initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/publish"))];
|
|
384
|
-
case 6:
|
|
385
|
-
r = _a.sent();
|
|
386
|
-
if (r) {
|
|
387
|
-
this.json.IsPageCheckedOutToCurrentUser = false;
|
|
388
|
-
}
|
|
389
|
-
_a.label = 7;
|
|
390
|
-
case 7:
|
|
391
|
-
this._bannerImageDirty = false;
|
|
392
|
-
this._bannerImageThumbnailUrlDirty = false;
|
|
393
|
-
// we need to ensure we reload from the latest data to ensure all urls are updated and current in the object (expecially for new pages)
|
|
394
|
-
return [4 /*yield*/, this.load()];
|
|
395
|
-
case 8:
|
|
396
|
-
// we need to ensure we reload from the latest data to ensure all urls are updated and current in the object (expecially for new pages)
|
|
397
|
-
_a.sent();
|
|
398
|
-
return [2 /*return*/, r];
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
};
|
|
403
|
-
/**
|
|
404
|
-
* Discards the checkout of this page
|
|
405
|
-
*/
|
|
406
|
-
_ClientsidePage.prototype.discardPageCheckout = function () {
|
|
407
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
408
|
-
var d;
|
|
409
|
-
return __generator(this, function (_a) {
|
|
410
|
-
switch (_a.label) {
|
|
411
|
-
case 0:
|
|
412
|
-
if (this.json.Id === null) {
|
|
413
|
-
throw Error("The id for this page is null. If you want to create a new page, please use ClientSidePage.Create");
|
|
414
|
-
}
|
|
415
|
-
return [4 /*yield*/, spPost(initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/discardPage"), body(metadata("SP.Publishing.SitePage")))];
|
|
416
|
-
case 1:
|
|
417
|
-
d = _a.sent();
|
|
418
|
-
this.fromJSON(d);
|
|
419
|
-
return [2 /*return*/];
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
};
|
|
424
|
-
/**
|
|
425
|
-
* Promotes this page as a news item
|
|
426
|
-
*/
|
|
427
|
-
_ClientsidePage.prototype.promoteToNews = function () {
|
|
428
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
429
|
-
return __generator(this, function (_a) {
|
|
430
|
-
return [2 /*return*/, this.promoteNewsImpl("promoteToNews")];
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
|
-
};
|
|
434
|
-
// API is currently broken on server side
|
|
435
|
-
// public async demoteFromNews(): Promise<boolean> {
|
|
436
|
-
// return this.promoteNewsImpl("demoteFromNews");
|
|
437
|
-
// }
|
|
438
|
-
/**
|
|
439
|
-
* Finds a control by the specified instance id
|
|
440
|
-
*
|
|
441
|
-
* @param id Instance id of the control to find
|
|
442
|
-
*/
|
|
443
|
-
_ClientsidePage.prototype.findControlById = function (id) {
|
|
444
|
-
return this.findControl(function (c) { return c.id === id; });
|
|
445
|
-
};
|
|
446
|
-
/**
|
|
447
|
-
* Finds a control within this page's control tree using the supplied predicate
|
|
448
|
-
*
|
|
449
|
-
* @param predicate Takes a control and returns true or false, if true that control is returned by findControl
|
|
450
|
-
*/
|
|
451
|
-
_ClientsidePage.prototype.findControl = function (predicate) {
|
|
452
|
-
// check all sections
|
|
453
|
-
for (var i = 0; i < this.sections.length; i++) {
|
|
454
|
-
// check all columns
|
|
455
|
-
for (var j = 0; j < this.sections[i].columns.length; j++) {
|
|
456
|
-
// check all controls
|
|
457
|
-
for (var k = 0; k < this.sections[i].columns[j].controls.length; k++) {
|
|
458
|
-
// check to see if the predicate likes this control
|
|
459
|
-
if (predicate(this.sections[i].columns[j].controls[k])) {
|
|
460
|
-
return this.sections[i].columns[j].controls[k];
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
// we found nothing so give nothing back
|
|
466
|
-
return null;
|
|
467
|
-
};
|
|
468
|
-
/**
|
|
469
|
-
* Creates a new page with all of the content copied from this page
|
|
470
|
-
*
|
|
471
|
-
* @param web The web where we will create the copy
|
|
472
|
-
* @param pageName The file name of the new page
|
|
473
|
-
* @param title The title of the new page
|
|
474
|
-
* @param publish If true the page will be published (Default: true)
|
|
475
|
-
*/
|
|
476
|
-
_ClientsidePage.prototype.copy = function (web, pageName, title, publish, promotedState) {
|
|
477
|
-
if (publish === void 0) { publish = true; }
|
|
478
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
479
|
-
var page;
|
|
480
|
-
return __generator(this, function (_a) {
|
|
481
|
-
switch (_a.label) {
|
|
482
|
-
case 0: return [4 /*yield*/, CreateClientsidePage(web, pageName, title, this.pageLayout, promotedState)];
|
|
483
|
-
case 1:
|
|
484
|
-
page = _a.sent();
|
|
485
|
-
return [2 /*return*/, this.copyTo(page, publish)];
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
};
|
|
490
|
-
/**
|
|
491
|
-
* Copies the content from this page to the supplied page instance NOTE: fully overwriting any previous content!!
|
|
492
|
-
*
|
|
493
|
-
* @param page Page whose content we replace with this page's content
|
|
494
|
-
* @param publish If true the page will be published after the copy, if false it will be saved but left unpublished (Default: true)
|
|
495
|
-
*/
|
|
496
|
-
_ClientsidePage.prototype.copyTo = function (page, publish) {
|
|
497
|
-
if (publish === void 0) { publish = true; }
|
|
498
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
499
|
-
var url, makeGuid, guidSite, guidWeb, guidFile, site, id, openWeb, file, props;
|
|
500
|
-
return __generator(this, function (_a) {
|
|
501
|
-
switch (_a.label) {
|
|
502
|
-
case 0:
|
|
503
|
-
// we know the method is on the class - but it is protected so not part of the interface
|
|
504
|
-
page.setControls(this.getControls());
|
|
505
|
-
if (!!stringIsNullOrEmpty(this.json.BannerImageUrl)) return [3 /*break*/, 4];
|
|
506
|
-
url = new URL(this.json.BannerImageUrl);
|
|
507
|
-
makeGuid = function (s) { return s.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/g, "$1-$2-$3-$4-$5"); };
|
|
508
|
-
if (!(url.searchParams.has("guidSite") && url.searchParams.has("guidWeb") && url.searchParams.has("guidFile"))) return [3 /*break*/, 4];
|
|
509
|
-
guidSite = makeGuid(url.searchParams.get("guidSite"));
|
|
510
|
-
guidWeb = makeGuid(url.searchParams.get("guidWeb"));
|
|
511
|
-
guidFile = makeGuid(url.searchParams.get("guidFile"));
|
|
512
|
-
site = Site(extractWebUrl(this.toUrl()));
|
|
513
|
-
return [4 /*yield*/, site.select("Id")()];
|
|
514
|
-
case 1:
|
|
515
|
-
id = _a.sent();
|
|
516
|
-
if (!(id.Id === guidSite)) return [3 /*break*/, 4];
|
|
517
|
-
return [4 /*yield*/, site.openWebById(guidWeb)];
|
|
518
|
-
case 2:
|
|
519
|
-
openWeb = _a.sent();
|
|
520
|
-
return [4 /*yield*/, openWeb.web.getFileById(guidFile).select("ServerRelativeUrl")()];
|
|
521
|
-
case 3:
|
|
522
|
-
file = _a.sent();
|
|
523
|
-
props = {};
|
|
524
|
-
if (this._layoutPart.properties) {
|
|
525
|
-
if (hOP(this._layoutPart.properties, "translateX")) {
|
|
526
|
-
props.translateX = this._layoutPart.properties.translateX;
|
|
527
|
-
}
|
|
528
|
-
if (hOP(this._layoutPart.properties, "translateY")) {
|
|
529
|
-
props.translateY = this._layoutPart.properties.translateY;
|
|
530
|
-
}
|
|
531
|
-
if (hOP(this._layoutPart.properties, "imageSourceType")) {
|
|
532
|
-
props.imageSourceType = this._layoutPart.properties.imageSourceType;
|
|
533
|
-
}
|
|
534
|
-
if (hOP(this._layoutPart.properties, "altText")) {
|
|
535
|
-
props.altText = this._layoutPart.properties.altText;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
page.setBannerImage(file.ServerRelativeUrl, props);
|
|
539
|
-
_a.label = 4;
|
|
540
|
-
case 4: return [4 /*yield*/, page.save(publish)];
|
|
541
|
-
case 5:
|
|
542
|
-
_a.sent();
|
|
543
|
-
return [2 /*return*/, page];
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
/**
|
|
549
|
-
* Sets the modern page banner image
|
|
550
|
-
*
|
|
551
|
-
* @param url Url of the image to display
|
|
552
|
-
* @param altText Alt text to describe the image
|
|
553
|
-
* @param bannerProps Additional properties to control display of the banner
|
|
554
|
-
*/
|
|
555
|
-
_ClientsidePage.prototype.setBannerImage = function (url, props) {
|
|
556
|
-
if (isUrlAbsolute(url)) {
|
|
557
|
-
// do our best to make this a server relative url by removing the x.sharepoint.com part
|
|
558
|
-
url = url.replace(/^https?:\/\/[a-z0-9.]*?\.[a-z]{2,3}\//i, "/");
|
|
559
|
-
}
|
|
560
|
-
this.json.BannerImageUrl = url;
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
request
|
|
607
|
-
request.query.set("
|
|
608
|
-
request.
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
*
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
.
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
*
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
.
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
this.
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
*
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
//
|
|
744
|
-
//
|
|
745
|
-
// *
|
|
746
|
-
// *
|
|
747
|
-
//
|
|
748
|
-
//
|
|
749
|
-
//
|
|
750
|
-
//
|
|
751
|
-
//
|
|
752
|
-
//
|
|
753
|
-
//
|
|
754
|
-
//
|
|
755
|
-
// }))
|
|
756
|
-
//
|
|
757
|
-
//
|
|
758
|
-
// }
|
|
759
|
-
//
|
|
760
|
-
//
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
* @
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
this.
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
//
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
if (!(
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
*
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
var
|
|
920
|
-
var
|
|
921
|
-
var
|
|
922
|
-
var
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
var
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
var
|
|
960
|
-
var
|
|
961
|
-
column.
|
|
962
|
-
section.
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
* @param
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
section
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
if (
|
|
1037
|
-
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
*
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
* @param
|
|
1062
|
-
* @param
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
};
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
this.
|
|
1099
|
-
this.
|
|
1100
|
-
this.
|
|
1101
|
-
this.
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
column
|
|
1150
|
-
column.
|
|
1151
|
-
column.data.position.
|
|
1152
|
-
column.
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
*
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
this.
|
|
1193
|
-
this.
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
this.controls[i].data.position.
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
if (
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
this.data.position.
|
|
1341
|
-
this.data.position.
|
|
1342
|
-
this.data.position.
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
this
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
this.data.
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
this.
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1
|
+
import { __awaiter, __decorate, __extends, __generator, __read, __spreadArray } from "tslib";
|
|
2
|
+
import { invokableFactory, body, headers } from "@pnp/odata";
|
|
3
|
+
import { assign, getGUID, hOP, stringIsNullOrEmpty, objectDefinedNotNull, combine, isUrlAbsolute, isArray } from "@pnp/common";
|
|
4
|
+
import { Item } from "../items/types.js";
|
|
5
|
+
import { SharePointQueryable, _SharePointQueryable, SharePointQueryableCollection } from "../sharepointqueryable.js";
|
|
6
|
+
import { metadata } from "../utils/metadata.js";
|
|
7
|
+
import { List } from "../lists/types.js";
|
|
8
|
+
import { odataUrlFrom } from "../odata.js";
|
|
9
|
+
import { Web } from "../webs/types.js";
|
|
10
|
+
import { extractWebUrl } from "../utils/extractweburl.js";
|
|
11
|
+
import { Site } from "../sites/types.js";
|
|
12
|
+
import { spPost } from "../operations.js";
|
|
13
|
+
import { getNextOrder, reindex } from "./funcs.js";
|
|
14
|
+
import "../files/web.js";
|
|
15
|
+
import "../comments/item.js";
|
|
16
|
+
import { tag } from "../telemetry.js";
|
|
17
|
+
/**
|
|
18
|
+
* Page promotion state
|
|
19
|
+
*/
|
|
20
|
+
export var PromotedState;
|
|
21
|
+
(function (PromotedState) {
|
|
22
|
+
/**
|
|
23
|
+
* Regular client side page
|
|
24
|
+
*/
|
|
25
|
+
PromotedState[PromotedState["NotPromoted"] = 0] = "NotPromoted";
|
|
26
|
+
/**
|
|
27
|
+
* Page that will be promoted as news article after publishing
|
|
28
|
+
*/
|
|
29
|
+
PromotedState[PromotedState["PromoteOnPublish"] = 1] = "PromoteOnPublish";
|
|
30
|
+
/**
|
|
31
|
+
* Page that is promoted as news article
|
|
32
|
+
*/
|
|
33
|
+
PromotedState[PromotedState["Promoted"] = 2] = "Promoted";
|
|
34
|
+
})(PromotedState || (PromotedState = {}));
|
|
35
|
+
function initFrom(o, url) {
|
|
36
|
+
return ClientsidePage(extractWebUrl(o.toUrl()), url).configureFrom(o);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Represents the data and methods associated with client side "modern" pages
|
|
40
|
+
*/
|
|
41
|
+
var _ClientsidePage = /** @class */ (function (_super) {
|
|
42
|
+
__extends(_ClientsidePage, _super);
|
|
43
|
+
/**
|
|
44
|
+
* PLEASE DON'T USE THIS CONSTRUCTOR DIRECTLY, thank you 🐇
|
|
45
|
+
*/
|
|
46
|
+
function _ClientsidePage(baseUrl, path, json, noInit, sections, commentsDisabled) {
|
|
47
|
+
if (noInit === void 0) { noInit = false; }
|
|
48
|
+
if (sections === void 0) { sections = []; }
|
|
49
|
+
if (commentsDisabled === void 0) { commentsDisabled = false; }
|
|
50
|
+
var _this = _super.call(this, baseUrl, path) || this;
|
|
51
|
+
_this.json = json;
|
|
52
|
+
_this.sections = sections;
|
|
53
|
+
_this.commentsDisabled = commentsDisabled;
|
|
54
|
+
_this._bannerImageDirty = false;
|
|
55
|
+
_this._bannerImageThumbnailUrlDirty = false;
|
|
56
|
+
// ensure we have a good url to build on for the pages api
|
|
57
|
+
if (typeof baseUrl === "string") {
|
|
58
|
+
_this.data.parentUrl = "";
|
|
59
|
+
_this.data.url = combine(extractWebUrl(baseUrl), path);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
_this.assign(initFrom(baseUrl, null), path);
|
|
63
|
+
}
|
|
64
|
+
// set a default page settings slice
|
|
65
|
+
_this._pageSettings = { controlType: 0, pageSettingsSlice: { isDefaultDescription: true, isDefaultThumbnail: true } };
|
|
66
|
+
// set a default layout part
|
|
67
|
+
_this._layoutPart = _ClientsidePage.getDefaultLayoutPart();
|
|
68
|
+
if (typeof json !== "undefined" && !noInit) {
|
|
69
|
+
_this.fromJSON(json);
|
|
70
|
+
}
|
|
71
|
+
return _this;
|
|
72
|
+
}
|
|
73
|
+
_ClientsidePage.getDefaultLayoutPart = function () {
|
|
74
|
+
return {
|
|
75
|
+
dataVersion: "1.4",
|
|
76
|
+
description: "Title Region Description",
|
|
77
|
+
id: "cbe7b0a9-3504-44dd-a3a3-0e5cacd07788",
|
|
78
|
+
instanceId: "cbe7b0a9-3504-44dd-a3a3-0e5cacd07788",
|
|
79
|
+
properties: {
|
|
80
|
+
authorByline: [],
|
|
81
|
+
authors: [],
|
|
82
|
+
layoutType: "FullWidthImage",
|
|
83
|
+
showPublishDate: false,
|
|
84
|
+
showTopicHeader: false,
|
|
85
|
+
textAlignment: "Left",
|
|
86
|
+
title: "",
|
|
87
|
+
topicHeader: "",
|
|
88
|
+
},
|
|
89
|
+
reservedHeight: 280,
|
|
90
|
+
serverProcessedContent: { htmlStrings: {}, searchablePlainTexts: {}, imageSources: {}, links: {} },
|
|
91
|
+
title: "Title area",
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
Object.defineProperty(_ClientsidePage.prototype, "pageLayout", {
|
|
95
|
+
get: function () {
|
|
96
|
+
return this.json.PageLayoutType;
|
|
97
|
+
},
|
|
98
|
+
set: function (value) {
|
|
99
|
+
this.json.PageLayoutType = value;
|
|
100
|
+
},
|
|
101
|
+
enumerable: false,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(_ClientsidePage.prototype, "bannerImageUrl", {
|
|
105
|
+
get: function () {
|
|
106
|
+
return this.json.BannerImageUrl;
|
|
107
|
+
},
|
|
108
|
+
set: function (value) {
|
|
109
|
+
this.setBannerImage(value);
|
|
110
|
+
},
|
|
111
|
+
enumerable: false,
|
|
112
|
+
configurable: true
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(_ClientsidePage.prototype, "thumbnailUrl", {
|
|
115
|
+
get: function () {
|
|
116
|
+
return this._pageSettings.pageSettingsSlice.isDefaultThumbnail ? this.json.BannerImageUrl : this.json.BannerThumbnailUrl;
|
|
117
|
+
},
|
|
118
|
+
set: function (value) {
|
|
119
|
+
this.json.BannerThumbnailUrl = value;
|
|
120
|
+
this._bannerImageThumbnailUrlDirty = true;
|
|
121
|
+
this._pageSettings.pageSettingsSlice.isDefaultThumbnail = false;
|
|
122
|
+
},
|
|
123
|
+
enumerable: false,
|
|
124
|
+
configurable: true
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(_ClientsidePage.prototype, "topicHeader", {
|
|
127
|
+
get: function () {
|
|
128
|
+
return objectDefinedNotNull(this.json.TopicHeader) ? this.json.TopicHeader : "";
|
|
129
|
+
},
|
|
130
|
+
set: function (value) {
|
|
131
|
+
this.json.TopicHeader = value;
|
|
132
|
+
this._layoutPart.properties.topicHeader = value;
|
|
133
|
+
if (stringIsNullOrEmpty(value)) {
|
|
134
|
+
this.showTopicHeader = false;
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
enumerable: false,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(_ClientsidePage.prototype, "title", {
|
|
141
|
+
get: function () {
|
|
142
|
+
return this._layoutPart.properties.title;
|
|
143
|
+
},
|
|
144
|
+
set: function (value) {
|
|
145
|
+
this.json.Title = value;
|
|
146
|
+
this._layoutPart.properties.title = value;
|
|
147
|
+
},
|
|
148
|
+
enumerable: false,
|
|
149
|
+
configurable: true
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(_ClientsidePage.prototype, "reservedHeight", {
|
|
152
|
+
get: function () {
|
|
153
|
+
return this._layoutPart.reservedHeight;
|
|
154
|
+
},
|
|
155
|
+
set: function (value) {
|
|
156
|
+
this._layoutPart.reservedHeight = value;
|
|
157
|
+
},
|
|
158
|
+
enumerable: false,
|
|
159
|
+
configurable: true
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(_ClientsidePage.prototype, "description", {
|
|
162
|
+
get: function () {
|
|
163
|
+
return this.json.Description;
|
|
164
|
+
},
|
|
165
|
+
set: function (value) {
|
|
166
|
+
if (!stringIsNullOrEmpty(value) && value.length > 255) {
|
|
167
|
+
throw Error("Modern Page description is limited to 255 chars.");
|
|
168
|
+
}
|
|
169
|
+
this.json.Description = value;
|
|
170
|
+
if (!hOP(this._pageSettings, "htmlAttributes")) {
|
|
171
|
+
this._pageSettings.htmlAttributes = [];
|
|
172
|
+
}
|
|
173
|
+
if (this._pageSettings.htmlAttributes.indexOf("modifiedDescription") < 0) {
|
|
174
|
+
this._pageSettings.htmlAttributes.push("modifiedDescription");
|
|
175
|
+
}
|
|
176
|
+
this._pageSettings.pageSettingsSlice.isDefaultDescription = false;
|
|
177
|
+
},
|
|
178
|
+
enumerable: false,
|
|
179
|
+
configurable: true
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(_ClientsidePage.prototype, "layoutType", {
|
|
182
|
+
get: function () {
|
|
183
|
+
return this._layoutPart.properties.layoutType;
|
|
184
|
+
},
|
|
185
|
+
set: function (value) {
|
|
186
|
+
this._layoutPart.properties.layoutType = value;
|
|
187
|
+
},
|
|
188
|
+
enumerable: false,
|
|
189
|
+
configurable: true
|
|
190
|
+
});
|
|
191
|
+
Object.defineProperty(_ClientsidePage.prototype, "headerTextAlignment", {
|
|
192
|
+
get: function () {
|
|
193
|
+
return this._layoutPart.properties.textAlignment;
|
|
194
|
+
},
|
|
195
|
+
set: function (value) {
|
|
196
|
+
this._layoutPart.properties.textAlignment = value;
|
|
197
|
+
},
|
|
198
|
+
enumerable: false,
|
|
199
|
+
configurable: true
|
|
200
|
+
});
|
|
201
|
+
Object.defineProperty(_ClientsidePage.prototype, "showTopicHeader", {
|
|
202
|
+
get: function () {
|
|
203
|
+
return this._layoutPart.properties.showTopicHeader;
|
|
204
|
+
},
|
|
205
|
+
set: function (value) {
|
|
206
|
+
this._layoutPart.properties.showTopicHeader = value;
|
|
207
|
+
},
|
|
208
|
+
enumerable: false,
|
|
209
|
+
configurable: true
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(_ClientsidePage.prototype, "showPublishDate", {
|
|
212
|
+
get: function () {
|
|
213
|
+
return this._layoutPart.properties.showPublishDate;
|
|
214
|
+
},
|
|
215
|
+
set: function (value) {
|
|
216
|
+
this._layoutPart.properties.showPublishDate = value;
|
|
217
|
+
},
|
|
218
|
+
enumerable: false,
|
|
219
|
+
configurable: true
|
|
220
|
+
});
|
|
221
|
+
Object.defineProperty(_ClientsidePage.prototype, "hasVerticalSection", {
|
|
222
|
+
get: function () {
|
|
223
|
+
return this.sections.findIndex(function (s) { return s.layoutIndex === 2; }) > -1;
|
|
224
|
+
},
|
|
225
|
+
enumerable: false,
|
|
226
|
+
configurable: true
|
|
227
|
+
});
|
|
228
|
+
Object.defineProperty(_ClientsidePage.prototype, "authorByLine", {
|
|
229
|
+
get: function () {
|
|
230
|
+
if (isArray(this._layoutPart.properties.authorByline) && this._layoutPart.properties.authorByline.length > 0) {
|
|
231
|
+
return this._layoutPart.properties.authorByline[0];
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
},
|
|
235
|
+
enumerable: false,
|
|
236
|
+
configurable: true
|
|
237
|
+
});
|
|
238
|
+
Object.defineProperty(_ClientsidePage.prototype, "verticalSection", {
|
|
239
|
+
get: function () {
|
|
240
|
+
if (this.hasVerticalSection) {
|
|
241
|
+
return this.addVerticalSection();
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
},
|
|
245
|
+
enumerable: false,
|
|
246
|
+
configurable: true
|
|
247
|
+
});
|
|
248
|
+
/**
|
|
249
|
+
* Add a section to this page
|
|
250
|
+
*/
|
|
251
|
+
_ClientsidePage.prototype.addSection = function () {
|
|
252
|
+
var section = new CanvasSection(this, getNextOrder(this.sections), 1);
|
|
253
|
+
this.sections.push(section);
|
|
254
|
+
return section;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Add a section to this page
|
|
258
|
+
*/
|
|
259
|
+
_ClientsidePage.prototype.addVerticalSection = function () {
|
|
260
|
+
// we can only have one vertical section so we find it if it exists
|
|
261
|
+
var sectionIndex = this.sections.findIndex(function (s) { return s.layoutIndex === 2; });
|
|
262
|
+
if (sectionIndex > -1) {
|
|
263
|
+
return this.sections[sectionIndex];
|
|
264
|
+
}
|
|
265
|
+
var section = new CanvasSection(this, getNextOrder(this.sections), 2);
|
|
266
|
+
this.sections.push(section);
|
|
267
|
+
return section;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Loads this instance from the appropriate JSON data
|
|
271
|
+
*
|
|
272
|
+
* @param pageData JSON data to load (replaces any existing data)
|
|
273
|
+
*/
|
|
274
|
+
_ClientsidePage.prototype.fromJSON = function (pageData) {
|
|
275
|
+
this.json = pageData;
|
|
276
|
+
var canvasControls = JSON.parse(pageData.CanvasContent1);
|
|
277
|
+
var layouts = JSON.parse(pageData.LayoutWebpartsContent);
|
|
278
|
+
if (layouts && layouts.length > 0) {
|
|
279
|
+
this._layoutPart = layouts[0];
|
|
280
|
+
}
|
|
281
|
+
this.setControls(canvasControls);
|
|
282
|
+
return this;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Loads this page's content from the server
|
|
286
|
+
*/
|
|
287
|
+
_ClientsidePage.prototype.load = function () {
|
|
288
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
289
|
+
var item, pageData;
|
|
290
|
+
return __generator(this, function (_a) {
|
|
291
|
+
switch (_a.label) {
|
|
292
|
+
case 0: return [4 /*yield*/, this.getItem("Id", "CommentsDisabled")];
|
|
293
|
+
case 1:
|
|
294
|
+
item = _a.sent();
|
|
295
|
+
return [4 /*yield*/, SharePointQueryable(this, "_api/sitepages/pages(" + item.Id + ")")()];
|
|
296
|
+
case 2:
|
|
297
|
+
pageData = _a.sent();
|
|
298
|
+
this.commentsDisabled = item.CommentsDisabled;
|
|
299
|
+
return [2 /*return*/, this.fromJSON(pageData)];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Persists the content changes (sections, columns, and controls) [does not work with batching]
|
|
306
|
+
*
|
|
307
|
+
* @param publish If true the page is published, if false the changes are persisted to SharePoint but not published [Default: true]
|
|
308
|
+
*/
|
|
309
|
+
_ClientsidePage.prototype.save = function (publish) {
|
|
310
|
+
if (publish === void 0) { publish = true; }
|
|
311
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
312
|
+
var previewPartialUrl, serverRelativePath, imgInfo_1, webUrl_1, web, batch, f, saveBody, bannerImageUrlValue, updater, r;
|
|
313
|
+
return __generator(this, function (_a) {
|
|
314
|
+
switch (_a.label) {
|
|
315
|
+
case 0:
|
|
316
|
+
if (this.json.Id === null) {
|
|
317
|
+
throw Error("The id for this page is null. If you want to create a new page, please use ClientSidePage.Create");
|
|
318
|
+
}
|
|
319
|
+
previewPartialUrl = "_layouts/15/getpreview.ashx";
|
|
320
|
+
if (!(this._bannerImageDirty && !this.bannerImageUrl.includes(previewPartialUrl))) return [3 /*break*/, 2];
|
|
321
|
+
serverRelativePath = this.bannerImageUrl;
|
|
322
|
+
web = Web(extractWebUrl(this.toUrl())).configureFrom(this);
|
|
323
|
+
batch = web.createBatch();
|
|
324
|
+
web.getFileByServerRelativePath(serverRelativePath.replace(/%20/ig, " "))
|
|
325
|
+
.select("ListId", "WebId", "UniqueId", "Name", "SiteId").inBatch(batch)().then(function (r1) { return imgInfo_1 = r1; });
|
|
326
|
+
web.select("Url").inBatch(batch)().then(function (r2) { return webUrl_1 = r2.Url; });
|
|
327
|
+
// we know the .then calls above will run before execute resolves, ensuring the vars are set
|
|
328
|
+
return [4 /*yield*/, batch.execute()];
|
|
329
|
+
case 1:
|
|
330
|
+
// we know the .then calls above will run before execute resolves, ensuring the vars are set
|
|
331
|
+
_a.sent();
|
|
332
|
+
f = SharePointQueryable(webUrl_1, previewPartialUrl);
|
|
333
|
+
f.query.set("guidSite", "" + imgInfo_1.SiteId);
|
|
334
|
+
f.query.set("guidWeb", "" + imgInfo_1.WebId);
|
|
335
|
+
f.query.set("guidFile", "" + imgInfo_1.UniqueId);
|
|
336
|
+
this.bannerImageUrl = f.toUrlAndQuery();
|
|
337
|
+
if (!objectDefinedNotNull(this._layoutPart.serverProcessedContent)) {
|
|
338
|
+
this._layoutPart.serverProcessedContent = {};
|
|
339
|
+
}
|
|
340
|
+
this._layoutPart.serverProcessedContent.imageSources = { imageSource: serverRelativePath };
|
|
341
|
+
if (!objectDefinedNotNull(this._layoutPart.serverProcessedContent.customMetadata)) {
|
|
342
|
+
this._layoutPart.serverProcessedContent.customMetadata = {};
|
|
343
|
+
}
|
|
344
|
+
this._layoutPart.serverProcessedContent.customMetadata.imageSource = {
|
|
345
|
+
listId: imgInfo_1.ListId,
|
|
346
|
+
siteId: imgInfo_1.SiteId,
|
|
347
|
+
uniqueId: imgInfo_1.UniqueId,
|
|
348
|
+
webId: imgInfo_1.WebId,
|
|
349
|
+
};
|
|
350
|
+
this._layoutPart.properties.webId = imgInfo_1.WebId;
|
|
351
|
+
this._layoutPart.properties.siteId = imgInfo_1.SiteId;
|
|
352
|
+
this._layoutPart.properties.listId = imgInfo_1.ListId;
|
|
353
|
+
this._layoutPart.properties.uniqueId = imgInfo_1.UniqueId;
|
|
354
|
+
_a.label = 2;
|
|
355
|
+
case 2:
|
|
356
|
+
if (!!this.json.IsPageCheckedOutToCurrentUser) return [3 /*break*/, 4];
|
|
357
|
+
return [4 /*yield*/, spPost(initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/checkoutpage"))];
|
|
358
|
+
case 3:
|
|
359
|
+
_a.sent();
|
|
360
|
+
_a.label = 4;
|
|
361
|
+
case 4:
|
|
362
|
+
saveBody = Object.assign(metadata("SP.Publishing.SitePage"), {
|
|
363
|
+
AuthorByline: this.json.AuthorByline || [],
|
|
364
|
+
CanvasContent1: this.getCanvasContent1(),
|
|
365
|
+
Description: this.description,
|
|
366
|
+
LayoutWebpartsContent: this.getLayoutWebpartsContent(),
|
|
367
|
+
Title: this.title,
|
|
368
|
+
TopicHeader: this.topicHeader,
|
|
369
|
+
BannerImageUrl: this.bannerImageUrl,
|
|
370
|
+
});
|
|
371
|
+
if (this._bannerImageDirty || this._bannerImageThumbnailUrlDirty) {
|
|
372
|
+
bannerImageUrlValue = this._bannerImageThumbnailUrlDirty ? this.thumbnailUrl : this.bannerImageUrl;
|
|
373
|
+
saveBody = assign(saveBody, {
|
|
374
|
+
BannerImageUrl: bannerImageUrlValue,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
updater = initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/savepage");
|
|
378
|
+
return [4 /*yield*/, spPost(updater, headers({ "if-match": "*" }, body(saveBody)))];
|
|
379
|
+
case 5:
|
|
380
|
+
_a.sent();
|
|
381
|
+
r = true;
|
|
382
|
+
if (!publish) return [3 /*break*/, 7];
|
|
383
|
+
return [4 /*yield*/, spPost(initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/publish"))];
|
|
384
|
+
case 6:
|
|
385
|
+
r = _a.sent();
|
|
386
|
+
if (r) {
|
|
387
|
+
this.json.IsPageCheckedOutToCurrentUser = false;
|
|
388
|
+
}
|
|
389
|
+
_a.label = 7;
|
|
390
|
+
case 7:
|
|
391
|
+
this._bannerImageDirty = false;
|
|
392
|
+
this._bannerImageThumbnailUrlDirty = false;
|
|
393
|
+
// we need to ensure we reload from the latest data to ensure all urls are updated and current in the object (expecially for new pages)
|
|
394
|
+
return [4 /*yield*/, this.load()];
|
|
395
|
+
case 8:
|
|
396
|
+
// we need to ensure we reload from the latest data to ensure all urls are updated and current in the object (expecially for new pages)
|
|
397
|
+
_a.sent();
|
|
398
|
+
return [2 /*return*/, r];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* Discards the checkout of this page
|
|
405
|
+
*/
|
|
406
|
+
_ClientsidePage.prototype.discardPageCheckout = function () {
|
|
407
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
408
|
+
var d;
|
|
409
|
+
return __generator(this, function (_a) {
|
|
410
|
+
switch (_a.label) {
|
|
411
|
+
case 0:
|
|
412
|
+
if (this.json.Id === null) {
|
|
413
|
+
throw Error("The id for this page is null. If you want to create a new page, please use ClientSidePage.Create");
|
|
414
|
+
}
|
|
415
|
+
return [4 /*yield*/, spPost(initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/discardPage"), body(metadata("SP.Publishing.SitePage")))];
|
|
416
|
+
case 1:
|
|
417
|
+
d = _a.sent();
|
|
418
|
+
this.fromJSON(d);
|
|
419
|
+
return [2 /*return*/];
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* Promotes this page as a news item
|
|
426
|
+
*/
|
|
427
|
+
_ClientsidePage.prototype.promoteToNews = function () {
|
|
428
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
429
|
+
return __generator(this, function (_a) {
|
|
430
|
+
return [2 /*return*/, this.promoteNewsImpl("promoteToNews")];
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
// API is currently broken on server side
|
|
435
|
+
// public async demoteFromNews(): Promise<boolean> {
|
|
436
|
+
// return this.promoteNewsImpl("demoteFromNews");
|
|
437
|
+
// }
|
|
438
|
+
/**
|
|
439
|
+
* Finds a control by the specified instance id
|
|
440
|
+
*
|
|
441
|
+
* @param id Instance id of the control to find
|
|
442
|
+
*/
|
|
443
|
+
_ClientsidePage.prototype.findControlById = function (id) {
|
|
444
|
+
return this.findControl(function (c) { return c.id === id; });
|
|
445
|
+
};
|
|
446
|
+
/**
|
|
447
|
+
* Finds a control within this page's control tree using the supplied predicate
|
|
448
|
+
*
|
|
449
|
+
* @param predicate Takes a control and returns true or false, if true that control is returned by findControl
|
|
450
|
+
*/
|
|
451
|
+
_ClientsidePage.prototype.findControl = function (predicate) {
|
|
452
|
+
// check all sections
|
|
453
|
+
for (var i = 0; i < this.sections.length; i++) {
|
|
454
|
+
// check all columns
|
|
455
|
+
for (var j = 0; j < this.sections[i].columns.length; j++) {
|
|
456
|
+
// check all controls
|
|
457
|
+
for (var k = 0; k < this.sections[i].columns[j].controls.length; k++) {
|
|
458
|
+
// check to see if the predicate likes this control
|
|
459
|
+
if (predicate(this.sections[i].columns[j].controls[k])) {
|
|
460
|
+
return this.sections[i].columns[j].controls[k];
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
// we found nothing so give nothing back
|
|
466
|
+
return null;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Creates a new page with all of the content copied from this page
|
|
470
|
+
*
|
|
471
|
+
* @param web The web where we will create the copy
|
|
472
|
+
* @param pageName The file name of the new page
|
|
473
|
+
* @param title The title of the new page
|
|
474
|
+
* @param publish If true the page will be published (Default: true)
|
|
475
|
+
*/
|
|
476
|
+
_ClientsidePage.prototype.copy = function (web, pageName, title, publish, promotedState) {
|
|
477
|
+
if (publish === void 0) { publish = true; }
|
|
478
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
479
|
+
var page;
|
|
480
|
+
return __generator(this, function (_a) {
|
|
481
|
+
switch (_a.label) {
|
|
482
|
+
case 0: return [4 /*yield*/, CreateClientsidePage(web, pageName, title, this.pageLayout, promotedState)];
|
|
483
|
+
case 1:
|
|
484
|
+
page = _a.sent();
|
|
485
|
+
return [2 /*return*/, this.copyTo(page, publish)];
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
};
|
|
490
|
+
/**
|
|
491
|
+
* Copies the content from this page to the supplied page instance NOTE: fully overwriting any previous content!!
|
|
492
|
+
*
|
|
493
|
+
* @param page Page whose content we replace with this page's content
|
|
494
|
+
* @param publish If true the page will be published after the copy, if false it will be saved but left unpublished (Default: true)
|
|
495
|
+
*/
|
|
496
|
+
_ClientsidePage.prototype.copyTo = function (page, publish) {
|
|
497
|
+
if (publish === void 0) { publish = true; }
|
|
498
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
499
|
+
var url, makeGuid, guidSite, guidWeb, guidFile, site, id, openWeb, file, props;
|
|
500
|
+
return __generator(this, function (_a) {
|
|
501
|
+
switch (_a.label) {
|
|
502
|
+
case 0:
|
|
503
|
+
// we know the method is on the class - but it is protected so not part of the interface
|
|
504
|
+
page.setControls(this.getControls());
|
|
505
|
+
if (!!stringIsNullOrEmpty(this.json.BannerImageUrl)) return [3 /*break*/, 4];
|
|
506
|
+
url = new URL(this.json.BannerImageUrl);
|
|
507
|
+
makeGuid = function (s) { return s.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/g, "$1-$2-$3-$4-$5"); };
|
|
508
|
+
if (!(url.searchParams.has("guidSite") && url.searchParams.has("guidWeb") && url.searchParams.has("guidFile"))) return [3 /*break*/, 4];
|
|
509
|
+
guidSite = makeGuid(url.searchParams.get("guidSite"));
|
|
510
|
+
guidWeb = makeGuid(url.searchParams.get("guidWeb"));
|
|
511
|
+
guidFile = makeGuid(url.searchParams.get("guidFile"));
|
|
512
|
+
site = Site(extractWebUrl(this.toUrl()));
|
|
513
|
+
return [4 /*yield*/, site.select("Id")()];
|
|
514
|
+
case 1:
|
|
515
|
+
id = _a.sent();
|
|
516
|
+
if (!(id.Id === guidSite)) return [3 /*break*/, 4];
|
|
517
|
+
return [4 /*yield*/, site.openWebById(guidWeb)];
|
|
518
|
+
case 2:
|
|
519
|
+
openWeb = _a.sent();
|
|
520
|
+
return [4 /*yield*/, openWeb.web.getFileById(guidFile).select("ServerRelativeUrl")()];
|
|
521
|
+
case 3:
|
|
522
|
+
file = _a.sent();
|
|
523
|
+
props = {};
|
|
524
|
+
if (this._layoutPart.properties) {
|
|
525
|
+
if (hOP(this._layoutPart.properties, "translateX")) {
|
|
526
|
+
props.translateX = this._layoutPart.properties.translateX;
|
|
527
|
+
}
|
|
528
|
+
if (hOP(this._layoutPart.properties, "translateY")) {
|
|
529
|
+
props.translateY = this._layoutPart.properties.translateY;
|
|
530
|
+
}
|
|
531
|
+
if (hOP(this._layoutPart.properties, "imageSourceType")) {
|
|
532
|
+
props.imageSourceType = this._layoutPart.properties.imageSourceType;
|
|
533
|
+
}
|
|
534
|
+
if (hOP(this._layoutPart.properties, "altText")) {
|
|
535
|
+
props.altText = this._layoutPart.properties.altText;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
page.setBannerImage(file.ServerRelativeUrl, props);
|
|
539
|
+
_a.label = 4;
|
|
540
|
+
case 4: return [4 /*yield*/, page.save(publish)];
|
|
541
|
+
case 5:
|
|
542
|
+
_a.sent();
|
|
543
|
+
return [2 /*return*/, page];
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* Sets the modern page banner image
|
|
550
|
+
*
|
|
551
|
+
* @param url Url of the image to display
|
|
552
|
+
* @param altText Alt text to describe the image
|
|
553
|
+
* @param bannerProps Additional properties to control display of the banner
|
|
554
|
+
*/
|
|
555
|
+
_ClientsidePage.prototype.setBannerImage = function (url, props) {
|
|
556
|
+
if (isUrlAbsolute(url)) {
|
|
557
|
+
// do our best to make this a server relative url by removing the x.sharepoint.com part
|
|
558
|
+
url = url.replace(/^https?:\/\/[a-z0-9.]*?\.[a-z]{2,3}\//i, "/");
|
|
559
|
+
}
|
|
560
|
+
this.json.BannerImageUrl = url;
|
|
561
|
+
// update serverProcessedContent (page behavior change 2021-Oct-13)
|
|
562
|
+
this._layoutPart.serverProcessedContent = { imageSources: { imageSource: url } };
|
|
563
|
+
this._bannerImageDirty = true;
|
|
564
|
+
/*
|
|
565
|
+
setting the banner image resets the thumbnail image (matching UI functionality)
|
|
566
|
+
but if the thumbnail is dirty they are likely trying to set them both to
|
|
567
|
+
different values, so we allow that here.
|
|
568
|
+
Also allows the banner image to be updated safely with the calculated one in save()
|
|
569
|
+
*/
|
|
570
|
+
if (!this._bannerImageThumbnailUrlDirty) {
|
|
571
|
+
this.thumbnailUrl = url;
|
|
572
|
+
this._pageSettings.pageSettingsSlice.isDefaultThumbnail = true;
|
|
573
|
+
}
|
|
574
|
+
// this seems to always be true, so default
|
|
575
|
+
this._layoutPart.properties.imageSourceType = 2;
|
|
576
|
+
if (objectDefinedNotNull(props)) {
|
|
577
|
+
if (hOP(props, "translateX")) {
|
|
578
|
+
this._layoutPart.properties.translateX = props.translateX;
|
|
579
|
+
}
|
|
580
|
+
if (hOP(props, "translateY")) {
|
|
581
|
+
this._layoutPart.properties.translateY = props.translateY;
|
|
582
|
+
}
|
|
583
|
+
if (hOP(props, "imageSourceType")) {
|
|
584
|
+
this._layoutPart.properties.imageSourceType = props.imageSourceType;
|
|
585
|
+
}
|
|
586
|
+
if (hOP(props, "altText")) {
|
|
587
|
+
this._layoutPart.properties.altText = props.altText;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
/**
|
|
592
|
+
* Sets the banner image url from an external source. You must call save to persist the changes
|
|
593
|
+
*
|
|
594
|
+
* @param url absolute url of the external file
|
|
595
|
+
* @param props optional set of properties to control display of the banner image
|
|
596
|
+
*/
|
|
597
|
+
_ClientsidePage.prototype.setBannerImageFromExternalUrl = function (url, props) {
|
|
598
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
599
|
+
var fileUrl, pageName, filename, request, result;
|
|
600
|
+
return __generator(this, function (_a) {
|
|
601
|
+
switch (_a.label) {
|
|
602
|
+
case 0:
|
|
603
|
+
fileUrl = new URL(url);
|
|
604
|
+
pageName = this.json.FileName.replace(/\.[^/.]+$/, "");
|
|
605
|
+
filename = fileUrl.pathname.split(/[\\/]/i).pop();
|
|
606
|
+
request = initFrom(this, "_api/sitepages/AddImageFromExternalUrl");
|
|
607
|
+
request.query.set("imageFileName", "'" + encodeURIComponent(filename) + "'");
|
|
608
|
+
request.query.set("pageName", "'" + encodeURIComponent(pageName) + "'");
|
|
609
|
+
request.query.set("externalUrl", "'" + encodeURIComponent(url) + "'");
|
|
610
|
+
request.select("ServerRelativeUrl");
|
|
611
|
+
return [4 /*yield*/, spPost(request)];
|
|
612
|
+
case 1:
|
|
613
|
+
result = _a.sent();
|
|
614
|
+
// set with the newly created relative url
|
|
615
|
+
this.setBannerImage(result.ServerRelativeUrl, props);
|
|
616
|
+
return [2 /*return*/];
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* Sets the authors for this page from the supplied list of user integer ids
|
|
623
|
+
*
|
|
624
|
+
* @param authorId The integer id of the user to set as the author
|
|
625
|
+
*/
|
|
626
|
+
_ClientsidePage.prototype.setAuthorById = function (authorId) {
|
|
627
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
628
|
+
var userLoginData;
|
|
629
|
+
return __generator(this, function (_a) {
|
|
630
|
+
switch (_a.label) {
|
|
631
|
+
case 0: return [4 /*yield*/, SharePointQueryableCollection(extractWebUrl(this.toUrl()), "/_api/web/siteusers")
|
|
632
|
+
.configureFrom(this)
|
|
633
|
+
.filter("Id eq " + authorId)
|
|
634
|
+
.select("LoginName")()];
|
|
635
|
+
case 1:
|
|
636
|
+
userLoginData = _a.sent();
|
|
637
|
+
if (userLoginData.length < 1) {
|
|
638
|
+
throw Error("Could not find user with id " + authorId + ".");
|
|
639
|
+
}
|
|
640
|
+
return [2 /*return*/, this.setAuthorByLoginName(userLoginData[0].LoginName)];
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
/**
|
|
646
|
+
* Sets the authors for this page from the supplied list of user integer ids
|
|
647
|
+
*
|
|
648
|
+
* @param authorLoginName The login name of the user (ex: i:0#.f|membership|name@tenant.com)
|
|
649
|
+
*/
|
|
650
|
+
_ClientsidePage.prototype.setAuthorByLoginName = function (authorLoginName) {
|
|
651
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
652
|
+
var userLoginData;
|
|
653
|
+
return __generator(this, function (_a) {
|
|
654
|
+
switch (_a.label) {
|
|
655
|
+
case 0: return [4 /*yield*/, SharePointQueryableCollection(extractWebUrl(this.toUrl()), "/_api/web/siteusers")
|
|
656
|
+
.configureFrom(this)
|
|
657
|
+
.filter("LoginName eq '" + authorLoginName + "'")
|
|
658
|
+
.select("UserPrincipalName", "Title")()];
|
|
659
|
+
case 1:
|
|
660
|
+
userLoginData = _a.sent();
|
|
661
|
+
if (userLoginData.length < 1) {
|
|
662
|
+
throw Error("Could not find user with login name '" + authorLoginName + "'.");
|
|
663
|
+
}
|
|
664
|
+
this.json.AuthorByline = [userLoginData[0].UserPrincipalName];
|
|
665
|
+
this._layoutPart.properties.authorByline = [userLoginData[0].UserPrincipalName];
|
|
666
|
+
this._layoutPart.properties.authors = [{
|
|
667
|
+
id: authorLoginName,
|
|
668
|
+
name: userLoginData[0].Title,
|
|
669
|
+
role: "",
|
|
670
|
+
upn: userLoginData[0].UserPrincipalName,
|
|
671
|
+
}];
|
|
672
|
+
return [2 /*return*/];
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
});
|
|
676
|
+
};
|
|
677
|
+
/**
|
|
678
|
+
* Gets the list item associated with this clientside page
|
|
679
|
+
*
|
|
680
|
+
* @param selects Specific set of fields to include when getting the item
|
|
681
|
+
*/
|
|
682
|
+
_ClientsidePage.prototype.getItem = function () {
|
|
683
|
+
var selects = [];
|
|
684
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
685
|
+
selects[_i] = arguments[_i];
|
|
686
|
+
}
|
|
687
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
688
|
+
var initer, listData, item, itemData;
|
|
689
|
+
return __generator(this, function (_a) {
|
|
690
|
+
switch (_a.label) {
|
|
691
|
+
case 0:
|
|
692
|
+
initer = initFrom(this, "/_api/lists/EnsureClientRenderedSitePagesLibrary").select("EnableModeration", "EnableMinorVersions", "Id");
|
|
693
|
+
return [4 /*yield*/, spPost(initer)];
|
|
694
|
+
case 1:
|
|
695
|
+
listData = _a.sent();
|
|
696
|
+
item = (List(listData["odata.id"])).configureFrom(this).items.getById(this.json.Id);
|
|
697
|
+
return [4 /*yield*/, item.select.apply(item, __spreadArray([], __read(selects), false))()];
|
|
698
|
+
case 2:
|
|
699
|
+
itemData = _a.sent();
|
|
700
|
+
return [2 /*return*/, assign((Item(odataUrlFrom(itemData))).configureFrom(this), itemData)];
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
};
|
|
705
|
+
/**
|
|
706
|
+
* Recycle this page
|
|
707
|
+
*/
|
|
708
|
+
_ClientsidePage.prototype.recycle = function () {
|
|
709
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
710
|
+
var item;
|
|
711
|
+
return __generator(this, function (_a) {
|
|
712
|
+
switch (_a.label) {
|
|
713
|
+
case 0: return [4 /*yield*/, this.getItem()];
|
|
714
|
+
case 1:
|
|
715
|
+
item = _a.sent();
|
|
716
|
+
return [4 /*yield*/, item.recycle()];
|
|
717
|
+
case 2:
|
|
718
|
+
_a.sent();
|
|
719
|
+
return [2 /*return*/];
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
});
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Delete this page
|
|
726
|
+
*/
|
|
727
|
+
_ClientsidePage.prototype.delete = function () {
|
|
728
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
729
|
+
var item;
|
|
730
|
+
return __generator(this, function (_a) {
|
|
731
|
+
switch (_a.label) {
|
|
732
|
+
case 0: return [4 /*yield*/, this.getItem()];
|
|
733
|
+
case 1:
|
|
734
|
+
item = _a.sent();
|
|
735
|
+
return [4 /*yield*/, item.delete()];
|
|
736
|
+
case 2:
|
|
737
|
+
_a.sent();
|
|
738
|
+
return [2 /*return*/];
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
// not yet active in service
|
|
744
|
+
// /**
|
|
745
|
+
// * Schedules a page for publishing
|
|
746
|
+
// *
|
|
747
|
+
// * @param publishDate Date to publish the item
|
|
748
|
+
// * @returns Publish work item details
|
|
749
|
+
// */
|
|
750
|
+
// public async schedulePublish(publishDate: Date): Promise<string> {
|
|
751
|
+
// let r: string;
|
|
752
|
+
// // currently the server throws an exception, but then the page is published as expected
|
|
753
|
+
// // so we just ignore that error for now, YMMV
|
|
754
|
+
// try {
|
|
755
|
+
// r = await spPost(initFrom(this, `_api/sitepages/pages(${this.json.Id})/SchedulePublish`), body({
|
|
756
|
+
// sitePage: { PublishStartDate: publishDate },
|
|
757
|
+
// }));
|
|
758
|
+
// } catch {
|
|
759
|
+
// r = "";
|
|
760
|
+
// }
|
|
761
|
+
// return r;
|
|
762
|
+
// }
|
|
763
|
+
/**
|
|
764
|
+
* Saves a copy of this page as a template in this library's Templates folder
|
|
765
|
+
*
|
|
766
|
+
* @param publish If true the template is published, false the template is not published (default: true)
|
|
767
|
+
* @returns IClientsidePage instance representing the new template page
|
|
768
|
+
*/
|
|
769
|
+
_ClientsidePage.prototype.saveAsTemplate = function (publish) {
|
|
770
|
+
if (publish === void 0) { publish = true; }
|
|
771
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
772
|
+
var data, page;
|
|
773
|
+
return __generator(this, function (_a) {
|
|
774
|
+
switch (_a.label) {
|
|
775
|
+
case 0: return [4 /*yield*/, spPost(initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/SavePageAsTemplate"))];
|
|
776
|
+
case 1:
|
|
777
|
+
data = _a.sent();
|
|
778
|
+
page = ClientsidePage(this, null, data);
|
|
779
|
+
page.title = this.title;
|
|
780
|
+
return [4 /*yield*/, page.save(publish)];
|
|
781
|
+
case 2:
|
|
782
|
+
_a.sent();
|
|
783
|
+
return [2 /*return*/, page];
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
});
|
|
787
|
+
};
|
|
788
|
+
/**
|
|
789
|
+
* Share this Page's Preview content by Email
|
|
790
|
+
*
|
|
791
|
+
* @param emails Set of emails to which the preview is shared
|
|
792
|
+
* @param message The message to include
|
|
793
|
+
* @returns void
|
|
794
|
+
*/
|
|
795
|
+
_ClientsidePage.prototype.share = function (emails, message) {
|
|
796
|
+
return spPost(initFrom(this, "_api/SP.Publishing.RichSharing/SharePageByEmail"), body({
|
|
797
|
+
recipientEmails: emails,
|
|
798
|
+
message: message,
|
|
799
|
+
url: this.json.AbsoluteUrl,
|
|
800
|
+
}));
|
|
801
|
+
};
|
|
802
|
+
/**
|
|
803
|
+
* Extends this queryable from the provided parent
|
|
804
|
+
*
|
|
805
|
+
* @param parent Parent queryable from which we will derive a base url
|
|
806
|
+
* @param path Additional path
|
|
807
|
+
*/
|
|
808
|
+
_ClientsidePage.prototype.assign = function (parent, path) {
|
|
809
|
+
this.data.parentUrl = parent.data.url;
|
|
810
|
+
this.data.url = combine(this.data.parentUrl, path || "");
|
|
811
|
+
this.configureFrom(parent);
|
|
812
|
+
};
|
|
813
|
+
_ClientsidePage.prototype.getCanvasContent1 = function () {
|
|
814
|
+
return JSON.stringify(this.getControls());
|
|
815
|
+
};
|
|
816
|
+
_ClientsidePage.prototype.getLayoutWebpartsContent = function () {
|
|
817
|
+
if (this._layoutPart) {
|
|
818
|
+
return JSON.stringify([this._layoutPart]);
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
return JSON.stringify(null);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
_ClientsidePage.prototype.setControls = function (controls) {
|
|
825
|
+
// reset the sections
|
|
826
|
+
this.sections = [];
|
|
827
|
+
if (controls && controls.length) {
|
|
828
|
+
for (var i = 0; i < controls.length; i++) {
|
|
829
|
+
// if no control type is present this is a column which we give type 0 to let us process it
|
|
830
|
+
var controlType = hOP(controls[i], "controlType") ? controls[i].controlType : 0;
|
|
831
|
+
switch (controlType) {
|
|
832
|
+
case 0:
|
|
833
|
+
// empty canvas column or page settings
|
|
834
|
+
if (hOP(controls[i], "pageSettingsSlice")) {
|
|
835
|
+
this._pageSettings = controls[i];
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
// we have an empty column
|
|
839
|
+
this.mergeColumnToTree(new CanvasColumn(controls[i]));
|
|
840
|
+
}
|
|
841
|
+
break;
|
|
842
|
+
case 3: {
|
|
843
|
+
var part = new ClientsideWebpart(controls[i]);
|
|
844
|
+
this.mergePartToTree(part, part.data.position);
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
case 4: {
|
|
848
|
+
var textData = controls[i];
|
|
849
|
+
var text = new ClientsideText(textData.innerHTML, textData);
|
|
850
|
+
this.mergePartToTree(text, text.data.position);
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
reindex(this.sections);
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
_ClientsidePage.prototype.getControls = function () {
|
|
859
|
+
var _this = this;
|
|
860
|
+
// reindex things
|
|
861
|
+
reindex(this.sections);
|
|
862
|
+
// rollup the control changes
|
|
863
|
+
var canvasData = [];
|
|
864
|
+
this.sections.forEach(function (section) {
|
|
865
|
+
section.columns.forEach(function (column) {
|
|
866
|
+
if (column.controls.length < 1) {
|
|
867
|
+
// empty column
|
|
868
|
+
canvasData.push({
|
|
869
|
+
displayMode: column.data.displayMode,
|
|
870
|
+
emphasis: _this.getEmphasisObj(section.emphasis),
|
|
871
|
+
position: column.data.position,
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
column.controls.forEach(function (control) {
|
|
876
|
+
control.data.emphasis = _this.getEmphasisObj(section.emphasis);
|
|
877
|
+
canvasData.push(_this.specialSaveHandling(control).data);
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
});
|
|
882
|
+
canvasData.push(this._pageSettings);
|
|
883
|
+
return canvasData;
|
|
884
|
+
};
|
|
885
|
+
_ClientsidePage.prototype.getEmphasisObj = function (value) {
|
|
886
|
+
if (value < 1 || value > 3) {
|
|
887
|
+
return {};
|
|
888
|
+
}
|
|
889
|
+
return { zoneEmphasis: value };
|
|
890
|
+
};
|
|
891
|
+
_ClientsidePage.prototype.promoteNewsImpl = function (method) {
|
|
892
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
893
|
+
var lastPubData;
|
|
894
|
+
return __generator(this, function (_a) {
|
|
895
|
+
switch (_a.label) {
|
|
896
|
+
case 0:
|
|
897
|
+
if (this.json.Id === null) {
|
|
898
|
+
throw Error("The id for this page is null.");
|
|
899
|
+
}
|
|
900
|
+
if (!stringIsNullOrEmpty(this.json.VersionInfo.LastVersionCreatedBy)) return [3 /*break*/, 2];
|
|
901
|
+
lastPubData = new Date(this.json.VersionInfo.LastVersionCreated);
|
|
902
|
+
if (!(lastPubData.getFullYear() < 2000)) return [3 /*break*/, 2];
|
|
903
|
+
return [4 /*yield*/, this.save(true)];
|
|
904
|
+
case 1:
|
|
905
|
+
_a.sent();
|
|
906
|
+
_a.label = 2;
|
|
907
|
+
case 2: return [4 /*yield*/, spPost(initFrom(this, "_api/sitepages/pages(" + this.json.Id + ")/" + method), body(metadata("SP.Publishing.SitePage")))];
|
|
908
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
});
|
|
912
|
+
};
|
|
913
|
+
/**
|
|
914
|
+
* Merges the control into the tree of sections and columns for this page
|
|
915
|
+
*
|
|
916
|
+
* @param control The control to merge
|
|
917
|
+
*/
|
|
918
|
+
_ClientsidePage.prototype.mergePartToTree = function (control, positionData) {
|
|
919
|
+
var _a, _b, _c;
|
|
920
|
+
var column = null;
|
|
921
|
+
var sectionFactor = 12;
|
|
922
|
+
var sectionIndex = 0;
|
|
923
|
+
var zoneIndex = 0;
|
|
924
|
+
var layoutIndex = 1;
|
|
925
|
+
// handle case where we don't have position data (shouldn't happen?)
|
|
926
|
+
if (positionData) {
|
|
927
|
+
if (hOP(positionData, "zoneIndex")) {
|
|
928
|
+
zoneIndex = positionData.zoneIndex;
|
|
929
|
+
}
|
|
930
|
+
if (hOP(positionData, "sectionIndex")) {
|
|
931
|
+
sectionIndex = positionData.sectionIndex;
|
|
932
|
+
}
|
|
933
|
+
if (hOP(positionData, "sectionFactor")) {
|
|
934
|
+
sectionFactor = positionData.sectionFactor;
|
|
935
|
+
}
|
|
936
|
+
if (hOP(positionData, "layoutIndex")) {
|
|
937
|
+
layoutIndex = positionData.layoutIndex;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
var zoneEmphasis = (_c = (_b = (_a = control.data) === null || _a === void 0 ? void 0 : _a.emphasis) === null || _b === void 0 ? void 0 : _b.zoneEmphasis) !== null && _c !== void 0 ? _c : 0;
|
|
941
|
+
var section = this.getOrCreateSection(zoneIndex, layoutIndex, zoneEmphasis);
|
|
942
|
+
var columns = section.columns.filter(function (c) { return c.order === sectionIndex; });
|
|
943
|
+
if (columns.length < 1) {
|
|
944
|
+
column = section.addColumn(sectionFactor, layoutIndex);
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
column = columns[0];
|
|
948
|
+
}
|
|
949
|
+
control.column = column;
|
|
950
|
+
column.addControl(control);
|
|
951
|
+
};
|
|
952
|
+
/**
|
|
953
|
+
* Merges the supplied column into the tree
|
|
954
|
+
*
|
|
955
|
+
* @param column Column to merge
|
|
956
|
+
* @param position The position data for the column
|
|
957
|
+
*/
|
|
958
|
+
_ClientsidePage.prototype.mergeColumnToTree = function (column) {
|
|
959
|
+
var _a, _b;
|
|
960
|
+
var order = hOP(column.data, "position") && hOP(column.data.position, "zoneIndex") ? column.data.position.zoneIndex : 0;
|
|
961
|
+
var layoutIndex = hOP(column.data, "position") && hOP(column.data.position, "layoutIndex") ? column.data.position.layoutIndex : 1;
|
|
962
|
+
var section = this.getOrCreateSection(order, layoutIndex, ((_b = (_a = column.data) === null || _a === void 0 ? void 0 : _a.emphasis) === null || _b === void 0 ? void 0 : _b.zoneEmphasis) || 0);
|
|
963
|
+
column.section = section;
|
|
964
|
+
section.columns.push(column);
|
|
965
|
+
};
|
|
966
|
+
/**
|
|
967
|
+
* Handle the logic to get or create a section based on the supplied order and layoutIndex
|
|
968
|
+
*
|
|
969
|
+
* @param order Section order
|
|
970
|
+
* @param layoutIndex Layout Index (1 === normal, 2 === vertical section)
|
|
971
|
+
* @param emphasis The section emphasis
|
|
972
|
+
*/
|
|
973
|
+
_ClientsidePage.prototype.getOrCreateSection = function (order, layoutIndex, emphasis) {
|
|
974
|
+
var section = null;
|
|
975
|
+
var sections = this.sections.filter(function (s) { return s.order === order && s.layoutIndex === layoutIndex; });
|
|
976
|
+
if (sections.length < 1) {
|
|
977
|
+
section = layoutIndex === 2 ? this.addVerticalSection() : this.addSection();
|
|
978
|
+
section.order = order;
|
|
979
|
+
section.emphasis = emphasis;
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
section = sections[0];
|
|
983
|
+
}
|
|
984
|
+
return section;
|
|
985
|
+
};
|
|
986
|
+
/**
|
|
987
|
+
* Based on issue #1690 we need to take special case actions to ensure some things
|
|
988
|
+
* can be saved properly without breaking existing pages.
|
|
989
|
+
*
|
|
990
|
+
* @param control The control we are ensuring is "ready" to be saved
|
|
991
|
+
*/
|
|
992
|
+
_ClientsidePage.prototype.specialSaveHandling = function (control) {
|
|
993
|
+
var _a, _b, _c;
|
|
994
|
+
// this is to handle the special case in issue #1690
|
|
995
|
+
// must ensure that searchablePlainTexts values have < replaced with < in links web part
|
|
996
|
+
if (control.data.controlType === 3 && control.data.webPartId === "c70391ea-0b10-4ee9-b2b4-006d3fcad0cd") {
|
|
997
|
+
var texts = ((_c = (_b = (_a = control.data) === null || _a === void 0 ? void 0 : _a.webPartData) === null || _b === void 0 ? void 0 : _b.serverProcessedContent) === null || _c === void 0 ? void 0 : _c.searchablePlainTexts) || null;
|
|
998
|
+
if (objectDefinedNotNull(texts)) {
|
|
999
|
+
var keys = Object.getOwnPropertyNames(texts);
|
|
1000
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1001
|
+
texts[keys[i]] = texts[keys[i]].replace(/</ig, "<");
|
|
1002
|
+
control.data.webPartData.serverProcessedContent.searchablePlainTexts = texts;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return control;
|
|
1007
|
+
};
|
|
1008
|
+
__decorate([
|
|
1009
|
+
tag("csp.load")
|
|
1010
|
+
], _ClientsidePage.prototype, "load", null);
|
|
1011
|
+
__decorate([
|
|
1012
|
+
tag("csp.save")
|
|
1013
|
+
], _ClientsidePage.prototype, "save", null);
|
|
1014
|
+
__decorate([
|
|
1015
|
+
tag("csp.discardPageCheckout")
|
|
1016
|
+
], _ClientsidePage.prototype, "discardPageCheckout", null);
|
|
1017
|
+
__decorate([
|
|
1018
|
+
tag("csp.promoteToNews")
|
|
1019
|
+
], _ClientsidePage.prototype, "promoteToNews", null);
|
|
1020
|
+
__decorate([
|
|
1021
|
+
tag("csp.copy")
|
|
1022
|
+
], _ClientsidePage.prototype, "copy", null);
|
|
1023
|
+
__decorate([
|
|
1024
|
+
tag("csp.copyTo")
|
|
1025
|
+
], _ClientsidePage.prototype, "copyTo", null);
|
|
1026
|
+
__decorate([
|
|
1027
|
+
tag("csp.getItem")
|
|
1028
|
+
], _ClientsidePage.prototype, "getItem", null);
|
|
1029
|
+
return _ClientsidePage;
|
|
1030
|
+
}(_SharePointQueryable));
|
|
1031
|
+
export { _ClientsidePage };
|
|
1032
|
+
/**
|
|
1033
|
+
* Invokable factory for IClientSidePage instances
|
|
1034
|
+
*/
|
|
1035
|
+
var ClientsidePage = function (baseUrl, path, json, noInit, sections, commentsDisabled) {
|
|
1036
|
+
if (noInit === void 0) { noInit = false; }
|
|
1037
|
+
if (sections === void 0) { sections = []; }
|
|
1038
|
+
if (commentsDisabled === void 0) { commentsDisabled = false; }
|
|
1039
|
+
return invokableFactory(_ClientsidePage)(baseUrl, path, json, noInit, sections, commentsDisabled);
|
|
1040
|
+
};
|
|
1041
|
+
/**
|
|
1042
|
+
* Loads a client side page from the supplied IFile instance
|
|
1043
|
+
*
|
|
1044
|
+
* @param file Source IFile instance
|
|
1045
|
+
*/
|
|
1046
|
+
export var ClientsidePageFromFile = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1047
|
+
var item, page;
|
|
1048
|
+
return __generator(this, function (_a) {
|
|
1049
|
+
switch (_a.label) {
|
|
1050
|
+
case 0: return [4 /*yield*/, file.getItem()];
|
|
1051
|
+
case 1:
|
|
1052
|
+
item = _a.sent();
|
|
1053
|
+
page = ClientsidePage(extractWebUrl(file.toUrl()), "", { Id: item.Id }, true);
|
|
1054
|
+
return [2 /*return*/, page.configureFrom(file).load()];
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
}); };
|
|
1058
|
+
/**
|
|
1059
|
+
* Creates a new client side page
|
|
1060
|
+
*
|
|
1061
|
+
* @param web The web or list
|
|
1062
|
+
* @param pageName The name of the page (filename)
|
|
1063
|
+
* @param title The page's title
|
|
1064
|
+
* @param PageLayoutType Layout to use when creating the page
|
|
1065
|
+
*/
|
|
1066
|
+
export var CreateClientsidePage = function (web, pageName, title, PageLayoutType, promotedState) {
|
|
1067
|
+
if (PageLayoutType === void 0) { PageLayoutType = "Article"; }
|
|
1068
|
+
if (promotedState === void 0) { promotedState = 0; }
|
|
1069
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
1070
|
+
var pageInitData, newPage;
|
|
1071
|
+
return __generator(this, function (_a) {
|
|
1072
|
+
switch (_a.label) {
|
|
1073
|
+
case 0:
|
|
1074
|
+
// patched because previously we used the full page name with the .aspx at the end
|
|
1075
|
+
// this allows folk's existing code to work after the re-write to the new API
|
|
1076
|
+
pageName = pageName.replace(/\.aspx$/i, "");
|
|
1077
|
+
return [4 /*yield*/, spPost(initFrom(web, "_api/sitepages/pages"), body(Object.assign(metadata("SP.Publishing.SitePage"), {
|
|
1078
|
+
PageLayoutType: PageLayoutType,
|
|
1079
|
+
PromotedState: promotedState,
|
|
1080
|
+
})))];
|
|
1081
|
+
case 1:
|
|
1082
|
+
pageInitData = _a.sent();
|
|
1083
|
+
newPage = ClientsidePage(web, "", pageInitData);
|
|
1084
|
+
newPage.title = pageName;
|
|
1085
|
+
return [4 /*yield*/, newPage.save(false)];
|
|
1086
|
+
case 2:
|
|
1087
|
+
_a.sent();
|
|
1088
|
+
newPage.title = title;
|
|
1089
|
+
return [2 /*return*/, newPage];
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
});
|
|
1093
|
+
};
|
|
1094
|
+
var CanvasSection = /** @class */ (function () {
|
|
1095
|
+
function CanvasSection(page, order, layoutIndex, columns, _emphasis) {
|
|
1096
|
+
if (columns === void 0) { columns = []; }
|
|
1097
|
+
if (_emphasis === void 0) { _emphasis = 0; }
|
|
1098
|
+
this.page = page;
|
|
1099
|
+
this.columns = columns;
|
|
1100
|
+
this._emphasis = _emphasis;
|
|
1101
|
+
this._memId = getGUID();
|
|
1102
|
+
this._order = order;
|
|
1103
|
+
this._layoutIndex = layoutIndex;
|
|
1104
|
+
}
|
|
1105
|
+
Object.defineProperty(CanvasSection.prototype, "order", {
|
|
1106
|
+
get: function () {
|
|
1107
|
+
return this._order;
|
|
1108
|
+
},
|
|
1109
|
+
set: function (value) {
|
|
1110
|
+
this._order = value;
|
|
1111
|
+
for (var i = 0; i < this.columns.length; i++) {
|
|
1112
|
+
this.columns[i].data.position.zoneIndex = value;
|
|
1113
|
+
}
|
|
1114
|
+
},
|
|
1115
|
+
enumerable: false,
|
|
1116
|
+
configurable: true
|
|
1117
|
+
});
|
|
1118
|
+
Object.defineProperty(CanvasSection.prototype, "layoutIndex", {
|
|
1119
|
+
get: function () {
|
|
1120
|
+
return this._layoutIndex;
|
|
1121
|
+
},
|
|
1122
|
+
set: function (value) {
|
|
1123
|
+
this._layoutIndex = value;
|
|
1124
|
+
for (var i = 0; i < this.columns.length; i++) {
|
|
1125
|
+
this.columns[i].data.position.layoutIndex = value;
|
|
1126
|
+
}
|
|
1127
|
+
},
|
|
1128
|
+
enumerable: false,
|
|
1129
|
+
configurable: true
|
|
1130
|
+
});
|
|
1131
|
+
Object.defineProperty(CanvasSection.prototype, "defaultColumn", {
|
|
1132
|
+
/**
|
|
1133
|
+
* Default column (this.columns[0]) for this section
|
|
1134
|
+
*/
|
|
1135
|
+
get: function () {
|
|
1136
|
+
if (this.columns.length < 1) {
|
|
1137
|
+
this.addColumn(12);
|
|
1138
|
+
}
|
|
1139
|
+
return this.columns[0];
|
|
1140
|
+
},
|
|
1141
|
+
enumerable: false,
|
|
1142
|
+
configurable: true
|
|
1143
|
+
});
|
|
1144
|
+
/**
|
|
1145
|
+
* Adds a new column to this section
|
|
1146
|
+
*/
|
|
1147
|
+
CanvasSection.prototype.addColumn = function (factor, layoutIndex) {
|
|
1148
|
+
if (layoutIndex === void 0) { layoutIndex = this.layoutIndex; }
|
|
1149
|
+
var column = new CanvasColumn();
|
|
1150
|
+
column.section = this;
|
|
1151
|
+
column.data.position.zoneIndex = this.order;
|
|
1152
|
+
column.data.position.layoutIndex = layoutIndex;
|
|
1153
|
+
column.data.position.sectionFactor = factor;
|
|
1154
|
+
column.order = getNextOrder(this.columns);
|
|
1155
|
+
this.columns.push(column);
|
|
1156
|
+
return column;
|
|
1157
|
+
};
|
|
1158
|
+
/**
|
|
1159
|
+
* Adds a control to the default column for this section
|
|
1160
|
+
*
|
|
1161
|
+
* @param control Control to add to the default column
|
|
1162
|
+
*/
|
|
1163
|
+
CanvasSection.prototype.addControl = function (control) {
|
|
1164
|
+
this.defaultColumn.addControl(control);
|
|
1165
|
+
return this;
|
|
1166
|
+
};
|
|
1167
|
+
Object.defineProperty(CanvasSection.prototype, "emphasis", {
|
|
1168
|
+
get: function () {
|
|
1169
|
+
return this._emphasis;
|
|
1170
|
+
},
|
|
1171
|
+
set: function (value) {
|
|
1172
|
+
this._emphasis = value;
|
|
1173
|
+
},
|
|
1174
|
+
enumerable: false,
|
|
1175
|
+
configurable: true
|
|
1176
|
+
});
|
|
1177
|
+
/**
|
|
1178
|
+
* Removes this section and all contained columns and controls from the collection
|
|
1179
|
+
*/
|
|
1180
|
+
CanvasSection.prototype.remove = function () {
|
|
1181
|
+
var _this = this;
|
|
1182
|
+
this.page.sections = this.page.sections.filter(function (section) { return section._memId !== _this._memId; });
|
|
1183
|
+
reindex(this.page.sections);
|
|
1184
|
+
};
|
|
1185
|
+
return CanvasSection;
|
|
1186
|
+
}());
|
|
1187
|
+
export { CanvasSection };
|
|
1188
|
+
var CanvasColumn = /** @class */ (function () {
|
|
1189
|
+
function CanvasColumn(json, controls) {
|
|
1190
|
+
if (json === void 0) { json = JSON.parse(JSON.stringify(CanvasColumn.Default)); }
|
|
1191
|
+
if (controls === void 0) { controls = []; }
|
|
1192
|
+
this.json = json;
|
|
1193
|
+
this.controls = controls;
|
|
1194
|
+
this._section = null;
|
|
1195
|
+
this._memId = getGUID();
|
|
1196
|
+
}
|
|
1197
|
+
Object.defineProperty(CanvasColumn.prototype, "data", {
|
|
1198
|
+
get: function () {
|
|
1199
|
+
return this.json;
|
|
1200
|
+
},
|
|
1201
|
+
enumerable: false,
|
|
1202
|
+
configurable: true
|
|
1203
|
+
});
|
|
1204
|
+
Object.defineProperty(CanvasColumn.prototype, "section", {
|
|
1205
|
+
get: function () {
|
|
1206
|
+
return this._section;
|
|
1207
|
+
},
|
|
1208
|
+
set: function (section) {
|
|
1209
|
+
this._section = section;
|
|
1210
|
+
},
|
|
1211
|
+
enumerable: false,
|
|
1212
|
+
configurable: true
|
|
1213
|
+
});
|
|
1214
|
+
Object.defineProperty(CanvasColumn.prototype, "order", {
|
|
1215
|
+
get: function () {
|
|
1216
|
+
return this.data.position.sectionIndex;
|
|
1217
|
+
},
|
|
1218
|
+
set: function (value) {
|
|
1219
|
+
this.data.position.sectionIndex = value;
|
|
1220
|
+
for (var i = 0; i < this.controls.length; i++) {
|
|
1221
|
+
this.controls[i].data.position.zoneIndex = this.data.position.zoneIndex;
|
|
1222
|
+
this.controls[i].data.position.layoutIndex = this.data.position.layoutIndex;
|
|
1223
|
+
this.controls[i].data.position.sectionIndex = value;
|
|
1224
|
+
}
|
|
1225
|
+
},
|
|
1226
|
+
enumerable: false,
|
|
1227
|
+
configurable: true
|
|
1228
|
+
});
|
|
1229
|
+
Object.defineProperty(CanvasColumn.prototype, "factor", {
|
|
1230
|
+
get: function () {
|
|
1231
|
+
return this.data.position.sectionFactor;
|
|
1232
|
+
},
|
|
1233
|
+
set: function (value) {
|
|
1234
|
+
this.data.position.sectionFactor = value;
|
|
1235
|
+
},
|
|
1236
|
+
enumerable: false,
|
|
1237
|
+
configurable: true
|
|
1238
|
+
});
|
|
1239
|
+
CanvasColumn.prototype.addControl = function (control) {
|
|
1240
|
+
control.column = this;
|
|
1241
|
+
this.controls.push(control);
|
|
1242
|
+
return this;
|
|
1243
|
+
};
|
|
1244
|
+
CanvasColumn.prototype.getControl = function (index) {
|
|
1245
|
+
return this.controls[index];
|
|
1246
|
+
};
|
|
1247
|
+
CanvasColumn.prototype.remove = function () {
|
|
1248
|
+
var _this = this;
|
|
1249
|
+
this.section.columns = this.section.columns.filter(function (column) { return column._memId !== _this._memId; });
|
|
1250
|
+
reindex(this.section.columns);
|
|
1251
|
+
};
|
|
1252
|
+
CanvasColumn.Default = {
|
|
1253
|
+
controlType: 0,
|
|
1254
|
+
displayMode: 2,
|
|
1255
|
+
emphasis: {},
|
|
1256
|
+
position: {
|
|
1257
|
+
layoutIndex: 1,
|
|
1258
|
+
sectionFactor: 12,
|
|
1259
|
+
sectionIndex: 1,
|
|
1260
|
+
zoneIndex: 1,
|
|
1261
|
+
},
|
|
1262
|
+
};
|
|
1263
|
+
return CanvasColumn;
|
|
1264
|
+
}());
|
|
1265
|
+
export { CanvasColumn };
|
|
1266
|
+
var ColumnControl = /** @class */ (function () {
|
|
1267
|
+
function ColumnControl(json) {
|
|
1268
|
+
this.json = json;
|
|
1269
|
+
}
|
|
1270
|
+
Object.defineProperty(ColumnControl.prototype, "id", {
|
|
1271
|
+
get: function () {
|
|
1272
|
+
return this.json.id;
|
|
1273
|
+
},
|
|
1274
|
+
enumerable: false,
|
|
1275
|
+
configurable: true
|
|
1276
|
+
});
|
|
1277
|
+
Object.defineProperty(ColumnControl.prototype, "data", {
|
|
1278
|
+
get: function () {
|
|
1279
|
+
return this.json;
|
|
1280
|
+
},
|
|
1281
|
+
enumerable: false,
|
|
1282
|
+
configurable: true
|
|
1283
|
+
});
|
|
1284
|
+
Object.defineProperty(ColumnControl.prototype, "column", {
|
|
1285
|
+
get: function () {
|
|
1286
|
+
return this._column;
|
|
1287
|
+
},
|
|
1288
|
+
set: function (value) {
|
|
1289
|
+
this._column = value;
|
|
1290
|
+
this.onColumnChange(this._column);
|
|
1291
|
+
},
|
|
1292
|
+
enumerable: false,
|
|
1293
|
+
configurable: true
|
|
1294
|
+
});
|
|
1295
|
+
ColumnControl.prototype.remove = function () {
|
|
1296
|
+
var _this = this;
|
|
1297
|
+
this.column.controls = this.column.controls.filter(function (control) { return control.id !== _this.id; });
|
|
1298
|
+
reindex(this.column.controls);
|
|
1299
|
+
};
|
|
1300
|
+
ColumnControl.prototype.setData = function (data) {
|
|
1301
|
+
this.json = data;
|
|
1302
|
+
};
|
|
1303
|
+
return ColumnControl;
|
|
1304
|
+
}());
|
|
1305
|
+
export { ColumnControl };
|
|
1306
|
+
var ClientsideText = /** @class */ (function (_super) {
|
|
1307
|
+
__extends(ClientsideText, _super);
|
|
1308
|
+
function ClientsideText(text, json) {
|
|
1309
|
+
if (json === void 0) { json = JSON.parse(JSON.stringify(ClientsideText.Default)); }
|
|
1310
|
+
var _this = this;
|
|
1311
|
+
if (stringIsNullOrEmpty(json.id)) {
|
|
1312
|
+
json.id = getGUID();
|
|
1313
|
+
json.anchorComponentId = json.id;
|
|
1314
|
+
}
|
|
1315
|
+
_this = _super.call(this, json) || this;
|
|
1316
|
+
_this.text = text;
|
|
1317
|
+
return _this;
|
|
1318
|
+
}
|
|
1319
|
+
Object.defineProperty(ClientsideText.prototype, "text", {
|
|
1320
|
+
get: function () {
|
|
1321
|
+
return this.data.innerHTML;
|
|
1322
|
+
},
|
|
1323
|
+
set: function (value) {
|
|
1324
|
+
this.data.innerHTML = value;
|
|
1325
|
+
},
|
|
1326
|
+
enumerable: false,
|
|
1327
|
+
configurable: true
|
|
1328
|
+
});
|
|
1329
|
+
Object.defineProperty(ClientsideText.prototype, "order", {
|
|
1330
|
+
get: function () {
|
|
1331
|
+
return this.data.position.controlIndex;
|
|
1332
|
+
},
|
|
1333
|
+
set: function (value) {
|
|
1334
|
+
this.data.position.controlIndex = value;
|
|
1335
|
+
},
|
|
1336
|
+
enumerable: false,
|
|
1337
|
+
configurable: true
|
|
1338
|
+
});
|
|
1339
|
+
ClientsideText.prototype.onColumnChange = function (col) {
|
|
1340
|
+
this.data.position.sectionFactor = col.factor;
|
|
1341
|
+
this.data.position.controlIndex = getNextOrder(col.controls);
|
|
1342
|
+
this.data.position.zoneIndex = col.data.position.zoneIndex;
|
|
1343
|
+
this.data.position.sectionIndex = col.order;
|
|
1344
|
+
this.data.position.layoutIndex = col.data.position.layoutIndex;
|
|
1345
|
+
};
|
|
1346
|
+
ClientsideText.Default = {
|
|
1347
|
+
addedFromPersistedData: false,
|
|
1348
|
+
anchorComponentId: "",
|
|
1349
|
+
controlType: 4,
|
|
1350
|
+
displayMode: 2,
|
|
1351
|
+
editorType: "CKEditor",
|
|
1352
|
+
emphasis: {},
|
|
1353
|
+
id: "",
|
|
1354
|
+
innerHTML: "",
|
|
1355
|
+
position: {
|
|
1356
|
+
controlIndex: 1,
|
|
1357
|
+
layoutIndex: 1,
|
|
1358
|
+
sectionFactor: 12,
|
|
1359
|
+
sectionIndex: 1,
|
|
1360
|
+
zoneIndex: 1,
|
|
1361
|
+
},
|
|
1362
|
+
};
|
|
1363
|
+
return ClientsideText;
|
|
1364
|
+
}(ColumnControl));
|
|
1365
|
+
export { ClientsideText };
|
|
1366
|
+
var ClientsideWebpart = /** @class */ (function (_super) {
|
|
1367
|
+
__extends(ClientsideWebpart, _super);
|
|
1368
|
+
function ClientsideWebpart(json) {
|
|
1369
|
+
if (json === void 0) { json = JSON.parse(JSON.stringify(ClientsideWebpart.Default)); }
|
|
1370
|
+
return _super.call(this, json) || this;
|
|
1371
|
+
}
|
|
1372
|
+
ClientsideWebpart.fromComponentDef = function (definition) {
|
|
1373
|
+
var part = new ClientsideWebpart();
|
|
1374
|
+
part.import(definition);
|
|
1375
|
+
return part;
|
|
1376
|
+
};
|
|
1377
|
+
Object.defineProperty(ClientsideWebpart.prototype, "title", {
|
|
1378
|
+
get: function () {
|
|
1379
|
+
return this.data.webPartData.title;
|
|
1380
|
+
},
|
|
1381
|
+
set: function (value) {
|
|
1382
|
+
this.data.webPartData.title = value;
|
|
1383
|
+
},
|
|
1384
|
+
enumerable: false,
|
|
1385
|
+
configurable: true
|
|
1386
|
+
});
|
|
1387
|
+
Object.defineProperty(ClientsideWebpart.prototype, "description", {
|
|
1388
|
+
get: function () {
|
|
1389
|
+
return this.data.webPartData.description;
|
|
1390
|
+
},
|
|
1391
|
+
set: function (value) {
|
|
1392
|
+
this.data.webPartData.description = value;
|
|
1393
|
+
},
|
|
1394
|
+
enumerable: false,
|
|
1395
|
+
configurable: true
|
|
1396
|
+
});
|
|
1397
|
+
Object.defineProperty(ClientsideWebpart.prototype, "order", {
|
|
1398
|
+
get: function () {
|
|
1399
|
+
return this.data.position.controlIndex;
|
|
1400
|
+
},
|
|
1401
|
+
set: function (value) {
|
|
1402
|
+
this.data.position.controlIndex = value;
|
|
1403
|
+
},
|
|
1404
|
+
enumerable: false,
|
|
1405
|
+
configurable: true
|
|
1406
|
+
});
|
|
1407
|
+
Object.defineProperty(ClientsideWebpart.prototype, "height", {
|
|
1408
|
+
get: function () {
|
|
1409
|
+
return this.data.reservedHeight;
|
|
1410
|
+
},
|
|
1411
|
+
set: function (value) {
|
|
1412
|
+
this.data.reservedHeight = value;
|
|
1413
|
+
},
|
|
1414
|
+
enumerable: false,
|
|
1415
|
+
configurable: true
|
|
1416
|
+
});
|
|
1417
|
+
Object.defineProperty(ClientsideWebpart.prototype, "width", {
|
|
1418
|
+
get: function () {
|
|
1419
|
+
return this.data.reservedWidth;
|
|
1420
|
+
},
|
|
1421
|
+
set: function (value) {
|
|
1422
|
+
this.data.reservedWidth = value;
|
|
1423
|
+
},
|
|
1424
|
+
enumerable: false,
|
|
1425
|
+
configurable: true
|
|
1426
|
+
});
|
|
1427
|
+
Object.defineProperty(ClientsideWebpart.prototype, "dataVersion", {
|
|
1428
|
+
get: function () {
|
|
1429
|
+
return this.data.webPartData.dataVersion;
|
|
1430
|
+
},
|
|
1431
|
+
set: function (value) {
|
|
1432
|
+
this.data.webPartData.dataVersion = value;
|
|
1433
|
+
},
|
|
1434
|
+
enumerable: false,
|
|
1435
|
+
configurable: true
|
|
1436
|
+
});
|
|
1437
|
+
ClientsideWebpart.prototype.setProperties = function (properties) {
|
|
1438
|
+
this.data.webPartData.properties = assign(this.data.webPartData.properties, properties);
|
|
1439
|
+
return this;
|
|
1440
|
+
};
|
|
1441
|
+
ClientsideWebpart.prototype.setServerProcessedContent = function (properties) {
|
|
1442
|
+
this.data.webPartData.serverProcessedContent = assign(this.data.webPartData.serverProcessedContent || {}, properties);
|
|
1443
|
+
return this;
|
|
1444
|
+
};
|
|
1445
|
+
ClientsideWebpart.prototype.getProperties = function () {
|
|
1446
|
+
return this.data.webPartData.properties;
|
|
1447
|
+
};
|
|
1448
|
+
ClientsideWebpart.prototype.getServerProcessedContent = function () {
|
|
1449
|
+
return this.data.webPartData.serverProcessedContent;
|
|
1450
|
+
};
|
|
1451
|
+
ClientsideWebpart.prototype.onColumnChange = function (col) {
|
|
1452
|
+
this.data.position.sectionFactor = col.factor;
|
|
1453
|
+
this.data.position.controlIndex = getNextOrder(col.controls);
|
|
1454
|
+
this.data.position.zoneIndex = col.data.position.zoneIndex;
|
|
1455
|
+
this.data.position.sectionIndex = col.data.position.sectionIndex;
|
|
1456
|
+
this.data.position.layoutIndex = col.data.position.layoutIndex;
|
|
1457
|
+
};
|
|
1458
|
+
ClientsideWebpart.prototype.import = function (component) {
|
|
1459
|
+
var id = getGUID();
|
|
1460
|
+
var componendId = component.Id.replace(/^\{|\}$/g, "").toLowerCase();
|
|
1461
|
+
var manifest = JSON.parse(component.Manifest);
|
|
1462
|
+
var preconfiguredEntries = manifest.preconfiguredEntries[0];
|
|
1463
|
+
this.setData(Object.assign({}, this.data, {
|
|
1464
|
+
id: id,
|
|
1465
|
+
webPartData: {
|
|
1466
|
+
dataVersion: "1.0",
|
|
1467
|
+
description: preconfiguredEntries.description.default,
|
|
1468
|
+
id: componendId,
|
|
1469
|
+
instanceId: id,
|
|
1470
|
+
properties: preconfiguredEntries.properties,
|
|
1471
|
+
title: preconfiguredEntries.title.default,
|
|
1472
|
+
},
|
|
1473
|
+
webPartId: componendId,
|
|
1474
|
+
}));
|
|
1475
|
+
};
|
|
1476
|
+
ClientsideWebpart.Default = {
|
|
1477
|
+
addedFromPersistedData: false,
|
|
1478
|
+
controlType: 3,
|
|
1479
|
+
displayMode: 2,
|
|
1480
|
+
emphasis: {},
|
|
1481
|
+
id: null,
|
|
1482
|
+
position: {
|
|
1483
|
+
controlIndex: 1,
|
|
1484
|
+
layoutIndex: 1,
|
|
1485
|
+
sectionFactor: 12,
|
|
1486
|
+
sectionIndex: 1,
|
|
1487
|
+
zoneIndex: 1,
|
|
1488
|
+
},
|
|
1489
|
+
reservedHeight: 500,
|
|
1490
|
+
reservedWidth: 500,
|
|
1491
|
+
webPartData: null,
|
|
1492
|
+
webPartId: null,
|
|
1493
|
+
};
|
|
1494
|
+
return ClientsideWebpart;
|
|
1495
|
+
}(ColumnControl));
|
|
1496
|
+
export { ClientsideWebpart };
|
|
1488
1497
|
//# sourceMappingURL=types.js.map
|