@phuong-tran-redoc/document-engine-angular 0.1.3 → 0.1.4
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.
|
@@ -5318,12 +5318,31 @@ const TEXT_CASE_OPTIONS = [
|
|
|
5318
5318
|
{ value: 'lowercase', label: 'lowercase' },
|
|
5319
5319
|
{ value: 'capitalize', label: 'Capitalize' },
|
|
5320
5320
|
];
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5321
|
+
/**
|
|
5322
|
+
* Heading levels offered when `heading` is enabled without an explicit `levels`
|
|
5323
|
+
* array — mirrors the Tiptap Heading extension default (1–6).
|
|
5324
|
+
*/
|
|
5325
|
+
const DEFAULT_HEADING_LEVELS = [1, 2, 3, 4, 5, 6];
|
|
5326
|
+
/**
|
|
5327
|
+
* Build the block-type dropdown options from the editor's configured heading
|
|
5328
|
+
* levels, so the toolbar offers exactly the levels the editor can produce: no
|
|
5329
|
+
* dead entry for a level the config omits, and no configured level left
|
|
5330
|
+
* unreachable. The leading "Normal text" (paragraph) entry is always present.
|
|
5331
|
+
* Levels are de-duplicated and sorted ascending; an empty or omitted list falls
|
|
5332
|
+
* back to {@link DEFAULT_HEADING_LEVELS}.
|
|
5333
|
+
*/
|
|
5334
|
+
function buildHeadingOptions(levels) {
|
|
5335
|
+
const source = levels && levels.length > 0 ? levels : DEFAULT_HEADING_LEVELS;
|
|
5336
|
+
const sorted = [...new Set(source)].sort((a, b) => a - b);
|
|
5337
|
+
return [
|
|
5338
|
+
{ value: null, label: 'Normal text', class: '' },
|
|
5339
|
+
...sorted.map((level) => ({
|
|
5340
|
+
value: level,
|
|
5341
|
+
label: `Heading ${level}`,
|
|
5342
|
+
class: `h${level}`,
|
|
5343
|
+
})),
|
|
5344
|
+
];
|
|
5345
|
+
}
|
|
5327
5346
|
const TEXT_ALIGN_OPTIONS = [
|
|
5328
5347
|
{ value: 'left', label: 'Align Left', icon: 'format_align_left' },
|
|
5329
5348
|
{ value: 'center', label: 'Align Center', icon: 'format_align_center' },
|
|
@@ -6057,7 +6076,10 @@ class ToolbarComponent {
|
|
|
6057
6076
|
fontSizeOptions = FONT_SIZE_OPTIONS;
|
|
6058
6077
|
lineHeightOptions = LINE_HEIGHT_OPTIONS;
|
|
6059
6078
|
textCaseOptions = TEXT_CASE_OPTIONS;
|
|
6060
|
-
|
|
6079
|
+
// Derived from the editor's configured heading levels in ngOnInit so the
|
|
6080
|
+
// block-type dropdown lists exactly the levels the config allows (no dead
|
|
6081
|
+
// entry, no unreachable level). Seeded with the default set for first paint.
|
|
6082
|
+
headingOptions = buildHeadingOptions();
|
|
6061
6083
|
textAlignOptions = TEXT_ALIGN_OPTIONS;
|
|
6062
6084
|
listStyleOptions = LIST_STYLE_OPTIONS;
|
|
6063
6085
|
colorBubbleMenu;
|
|
@@ -6108,6 +6130,10 @@ class ToolbarComponent {
|
|
|
6108
6130
|
});
|
|
6109
6131
|
};
|
|
6110
6132
|
ngOnInit() {
|
|
6133
|
+
// Build the block-type dropdown from the configured heading levels (semantic
|
|
6134
|
+
// mode = 2/3/4, etc.) rather than a fixed 1/2/3 set. Done before the first
|
|
6135
|
+
// updateToolbarState() so its heading-active scan iterates the real options.
|
|
6136
|
+
this.headingOptions = buildHeadingOptions(this.resolveHeadingLevels());
|
|
6111
6137
|
// Subscribe to selectionUpdate to keep toolbar state in sync when cursor/selection changes
|
|
6112
6138
|
this.editor.on('update', this.updateToolbarState);
|
|
6113
6139
|
this.editor.on('transaction', this.throttleUpdateToolbarState);
|
|
@@ -6123,6 +6149,19 @@ class ToolbarComponent {
|
|
|
6123
6149
|
this.toolbarService.ngOnDestroy();
|
|
6124
6150
|
this.editor.destroy();
|
|
6125
6151
|
}
|
|
6152
|
+
/**
|
|
6153
|
+
* Read the configured heading levels off `config.heading`. It may be a boolean
|
|
6154
|
+
* (`true` = default levels, handled by buildHeadingOptions' fallback) or a
|
|
6155
|
+
* `Partial<HeadingOptions>` carrying a `levels` array. Returns undefined when no
|
|
6156
|
+
* explicit levels are set so the caller falls back to the default set.
|
|
6157
|
+
*/
|
|
6158
|
+
resolveHeadingLevels() {
|
|
6159
|
+
const heading = this.config?.heading;
|
|
6160
|
+
if (heading && typeof heading === 'object' && Array.isArray(heading.levels)) {
|
|
6161
|
+
return heading.levels;
|
|
6162
|
+
}
|
|
6163
|
+
return undefined;
|
|
6164
|
+
}
|
|
6126
6165
|
runAndEmit(actionName, chain) {
|
|
6127
6166
|
chain();
|
|
6128
6167
|
this.toolbarService.emit(actionName);
|