1 | import { IFile } from "../files/types.js";
|
2 | import { IItem } from "../items/types.js";
|
3 | import { _SPQueryable, SPInit } from "../spqueryable.js";
|
4 | import { IWeb } from "../webs/types.js";
|
5 | import "../files/web.js";
|
6 | import "../comments/item.js";
|
7 |
|
8 |
|
9 |
|
10 | export declare const enum PromotedState {
|
11 | |
12 |
|
13 |
|
14 | NotPromoted = 0,
|
15 | |
16 |
|
17 |
|
18 | PromoteOnPublish = 1,
|
19 | |
20 |
|
21 |
|
22 | Promoted = 2
|
23 | }
|
24 |
|
25 |
|
26 |
|
27 | export declare type ClientsidePageLayoutType = "Article" | "Home" | "SingleWebPartAppPage" | "RepostPage";
|
28 |
|
29 |
|
30 |
|
31 | export declare type CanvasColumnFactor = 0 | 2 | 4 | 6 | 8 | 12;
|
32 |
|
33 |
|
34 |
|
35 | export declare class _ClientsidePage extends _SPQueryable {
|
36 | protected json?: Partial<IPageData>;
|
37 | sections: CanvasSection[];
|
38 | commentsDisabled: boolean;
|
39 | private _pageSettings;
|
40 | private _layoutPart;
|
41 | private _bannerImageDirty;
|
42 | private _bannerImageThumbnailUrlDirty;
|
43 | |
44 |
|
45 |
|
46 | constructor(base: SPInit, path?: string, json?: Partial<IPageData>, noInit?: boolean, sections?: CanvasSection[], commentsDisabled?: boolean);
|
47 | private static getDefaultLayoutPart;
|
48 | get pageLayout(): ClientsidePageLayoutType;
|
49 | set pageLayout(value: ClientsidePageLayoutType);
|
50 | get bannerImageUrl(): string;
|
51 | set bannerImageUrl(value: string);
|
52 | get thumbnailUrl(): string;
|
53 | set thumbnailUrl(value: string);
|
54 | get topicHeader(): string;
|
55 | set topicHeader(value: string);
|
56 | get title(): string;
|
57 | set title(value: string);
|
58 | get reservedHeight(): number;
|
59 | set reservedHeight(value: number);
|
60 | get description(): string;
|
61 | set description(value: string);
|
62 | get layoutType(): LayoutType;
|
63 | set layoutType(value: LayoutType);
|
64 | get headerTextAlignment(): TextAlignment;
|
65 | set headerTextAlignment(value: TextAlignment);
|
66 | get showTopicHeader(): boolean;
|
67 | set showTopicHeader(value: boolean);
|
68 | get showPublishDate(): boolean;
|
69 | set showPublishDate(value: boolean);
|
70 | get hasVerticalSection(): boolean;
|
71 | get authorByLine(): string | null;
|
72 | get verticalSection(): CanvasSection | null;
|
73 | /**
|
74 | * Add a section to this page
|
75 | */
|
76 | addSection(): CanvasSection;
|
77 | /**
|
78 | * Add a section to this page
|
79 | */
|
80 | addVerticalSection(): CanvasSection;
|
81 | /**
|
82 | * Loads this instance from the appropriate JSON data
|
83 | *
|
84 | * @param pageData JSON data to load (replaces any existing data)
|
85 | */
|
86 | fromJSON(pageData: Partial<IPageData>): this;
|
87 | /**
|
88 | * Loads this page's content from the server
|
89 | */
|
90 | load(): Promise<IClientsidePage>;
|
91 | /**
|
92 | * Persists the content changes (sections, columns, and controls) [does not work with batching]
|
93 | *
|
94 | * @param publish If true the page is published, if false the changes are persisted to SharePoint but not published [Default: true]
|
95 | */
|
96 | save(publish?: boolean): Promise<boolean>;
|
97 | /**
|
98 | * Discards the checkout of this page
|
99 | */
|
100 | discardPageCheckout(): Promise<void>;
|
101 | /**
|
102 | * Promotes this page as a news item
|
103 | */
|
104 | promoteToNews(): Promise<boolean>;
|
105 | /**
|
106 | * Finds a control by the specified instance id
|
107 | *
|
108 | * @param id Instance id of the control to find
|
109 | */
|
110 | findControlById<T extends ColumnControl<any> = ColumnControl<any>>(id: string): T;
|
111 | /**
|
112 | * Finds a control within this page's control tree using the supplied predicate
|
113 | *
|
114 | * @param predicate Takes a control and returns true or false, if true that control is returned by findControl
|
115 | */
|
116 | findControl<T extends ColumnControl<any> = ColumnControl<any>>(predicate: (c: ColumnControl<any>) => boolean): T;
|
117 | /**
|
118 | * Creates a new page with all of the content copied from this page
|
119 | *
|
120 | * @param web The web where we will create the copy
|
121 | * @param pageName The file name of the new page
|
122 | * @param title The title of the new page
|
123 | * @param publish If true the page will be published (Default: true)
|
124 | */
|
125 | copy(web: IWeb, pageName: string, title: string, publish?: boolean, promotedState?: PromotedState): Promise<IClientsidePage>;
|
126 | /**
|
127 | * Copies the content from this page to the supplied page instance NOTE: fully overwriting any previous content!!
|
128 | *
|
129 | * @param page Page whose content we replace with this page's content
|
130 | * @param publish If true the page will be published after the copy, if false it will be saved but left unpublished (Default: true)
|
131 | */
|
132 | copyTo(page: IClientsidePage, publish?: boolean): Promise<IClientsidePage>;
|
133 | /**
|
134 | * Sets the modern page banner image
|
135 | *
|
136 | * @param url Url of the image to display
|
137 | * @param altText Alt text to describe the image
|
138 | * @param bannerProps Additional properties to control display of the banner
|
139 | */
|
140 | setBannerImage(url: string, props?: IBannerImageProps): void;
|
141 | /**
|
142 | * Sets the banner image url from an external source. You must call save to persist the changes
|
143 | *
|
144 | * @param url absolute url of the external file
|
145 | * @param props optional set of properties to control display of the banner image
|
146 | */
|
147 | setBannerImageFromExternalUrl(url: string, props?: IBannerImageProps): Promise<void>;
|
148 | /**
|
149 | * Sets the authors for this page from the supplied list of user integer ids
|
150 | *
|
151 | * @param authorId The integer id of the user to set as the author
|
152 | */
|
153 | setAuthorById(authorId: number): Promise<void>;
|
154 | /**
|
155 | * Sets the authors for this page from the supplied list of user integer ids
|
156 | *
|
157 | * @param authorLoginName The login name of the user (ex: i:0#.f|membership|name@tenant.com)
|
158 | */
|
159 | setAuthorByLoginName(authorLoginName: string): Promise<void>;
|
160 | /**
|
161 | * Gets the list item associated with this clientside page
|
162 | *
|
163 | * @param selects Specific set of fields to include when getting the item
|
164 | */
|
165 | getItem<T>(...selects: string[]): Promise<IItem & T>;
|
166 | /**
|
167 | * Recycle this page
|
168 | */
|
169 | recycle(): Promise<void>;
|
170 | /**
|
171 | * Delete this page
|
172 | */
|
173 | delete(): Promise<void>;
|
174 | /**
|
175 | * Saves a copy of this page as a template in this library's Templates folder
|
176 | *
|
177 | * @param publish If true the template is published, false the template is not published (default: true)
|
178 | * @returns IClientsidePage instance representing the new template page
|
179 | */
|
180 | saveAsTemplate(publish?: boolean): Promise<IClientsidePage>;
|
181 | /**
|
182 | * Share this Page's Preview content by Email
|
183 | *
|
184 | * @param emails Set of emails to which the preview is shared
|
185 | * @param message The message to include
|
186 | * @returns void
|
187 | */
|
188 | share(emails: string[], message: string): Promise<void>;
|
189 | protected getCanvasContent1(): string;
|
190 | protected getLayoutWebpartsContent(): string;
|
191 | protected setControls(controls: IClientsideControlBaseData[]): void;
|
192 | protected getControls(): IClientsideControlBaseData[];
|
193 | private getEmphasisObj;
|
194 | private promoteNewsImpl;
|
195 | /**
|
196 | * Merges the control into the tree of sections and columns for this page
|
197 | *
|
198 | * @param control The control to merge
|
199 | */
|
200 | private mergePartToTree;
|
201 | /**
|
202 | * Merges the supplied column into the tree
|
203 | *
|
204 | * @param column Column to merge
|
205 | * @param position The position data for the column
|
206 | */
|
207 | private mergeColumnToTree;
|
208 | /**
|
209 | * Handle the logic to get or create a section based on the supplied order and layoutIndex
|
210 | *
|
211 | * @param order Section order
|
212 | * @param layoutIndex Layout Index (1 === normal, 2 === vertical section)
|
213 | * @param emphasis The section emphasis
|
214 | */
|
215 | private getOrCreateSection;
|
216 | /**
|
217 | * Based on issue #1690 we need to take special case actions to ensure some things
|
218 | * can be saved properly without breaking existing pages.
|
219 | *
|
220 | * @param control The control we are ensuring is "ready" to be saved
|
221 | */
|
222 | private specialSaveHandling;
|
223 | }
|
224 | export interface IClientsidePage extends _ClientsidePage {
|
225 | }
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | export declare const ClientsidePageFromFile: (file: IFile) => Promise<IClientsidePage>;
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | export declare const CreateClientsidePage: (web: IWeb, pageName: string, title: string, PageLayoutType?: ClientsidePageLayoutType, promotedState?: PromotedState) => Promise<IClientsidePage>;
|
241 | export declare class CanvasSection {
|
242 | protected page: IClientsidePage;
|
243 | columns: CanvasColumn[];
|
244 | private _emphasis;
|
245 | |
246 |
|
247 |
|
248 | private _memId;
|
249 | private _order;
|
250 | private _layoutIndex;
|
251 | constructor(page: IClientsidePage, order: number, layoutIndex: number, columns?: CanvasColumn[], _emphasis?: 0 | 1 | 2 | 3);
|
252 | get order(): number;
|
253 | set order(value: number);
|
254 | get layoutIndex(): number;
|
255 | set layoutIndex(value: number);
|
256 | /**
|
257 | * Default column (this.columns[0]) for this section
|
258 | */
|
259 | get defaultColumn(): CanvasColumn;
|
260 | /**
|
261 | * Adds a new column to this section
|
262 | */
|
263 | addColumn(factor: CanvasColumnFactor, layoutIndex?: number): CanvasColumn;
|
264 | /**
|
265 | * Adds a control to the default column for this section
|
266 | *
|
267 | * @param control Control to add to the default column
|
268 | */
|
269 | addControl(control: ColumnControl<any>): this;
|
270 | get emphasis(): 0 | 1 | 2 | 3;
|
271 | set emphasis(value: 0 | 1 | 2 | 3);
|
272 | /**
|
273 | * Removes this section and all contained columns and controls from the collection
|
274 | */
|
275 | remove(): void;
|
276 | }
|
277 | export declare class CanvasColumn {
|
278 | protected json: IClientsidePageColumnData;
|
279 | controls: ColumnControl<any>[];
|
280 | static Default: IClientsidePageColumnData;
|
281 | private _section;
|
282 | private _memId;
|
283 | constructor(json?: IClientsidePageColumnData, controls?: ColumnControl<any>[]);
|
284 | get data(): IClientsidePageColumnData;
|
285 | get section(): CanvasSection;
|
286 | set section(section: CanvasSection);
|
287 | get order(): number;
|
288 | set order(value: number);
|
289 | get factor(): CanvasColumnFactor;
|
290 | set factor(value: CanvasColumnFactor);
|
291 | addControl(control: ColumnControl<any>): this;
|
292 | getControl<T extends ColumnControl<any>>(index: number): T;
|
293 | remove(): void;
|
294 | }
|
295 | export declare abstract class ColumnControl<T extends ICanvasControlBaseData> {
|
296 | protected json: T;
|
297 | private _column;
|
298 | constructor(json: T);
|
299 | abstract get order(): number;
|
300 | abstract set order(value: number);
|
301 | get id(): string;
|
302 | get data(): T;
|
303 | get column(): CanvasColumn | null;
|
304 | set column(value: CanvasColumn);
|
305 | remove(): void;
|
306 | protected setData(data: T): void;
|
307 | protected abstract onColumnChange(col: CanvasColumn): void;
|
308 | }
|
309 | export declare class ClientsideText extends ColumnControl<IClientsideTextData> {
|
310 | static Default: IClientsideTextData;
|
311 | constructor(text: string, json?: IClientsideTextData);
|
312 | get text(): string;
|
313 | set text(value: string);
|
314 | get order(): number;
|
315 | set order(value: number);
|
316 | protected onColumnChange(col: CanvasColumn): void;
|
317 | }
|
318 | export declare class ClientsideWebpart extends ColumnControl<IClientsideWebPartData> {
|
319 | static Default: IClientsideWebPartData;
|
320 | constructor(json?: IClientsideWebPartData);
|
321 | static fromComponentDef(definition: IClientsidePageComponent): ClientsideWebpart;
|
322 | get title(): string;
|
323 | set title(value: string);
|
324 | get description(): string;
|
325 | set description(value: string);
|
326 | get order(): number;
|
327 | set order(value: number);
|
328 | get height(): number;
|
329 | set height(value: number);
|
330 | get width(): number;
|
331 | set width(value: number);
|
332 | get dataVersion(): string;
|
333 | set dataVersion(value: string);
|
334 | setProperties<T = any>(properties: T): this;
|
335 | getProperties<T = any>(): T;
|
336 | setServerProcessedContent<T = any>(properties: T): this;
|
337 | getServerProcessedContent<T = any>(): T;
|
338 | protected onColumnChange(col: CanvasColumn): void;
|
339 | protected import(component: IClientsidePageComponent): void;
|
340 | }
|
341 | export interface IPageData {
|
342 | readonly "odata.metadata": string;
|
343 | readonly "odata.type": "SP.Publishing.SitePage";
|
344 | readonly "odata.id": string;
|
345 | readonly "odata.editLink": string;
|
346 | AbsoluteUrl: string;
|
347 | AuthorByline: string[] | null;
|
348 | BannerImageUrl: string;
|
349 | BannerThumbnailUrl: string;
|
350 | ContentTypeId: null | string;
|
351 | Description: string;
|
352 | DoesUserHaveEditPermission: boolean;
|
353 | FileName: string;
|
354 | readonly FirstPublished: string;
|
355 | readonly Id: number;
|
356 | IsPageCheckedOutToCurrentUser: boolean;
|
357 | IsWebWelcomePage: boolean;
|
358 | readonly Modified: string;
|
359 | PageLayoutType: ClientsidePageLayoutType;
|
360 | Path: {
|
361 | DecodedUrl: string;
|
362 | };
|
363 | PromotedState: number;
|
364 | Title: string;
|
365 | TopicHeader: null | string;
|
366 | readonly UniqueId: string;
|
367 | Url: string;
|
368 | readonly Version: string;
|
369 | readonly VersionInfo: {
|
370 | readonly LastVersionCreated: string;
|
371 | readonly LastVersionCreatedBy: string;
|
372 | };
|
373 | AlternativeUrlMap: string;
|
374 | CanvasContent1: string;
|
375 | LayoutWebpartsContent: string;
|
376 | }
|
377 |
|
378 |
|
379 |
|
380 | export interface IClientsidePageComponent {
|
381 | |
382 |
|
383 |
|
384 | ComponentType: number;
|
385 | |
386 |
|
387 |
|
388 | Id: string;
|
389 | |
390 |
|
391 |
|
392 | Manifest: string;
|
393 | |
394 |
|
395 |
|
396 | ManifestType: number;
|
397 | |
398 |
|
399 |
|
400 | Name: string;
|
401 | |
402 |
|
403 |
|
404 | Status: number;
|
405 | }
|
406 | export interface IClientsideControlBaseData {
|
407 | controlType: number;
|
408 | }
|
409 | export interface ICanvasControlBaseData extends IClientsideControlBaseData {
|
410 | id: string;
|
411 | emphasis: IClientControlEmphasis;
|
412 | displayMode: number;
|
413 | }
|
414 | export interface IClientsidePageSettingsSlice extends IClientsideControlBaseData {
|
415 | htmlAttributes?: string[];
|
416 | pageSettingsSlice: {
|
417 | "isDefaultDescription": boolean;
|
418 | "isDefaultThumbnail": boolean;
|
419 | };
|
420 | }
|
421 | export interface IClientsidePageColumnData extends IClientsideControlBaseData {
|
422 | controlType: 0;
|
423 | displayMode: number;
|
424 | emphasis: IClientControlEmphasis;
|
425 | position: IPosition;
|
426 | }
|
427 | interface IPosition {
|
428 | zoneIndex: number;
|
429 | sectionIndex: number;
|
430 | controlIndex?: number;
|
431 | sectionFactor?: CanvasColumnFactor;
|
432 | layoutIndex: number;
|
433 | }
|
434 | export interface IClientsideTextData extends ICanvasControlBaseData {
|
435 | controlType: 4;
|
436 | position: IPosition;
|
437 | anchorComponentId: string;
|
438 | editorType: "CKEditor";
|
439 | addedFromPersistedData: boolean;
|
440 | innerHTML: string;
|
441 | }
|
442 | export interface IClientsideWebPartData<PropertiesType = any> extends ICanvasControlBaseData {
|
443 | controlType: 3;
|
444 | position: IPosition;
|
445 | webPartId: string;
|
446 | reservedHeight: number;
|
447 | reservedWidth: number;
|
448 | addedFromPersistedData: boolean;
|
449 | webPartData: {
|
450 | id: string;
|
451 | instanceId: string;
|
452 | title: string;
|
453 | description: string;
|
454 | serverProcessedContent?: {
|
455 | htmlStrings?: Record<string, string>;
|
456 | searchablePlainTexts?: Record<string, string>;
|
457 | imageSources?: Record<string, string>;
|
458 | links?: Record<string, string>;
|
459 | };
|
460 | dataVersion: string;
|
461 | properties: PropertiesType;
|
462 | };
|
463 | }
|
464 | export interface IClientControlEmphasis {
|
465 | zoneEmphasis?: 0 | 1 | 2 | 3;
|
466 | }
|
467 | export declare type LayoutType = "FullWidthImage" | "NoImage" | "ColorBlock" | "CutInShape";
|
468 | export declare type TextAlignment = "Left" | "Center";
|
469 | export interface IBannerImageProps {
|
470 | altText?: string;
|
471 | imageSourceType?: number;
|
472 | translateX?: number;
|
473 | translateY?: number;
|
474 | }
|
475 | export interface IRepostPage {
|
476 | Description?: string;
|
477 | IsBannerImageUrlExternal?: boolean;
|
478 | OriginalSourceListId?: string;
|
479 | ShouldSaveAsDraft?: boolean;
|
480 | OriginalSourceSiteId?: string;
|
481 | BannerImageUrl?: string;
|
482 | Title?: string;
|
483 | OriginalSourceItemId?: string;
|
484 | OriginalSourceUrl?: string;
|
485 | OriginalSourceWebId?: string;
|
486 | }
|
487 | export {};
|
488 |
|
\ | No newline at end of file |