@wdprlib/ast 4.1.0 → 4.3.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/dist/index.cjs CHANGED
@@ -40,6 +40,7 @@ __export(exports_src, {
40
40
  isTruthy: () => isTruthy,
41
41
  isStringContainerType: () => isStringContainerType,
42
42
  isParagraphSafe: () => isParagraphSafe,
43
+ isPageButtonAction: () => isPageButtonAction,
43
44
  isHeaderType: () => isHeaderType,
44
45
  isContainerTypeParagraphSafe: () => isContainerTypeParagraphSafe,
45
46
  isAlignType: () => isAlignType,
@@ -62,8 +63,8 @@ module.exports = __toCommonJS(exports_src);
62
63
 
63
64
  // packages/ast/src/build-info.generated.ts
64
65
  var buildInfo = Object.freeze({
65
- version: "4.1.0",
66
- sha: "cc290b0d882de3ed9ea33ec060ddfc8a7b9da59a",
66
+ version: "4.3.0",
67
+ sha: "5e221ddeccc585e64dd1a2eb49b14817c3c1be5d",
67
68
  dirty: false
68
69
  });
69
70
  // packages/ast/src/position.ts
@@ -159,6 +160,7 @@ function isContainerTypeParagraphSafe(type) {
159
160
  case "size":
160
161
  return true;
161
162
  case "div":
163
+ case "note":
162
164
  case "blockquote":
163
165
  case "paragraph":
164
166
  case "heading":
@@ -218,7 +220,10 @@ function isParagraphSafe(element) {
218
220
  case "user":
219
221
  return true;
220
222
  case "date":
223
+ case "social":
221
224
  return true;
225
+ case "button":
226
+ return isPageButtonAction(element.data.action);
222
227
  case "color":
223
228
  return true;
224
229
  case "code":
@@ -259,6 +264,30 @@ function isParagraphSafe(element) {
259
264
  return false;
260
265
  }
261
266
  }
267
+ function isPageButtonAction(action) {
268
+ switch (action) {
269
+ case "edit":
270
+ case "edit-append":
271
+ case "edit-sections":
272
+ case "history":
273
+ case "print":
274
+ case "files":
275
+ case "tags":
276
+ case "source":
277
+ case "backlinks":
278
+ case "talk":
279
+ case "delete":
280
+ case "rename":
281
+ case "site-tools":
282
+ case "edit-meta":
283
+ case "watchers":
284
+ case "parent":
285
+ case "lock-page":
286
+ return true;
287
+ default:
288
+ return false;
289
+ }
290
+ }
262
291
  // packages/ast/src/constants.ts
263
292
  var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
264
293
  var STYLE_ANCHOR_PREFIX = "\x00__STYLE_ANCHOR__";
package/dist/index.d.cts CHANGED
@@ -171,7 +171,7 @@ interface AlignType {
171
171
  *
172
172
  * @group Container Types
173
173
  */
174
- type StringContainerType = "bold" | "italics" | "underline" | "superscript" | "subscript" | "strikethrough" | "monospace" | "span" | "div" | "blockquote" | "size" | "paragraph" | "heading" | "collapsible" | "definition-list" | "definition-list-item" | "definition-list-key" | "definition-list-value" | "table-row" | "table-cell";
174
+ type StringContainerType = "bold" | "italics" | "underline" | "superscript" | "subscript" | "strikethrough" | "monospace" | "span" | "div" | "note" | "blockquote" | "size" | "paragraph" | "heading" | "collapsible" | "definition-list" | "definition-list-item" | "definition-list-key" | "definition-list-value" | "table-row" | "table-cell";
175
175
  /**
176
176
  * Union of all container type discriminators.
177
177
  * Every container element in the AST carries one of these to identify
@@ -730,6 +730,20 @@ interface TableOfContentsData {
730
730
  align: Alignment | null;
731
731
  }
732
732
  /**
733
+ * Resolved pagination state and navigation targets.
734
+ *
735
+ * @group Element Data
736
+ */
737
+ interface PagerData {
738
+ currentPage: number;
739
+ totalPages: number;
740
+ /** Ascending targets, including the current page, its neighbors, and both ends. */
741
+ pages: {
742
+ page: number;
743
+ href: string;
744
+ }[];
745
+ }
746
+ /**
733
747
  * Data for `[[footnoteblock]]` elements.
734
748
  *
735
749
  * @group Element Data
@@ -785,9 +799,29 @@ interface DateData {
785
799
  value: DateItem;
786
800
  /** strftime-style format string, or null for default */
787
801
  format: string | null;
788
- /** Whether to show a tooltip with the full date on hover */
802
+ /** Whether to show elapsed time in a tooltip on hover */
789
803
  hover: boolean;
790
804
  }
805
+ /** Standalone page-option action, used by [[button action]].
806
+ * @group Element Data
807
+ */
808
+ type PageButtonAction = "edit" | "edit-append" | "edit-sections" | "history" | "print" | "files" | "tags" | "source" | "backlinks" | "talk" | "delete" | "rename" | "site-tools" | "edit-meta" | "watchers" | "parent" | "lock-page";
809
+ /** Data for a standalone [[button]] element.
810
+ * @group Element Data
811
+ */
812
+ interface PageButtonData {
813
+ /** Unknown actions remain representable so the renderer can display the error. */
814
+ action: string;
815
+ text: string | null;
816
+ attributes: AttributeMap;
817
+ }
818
+ /** Data for [[social]], with null selecting the default services.
819
+ * @group Element Data
820
+ */
821
+ interface SocialData {
822
+ /** Unsupported names remain representable, but produce no share link. */
823
+ sites: string[] | null;
824
+ }
791
825
  /**
792
826
  * Data for `##color|text##` inline color syntax.
793
827
  *
@@ -936,6 +970,7 @@ type ElementDataMap = {
936
970
  "definition-list": DefinitionListItem[];
937
971
  collapsible: CollapsibleData;
938
972
  "table-of-contents": TableOfContentsData;
973
+ pager: PagerData;
939
974
  footnote: void;
940
975
  "footnote-ref": number;
941
976
  "footnote-block": FootnoteBlockData;
@@ -943,6 +978,8 @@ type ElementDataMap = {
943
978
  "bibliography-block": BibliographyBlockData;
944
979
  user: UserData;
945
980
  date: DateData;
981
+ button: PageButtonData;
982
+ social: SocialData;
946
983
  color: ColorData;
947
984
  code: CodeBlockData;
948
985
  math: MathData;
@@ -1147,6 +1184,8 @@ declare function isContainerTypeParagraphSafe(type: ContainerType): boolean;
1147
1184
  * @group Utilities
1148
1185
  */
1149
1186
  declare function isParagraphSafe(element: Element): boolean;
1187
+ /** Whether a standalone button names a supported page action. */
1188
+ declare function isPageButtonAction(action: string): action is PageButtonAction;
1150
1189
  /**
1151
1190
  * Severity level of a diagnostic.
1152
1191
  *
@@ -1439,4 +1478,4 @@ interface WikitextPageContext {
1439
1478
  * @group Core
1440
1479
  */
1441
1480
  type Version = "wikidot";
1442
- export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, buildInfo, bold, WikitextSettings, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, STYLE_ANCHOR_PREFIX, Position, Point, ParseResult, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
1481
+ export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isPageButtonAction, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, buildInfo, bold, WikitextSettings, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, SocialData, STYLE_SLOT_PREFIX, STYLE_ANCHOR_PREFIX, Position, Point, ParseResult, PagerData, PageRef, PageButtonData, PageButtonAction, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
package/dist/index.d.ts CHANGED
@@ -171,7 +171,7 @@ interface AlignType {
171
171
  *
172
172
  * @group Container Types
173
173
  */
174
- type StringContainerType = "bold" | "italics" | "underline" | "superscript" | "subscript" | "strikethrough" | "monospace" | "span" | "div" | "blockquote" | "size" | "paragraph" | "heading" | "collapsible" | "definition-list" | "definition-list-item" | "definition-list-key" | "definition-list-value" | "table-row" | "table-cell";
174
+ type StringContainerType = "bold" | "italics" | "underline" | "superscript" | "subscript" | "strikethrough" | "monospace" | "span" | "div" | "note" | "blockquote" | "size" | "paragraph" | "heading" | "collapsible" | "definition-list" | "definition-list-item" | "definition-list-key" | "definition-list-value" | "table-row" | "table-cell";
175
175
  /**
176
176
  * Union of all container type discriminators.
177
177
  * Every container element in the AST carries one of these to identify
@@ -730,6 +730,20 @@ interface TableOfContentsData {
730
730
  align: Alignment | null;
731
731
  }
732
732
  /**
733
+ * Resolved pagination state and navigation targets.
734
+ *
735
+ * @group Element Data
736
+ */
737
+ interface PagerData {
738
+ currentPage: number;
739
+ totalPages: number;
740
+ /** Ascending targets, including the current page, its neighbors, and both ends. */
741
+ pages: {
742
+ page: number;
743
+ href: string;
744
+ }[];
745
+ }
746
+ /**
733
747
  * Data for `[[footnoteblock]]` elements.
734
748
  *
735
749
  * @group Element Data
@@ -785,9 +799,29 @@ interface DateData {
785
799
  value: DateItem;
786
800
  /** strftime-style format string, or null for default */
787
801
  format: string | null;
788
- /** Whether to show a tooltip with the full date on hover */
802
+ /** Whether to show elapsed time in a tooltip on hover */
789
803
  hover: boolean;
790
804
  }
805
+ /** Standalone page-option action, used by [[button action]].
806
+ * @group Element Data
807
+ */
808
+ type PageButtonAction = "edit" | "edit-append" | "edit-sections" | "history" | "print" | "files" | "tags" | "source" | "backlinks" | "talk" | "delete" | "rename" | "site-tools" | "edit-meta" | "watchers" | "parent" | "lock-page";
809
+ /** Data for a standalone [[button]] element.
810
+ * @group Element Data
811
+ */
812
+ interface PageButtonData {
813
+ /** Unknown actions remain representable so the renderer can display the error. */
814
+ action: string;
815
+ text: string | null;
816
+ attributes: AttributeMap;
817
+ }
818
+ /** Data for [[social]], with null selecting the default services.
819
+ * @group Element Data
820
+ */
821
+ interface SocialData {
822
+ /** Unsupported names remain representable, but produce no share link. */
823
+ sites: string[] | null;
824
+ }
791
825
  /**
792
826
  * Data for `##color|text##` inline color syntax.
793
827
  *
@@ -936,6 +970,7 @@ type ElementDataMap = {
936
970
  "definition-list": DefinitionListItem[];
937
971
  collapsible: CollapsibleData;
938
972
  "table-of-contents": TableOfContentsData;
973
+ pager: PagerData;
939
974
  footnote: void;
940
975
  "footnote-ref": number;
941
976
  "footnote-block": FootnoteBlockData;
@@ -943,6 +978,8 @@ type ElementDataMap = {
943
978
  "bibliography-block": BibliographyBlockData;
944
979
  user: UserData;
945
980
  date: DateData;
981
+ button: PageButtonData;
982
+ social: SocialData;
946
983
  color: ColorData;
947
984
  code: CodeBlockData;
948
985
  math: MathData;
@@ -1147,6 +1184,8 @@ declare function isContainerTypeParagraphSafe(type: ContainerType): boolean;
1147
1184
  * @group Utilities
1148
1185
  */
1149
1186
  declare function isParagraphSafe(element: Element): boolean;
1187
+ /** Whether a standalone button names a supported page action. */
1188
+ declare function isPageButtonAction(action: string): action is PageButtonAction;
1150
1189
  /**
1151
1190
  * Severity level of a diagnostic.
1152
1191
  *
@@ -1439,4 +1478,4 @@ interface WikitextPageContext {
1439
1478
  * @group Core
1440
1479
  */
1441
1480
  type Version = "wikidot";
1442
- export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, buildInfo, bold, WikitextSettings, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, STYLE_SLOT_PREFIX, STYLE_ANCHOR_PREFIX, Position, Point, ParseResult, PageRef, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
1481
+ export { text, paragraph, listItemSubList, listItemElements, list, link, lineBreak, italics, isTruthy, isStringContainerType, isParagraphSafe, isPageButtonAction, isHeaderType, isContainerTypeParagraphSafe, isAlignType, horizontalRule, heading, formatExprValue, evaluateExpression, createSettings, createPosition, createPoint, container, buildInfo, bold, WikitextSettings, WikitextPageFile, WikitextPageContext, WikitextMode, Version, VariableMap, UserData, TocEntry, TableRow, TableOfContentsData, TableData, TableCell, TabData, SyntaxTree, StringContainerType, SocialData, STYLE_SLOT_PREFIX, STYLE_ANCHOR_PREFIX, Position, Point, ParseResult, PagerData, PageRef, PageButtonData, PageButtonAction, Module, MathInlineData, MathData, ListType, ListItem, ListData, LinkType, LinkLocation, LinkLabel, LinkData, IncludeData, ImageSource, ImageData, IframeData, IfTagsData, IfExprData, IfCondData, HtmlData, HeadingLevel, Heading, HeaderType, GallerySize, GalleryOrder, GalleryItem, GalleryData, GalleryContent, FootnoteBlockData, FloatAlignment, ExprResult, ExprData, EmbedBlockData, Embed, ElementOf, ElementName, ElementDataMap, ElementData, Element, DiagnosticSeverity, Diagnostic, DefinitionListItem, DateItem, DateData, DEFAULT_SETTINGS, CssLengthUnit, ContainerType, ContainerData, ColorData, CollapsibleData, CodeBlockData, ClearFloat, CSS_LENGTH_UNITS, BibliographyCiteData, BibliographyBlockData, AttributeMap, AnchorTarget, AnchorData, Alignment, AlignType };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // packages/ast/src/build-info.generated.ts
2
2
  var buildInfo = Object.freeze({
3
- version: "4.1.0",
4
- sha: "cc290b0d882de3ed9ea33ec060ddfc8a7b9da59a",
3
+ version: "4.3.0",
4
+ sha: "5e221ddeccc585e64dd1a2eb49b14817c3c1be5d",
5
5
  dirty: false
6
6
  });
7
7
  // packages/ast/src/position.ts
@@ -97,6 +97,7 @@ function isContainerTypeParagraphSafe(type) {
97
97
  case "size":
98
98
  return true;
99
99
  case "div":
100
+ case "note":
100
101
  case "blockquote":
101
102
  case "paragraph":
102
103
  case "heading":
@@ -156,7 +157,10 @@ function isParagraphSafe(element) {
156
157
  case "user":
157
158
  return true;
158
159
  case "date":
160
+ case "social":
159
161
  return true;
162
+ case "button":
163
+ return isPageButtonAction(element.data.action);
160
164
  case "color":
161
165
  return true;
162
166
  case "code":
@@ -197,6 +201,30 @@ function isParagraphSafe(element) {
197
201
  return false;
198
202
  }
199
203
  }
204
+ function isPageButtonAction(action) {
205
+ switch (action) {
206
+ case "edit":
207
+ case "edit-append":
208
+ case "edit-sections":
209
+ case "history":
210
+ case "print":
211
+ case "files":
212
+ case "tags":
213
+ case "source":
214
+ case "backlinks":
215
+ case "talk":
216
+ case "delete":
217
+ case "rename":
218
+ case "site-tools":
219
+ case "edit-meta":
220
+ case "watchers":
221
+ case "parent":
222
+ case "lock-page":
223
+ return true;
224
+ default:
225
+ return false;
226
+ }
227
+ }
200
228
  // packages/ast/src/constants.ts
201
229
  var STYLE_SLOT_PREFIX = "\x00__IFTAGS_SLOT__";
202
230
  var STYLE_ANCHOR_PREFIX = "\x00__STYLE_ANCHOR__";
@@ -687,6 +715,7 @@ export {
687
715
  isTruthy,
688
716
  isStringContainerType,
689
717
  isParagraphSafe,
718
+ isPageButtonAction,
690
719
  isHeaderType,
691
720
  isContainerTypeParagraphSafe,
692
721
  isAlignType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdprlib/ast",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "AST types for Wikidot markup",
5
5
  "keywords": [
6
6
  "ast",
@@ -5,7 +5,7 @@ export const buildInfo: Readonly<{
5
5
  sha: string | null;
6
6
  dirty: boolean | null;
7
7
  }> = Object.freeze({
8
- version: "4.1.0",
9
- sha: "cc290b0d882de3ed9ea33ec060ddfc8a7b9da59a",
8
+ version: "4.3.0",
9
+ sha: "5e221ddeccc585e64dd1a2eb49b14817c3c1be5d",
10
10
  dirty: false,
11
11
  });
package/src/element.ts CHANGED
@@ -122,6 +122,7 @@ export type StringContainerType =
122
122
  | "monospace"
123
123
  | "span"
124
124
  | "div"
125
+ | "note"
125
126
  | "blockquote"
126
127
  | "size"
127
128
  | "paragraph"
@@ -742,6 +743,18 @@ export interface TableOfContentsData {
742
743
  align: Alignment | null;
743
744
  }
744
745
 
746
+ /**
747
+ * Resolved pagination state and navigation targets.
748
+ *
749
+ * @group Element Data
750
+ */
751
+ export interface PagerData {
752
+ currentPage: number;
753
+ totalPages: number;
754
+ /** Ascending targets, including the current page, its neighbors, and both ends. */
755
+ pages: { page: number; href: string }[];
756
+ }
757
+
745
758
  /**
746
759
  * Data for `[[footnoteblock]]` elements.
747
760
  *
@@ -802,10 +815,50 @@ export interface DateData {
802
815
  value: DateItem;
803
816
  /** strftime-style format string, or null for default */
804
817
  format: string | null;
805
- /** Whether to show a tooltip with the full date on hover */
818
+ /** Whether to show elapsed time in a tooltip on hover */
806
819
  hover: boolean;
807
820
  }
808
821
 
822
+ /** Standalone page-option action, used by [[button action]].
823
+ * @group Element Data
824
+ */
825
+ export type PageButtonAction =
826
+ | "edit"
827
+ | "edit-append"
828
+ | "edit-sections"
829
+ | "history"
830
+ | "print"
831
+ | "files"
832
+ | "tags"
833
+ | "source"
834
+ | "backlinks"
835
+ | "talk"
836
+ | "delete"
837
+ | "rename"
838
+ | "site-tools"
839
+ | "edit-meta"
840
+ | "watchers"
841
+ | "parent"
842
+ | "lock-page";
843
+
844
+ /** Data for a standalone [[button]] element.
845
+ * @group Element Data
846
+ */
847
+ export interface PageButtonData {
848
+ /** Unknown actions remain representable so the renderer can display the error. */
849
+ action: string;
850
+ text: string | null;
851
+ attributes: AttributeMap;
852
+ }
853
+
854
+ /** Data for [[social]], with null selecting the default services.
855
+ * @group Element Data
856
+ */
857
+ export interface SocialData {
858
+ /** Unsupported names remain representable, but produce no share link. */
859
+ sites: string[] | null;
860
+ }
861
+
809
862
  /**
810
863
  * Data for `##color|text##` inline color syntax.
811
864
  *
@@ -969,6 +1022,7 @@ export type ElementDataMap = {
969
1022
  "definition-list": DefinitionListItem[];
970
1023
  collapsible: CollapsibleData;
971
1024
  "table-of-contents": TableOfContentsData;
1025
+ pager: PagerData;
972
1026
  footnote: void;
973
1027
  "footnote-ref": number;
974
1028
  "footnote-block": FootnoteBlockData;
@@ -976,6 +1030,8 @@ export type ElementDataMap = {
976
1030
  "bibliography-block": BibliographyBlockData;
977
1031
  user: UserData;
978
1032
  date: DateData;
1033
+ button: PageButtonData;
1034
+ social: SocialData;
979
1035
  color: ColorData;
980
1036
  code: CodeBlockData;
981
1037
  math: MathData;
@@ -1269,6 +1325,7 @@ export function isContainerTypeParagraphSafe(type: ContainerType): boolean {
1269
1325
  case "size":
1270
1326
  return true;
1271
1327
  case "div":
1328
+ case "note":
1272
1329
  case "blockquote":
1273
1330
  case "paragraph":
1274
1331
  case "heading":
@@ -1341,7 +1398,10 @@ export function isParagraphSafe(element: Element): boolean {
1341
1398
  case "user":
1342
1399
  return true;
1343
1400
  case "date":
1401
+ case "social":
1344
1402
  return true;
1403
+ case "button":
1404
+ return isPageButtonAction(element.data.action);
1345
1405
  case "color":
1346
1406
  return true;
1347
1407
  case "code":
@@ -1382,3 +1442,29 @@ export function isParagraphSafe(element: Element): boolean {
1382
1442
  return false;
1383
1443
  }
1384
1444
  }
1445
+
1446
+ /** Whether a standalone button names a supported page action. */
1447
+ export function isPageButtonAction(action: string): action is PageButtonAction {
1448
+ switch (action) {
1449
+ case "edit":
1450
+ case "edit-append":
1451
+ case "edit-sections":
1452
+ case "history":
1453
+ case "print":
1454
+ case "files":
1455
+ case "tags":
1456
+ case "source":
1457
+ case "backlinks":
1458
+ case "talk":
1459
+ case "delete":
1460
+ case "rename":
1461
+ case "site-tools":
1462
+ case "edit-meta":
1463
+ case "watchers":
1464
+ case "parent":
1465
+ case "lock-page":
1466
+ return true;
1467
+ default:
1468
+ return false;
1469
+ }
1470
+ }
package/src/index.ts CHANGED
@@ -75,11 +75,15 @@ export type {
75
75
  GalleryContent,
76
76
  GalleryData,
77
77
  TableOfContentsData,
78
+ PagerData,
78
79
  FootnoteBlockData,
79
80
  BibliographyCiteData,
80
81
  BibliographyBlockData,
81
82
  UserData,
82
83
  DateData,
84
+ PageButtonAction,
85
+ PageButtonData,
86
+ SocialData,
83
87
  ColorData,
84
88
  MathData,
85
89
  MathInlineData,
@@ -109,6 +113,7 @@ export {
109
113
  isAlignType,
110
114
  isContainerTypeParagraphSafe,
111
115
  isParagraphSafe,
116
+ isPageButtonAction,
112
117
  } from "./element";
113
118
 
114
119
  // Diagnostics