suneditor 3.2.5 → 3.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/suneditor-contents.min.css +1 -1
- package/dist/suneditor.min.css +3 -3
- package/dist/suneditor.min.js +1 -1
- package/package.json +4 -4
- package/src/assets/design/color.css +5 -2
- package/src/assets/design/size.css +6 -2
- package/src/assets/icons/defaultIcons.js +195 -162
- package/src/assets/suneditor.css +99 -99
- package/src/core/config/optionProvider.js +5 -4
- package/src/core/event/actions/index.js +8 -4
- package/src/core/event/effects/keydown.registry.js +59 -10
- package/src/core/event/ports.js +2 -0
- package/src/core/event/rules/keydown.rule.backspace.js +52 -1
- package/src/core/event/rules/keydown.rule.delete.js +51 -0
- package/src/core/logic/dom/selection.js +4 -2
- package/src/core/logic/panel/finder.js +3 -0
- package/src/core/logic/panel/menu.js +38 -1
- package/src/core/logic/panel/toolbar.js +1 -0
- package/src/core/logic/shell/_commandExecutor.js +2 -1
- package/src/core/logic/shell/ui.js +41 -5
- package/src/core/schema/frameContext.js +1 -1
- package/src/core/schema/options.js +33 -3
- package/src/core/section/constructor.js +5 -1
- package/src/modules/contract/Controller.js +14 -0
- package/src/modules/ui/CommandMenu.js +8 -11
- package/src/modules/ui/SelectMenu.js +6 -0
- package/src/plugins/dropdown/table/services/table.cell.js +4 -7
- package/types/assets/icons/defaultIcons.d.ts +1 -0
- package/types/core/event/actions/index.d.ts +1 -0
- package/types/core/event/effects/keydown.registry.d.ts +4 -0
- package/types/core/event/ports.d.ts +3 -0
- package/types/core/logic/panel/menu.d.ts +8 -0
- package/types/core/logic/shell/ui.d.ts +17 -0
- package/types/core/schema/frameContext.d.ts +6 -2
- package/types/core/schema/options.d.ts +70 -4
|
@@ -118,6 +118,14 @@ declare class Menu {
|
|
|
118
118
|
* @description Closes the currently open dropdown menu.
|
|
119
119
|
*/
|
|
120
120
|
dropdownOff(): void;
|
|
121
|
+
/**
|
|
122
|
+
* @description Subscribe to be notified after a dropdown is turned off — i.e. a dropdown-free
|
|
123
|
+
* plugin committed and closed itself via {@link dropdownOff}. Mirrors {@link Store#subscribe}:
|
|
124
|
+
* returns an unsubscribe function.
|
|
125
|
+
* @param {() => void} callback
|
|
126
|
+
* @returns {() => void} Unsubscribe function
|
|
127
|
+
*/
|
|
128
|
+
subscribeDropdownOff(callback: () => void): () => void;
|
|
121
129
|
/**
|
|
122
130
|
* @description Shows a previously hidden dropdown menu that is still in `on` state.
|
|
123
131
|
* - Only works when a dropdown is active (`currentButton` exists)
|
|
@@ -231,6 +231,23 @@ declare class UIManager {
|
|
|
231
231
|
* @param {SunEditor.FrameContext} [fc] - Frame context (defaults to current frameContext)
|
|
232
232
|
*/
|
|
233
233
|
_updatePlaceholder(fc?: SunEditor.FrameContext): void;
|
|
234
|
+
/**
|
|
235
|
+
* @description Resolves the per-line placeholder text for an empty line from the `placeholder_line` option.
|
|
236
|
+
* - String option: one hint for every empty line — except list cells and table cells (backward compatible).
|
|
237
|
+
* - Object option: keyed by tag name or a category sentinel matching the editor's format classification
|
|
238
|
+
* ({@link Format#isNormalLine}, `isBrLine`, `isClosureBrLine`, `isBlock`, `isClosureBlock`, list cells).
|
|
239
|
+
* @param {?Node} line - The (empty) line element.
|
|
240
|
+
* @param {string|Object<string, string>} opt - The `placeholder_line` option value.
|
|
241
|
+
* @returns {string} The resolved placeholder text (`''` = none).
|
|
242
|
+
*/
|
|
243
|
+
resolveLinePlaceholder(
|
|
244
|
+
line: Node | null,
|
|
245
|
+
opt:
|
|
246
|
+
| string
|
|
247
|
+
| {
|
|
248
|
+
[x: string]: string;
|
|
249
|
+
},
|
|
250
|
+
): string;
|
|
234
251
|
/**
|
|
235
252
|
* @internal
|
|
236
253
|
* @description Synchronizes frame UI state after content changes.
|
|
@@ -33,7 +33,7 @@ import type {} from '../../typedef';
|
|
|
33
33
|
* @property {HTMLTextAreaElement} markdown - Markdown view editing element (a <textarea>).
|
|
34
34
|
* @property {HTMLTextAreaElement} markdownNumbers - Element displaying line numbers in markdown view mode.
|
|
35
35
|
* @property {HTMLElement} placeholder - Placeholder element shown when the editor is empty.
|
|
36
|
-
* @property {string} placeholder_line - Per-line placeholder text, rendered via a `::before` on the focused empty line.
|
|
36
|
+
* @property {string|Object<string, string>} placeholder_line - Per-line placeholder text, rendered via a `::before` on the focused empty line.
|
|
37
37
|
* @property {HTMLElement} statusbar - Editor status bar element (for resizing, info, etc.).
|
|
38
38
|
* @property {HTMLElement} navigation - Navigation element (e.g., for outline or bookmarks).
|
|
39
39
|
* @property {HTMLElement} charWrapper - Wrapper for the character counter element.
|
|
@@ -216,7 +216,11 @@ export type FrameContextStore = {
|
|
|
216
216
|
/**
|
|
217
217
|
* - Per-line placeholder text, rendered via a `::before` on the focused empty line.
|
|
218
218
|
*/
|
|
219
|
-
placeholder_line:
|
|
219
|
+
placeholder_line:
|
|
220
|
+
| string
|
|
221
|
+
| {
|
|
222
|
+
[x: string]: string;
|
|
223
|
+
};
|
|
220
224
|
/**
|
|
221
225
|
* - Editor status bar element (for resizing, info, etc.).
|
|
222
226
|
*/
|
|
@@ -56,8 +56,22 @@ export namespace DEFAULTS {
|
|
|
56
56
|
* === Content & Editing ===
|
|
57
57
|
* @property {string} [value=""] - Initial value for the editor.
|
|
58
58
|
* @property {string} [placeholder=""] - Placeholder text shown when the whole editor is empty.
|
|
59
|
-
* @property {string} [placeholder_line=""] - per-line placeholder shown on the focused
|
|
59
|
+
* @property {string|Object<string, string>} [placeholder_line=""] - per-line placeholder shown on the focused
|
|
60
60
|
* line when that line is empty. Takes priority over `placeholder` while a line is focused.
|
|
61
|
+
* - **string**: one hint for every empty line (list cells and table cells excluded).
|
|
62
|
+
* - **object**: per-type hints keyed by tag name (`p`, `pre`, `blockquote`, ...) or a category sentinel
|
|
63
|
+
* matching the editor's format classification: `@line`, `@normalLine`, `@list`, `@brLine`, `@closureBrLine`,
|
|
64
|
+
* `@block`, `@closureBlock`. Resolved most-specific → least, like `tagStyles`:
|
|
65
|
+
* `<tag>` → `@list` → `@closureBrLine` → `@brLine` → block container (`<blockTag>` → `@closureBlock` → `@block`)
|
|
66
|
+
* → `@normalLine` → `@line`. A missing key = no placeholder for that type; an explicit `''` suppresses it.
|
|
67
|
+
* ```js
|
|
68
|
+
* // one hint everywhere
|
|
69
|
+
* placeholder_line: 'Type something…'
|
|
70
|
+
* // per-type
|
|
71
|
+
* placeholder_line: {
|
|
72
|
+
* '@normalLine': 'Type…', '@list': 'List item', '@block': 'Quote…', '@closureBlock': 'Cell', pre: '// code'
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
61
75
|
* @property {Object<string, string>} [editableFrameAttributes={spellcheck: "false"}] - Attributes for the editable frame[.sun-editor-editable].
|
|
62
76
|
* ```js
|
|
63
77
|
* { editableFrameAttributes: { spellcheck: 'true', autocomplete: 'on' } }
|
|
@@ -403,6 +417,13 @@ export namespace DEFAULTS {
|
|
|
403
417
|
* - Formats that include `line`, such as "Quote", still operate on a `line` basis.
|
|
404
418
|
* - suneditor processes work in `line` units.
|
|
405
419
|
* - When set to `br`, performance may decrease when editing a lot of data.
|
|
420
|
+
* @property {boolean} [lineBreakClearStyle=false] - When `true`, pressing Enter at the **end** of a line
|
|
421
|
+
* starts a fresh line that does not carry the caret's inline style nodes (e.g. bold/italic/color spans, links);
|
|
422
|
+
* the line-level element and its attributes are preserved.
|
|
423
|
+
* Only affects the end-of-line case — mid-line splits, start-of-line breaks, and Shift+Enter are unchanged.
|
|
424
|
+
* ```js
|
|
425
|
+
* { lineBreakClearStyle: true }
|
|
426
|
+
* ```
|
|
406
427
|
* @property {string} [lineAttrReset=""] - Line properties that should be reset when changing lines. Delimiter: `"|"`.
|
|
407
428
|
* ```js
|
|
408
429
|
* { lineAttrReset: 'id|name' }
|
|
@@ -453,12 +474,16 @@ export namespace DEFAULTS {
|
|
|
453
474
|
* { toolbar_innerWidth: 'auto' }
|
|
454
475
|
* ```
|
|
455
476
|
* @property {?HTMLElement} [toolbar_container] - Container element for the toolbar.
|
|
456
|
-
* @property {number|{top: number, offset
|
|
477
|
+
* @property {number|{top: number, offset?: number, position?: "sticky"|"fixed"}} [toolbar_sticky=0] - Enables sticky toolbar.
|
|
457
478
|
* - `number`: Sets the sticky top position (px). Use `-1` to disable sticky.
|
|
458
479
|
* - `{top, offset}`: `top` is the sticky position when the page header is visible.
|
|
459
480
|
* - `offset` is the sticky position when a virtual keyboard shifts the viewport (e.g., on tablets, touch devices).
|
|
460
481
|
* - When the virtual keyboard is active, `offset` replaces `top` so the toolbar doesn't leave a gap
|
|
461
482
|
* - for a page header that has scrolled out of view. Default `offset` is `0`.
|
|
483
|
+
* - `position` (default `"sticky"`): the positioning engine.
|
|
484
|
+
* - `"sticky"` uses native CSS `position: sticky` (with a JS `position: fixed` fallback where unsupported).
|
|
485
|
+
* `"fixed"` forces the JS `position: fixed` engine
|
|
486
|
+
* - even when CSS sticky is supported — for environments where CSS sticky silently misbehaves and can't be
|
|
462
487
|
* ```js
|
|
463
488
|
* // Basic usage — sticky at top with 0px offset
|
|
464
489
|
* toolbar_sticky: 0
|
|
@@ -468,6 +493,9 @@ export namespace DEFAULTS {
|
|
|
468
493
|
*
|
|
469
494
|
* // 92px header on desktop, but 0px when virtual keyboard pushes the viewport
|
|
470
495
|
* toolbar_sticky: { top: 92, offset: 0 }
|
|
496
|
+
*
|
|
497
|
+
* // Force the JS position:fixed engine (CSS sticky unreliable in this environment)
|
|
498
|
+
* toolbar_sticky: { top: 0, position: 'fixed' }
|
|
471
499
|
* ```
|
|
472
500
|
* @property {boolean} [toolbar_hide=false] - Hides toolbar initially.
|
|
473
501
|
* @property {Object} [subToolbar={}] - Sub-toolbar configuration. A secondary toolbar that appears on text selection.
|
|
@@ -669,8 +697,26 @@ export type EditorFrameOptions = {
|
|
|
669
697
|
/**
|
|
670
698
|
* - per-line placeholder shown on the focused
|
|
671
699
|
* line when that line is empty. Takes priority over `placeholder` while a line is focused.
|
|
700
|
+
* - **string**: one hint for every empty line (list cells and table cells excluded).
|
|
701
|
+
* - **object**: per-type hints keyed by tag name (`p`, `pre`, `blockquote`, ...) or a category sentinel
|
|
702
|
+
* matching the editor's format classification: `@line`, `@normalLine`, `@list`, `@brLine`, `@closureBrLine`,
|
|
703
|
+
* `@block`, `@closureBlock`. Resolved most-specific → least, like `tagStyles`:
|
|
704
|
+
* `<tag>` → `@list` → `@closureBrLine` → `@brLine` → block container (`<blockTag>` → `@closureBlock` → `@block`)
|
|
705
|
+
* → `@normalLine` → `@line`. A missing key = no placeholder for that type; an explicit `''` suppresses it.
|
|
706
|
+
* ```js
|
|
707
|
+
* // one hint everywhere
|
|
708
|
+
* placeholder_line: 'Type something…'
|
|
709
|
+
* // per-type
|
|
710
|
+
* placeholder_line: {
|
|
711
|
+
* '@normalLine': 'Type…', '@list': 'List item', '@block': 'Quote…', '@closureBlock': 'Cell', pre: '// code'
|
|
712
|
+
* }
|
|
713
|
+
* ```
|
|
672
714
|
*/
|
|
673
|
-
placeholder_line?:
|
|
715
|
+
placeholder_line?:
|
|
716
|
+
| string
|
|
717
|
+
| {
|
|
718
|
+
[x: string]: string;
|
|
719
|
+
};
|
|
674
720
|
/**
|
|
675
721
|
* - Attributes for the editable frame[.sun-editor-editable].
|
|
676
722
|
* ```js
|
|
@@ -1232,6 +1278,16 @@ export type EditorBaseOptions = {
|
|
|
1232
1278
|
* - When set to `br`, performance may decrease when editing a lot of data.
|
|
1233
1279
|
*/
|
|
1234
1280
|
defaultLineBreakFormat?: 'line' | 'br';
|
|
1281
|
+
/**
|
|
1282
|
+
* - When `true`, pressing Enter at the **end** of a line
|
|
1283
|
+
* starts a fresh line that does not carry the caret's inline style nodes (e.g. bold/italic/color spans, links);
|
|
1284
|
+
* the line-level element and its attributes are preserved.
|
|
1285
|
+
* Only affects the end-of-line case — mid-line splits, start-of-line breaks, and Shift+Enter are unchanged.
|
|
1286
|
+
* ```js
|
|
1287
|
+
* { lineBreakClearStyle: true }
|
|
1288
|
+
* ```
|
|
1289
|
+
*/
|
|
1290
|
+
lineBreakClearStyle?: boolean;
|
|
1235
1291
|
/**
|
|
1236
1292
|
* - Line properties that should be reset when changing lines. Delimiter: `"|"`.
|
|
1237
1293
|
* ```js
|
|
@@ -1325,6 +1381,10 @@ export type EditorBaseOptions = {
|
|
|
1325
1381
|
* - `offset` is the sticky position when a virtual keyboard shifts the viewport (e.g., on tablets, touch devices).
|
|
1326
1382
|
* - When the virtual keyboard is active, `offset` replaces `top` so the toolbar doesn't leave a gap
|
|
1327
1383
|
* - for a page header that has scrolled out of view. Default `offset` is `0`.
|
|
1384
|
+
* - `position` (default `"sticky"`): the positioning engine.
|
|
1385
|
+
* - `"sticky"` uses native CSS `position: sticky` (with a JS `position: fixed` fallback where unsupported).
|
|
1386
|
+
* `"fixed"` forces the JS `position: fixed` engine
|
|
1387
|
+
* - even when CSS sticky is supported — for environments where CSS sticky silently misbehaves and can't be
|
|
1328
1388
|
* ```js
|
|
1329
1389
|
* // Basic usage — sticky at top with 0px offset
|
|
1330
1390
|
* toolbar_sticky: 0
|
|
@@ -1334,13 +1394,17 @@ export type EditorBaseOptions = {
|
|
|
1334
1394
|
*
|
|
1335
1395
|
* // 92px header on desktop, but 0px when virtual keyboard pushes the viewport
|
|
1336
1396
|
* toolbar_sticky: { top: 92, offset: 0 }
|
|
1397
|
+
*
|
|
1398
|
+
* // Force the JS position:fixed engine (CSS sticky unreliable in this environment)
|
|
1399
|
+
* toolbar_sticky: { top: 0, position: 'fixed' }
|
|
1337
1400
|
* ```
|
|
1338
1401
|
*/
|
|
1339
1402
|
toolbar_sticky?:
|
|
1340
1403
|
| number
|
|
1341
1404
|
| {
|
|
1342
1405
|
top: number;
|
|
1343
|
-
offset
|
|
1406
|
+
offset?: number;
|
|
1407
|
+
position?: 'sticky' | 'fixed';
|
|
1344
1408
|
};
|
|
1345
1409
|
/**
|
|
1346
1410
|
* - Hides toolbar initially.
|
|
@@ -1654,6 +1718,7 @@ export type TransformedOptionKeys =
|
|
|
1654
1718
|
| 'toolbar_container'
|
|
1655
1719
|
| '_toolbar_sticky'
|
|
1656
1720
|
| '_toolbar_sticky_offset'
|
|
1721
|
+
| '_toolbar_sticky_fixed'
|
|
1657
1722
|
| 'strictMode'
|
|
1658
1723
|
| 'lineAttrReset';
|
|
1659
1724
|
export type StrictModeOptions = {
|
|
@@ -1707,6 +1772,7 @@ export type TransformedOptions = {
|
|
|
1707
1772
|
toolbar_container: HTMLElement | null;
|
|
1708
1773
|
_toolbar_sticky: number;
|
|
1709
1774
|
_toolbar_sticky_offset: number;
|
|
1775
|
+
_toolbar_sticky_fixed: boolean;
|
|
1710
1776
|
strictMode: StrictModeOptions;
|
|
1711
1777
|
lineAttrReset: string[];
|
|
1712
1778
|
};
|