Skip to content

Commit 7e92ad0

Browse files
authored
Merge pull request #304 from codesnippetspro/fix/tinymce-plugin-issue
fix: tinymce plugin issue
2 parents fd80caa + bb30323 commit 7e92ad0

File tree

18 files changed

+387
-184
lines changed

18 files changed

+387
-184
lines changed

.browserslistrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,45 @@ command:
6969
npm run watch
7070
```
7171

72+
## Managing Composer dependencies
73+
74+
Code Snippets uses the [Imposter plugin](https://github.com/TypistTech/imposter) to namespace-prefix all vendor
75+
dependencies under `Code_Snippets\Vendor\`. This prevents conflicts with other WordPress plugins that might use the
76+
same libraries (e.g., Guzzle, Minify, Monolog).
77+
78+
### Adding a new dependency
79+
80+
When adding a new Composer dependency that might exist in other plugins:
81+
82+
1. Add the package to `src/composer.json` as usual:
83+
```shell
84+
cd src
85+
composer require vendor/package
86+
```
87+
88+
2. Add corresponding PSR-4 autoload entries for the prefixed namespace in `src/composer.json`:
89+
```json
90+
"autoload": {
91+
"psr-4": {
92+
"Code_Snippets\\Vendor\\OriginalVendor\\PackageName\\": "vendor/vendor-name/package-name/src/"
93+
}
94+
}
95+
```
96+
97+
3. Run `composer dump-autoload -o` to regenerate autoload files.
98+
99+
4. The Imposter plugin will automatically rewrite the namespaces during `post-install-cmd` and `post-update-cmd` hooks.
100+
101+
5. Our autoloader in `src/php/load.php` automatically removes original (non-prefixed) namespace mappings to prevent
102+
collisions, so no code changes are needed.
103+
104+
### How it works
105+
106+
- Imposter rewrites all vendor code from `Vendor\Package\Class` to `Code_Snippets\Vendor\Vendor\Package\Class`
107+
- The `load.php` file dynamically detects and removes original namespace PSR-4 mappings at runtime
108+
- Other plugins can load their own versions of the same libraries without conflicts
109+
- Your code should always use the prefixed namespace: `use Code_Snippets\Vendor\Vendor\Package\Class;`
110+
72111
## Preparing for release
73112

74113
The plugin repository includes a number of files that are unnecessary when distributing the plugin files for

src/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
"autoload": {
2424
"classmap": [
2525
"php/"
26-
]
26+
],
27+
"psr-4": {
28+
}
2729
},
2830
"require": {
2931
"php": ">=7.4",

src/css/common/_badges.scss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
gap: 5px;
2121
line-height: 1;
2222

23-
@at-root .row-actions & {
24-
color: #8c8c8c;
25-
padding-inline: 0px;
26-
text-transform: capitalize;
27-
font-weight: 500;
28-
}
23+
@at-root .row-actions & {
24+
color: #8c8c8c;
25+
padding-inline: 0;
26+
text-transform: capitalize;
27+
font-weight: 500;
28+
}
2929

3030
.dashicons {
3131
font-size: 18px;
@@ -37,7 +37,7 @@
3737
.network-shared {
3838
color: #2271b1;
3939
font-size: 22px;
40-
width: 100%;
40+
inline-size: 100%;
4141
cursor: help;
4242
}
4343

@@ -89,9 +89,9 @@
8989
background-color: #a7aaad;
9090
border-color: #fff !important;
9191

92-
.dashicons {
93-
color: #fff;
94-
}
92+
.dashicons {
93+
color: #fff;
94+
}
9595
}
9696

9797
.nav-tab-inactive {

src/css/edit.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,13 @@
9595
form.condition-snippet .snippet-code-container {
9696
display: none;
9797
}
98+
99+
.cs-back {
100+
cursor: pointer;
101+
102+
&::before {
103+
content: '<';
104+
color: #2271b1;
105+
margin-inline-end: 3px;
106+
}
107+
}

src/css/edit/_gpt.scss

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,66 @@
2020
.generate-button {
2121
display: flex;
2222
align-items: center;
23+
gap: 5px;
2324

2425
.dashicons-warning {
2526
color: #b32d2e;
2627
}
28+
29+
.snippet-tags-container &,
30+
.snippet-description-container & {
31+
float: inline-end;
32+
}
2733
}
2834

2935
.code-line-explanation {
3036
display: flex;
31-
align-items: center;
32-
font-size: 13px;
37+
cursor: default;
38+
font-size: inherit;
3339
margin: 0;
34-
padding-block: 0;
35-
padding-inline: 8px;
36-
background-color: #fff;
37-
border: 1px solid #bbb;
38-
border-inline-start: 0;
39-
border-inline-end: 0;
40+
padding-inline: 6px;
41+
border-inline-start: none;
42+
border-inline-end: none;
43+
border-block-start: 1px solid rgb(0 0 0 / 15%);
44+
border-block-end: 1px solid rgb(0 0 0 / 15%);
45+
border-image-slice: 1;
46+
border-image-width: 1;
47+
border-image-repeat: stretch;
4048
color: #666;
4149
font-style: italic;
42-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
50+
font-family: monospace;
51+
gap: 5px;
52+
align-items: center;
4353

4454
img {
4555
block-size: 1rem;
46-
padding-inline-end: 5px;
56+
opacity: 0.7;
57+
}
58+
59+
.code-line-actions {
60+
cursor: default;
61+
gap: 7px;
62+
display: inline-flex;
63+
margin-inline-start: 5px;
64+
font-family: system-ui;
65+
font-style: normal;
66+
67+
.commit {
68+
color: #3d9970;
69+
}
70+
71+
.remove {
72+
color: #b32d2e;
73+
}
74+
75+
.action {
76+
cursor: pointer;
77+
opacity: 0.6;
78+
79+
&:hover {
80+
opacity: 1;
81+
}
82+
}
4783
}
4884
}
4985

src/css/manage/_cloud.scss

Lines changed: 74 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ td.column-name {
6969
}
7070
}
7171

72-
td.column-download {
73-
display: flex;
74-
gap: 0.5em;
75-
flex-flow: column;
76-
text-align: center;
77-
}
78-
7972
.cloud-snippet-download {
8073
color: theme.$accent !important;
8174
}
@@ -218,12 +211,74 @@ td.column-download {
218211
display: flex;
219212
flex-wrap: wrap;
220213
justify-content: center;
214+
215+
.plugin-card {
216+
display: flex;
217+
flex-direction: column;
218+
justify-content: space-between;
219+
220+
.cloud-meta-row {
221+
display: flex;
222+
justify-content: space-between;
223+
align-items: center;
224+
flex-grow: 1;
225+
}
226+
227+
.column-name {
228+
display: flex;
229+
justify-content: space-between;
230+
231+
h3 {
232+
display: inline-flex;
233+
flex-shrink: 1;
234+
}
235+
236+
.title-icon {
237+
block-size: 90px;
238+
margin-block-start: -7px;
239+
}
240+
}
241+
242+
.column-votes {
243+
display: inline-flex;
244+
gap: 3px;
245+
246+
&:hover {
247+
.thumbs-up {
248+
stroke: #059669;
249+
fill: #6ee7b7;
250+
animation: thumb 1s ease-in-out infinite;
251+
}
252+
}
253+
254+
.num-votes {
255+
display: inline-flex;
256+
align-items: flex-end;
257+
}
258+
}
259+
}
260+
261+
.action-buttons {
262+
margin: 0;
263+
align-items: flex-end;
264+
265+
.button {
266+
inline-size: 100%;
267+
text-align: center;
268+
}
269+
}
221270
}
222271

223-
.cloud-snippets .plugin-card {
224-
display: flex;
225-
flex-direction: column;
226-
justify-content: space-between;
272+
.cloud-snippets #the-list {
273+
.column-download {
274+
display: flex;
275+
flex-flow: column;
276+
text-align: end;
277+
278+
li {
279+
list-style: none;
280+
}
281+
}
227282
}
228283

229284
.cloud-connect-wrap {
@@ -264,6 +319,7 @@ td.column-download {
264319
background-color: #ce0000;
265320
border-radius: 50%;
266321

322+
267323
.cloud-connect-active & {
268324
background-color: #25a349;
269325
}
@@ -282,33 +338,16 @@ td.column-download {
282338
block-size: 1.25rem; /* 20px */
283339
transform-origin: bottom left;
284340

285-
[dir="rtl"] & {
286-
transform-origin: bottom right;
287-
}
288-
289341
&:hover {
290342
stroke: #059669;
291343
fill: #6ee7b7;
292344
}
293345
}
294346

295-
.voted-info {
296-
display: inline-flex;
297-
gap: 3px;
298-
align-items: center;
299-
margin-block-end: 6px !important;
300-
301-
&:hover {
302-
.thumbs-up {
303-
stroke: #059669;
304-
fill: #6ee7b7;
305-
animation: thumb 1s ease-in-out infinite;
306-
}
307-
}
308-
}
309-
310347
.plugin-card-bottom {
311348
overflow: visible !important;
349+
display: flex;
350+
align-items: center;
312351
}
313352

314353
.beta-test-notice {
@@ -323,22 +362,22 @@ td.column-download {
323362

324363
@keyframes thumb {
325364
0% {
326-
transform: rotate(0)
365+
transform: rotate(0);
327366
}
328367

329368
33% {
330-
transform: rotate(calc(7deg * var(--cs-direction-multiplier)));
369+
transform: rotate(7deg);
331370
}
332371

333372
66% {
334-
transform: rotate(calc(-15deg * var(--cs-direction-multiplier)));
373+
transform: rotate(-15deg);
335374
}
336375

337376
90% {
338-
transform: rotate(calc(5deg * var(--cs-direction-multiplier)));
377+
transform: rotate(5deg);
339378
}
340379

341380
100% {
342-
transform: rotate(0)
381+
transform: rotate(0);
343382
}
344383
}

src/js/components/SnippetForm/SnippetForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const EditFormWrap: React.FC = () => {
145145

146146
return (
147147
<div className="wrap">
148-
<p><small>
148+
<p><small className="cs-back">
149149
{isCondition(snippet)
150150
? <a href={addQueryArgs(window.CODE_SNIPPETS?.urls.manage, { type: 'cond' })}>
151151
{__('Back to all conditions', 'code-snippets')}

0 commit comments

Comments
 (0)