ckeditor5-elements-core 49.0.0-alpha.2 → 49.0.0-alpha.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.
@@ -1,118 +0,0 @@
1
- import { DropdownMenuRootListView, ListSeparatorView } from 'ckeditor5';
2
- import {} from './elementMenu.js';
3
- import { bindButtonToCommand } from './elementOrPositionButtonView.js';
4
- import ElementOrPositionCommand, {} from './elementOrPositionCommand.js';
5
- /**
6
- * The menu of an element: CKEditor's dropdown menu (`DropdownMenuRootListView`), built from commands, submenus and
7
- * separators.
8
- *
9
- * CKEditor builds the menu and handles it: the nested menus (opened on click, hover, or the right arrow; placed where
10
- * they fit), the keyboard, and right-to-left languages. This view only connects the buttons to the commands: they
11
- * reflect the command title, icon and {@link ElementOrPositionCommand#getState state} for the target, and execute the
12
- * command for it. It also adds the separators, which CKEditor's menu definitions do not have.
13
- *
14
- * Submenus are enabled when one of their items is. Right-clicking the menu does not open the native context menu.
15
- */
16
- export default class ElementMenuView extends DropdownMenuRootListView {
17
- /**
18
- * The element or position the commands are executed for.
19
- */
20
- target;
21
- _commands;
22
- _submenus;
23
- /**
24
- * The positions of the separators in each list, by the id of the submenu (`''` for the menu itself).
25
- */
26
- _separators;
27
- constructor(locale, bodyCollection, items, target) {
28
- const maps = { commands: new Map(), submenus: new Map(), separators: new Map() };
29
- super(locale, bodyCollection, createDefinitions(items, '', maps));
30
- this.target = target;
31
- this._commands = maps.commands;
32
- this._submenus = maps.submenus;
33
- this._separators = maps.separators;
34
- this.menuPanelClass = 'ck-elements-menu__panel';
35
- this.extendTemplate({
36
- attributes: { class: 'ck-elements-menu' },
37
- on: { contextmenu: this.bindTemplate.to(preventDefault) }
38
- });
39
- }
40
- /**
41
- * Renders the menu: CKEditor builds it from the definitions; then the buttons are connected to the commands, and the
42
- * separators are added.
43
- */
44
- render() {
45
- super.render();
46
- for (const button of this.buttons) {
47
- const command = this._commands.get(button.id);
48
- if (command) {
49
- bindButtonToCommand(button, command, { withText: true, target: this.target });
50
- // A toggleable button with a checkable role tells assistive technology whether it is "on" with `aria-checked`.
51
- button.role = command.isToggleable ? 'menuitemcheckbox' : 'menuitem';
52
- }
53
- }
54
- for (const menu of this.menus) {
55
- const submenu = this._submenus.get(menu.id);
56
- if (submenu) {
57
- menu.buttonView.icon = submenu.icon;
58
- menu.isEnabled = this._isEnabled(submenu);
59
- }
60
- // The panels of nested menus are not inside the menu.
61
- if (menu.panelView.element) {
62
- this.listenTo(menu.panelView.element, 'contextmenu', (evt, domEvent) => {
63
- preventDefault(domEvent);
64
- });
65
- }
66
- }
67
- this._addSeparators('', this);
68
- for (const menu of this.menus) {
69
- this._addSeparators(menu.id, menu.listView);
70
- }
71
- }
72
- _addSeparators(id, list) {
73
- for (const position of this._separators.get(id) ?? []) {
74
- const separator = new ListSeparatorView(this.locale);
75
- separator.extendTemplate({ attributes: { role: 'separator' } });
76
- list.items.add(separator, position);
77
- }
78
- }
79
- _isEnabled(item) {
80
- if (item === '|') {
81
- return false;
82
- }
83
- return item instanceof ElementOrPositionCommand
84
- ? item.getState(this.target).isEnabled
85
- : item.items.some(child => !!child && this._isEnabled(child));
86
- }
87
- }
88
- /**
89
- * Creates CKEditor's menu definitions for the items. The ids are paths of positions (e.g. `'2.0'`). Collects the
90
- * commands and submenus by id, and the positions of the separators by the id of their submenu.
91
- */
92
- function createDefinitions(items, parentId, maps) {
93
- const definitions = [];
94
- let position = 0;
95
- for (const item of items) {
96
- const id = parentId ? `${parentId}.${String(position)}` : String(position);
97
- if (!item) {
98
- continue;
99
- }
100
- if (item === '|') {
101
- maps.separators.set(parentId, [...(maps.separators.get(parentId) ?? []), position]);
102
- }
103
- else if (item instanceof ElementOrPositionCommand) {
104
- maps.commands.set(id, item);
105
- definitions.push({ id, label: item.title });
106
- }
107
- else {
108
- maps.submenus.set(id, item);
109
- definitions.push({ id, menu: item.title, children: createDefinitions(item.items, id, maps) });
110
- }
111
- position++;
112
- }
113
- return definitions;
114
- }
115
- function preventDefault(domEvent) {
116
- domEvent.preventDefault();
117
- }
118
- //# sourceMappingURL=elementMenuView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"elementMenuView.js","sourceRoot":"","sources":["../src/elementMenuView.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,iBAAiB,EAKjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAA6C,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,wBAAwB,EAAE,EAA0B,MAAM,+BAA+B,CAAC;AAEjG;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,wBAAwB;IACpE;;OAEG;IACa,MAAM,CAAoB;IAEzB,SAAS,CAAwC;IACjD,SAAS,CAA8B;IAExD;;OAEG;IACc,WAAW,CAAwB;IAEpD,YACC,MAAc,EACd,cAA8B,EAC9B,KAAsD,EACtD,MAAyB;QAEzB,MAAM,IAAI,GAAmB,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;QAEjG,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,iBAAiB,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;QAElE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,yBAAyB,CAAC;QAEhD,IAAI,CAAC,cAAc,CAAC;YACnB,UAAU,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE;YACzC,EAAE,EAAE,EAAE,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AQ,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE3E,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,SAAS;QACV,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;QACrF,CAAC;aAAM,IAAI,IAAI,YAAY,wBAAwB,EAAE,CAAC;YACrD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YAC5B,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YAC5B,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;QAED,QAAQ,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,QAAe;IACtC,QAAQ,CAAC,cAAc,EAAE,CAAC;AAC3B,CAAC"}
@@ -1,8 +0,0 @@
1
- import { ListSeparatorView, type Locale } from 'ckeditor5';
2
- /**
3
- * A line between groups of menu items: CKEditor's list separator, with the `separator` role.
4
- */
5
- export default class MenuSeparatorView extends ListSeparatorView {
6
- constructor(locale?: Locale);
7
- }
8
- //# sourceMappingURL=menuSeparatorView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menuSeparatorView.d.ts","sourceRoot":"","sources":["../src/menuSeparatorView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,iBAAiB;gBACnD,MAAM,CAAC,EAAE,MAAM;CAU3B"}
@@ -1,16 +0,0 @@
1
- import { ListSeparatorView } from 'ckeditor5';
2
- /**
3
- * A line between groups of menu items: CKEditor's list separator, with the `separator` role.
4
- */
5
- export default class MenuSeparatorView extends ListSeparatorView {
6
- constructor(locale) {
7
- super(locale);
8
- this.extendTemplate({
9
- attributes: {
10
- class: 'ck-elements-menu__separator',
11
- role: 'separator'
12
- }
13
- });
14
- }
15
- }
16
- //# sourceMappingURL=menuSeparatorView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menuSeparatorView.js","sourceRoot":"","sources":["../src/menuSeparatorView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,WAAW,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,iBAAiB;IAC/D,YAAY,MAAe;QAC1B,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,cAAc,CAAC;YACnB,UAAU,EAAE;gBACX,KAAK,EAAE,6BAA6B;gBACpC,IAAI,EAAE,WAAW;aACjB;SACD,CAAC,CAAC;IACJ,CAAC;CACD"}
@@ -1,68 +0,0 @@
1
- import { DropdownMenuButtonView, DropdownMenuNestedMenuPanelView, KeystrokeHandler, View, type BodyCollection, type Locale } from 'ckeditor5';
2
- import ElementMenuView, { type ElementMenuViewItem } from './elementMenuView.js';
3
- /**
4
- * A menu item that opens a nested menu next to it, built of CKEditor's nested menu parts: a
5
- * `DropdownMenuButtonView` (with an arrow, `aria-haspopup` and `aria-expanded`) and a `DropdownMenuNestedMenuPanelView`.
6
- *
7
- * The panel is added to the editor's body collection while the nested menu is open, so it is not clipped by the menu.
8
- * It is placed next to the item, on the side where it fits (in right-to-left languages, preferably on the left).
9
- *
10
- * Clicking the item, hovering it, or pressing the right arrow (left in right-to-left languages) opens the nested menu;
11
- * the opposite arrow or Esc closes it. When one of the nested items fires `execute`, the submenu fires `execute` too,
12
- * so the whole menu can close.
13
- */
14
- export default class SubmenuView extends View {
15
- /**
16
- * The item that opens the nested menu.
17
- */
18
- readonly buttonView: DropdownMenuButtonView;
19
- /**
20
- * The panel of the nested menu.
21
- */
22
- readonly panelView: DropdownMenuNestedMenuPanelView;
23
- /**
24
- * The nested menu, in the {@link panelView}.
25
- */
26
- readonly listView: ElementMenuView;
27
- /**
28
- * Handles the keystrokes within the submenu and its panel.
29
- */
30
- readonly keystrokes: KeystrokeHandler;
31
- /**
32
- * Whether the nested menu is open.
33
- *
34
- * @observable
35
- */
36
- isOpen: boolean;
37
- private readonly _bodyCollection;
38
- constructor(locale: Locale, bodyCollection: BodyCollection, label: string, items: ElementMenuViewItem[], { icon }?: {
39
- icon?: string;
40
- });
41
- /**
42
- * Renders the submenu and its panel, and sets up the keystrokes that open and close the nested menu.
43
- */
44
- render(): void;
45
- /**
46
- * Opens the nested menu and focuses its first item.
47
- */
48
- open(): void;
49
- /**
50
- * Closes the nested menu and focuses the item that opens it.
51
- */
52
- close(): void;
53
- /**
54
- * Focuses the item that opens the nested menu.
55
- */
56
- focus(): void;
57
- /**
58
- * Destroys the submenu, its panel and keystroke handler.
59
- */
60
- destroy(): void;
61
- /**
62
- * The positions of the panel, in the order they are tried: as in CKEditor's nested dropdown menus.
63
- */
64
- private get _panelPositions();
65
- private _addPanelToBody;
66
- private _removePanelFromBody;
67
- }
68
- //# sourceMappingURL=submenuView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"submenuView.d.ts","sourceRoot":"","sources":["../src/submenuView.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EACtB,+BAA+B,EAE/B,gBAAgB,EAChB,IAAI,EACJ,KAAK,cAAc,EACnB,KAAK,MAAM,EAEX,MAAM,WAAW,CAAC;AACnB,OAAO,eAAe,EAAE,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,IAAI;IAC5C;;OAEG;IACH,SAAgB,UAAU,EAAE,sBAAsB,CAAC;IAEnD;;OAEG;IACH,SAAgB,SAAS,EAAE,+BAA+B,CAAC;IAE3D;;OAEG;IACH,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAE1C;;OAEG;IACH,SAAgB,UAAU,mBAA0B;IAEpD;;;;OAIG;IACY,MAAM,EAAE,OAAO,CAAC;IAE/B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;gBAGhD,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,mBAAmB,EAAE,EAC5B,EAAE,IAAI,EAAE,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO;IAkDjC;;OAEG;IACa,MAAM,IAAI,IAAI;IA4B9B;;OAEG;IACI,IAAI,IAAI,IAAI;IAKnB;;OAEG;IACI,KAAK,IAAI,IAAI;IAKpB;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;OAEG;IACa,OAAO,IAAI,IAAI;IAO/B;;OAEG;IACH,OAAO,KAAK,eAAe,GAM1B;IAED,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,oBAAoB;CAS5B"}
@@ -1,159 +0,0 @@
1
- import { DropdownMenuButtonView, DropdownMenuNestedMenuPanelView, DropdownMenuPanelPositioningFunctions, KeystrokeHandler, View } from 'ckeditor5';
2
- import ElementMenuView, {} from './elementMenuView.js';
3
- /**
4
- * A menu item that opens a nested menu next to it, built of CKEditor's nested menu parts: a
5
- * `DropdownMenuButtonView` (with an arrow, `aria-haspopup` and `aria-expanded`) and a `DropdownMenuNestedMenuPanelView`.
6
- *
7
- * The panel is added to the editor's body collection while the nested menu is open, so it is not clipped by the menu.
8
- * It is placed next to the item, on the side where it fits (in right-to-left languages, preferably on the left).
9
- *
10
- * Clicking the item, hovering it, or pressing the right arrow (left in right-to-left languages) opens the nested menu;
11
- * the opposite arrow or Esc closes it. When one of the nested items fires `execute`, the submenu fires `execute` too,
12
- * so the whole menu can close.
13
- */
14
- export default class SubmenuView extends View {
15
- /**
16
- * The item that opens the nested menu.
17
- */
18
- buttonView;
19
- /**
20
- * The panel of the nested menu.
21
- */
22
- panelView;
23
- /**
24
- * The nested menu, in the {@link panelView}.
25
- */
26
- listView;
27
- /**
28
- * Handles the keystrokes within the submenu and its panel.
29
- */
30
- keystrokes = new KeystrokeHandler();
31
- _bodyCollection;
32
- constructor(locale, bodyCollection, label, items, { icon } = {}) {
33
- super(locale);
34
- this._bodyCollection = bodyCollection;
35
- this.set('isOpen', false);
36
- this.buttonView = new DropdownMenuButtonView(locale);
37
- this.buttonView.set({ label, icon });
38
- this.buttonView.bind('isOn').to(this, 'isOpen');
39
- this.buttonView.extendTemplate({ attributes: { class: 'ck-elements-submenu__button' } });
40
- // Only opens, as in CKEditor's menus: hovering the item has opened it already when it is clicked.
41
- this.buttonView.on('execute', () => {
42
- this.open();
43
- });
44
- this.listView = new ElementMenuView(locale, { label });
45
- this.listView.addItems(items);
46
- this.listView.on('cancel', () => {
47
- this.close();
48
- });
49
- this.panelView = new DropdownMenuNestedMenuPanelView(locale);
50
- this.panelView.isVisible = true;
51
- this.panelView.extendTemplate({ attributes: { class: 'ck-elements-submenu__panel' } });
52
- this.panelView.content.add(this.listView);
53
- for (const item of items) {
54
- item.delegate('execute').to(this);
55
- }
56
- this.on('change:isOpen', (evt, name, isOpen) => {
57
- if (isOpen) {
58
- this._addPanelToBody();
59
- }
60
- else {
61
- this._removePanelFromBody();
62
- }
63
- });
64
- this.setTemplate({
65
- tag: 'div',
66
- attributes: {
67
- class: ['ck', 'ck-elements-submenu', 'ck-dropdown-menu-list__nested-menu'],
68
- role: 'presentation'
69
- },
70
- children: [this.buttonView]
71
- });
72
- }
73
- /**
74
- * Renders the submenu and its panel, and sets up the keystrokes that open and close the nested menu.
75
- */
76
- render() {
77
- super.render();
78
- this.panelView.render();
79
- const isRtl = this.locale?.uiLanguageDirection === 'rtl';
80
- // The panel is not inside the submenu, so its keystrokes do not bubble up to it.
81
- for (const element of [this.element, this.panelView.element]) {
82
- if (element) {
83
- this.keystrokes.listenTo(element);
84
- }
85
- }
86
- this.keystrokes.set(isRtl ? 'arrowleft' : 'arrowright', (data, cancel) => {
87
- if (document.activeElement === this.buttonView.element) {
88
- this.open();
89
- cancel();
90
- }
91
- });
92
- this.keystrokes.set(isRtl ? 'arrowright' : 'arrowleft', (data, cancel) => {
93
- if (this.isOpen && this.panelView.element?.contains(document.activeElement)) {
94
- this.close();
95
- cancel();
96
- }
97
- });
98
- }
99
- /**
100
- * Opens the nested menu and focuses its first item.
101
- */
102
- open() {
103
- this.isOpen = true;
104
- this.listView.focus();
105
- }
106
- /**
107
- * Closes the nested menu and focuses the item that opens it.
108
- */
109
- close() {
110
- this.isOpen = false;
111
- this.buttonView.focus();
112
- }
113
- /**
114
- * Focuses the item that opens the nested menu.
115
- */
116
- focus() {
117
- this.buttonView.focus();
118
- }
119
- /**
120
- * Destroys the submenu, its panel and keystroke handler.
121
- */
122
- destroy() {
123
- this._removePanelFromBody();
124
- super.destroy();
125
- this.panelView.destroy();
126
- this.keystrokes.destroy();
127
- }
128
- /**
129
- * The positions of the panel, in the order they are tried: as in CKEditor's nested dropdown menus.
130
- */
131
- get _panelPositions() {
132
- const { eastSouth, eastNorth, westSouth, westNorth } = DropdownMenuPanelPositioningFunctions;
133
- return this.locale?.uiLanguageDirection === 'rtl'
134
- ? [westSouth, westNorth, eastSouth, eastNorth]
135
- : [eastSouth, eastNorth, westSouth, westNorth];
136
- }
137
- _addPanelToBody() {
138
- if (!this._bodyCollection.has(this.panelView)) {
139
- this._bodyCollection.add(this.panelView);
140
- }
141
- if (this.buttonView.element) {
142
- this.panelView.pin({
143
- target: this.buttonView.element,
144
- positions: this._panelPositions,
145
- limiter: document.body,
146
- fitInViewport: true
147
- });
148
- }
149
- }
150
- _removePanelFromBody() {
151
- // Nested submenus close with their parent.
152
- this.listView.closeSubmenus();
153
- if (this._bodyCollection.has(this.panelView)) {
154
- this.panelView.unpin();
155
- this._bodyCollection.remove(this.panelView);
156
- }
157
- }
158
- }
159
- //# sourceMappingURL=submenuView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"submenuView.js","sourceRoot":"","sources":["../src/submenuView.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EACtB,+BAA+B,EAC/B,qCAAqC,EACrC,gBAAgB,EAChB,IAAI,EAIJ,MAAM,WAAW,CAAC;AACnB,OAAO,eAAe,EAAE,EAA4B,MAAM,sBAAsB,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,IAAI;IAC5C;;OAEG;IACa,UAAU,CAAyB;IAEnD;;OAEG;IACa,SAAS,CAAkC;IAE3D;;OAEG;IACa,QAAQ,CAAkB;IAE1C;;OAEG;IACa,UAAU,GAAG,IAAI,gBAAgB,EAAE,CAAC;IASnC,eAAe,CAAiB;IAEjD,YACC,MAAc,EACd,cAA8B,EAC9B,KAAa,EACb,KAA4B,EAC5B,EAAE,IAAI,KAAwB,EAAE;QAEhC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAE1B,IAAI,CAAC,UAAU,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE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