@blocklet/editor 2.3.2 → 2.3.3

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.
@@ -28,7 +28,7 @@ export default function AlertComponent({ text, severity, onChange }) {
28
28
  setEditing(true);
29
29
  }
30
30
  };
31
- return (_jsxs(Alert, { severity: severity, icon: false, sx: { '.MuiAlert-message': { width: '100%' } }, children: [!editing && (_jsx(Box, { onClick: edit, sx: { ...(!text && { height: '1em' }) }, children: text })), editing && (_jsx(Box, { component: "input", type: "text", value: value, onClick: (e) => e.stopPropagation(), onChange: (e) => setValue(e.target.value), onBlur: handleChange, onKeyDown: (e) => {
31
+ return (_jsxs(Alert, { severity: severity, sx: { '.MuiAlert-message': { width: '100%' } }, children: [!editing && (_jsx(Box, { onClick: edit, sx: { ...(!text && { height: '1em' }) }, children: text })), editing && (_jsx(Box, { component: "input", type: "text", value: value, onClick: (e) => e.stopPropagation(), onChange: (e) => setValue(e.target.value), onBlur: handleChange, onKeyDown: (e) => {
32
32
  if (e.key === 'Enter') {
33
33
  e.preventDefault();
34
34
  e.stopPropagation();
@@ -0,0 +1,3 @@
1
+ export declare const icons: {
2
+ [key: string]: string;
3
+ };
@@ -0,0 +1,25 @@
1
+ export const icons = {
2
+ paragraph: 'tabler:letter-case',
3
+ h1: 'tabler:h-1',
4
+ h2: 'tabler:h-2',
5
+ h3: 'tabler:h-3',
6
+ bullet: 'tabler:list',
7
+ number: 'tabler:list-numbers',
8
+ check: 'tabler:list-details',
9
+ quote: 'tabler:quote',
10
+ code: 'tabler:code',
11
+ alignLeft: 'tabler:align-left',
12
+ alignCenter: 'tabler:align-center',
13
+ alignRight: 'tabler:align-right',
14
+ alignJustify: 'tabler:align-justified',
15
+ table: 'tabler:table',
16
+ divider: 'tabler:separator',
17
+ alert: 'tabler:alert-circle',
18
+ media: 'tabler:photo-plus',
19
+ template: 'tabler:template',
20
+ collapsible: 'tabler:layout-sidebar-right-collapse',
21
+ copy: 'tabler:copy',
22
+ copySuccess: 'tabler:check',
23
+ brandX: 'tabler:brand-x',
24
+ brandFigma: 'tabler:brand-figma',
25
+ };
@@ -0,0 +1,3 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M17.9643 15.1993C17.9502 15.1865 17.9331 15.1775 17.9145 15.1733C17.896 15.1691 17.8767 15.1698 17.8585 15.1753C17.0221 13.937 15.9582 12.7627 14.9283 11.6285L14.7586 11.4424C14.7586 11.4204 14.7486 11.4004 14.7347 11.3824C14.7178 11.3611 14.6936 11.3468 14.6668 11.3424L14.6329 11.3064L14.6089 11.2884C14.579 11.2244 14.5031 11.1764 14.4193 11.2184C14.1039 11.3804 13.8205 11.6125 13.541 11.8265C13.1678 12.1126 12.8025 12.4107 12.4592 12.7307C12.3195 12.8608 12.1817 12.9968 12.066 13.1488C12.0101 13.2229 12.052 13.2929 12.1199 13.3229C11.8763 13.5629 11.6308 13.813 11.3853 14.0711C11.3634 14.0951 11.3514 14.1271 11.3534 14.1591C11.3554 14.1911 11.3713 14.2211 11.3973 14.2411L11.8284 14.5712C11.8284 14.5712 11.8304 14.5772 11.8344 14.5792C12.4512 15.1893 13.533 16.0355 14.6788 16.9317C14.8484 17.0658 15.0201 17.1998 15.1918 17.3338C15.2696 17.4279 15.3435 17.5219 15.4153 17.6139C15.4532 17.6639 15.5251 17.6739 15.575 17.6359C15.6009 17.6559 15.6269 17.6779 15.6528 17.6979C15.6646 17.7071 15.6781 17.7139 15.6925 17.7179C15.7069 17.7218 15.722 17.7229 15.7368 17.7211C15.7516 17.7192 15.766 17.7145 15.779 17.707C15.7919 17.6996 15.8033 17.6897 15.8125 17.6779C15.8265 17.6599 15.8325 17.6379 15.8345 17.6159C15.8425 17.6159 15.8485 17.6219 15.8544 17.6219C15.8844 17.6219 15.9163 17.6099 15.9383 17.5859L17.9702 15.3614C17.9804 15.3504 17.9882 15.3375 17.9933 15.3235C17.9984 15.3095 18.0006 15.2946 17.9999 15.2797C17.9991 15.2648 17.9954 15.2501 17.9889 15.2367C17.9825 15.2232 17.9734 15.2112 17.9623 15.2013L17.9643 15.1993ZM12.1298 14.4291C12.1438 14.4471 12.1578 14.4632 12.1717 14.4792C12.4033 14.6752 12.6508 14.8873 12.9023 15.1033L11.8803 14.3211C11.8803 14.3211 11.8165 14.2771 11.7765 14.2491C11.7546 14.2331 11.7346 14.2171 11.7147 14.2011L11.6388 14.1371C11.6388 14.1371 11.6528 14.1231 11.6588 14.1151L11.7286 14.0451C12.0719 13.697 12.6608 13.1168 12.9642 12.8328C12.6428 13.1568 11.9921 14.1071 12.1318 14.4291H12.1298ZM15.6289 17.1918L14.7866 16.5477C14.4572 16.2056 14.1019 15.8675 13.7406 15.5414C14.1957 15.8935 14.585 16.1916 14.6428 16.2436C15.084 16.6377 15.064 16.5657 15.3674 16.8257L15.7327 17.0918C15.6968 17.1238 15.6608 17.1578 15.6269 17.1898L15.6289 17.1918ZM15.8405 17.3538L15.8245 17.3418C15.8564 17.3158 15.8904 17.2918 15.9223 17.2658L15.8425 17.3538H15.8405ZM2.48097 4.29073C2.50892 4.43476 2.53487 4.57679 2.56082 4.71283C2.69854 5.453 2.82629 6.11916 3.06981 6.62528L3.16562 7.00938C3.20354 7.15541 3.25743 7.33745 3.30733 7.37546C3.87621 7.87958 4.74848 8.63176 5.68063 9.33993C5.72254 9.37194 5.78043 9.36994 5.82035 9.33793C5.82235 9.34193 5.82634 9.34393 5.82833 9.34593C5.85029 9.36594 5.87624 9.37594 5.90418 9.37594C5.93612 9.37594 5.96606 9.36394 5.98802 9.33793C7.18165 8.00761 8.06989 6.91335 8.70263 5.99713C8.74255 5.94712 8.76251 5.88911 8.76051 5.82909C8.80044 5.78108 8.84235 5.73307 8.88028 5.69306C8.89183 5.68118 8.90059 5.66686 8.90592 5.65116C8.91126 5.63546 8.91304 5.61876 8.91112 5.60228C8.90921 5.58581 8.90366 5.56996 8.89487 5.55591C8.88608 5.54185 8.87428 5.52993 8.86032 5.52102C8.85787 5.49374 8.84585 5.46822 8.82638 5.449C8.54893 5.18094 8.34334 4.98689 8.13576 4.79285C7.76848 4.44876 7.38924 4.09268 6.58483 3.29049C6.58084 3.28649 6.57485 3.28249 6.57086 3.27848C6.55865 3.26579 6.5436 3.25619 6.52695 3.25048C6.30539 3.17246 5.85029 3.09444 5.27743 2.99442C4.4351 2.85038 3.28139 2.65033 2.24345 2.34026H2.23546V2.33826C2.23546 2.33826 2.23147 2.33826 2.22947 2.34226H2.22748L2.23546 2.33826C2.23546 2.33826 2.17358 2.34026 2.16161 2.34626C2.14564 2.35426 2.13366 2.36427 2.12368 2.37627C2.1137 2.38827 2.10572 2.40028 2.02987 2.41628C1.95402 2.43228 2.04584 2.41628 2.05183 2.41628H2.02987V2.42228C2.04384 2.4903 2.03985 2.53831 2.06181 2.61633C2.05781 2.63633 2.10372 2.82038 2.10971 2.83838L2.47499 4.29073H2.48097ZM8.65872 5.59904C8.65872 5.59904 8.65273 5.60704 8.65073 5.60904L8.52299 5.46701C8.5669 5.50902 8.61081 5.55103 8.65872 5.59904ZM7.24353 7.47749C7.24353 7.47749 7.22955 7.49349 7.22356 7.50149L7.21957 7.49749C7.22756 7.49149 7.23554 7.48349 7.24552 7.47749H7.24353ZM6.43513 3.45653C6.50499 3.52654 6.78244 3.78661 6.84631 3.85062C6.55689 3.71859 5.83632 3.38251 5.50098 3.27448C5.83033 3.3325 6.28543 3.40651 6.43513 3.45653ZM2.60672 2.90239C2.77439 3.19046 2.90613 4.2007 3.03787 5.18294C2.96402 4.86686 2.90014 4.55879 2.84026 4.26272C2.73647 3.7506 2.64066 3.29249 2.50692 2.88639C2.53487 2.88839 2.5688 2.89239 2.60473 2.89639C2.60473 2.89839 2.60473 2.90039 2.60872 2.90239H2.60672ZM2.54884 2.66034C2.50293 2.65634 2.46101 2.65234 2.42508 2.65033C2.42109 2.64233 2.4191 2.63433 2.4171 2.62633L2.54884 2.66234V2.66034ZM17.7826 2.5143C17.7906 2.46829 17.5631 2.26624 17.6349 2.26224C17.8046 2.25424 17.8066 1.99218 17.6349 2.00018C17.4094 2.01218 17.1818 2.06419 16.9622 2.1062C16.567 2.18022 16.1738 2.26224 15.7806 2.34826C14.9043 2.53631 14.0301 2.73435 13.1658 2.97041C12.8943 3.04443 12.5949 3.11044 12.3454 3.24248C12.2616 3.28649 12.2656 3.37651 12.3115 3.43252C12.2935 3.44252 12.2755 3.44853 12.2556 3.45053C12.1817 3.46453 12.1079 3.47653 12.034 3.48853C12.0156 3.49149 11.9982 3.49897 11.9833 3.51032C11.9685 3.52168 11.9567 3.53654 11.949 3.55358C11.9412 3.57063 11.9379 3.58932 11.9391 3.60799C11.9404 3.62666 11.9462 3.64473 11.9562 3.66058C11.4931 4.28072 10.9661 4.94888 10.3953 5.65105C9.83438 6.2932 9.25154 6.97737 8.65473 7.67953C6.77645 9.89206 4.64668 12.4007 2.28736 14.6092C2.24145 14.6512 2.23945 14.7232 2.28137 14.7692C2.29135 14.7812 2.30532 14.7892 2.3193 14.7952C2.28736 14.8252 2.25542 14.8552 2.22349 14.8833C2.20352 14.9013 2.19554 14.9233 2.19155 14.9473C2.17558 14.9633 2.15961 14.9813 2.14564 14.9973C2.10372 15.0433 2.10572 15.1153 2.15163 15.1573C2.19754 15.1993 2.26939 15.1973 2.31131 15.1513C2.31929 15.1433 2.32728 15.1333 2.33526 15.1253C2.35093 15.1087 2.36981 15.0955 2.39074 15.0865C2.41168 15.0775 2.43423 15.0728 2.45702 15.0728C2.47981 15.0728 2.50236 15.0775 2.5233 15.0865C2.54423 15.0955 2.56311 15.1087 2.57878 15.1253C2.71651 15.2733 2.84625 15.4134 2.96801 15.5434L2.69255 15.3134C2.66948 15.2941 2.63975 15.2848 2.60983 15.2874C2.57992 15.29 2.55226 15.3044 2.53287 15.3274C2.49295 15.3754 2.49894 15.4474 2.54684 15.4874L5.50497 17.974C5.52693 17.992 5.55288 18 5.57883 18C5.60877 18 5.63671 17.988 5.65867 17.966L5.73053 17.894C5.75142 17.9034 5.77468 17.9061 5.79717 17.9018C5.81966 17.8975 5.84029 17.8864 5.85628 17.87C9.86632 13.833 13.0959 10.7823 16.7946 8.05562C16.8285 8.03162 16.8445 7.99161 16.8405 7.9536C16.8623 7.95122 16.8829 7.94258 16.8999 7.92875C16.9169 7.91491 16.9295 7.89645 16.9363 7.87558C17.6189 5.78308 17.7507 3.93064 17.7906 3.02042C17.7906 3.01442 17.7926 3.01042 17.7946 3.00642C17.7986 2.99642 17.8006 2.98641 17.8026 2.97841C17.8086 2.95641 17.8126 2.9404 17.8126 2.9404C17.8645 2.78437 17.8465 2.63433 17.7826 2.5103V2.5143ZM10.6128 5.78908C10.7925 5.58303 10.9701 5.38099 11.1458 5.18494C9.99606 6.7013 8.09184 9.03786 5.39519 11.8145C7.23155 9.77804 9.08188 7.66753 10.6128 5.78908ZM4.11573 16.3536L4.10974 16.3476C4.1317 16.3516 4.14767 16.3556 4.14966 16.3556C4.13845 16.3535 4.12695 16.3535 4.11573 16.3556V16.3536ZM5.493 17.6379L5.48302 17.6299L5.48901 17.6239C5.493 17.6239 5.49499 17.6279 5.49699 17.6279C5.49699 17.6319 5.493 17.6339 5.491 17.6379H5.493ZM7.16169 16.1956L7.43714 15.9075C7.43914 15.9095 7.44113 15.9135 7.44313 15.9175C7.34932 16.0095 7.2555 16.1035 7.15969 16.1956H7.16169ZM7.6088 15.7535C7.6607 15.6934 7.72058 15.6234 7.78246 15.5494C7.78445 15.5474 7.78645 15.5434 7.79044 15.5414C8.44714 14.8633 9.12379 14.1771 9.82241 13.4909C9.8264 13.4869 9.83239 13.4829 9.83638 13.4789C10.008 13.3469 10.1997 13.2009 10.3793 13.0628C9.47709 13.927 8.56091 14.8192 7.6088 15.7555V15.7535ZM11.9302 4.57479C11.559 5.05891 11.1518 5.68706 10.8065 6.18918C9.71662 7.77156 6.20758 11.6465 6.12973 11.7205C5.58881 12.2446 3.95804 13.813 2.91811 14.7952C2.89016 14.8212 2.86821 14.8432 2.85024 14.8653C2.8357 14.8501 2.8243 14.8322 2.81672 14.8126C2.80914 14.7929 2.80552 14.772 2.80608 14.751C2.80664 14.7299 2.81136 14.7092 2.81996 14.69C2.82857 14.6709 2.8409 14.6536 2.85623 14.6392C7.8104 9.95808 10.8164 6.05915 12.038 4.36074C12.0121 4.42676 11.9901 4.49878 11.9282 4.57879L11.9302 4.57479ZM15.2257 5.99513L15.2237 5.99913C15.2237 5.99513 15.2197 5.98513 15.2257 5.99513ZM13.8684 6.85934C13.4173 6.59728 13.2057 6.20518 13.3275 5.80909L13.3654 5.67706C13.3813 5.63905 13.3993 5.60104 13.4213 5.56303C13.539 5.36698 13.7187 5.19294 13.9243 5.09092C13.9343 5.08692 13.9442 5.08492 13.9542 5.08292C13.9437 5.05553 13.9409 5.02576 13.9462 4.99689C13.9562 4.93488 13.9961 4.88087 14.078 4.88087C14.2117 4.88087 14.6269 5.0049 14.7846 5.14093C14.8325 5.17894 14.8784 5.22095 14.9203 5.26696C14.9802 5.33698 15.068 5.451 15.1119 5.53302C15.1379 5.54503 15.1578 5.65705 15.1878 5.71507C15.2157 5.80709 15.2277 5.90111 15.2237 5.99513C15.2237 5.99913 15.2237 5.99913 15.2257 6.00113C15.2197 6.01514 15.2257 6.07515 15.2177 6.08115C15.1977 6.22519 15.1458 6.36722 15.068 6.49125C15.06 6.50125 15.054 6.51326 15.046 6.52326C15.046 6.52526 15.0421 6.52726 15.0401 6.53126C14.9802 6.61728 14.9103 6.6973 14.8245 6.75731C14.573 6.93536 14.2796 6.98937 13.9861 6.91535C13.9474 6.90056 13.9095 6.88387 13.8724 6.86534L13.8684 6.85934ZM17.1159 6.53326C17.0181 6.94336 16.8984 7.37146 16.7566 7.80957C16.7507 7.82557 16.7507 7.84157 16.7507 7.85558C16.7307 7.85758 16.7127 7.86558 16.6968 7.87758C15.8105 8.52974 14.9542 9.2019 14.1059 9.90006C14.8385 9.23591 15.581 8.57575 16.3475 7.90959C16.5695 7.71616 16.7183 7.45192 16.7686 7.16141L16.8804 6.48725L16.8864 6.46725C16.9363 6.32521 17.1539 6.38723 17.1199 6.53326H17.1159Z" fill="#71717B" style="fill:#71717B;fill:color(display-p3 0.4431 0.4431 0.4824);fill-opacity:1;"/>
3
+ </svg>
@@ -138,7 +138,7 @@
138
138
  list-style: none;
139
139
  margin: 0;
140
140
  border-radius: 8px;
141
- max-height: 200px;
141
+ max-height: 280px;
142
142
  overflow-y: scroll;
143
143
  }
144
144
 
@@ -149,6 +149,7 @@
149
149
  .typeahead-popover ul {
150
150
  -ms-overflow-style: none;
151
151
  scrollbar-width: none;
152
+ padding: 8px 0;
152
153
  }
153
154
 
154
155
  .typeahead-popover ul li {
@@ -157,7 +158,6 @@
157
158
  font-size: 14px;
158
159
  outline: none;
159
160
  cursor: pointer;
160
- border-radius: 8px;
161
161
  }
162
162
 
163
163
  .typeahead-popover ul li.selected {
@@ -176,7 +176,6 @@
176
176
  flex-direction: row;
177
177
  flex-shrink: 0;
178
178
  background-color: #fff;
179
- border-radius: 8px;
180
179
  border: 0;
181
180
  }
182
181
 
@@ -187,14 +186,6 @@
187
186
  background-size: contain;
188
187
  }
189
188
 
190
- .typeahead-popover li:first-child {
191
- border-radius: 8px 8px 0px 0px;
192
- }
193
-
194
- .typeahead-popover li:last-child {
195
- border-radius: 0px 0px 8px 8px;
196
- }
197
-
198
189
  .typeahead-popover li:hover {
199
190
  background-color: #eee;
200
191
  }
@@ -472,7 +463,6 @@ i.prettier-error {
472
463
  }
473
464
 
474
465
  .dropdown .item {
475
- margin: 0 8px 0 8px;
476
466
  padding: 8px;
477
467
  color: #050505;
478
468
  cursor: pointer;
@@ -484,7 +474,6 @@ i.prettier-error {
484
474
  flex-shrink: 0;
485
475
  justify-content: space-between;
486
476
  background-color: #fff;
487
- border-radius: 8px;
488
477
  border: 0;
489
478
  max-width: 250px;
490
479
  min-width: 100px;
@@ -1344,3 +1333,10 @@ li.embed-option-disabled > span:after {
1344
1333
  .inline-translation-node-inline > * {
1345
1334
  border-bottom: 2px dashed #3890f9;
1346
1335
  }
1336
+
1337
+ .bg-excalidraw {
1338
+ background-image: url(images/excalidraw.svg);
1339
+ background-size: contain;
1340
+ background-repeat: no-repeat;
1341
+ background-position: center;
1342
+ }
@@ -138,7 +138,7 @@ function BlockFormatDropDown({ editor, blockType, disabled = false, }) {
138
138
  }
139
139
  };
140
140
  const icons = {
141
- paragraph: 'tabler:align-justified',
141
+ paragraph: 'tabler:letter-case',
142
142
  h1: 'tabler:h-1',
143
143
  h2: 'tabler:h-2',
144
144
  h3: 'tabler:h-3',
@@ -13,6 +13,7 @@ export interface PlaygroundEmbedConfig extends EmbedConfig {
13
13
  exampleUrl: string;
14
14
  keywords: Array<string>;
15
15
  description?: string;
16
+ skipDefaultEmbedOption?: boolean;
16
17
  }
17
18
  export declare const YoutubeEmbedConfig: PlaygroundEmbedConfig;
18
19
  export declare const TwitterEmbedConfig: PlaygroundEmbedConfig;
@@ -30,6 +30,7 @@ import { $createEmojiNode } from '../../nodes/EmojiNode';
30
30
  import { useEditorConfig } from '../../../config';
31
31
  import { fetchOpenGraphInfo } from '../../../ext/utils';
32
32
  import createPortal from '../../../components/createPortal';
33
+ import { icons } from '../../icons';
33
34
  export const YoutubeEmbedConfig = {
34
35
  contentName: 'Youtube Video',
35
36
  exampleUrl: 'https://www.youtube.com/watch?v=jNQXAC9IVRw',
@@ -55,10 +56,10 @@ export const YoutubeEmbedConfig = {
55
56
  };
56
57
  export const TwitterEmbedConfig = {
57
58
  // e.g. Tweet or Google Map.
58
- contentName: 'Tweet',
59
+ contentName: 'X',
59
60
  exampleUrl: 'https://twitter.com/jack/status/20',
60
61
  // Icon for display.
61
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:twitter" }),
62
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.brandX }),
62
63
  // Create the Lexical embed node from the url data.
63
64
  insertNode: (editor, result) => {
64
65
  editor.dispatchCommand(INSERT_TWEET_COMMAND, result.id);
@@ -79,9 +80,9 @@ export const TwitterEmbedConfig = {
79
80
  type: 'tweet',
80
81
  };
81
82
  export const FigmaEmbedConfig = {
82
- contentName: 'Figma Document',
83
+ contentName: 'Figma',
83
84
  exampleUrl: 'https://www.figma.com/file/LKQ4FJ4bTnCSjedbRpk931/Sample-File',
84
- icon: _jsx("i", { className: "iconify", "data-icon": "ph:figma-logo-bold" }),
85
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.brandFigma }),
85
86
  insertNode: (editor, result) => {
86
87
  editor.dispatchCommand(INSERT_FIGMA_COMMAND, result.id);
87
88
  },
@@ -100,10 +101,10 @@ export const FigmaEmbedConfig = {
100
101
  type: 'figma',
101
102
  };
102
103
  export const GithubConfig = {
103
- contentName: '',
104
+ contentName: 'GitHub',
104
105
  exampleUrl: 'https://github.com/blocklet/discuss-kit/pull/722',
105
106
  // Icon for display.
106
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:github" }),
107
+ icon: _jsx("i", { className: "iconify", "data-icon": "tabler:brand-github" }),
107
108
  // Create the Lexical embed node from the url data.
108
109
  insertNode: (editor, result) => { },
109
110
  // For extra searching.
@@ -123,6 +124,7 @@ export const GithubConfig = {
123
124
  return null;
124
125
  }
125
126
  }, 'github'),
127
+ skipDefaultEmbedOption: true,
126
128
  type: 'github',
127
129
  };
128
130
  const LinkFallbackConfig = {
@@ -137,6 +139,7 @@ const LinkFallbackConfig = {
137
139
  }
138
140
  return { id: text, url: text };
139
141
  },
142
+ skipDefaultEmbedOption: true,
140
143
  type: 'link-fallback',
141
144
  };
142
145
  export const EmbedConfigs = [
@@ -224,7 +227,7 @@ export default function AutoEmbedPlugin() {
224
227
  new AutoEmbedOption('Dismiss', {
225
228
  onSelect: dismissFn,
226
229
  }),
227
- ...(activeEmbedConfig.contentName
230
+ ...(activeEmbedConfig.skipDefaultEmbedOption !== true
228
231
  ? [
229
232
  new AutoEmbedOption(`Embed ${activeEmbedConfig.contentName}`, {
230
233
  onSelect: embedFn,
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
3
  * Copyright (c) Meta Platforms, Inc. and affiliates.
4
4
  *
@@ -9,7 +9,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
9
9
  import { $isCodeNode } from '@lexical/code';
10
10
  import { $getNearestNodeFromDOMNode, $getSelection, $setSelection } from 'lexical';
11
11
  import { useState } from 'react';
12
+ import { Box } from '@mui/material';
12
13
  import { useDebounce } from '../../utils';
14
+ import { icons } from '../../../../icons';
13
15
  export function CopyButton({ editor, getCodeDOMNode }) {
14
16
  const [isCopyCompleted, setCopyCompleted] = useState(false);
15
17
  const removeSuccessIcon = useDebounce(() => {
@@ -38,5 +40,5 @@ export function CopyButton({ editor, getCodeDOMNode }) {
38
40
  console.error('Failed to copy: ', err);
39
41
  }
40
42
  }
41
- return (_jsx("button", { className: "menu-item", onClick: handleClick, "aria-label": "copy", children: isCopyCompleted ? _jsx("i", { className: "format success" }) : _jsx("i", { className: "format copy" }) }));
43
+ return (_jsxs(_Fragment, { children: [_jsx("button", { className: "menu-item", onClick: handleClick, "aria-label": "copy", style: { display: isCopyCompleted ? 'none' : 'inline-block' }, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": icons.copy, "data-height": 20 }) }), _jsx("button", { className: "menu-item", "aria-label": "copy", style: { display: isCopyCompleted ? 'inline-block' : 'none' }, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": icons.copySuccess, "data-height": 20 }) })] }));
42
44
  }
@@ -22,7 +22,7 @@
22
22
  flex-shrink: 0;
23
23
  display: flex;
24
24
  align-items: center;
25
- color: rgba(0, 0, 0, 0.5);
25
+ color: #fff;
26
26
  text-transform: uppercase;
27
27
  }
28
28
 
@@ -41,6 +41,6 @@
41
41
  }
42
42
 
43
43
  .code-action-menu-container button.menu-item:active {
44
- background-color: rgba(223, 232, 250);
45
- border: 1px solid rgba(0, 0, 0, 0.45);
44
+ /* background-color: rgba(223, 232, 250);
45
+ border: 1px solid rgba(0, 0, 0, 0.45); */
46
46
  }
@@ -1,6 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import './index.css';
3
- import { $isCodeNode, CodeNode, getLanguageFriendlyName } from '@lexical/code';
3
+ import { $isCodeNode, CodeNode } from '@lexical/code';
4
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
5
5
  import { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical';
6
6
  import { useEffect, useRef, useState } from 'react';
@@ -82,15 +82,14 @@ function CodeActionMenuContainer({ anchorElem }) {
82
82
  setShouldListenMouseMove(codeSetRef.current.size > 0);
83
83
  }, { skipInitialization: false });
84
84
  }, [editor]);
85
- const codeFriendlyName = getLanguageFriendlyName(lang);
86
85
  return (
87
86
  // eslint-disable-next-line react/jsx-no-useless-fragment
88
- _jsx(_Fragment, { children: isShown ? (_jsxs("div", { className: "code-action-menu-container", style: { ...position }, children: [_jsx("div", { className: "code-highlight-language", children: codeFriendlyName }), _jsx(CopyButton, { editor: editor, getCodeDOMNode: getCodeDOMNode })] })) : null }));
87
+ _jsx(_Fragment, { children: isShown ? (_jsx("div", { className: "code-action-menu-container", style: { ...position }, children: _jsx(CopyButton, { editor: editor, getCodeDOMNode: getCodeDOMNode }) })) : null }));
89
88
  }
90
89
  function getMouseInfo(event) {
91
90
  const { target } = event;
92
91
  if (isHTMLElement(target)) {
93
- const codeDOMNode = target.closest('code.PlaygroundEditorTheme__code');
92
+ const codeDOMNode = target.closest('code');
94
93
  const isOutside = !(codeDOMNode || target.closest('div.code-action-menu-container'));
95
94
  return { codeDOMNode, isOutside };
96
95
  }
@@ -1,12 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /**
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- */
9
- import styled from '@emotion/styled';
10
2
  import { $createCodeNode } from '@lexical/code';
11
3
  import { INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND } from '@lexical/list';
12
4
  import { INSERT_EMBED_COMMAND } from '@lexical/react/LexicalAutoEmbedPlugin';
@@ -37,6 +29,7 @@ import { INSERT_PDF_COMMAND, isPdf } from '../../../ext/PdfPlugin';
37
29
  import { INSERT_FILE_COMMAND } from '../../../ext/FilePlugin';
38
30
  import { $insertSubpageListing } from '../../../ext/SubpageListingPlugin/SubpageListingPlugin';
39
31
  import { INSERT_PAGES_KIT_COMPONENT_COMMAND, usePagesKitComponents, } from '../../../ext/PagesKitComponent/PagesKitComponentPlugin';
32
+ import { icons } from '../../icons';
40
33
  class ComponentPickerOption extends TypeaheadOption {
41
34
  // What shows up in the editor
42
35
  title;
@@ -62,7 +55,17 @@ function ComponentPickerMenuItem({ index, isSelected, onClick, onMouseEnter, opt
62
55
  if (isSelected) {
63
56
  className += ' selected';
64
57
  }
65
- return (_jsxs("li", { tabIndex: -1, className: className, ref: option.setRefElement, role: "option", "aria-selected": isSelected, id: `typeahead-item-${index}`, onMouseEnter: onMouseEnter, onClick: onClick, children: [option.icon, _jsx("span", { className: "text", children: option.title })] }, option.key));
58
+ return (_jsxs(Box, { component: "li", tabIndex: -1, className: className, ref: option.setRefElement, role: "option", "aria-selected": isSelected, id: `typeahead-item-${index}`, onMouseEnter: onMouseEnter, onClick: onClick, sx: {
59
+ display: 'flex',
60
+ alignItems: 'center',
61
+ gap: 1,
62
+ svg: {
63
+ width: '1em',
64
+ height: '1em',
65
+ fontSize: 20,
66
+ color: 'text.secondary',
67
+ },
68
+ }, children: [option.icon, _jsx("span", { className: "text", children: option.title })] }, option.key));
66
69
  }
67
70
  export const INSERT_COMPONENT_COMMAND = createCommand('INSERT_COMPONENT_COMMAND');
68
71
  export default function ComponentPickerMenuPlugin() {
@@ -112,7 +115,7 @@ export default function ComponentPickerMenuPlugin() {
112
115
  const baseOptions = [
113
116
  !minimalMode &&
114
117
  new ComponentPickerOption('Paragraph', {
115
- icon: _jsx("i", { className: "iconify", "data-icon": "bi:text-paragraph" }),
118
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.paragraph }),
116
119
  keywords: ['normal', 'paragraph', 'p', 'text'],
117
120
  onSelect: () => editor.update(() => {
118
121
  const selection = $getSelection();
@@ -145,7 +148,7 @@ export default function ComponentPickerMenuPlugin() {
145
148
  // }),
146
149
  ...(hasNodes('heading') && !minimalMode
147
150
  ? Array.from({ length: 3 }, (_, i) => i + 1).map((n) => new ComponentPickerOption(`Heading ${n}`, {
148
- icon: _jsx("i", { className: "iconify", "data-icon": `mdi:format-heading-${n}` }),
151
+ icon: _jsx("i", { className: "iconify", "data-icon": icons[`h${n}`] }),
149
152
  keywords: ['heading', 'header', `h${n}`],
150
153
  onSelect: () => editor.update(() => {
151
154
  const selection = $getSelection();
@@ -160,35 +163,35 @@ export default function ComponentPickerMenuPlugin() {
160
163
  hasNodes('table') &&
161
164
  !minimalMode &&
162
165
  new ComponentPickerOption('Table', {
163
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:table" }),
166
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.table }),
164
167
  keywords: ['table'],
165
168
  onSelect: () => showModal('Insert Table', (onClose) => _jsx(InsertTableDialog, { activeEditor: editor, onClose: onClose })),
166
169
  }),
167
170
  hasNodes('list', 'listitem') &&
168
171
  !minimalMode &&
169
172
  new ComponentPickerOption('Numbered List', {
170
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:format-list-numbered" }),
173
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.number }),
171
174
  keywords: ['numbered list', 'ordered list', 'ol'],
172
175
  onSelect: () => editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined),
173
176
  }),
174
177
  hasNodes('list', 'listitem') &&
175
178
  !minimalMode &&
176
179
  new ComponentPickerOption('Bulleted List', {
177
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:format-list-bulleted" }),
180
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.bullet }),
178
181
  keywords: ['bulleted list', 'unordered list', 'ul'],
179
182
  onSelect: () => editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined),
180
183
  }),
181
184
  hasNodes('list', 'listitem') &&
182
185
  !minimalMode &&
183
186
  new ComponentPickerOption('Check List', {
184
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:format-list-checkbox" }),
187
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.check }),
185
188
  keywords: ['check list', 'todo list'],
186
189
  onSelect: () => editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined),
187
190
  }),
188
191
  !minimalMode &&
189
192
  hasNodes('quote') &&
190
193
  new ComponentPickerOption('Quote', {
191
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:comment-quote-outline" }),
194
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.quote }),
192
195
  keywords: ['block quote'],
193
196
  onSelect: () => editor.update(() => {
194
197
  const selection = $getSelection();
@@ -200,34 +203,34 @@ export default function ComponentPickerMenuPlugin() {
200
203
  !minimalMode &&
201
204
  hasNodes('alert') &&
202
205
  new ComponentPickerOption('Alert (Warning)', {
203
- icon: _jsx("i", { className: "iconify", "data-icon": "ic:outline-info" }),
206
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.alert }),
204
207
  keywords: ['alert', 'warning'],
205
208
  onSelect: () => $insertAlert(editor, 'warning'),
206
209
  }),
207
210
  !minimalMode &&
208
211
  hasNodes('alert') &&
209
212
  new ComponentPickerOption('Alert (Success)', {
210
- icon: _jsx("i", { className: "iconify", "data-icon": "ic:outline-info" }),
213
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.alert }),
211
214
  keywords: ['alert', 'success'],
212
215
  onSelect: () => $insertAlert(editor, 'success'),
213
216
  }),
214
217
  !minimalMode &&
215
218
  hasNodes('alert') &&
216
219
  new ComponentPickerOption('Alert (Info)', {
217
- icon: _jsx("i", { className: "iconify", "data-icon": "ic:outline-info" }),
220
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.alert }),
218
221
  keywords: ['alert', 'info'],
219
222
  onSelect: () => $insertAlert(editor, 'info'),
220
223
  }),
221
224
  !minimalMode &&
222
225
  hasNodes('alert') &&
223
226
  new ComponentPickerOption('Alert (Error)', {
224
- icon: _jsx("i", { className: "iconify", "data-icon": "ic:outline-info" }),
227
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.alert }),
225
228
  keywords: ['alert', 'error'],
226
229
  onSelect: () => $insertAlert(editor, 'error'),
227
230
  }),
228
231
  hasNodes('code') &&
229
232
  new ComponentPickerOption('Code', {
230
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:code-tags" }),
233
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.code }),
231
234
  keywords: ['javascript', 'python', 'js', 'codeblock'],
232
235
  onSelect: () => editor.update(() => {
233
236
  const selection = $getSelection();
@@ -248,14 +251,14 @@ export default function ComponentPickerMenuPlugin() {
248
251
  !minimalMode &&
249
252
  hasNodes('horizontalrule') &&
250
253
  new ComponentPickerOption('Divider', {
251
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:border-horizontal" }),
254
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.divider }),
252
255
  keywords: ['horizontal rule', 'divider', 'hr'],
253
256
  onSelect: () => editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, undefined),
254
257
  }),
255
258
  !minimalMode &&
256
259
  hasNodes('excalidraw') &&
257
260
  new ComponentPickerOption('Excalidraw', {
258
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:graph-outline" }),
261
+ icon: (_jsx(Box, { component: "span", className: "bg-excalidraw", sx: { display: 'inline-block', width: 20, height: 20 } })),
259
262
  keywords: ['excalidraw', 'diagram', 'drawing'],
260
263
  onSelect: () => editor.dispatchCommand(INSERT_EXCALIDRAW_COMMAND, undefined),
261
264
  }),
@@ -270,7 +273,7 @@ export default function ComponentPickerMenuPlugin() {
270
273
  hasNodes('image') &&
271
274
  hasUploader &&
272
275
  new ComponentPickerOption(isExistAiKit() ? 'Media (Support AI)' : 'Media', {
273
- icon: _jsx("i", { className: "iconify", "data-icon": "mdi:file-image-plus" }),
276
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.media }),
274
277
  keywords: ['image', 'photo', 'picture', 'file', 'video', 'media', 'pdf'],
275
278
  onSelect: () => {
276
279
  uploadFile(editor);
@@ -278,7 +281,7 @@ export default function ComponentPickerMenuPlugin() {
278
281
  }),
279
282
  !minimalMode &&
280
283
  new ComponentPickerOption('Templates', {
281
- icon: _jsx("i", { className: "iconify", "data-icon": "tabler:template" }),
284
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.template }),
282
285
  keywords: ['templates'],
283
286
  onSelect: () => {
284
287
  editor.dispatchCommand(INSERT_TEMPLATE_COMMAND, undefined);
@@ -287,14 +290,14 @@ export default function ComponentPickerMenuPlugin() {
287
290
  !minimalMode &&
288
291
  hasNodes('collapsible-container') &&
289
292
  new ComponentPickerOption('Collapsible', {
290
- icon: _jsx("i", { className: "iconify", "data-icon": "bi:caret-right-fill" }),
293
+ icon: _jsx("i", { className: "iconify", "data-icon": icons.collapsible }),
291
294
  keywords: ['collapse', 'collapsible', 'toggle'],
292
295
  onSelect: () => editor.dispatchCommand(INSERT_COLLAPSIBLE_COMMAND, undefined),
293
296
  }),
294
297
  ...(minimalMode
295
298
  ? []
296
299
  : ['left', 'center', 'right', 'justify'].map((alignment) => new ComponentPickerOption(`Align ${alignment}`, {
297
- icon: _jsx("i", { className: "iconify", "data-icon": `mdi:format-align-${alignment}` }),
300
+ icon: (_jsx("i", { className: "iconify", "data-icon": icons[`align${alignment.charAt(0).toUpperCase() + alignment.slice(1)}`] })),
298
301
  keywords: ['align', 'justify', alignment],
299
302
  onSelect: () =>
300
303
  // @ts-ignore Correct types, but since they're dynamic TS doesn't like it.
@@ -370,7 +373,7 @@ export default function ComponentPickerMenuPlugin() {
370
373
  }, [editor]);
371
374
  return (_jsxs(_Fragment, { children: [modal, _jsx(LexicalTypeaheadMenuPlugin, { onQueryChange: setQueryString, onSelectOption: onSelectOption, triggerFn: checkForTriggerMatch, options: options, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
372
375
  return anchorElementRef.current && options.length
373
- ? createPortal(_jsx("div", { className: "typeahead-popover component-picker-menu", children: _jsx(List, { children: options.map((option, i) => (_jsx(ComponentPickerMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
376
+ ? createPortal(_jsx("div", { className: "typeahead-popover component-picker-menu", children: _jsx("ul", { children: options.map((option, i) => (_jsx(ComponentPickerMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
374
377
  setHighlightedIndex(i);
375
378
  selectOptionAndCleanUp(option);
376
379
  }, onMouseEnter: () => {
@@ -435,15 +438,3 @@ export const uploadFile = (editor) => {
435
438
  throw new Error('Missing required `window.uploaderRef`');
436
439
  }
437
440
  };
438
- const List = styled.ul `
439
- > li {
440
- display: flex;
441
- align-items: center;
442
-
443
- .iconify {
444
- font-size: 16px;
445
- width: 20px;
446
- opacity: 0.6;
447
- }
448
- }
449
- `;
@@ -122,7 +122,7 @@ function BlockFormatDropDown({ editor, blockType, disabled = false, }) {
122
122
  }
123
123
  };
124
124
  const icons = {
125
- paragraph: 'tabler:align-justified',
125
+ paragraph: 'tabler:letter-case',
126
126
  h1: 'tabler:h-1',
127
127
  h2: 'tabler:h-2',
128
128
  h3: 'tabler:h-3',
@@ -389,7 +389,7 @@ export default function ToolbarPlugin() {
389
389
  }
390
390
  case 'strikethrough': {
391
391
  if (blockType !== 'code') {
392
- menus.push(_jsxs(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item spaced text-format-additional", buttonLabel: "", buttonAriaLabel: "Formatting options for additional text styles", buttonIconData: "tabler:letter-case", buttonIconClassName: "iconify", children: [_jsxs(DropDownItem, { onClick: () => {
392
+ menus.push(_jsxs(DropDown, { disabled: !isEditable, buttonClassName: "toolbar-item spaced text-format-additional", buttonLabel: "", buttonAriaLabel: "Formatting options for additional text styles", buttonIconData: "tabler:adjustments", buttonIconClassName: "iconify", children: [_jsxs(DropDownItem, { onClick: () => {
393
393
  activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough');
394
394
  }, className: `item ${dropDownActiveClass(isStrikethrough)}`, title: "Strikethrough", "aria-label": "Format text with a strikethrough", children: [_jsx("i", { className: "iconify", "data-icon": "tabler:strikethrough" }), _jsx("span", { className: "text", children: "Strikethrough" })] }), _jsxs(DropDownItem, { onClick: () => {
395
395
  activeEditor.dispatchCommand(FORMAT_TEXT_COMMAND, 'subscript');
@@ -227,6 +227,28 @@ const createCustomTheme = (theme) => {
227
227
  }
228
228
  }
229
229
  }
230
+ `;
231
+ const code = css `
232
+ background-color: #18181b;
233
+ color: #fff;
234
+ font-family: Menlo, Consolas, Monaco, monospace;
235
+ display: block;
236
+ padding: 16px;
237
+ line-height: 1.53;
238
+ font-size: 13px;
239
+ margin: 0;
240
+ margin-top: 8px;
241
+ margin-bottom: 8px;
242
+ tab-size: 2;
243
+ /* white-space: pre; */
244
+ overflow-x: auto;
245
+ position: relative;
246
+ border-radius: 8px;
247
+ border: 1px solid #27272;
248
+
249
+ &:before {
250
+ display: none;
251
+ }
230
252
  `;
231
253
  /**
232
254
  * 基于 mui theme 的自定义主题
@@ -266,6 +288,7 @@ const createCustomTheme = (theme) => {
266
288
  focus: alertFocus,
267
289
  },
268
290
  image: `${defaultTheme.image} ${image}`,
291
+ code,
269
292
  };
270
293
  return customTheme;
271
294
  };
@@ -452,28 +452,28 @@ const nestedListItem = css `
452
452
  }
453
453
  `;
454
454
  const tokenComment = css `
455
- color: slategray;
455
+ color: #6a9955;
456
456
  `;
457
457
  const tokenPunctuation = css `
458
- color: #999;
458
+ color: #d4d4d4;
459
459
  `;
460
460
  const tokenProperty = css `
461
- color: #905;
461
+ color: #9cdcfe;
462
462
  `;
463
463
  const tokenSelector = css `
464
- color: #690;
464
+ color: #d7ba7d;
465
465
  `;
466
466
  const tokenOperator = css `
467
- color: #9a6e3a;
467
+ color: #d4d4d4;
468
468
  `;
469
469
  const tokenAttr = css `
470
- color: #07a;
470
+ color: #9cdcfe;
471
471
  `;
472
472
  const tokenVariable = css `
473
- color: #e90;
473
+ color: #9cdcfe;
474
474
  `;
475
475
  const tokenFunction = css `
476
- color: #dd4a68;
476
+ color: #dcdcaa;
477
477
  `;
478
478
  const mark = css `
479
479
  background: rgba(255, 212, 0, 0.14);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/editor",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "main": "lib/index.js",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -68,7 +68,7 @@
68
68
  "ufo": "^1.5.4",
69
69
  "url-join": "^4.0.1",
70
70
  "zustand": "^4.5.5",
71
- "@blocklet/pdf": "^2.3.2"
71
+ "@blocklet/pdf": "^2.3.3"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@babel/core": "^7.25.2",