@editora/plugins 1.0.7 → 1.0.9
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/LICENSE +21 -0
- package/README.md +72 -4
- package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/anchor.cjs.js +11 -11
- package/dist/anchor.esm.js +130 -107
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/approval-workflow.cjs.js +447 -0
- package/dist/approval-workflow.esm.js +1070 -0
- package/dist/background-color.cjs.js +3 -3
- package/dist/background-color.esm.js +116 -119
- package/dist/blocks-library.cjs.js +442 -0
- package/dist/blocks-library.esm.js +1317 -0
- package/dist/citations.cjs.js +548 -0
- package/dist/citations.esm.js +1457 -0
- package/dist/code.cjs.js +82 -102
- package/dist/code.esm.js +1172 -662
- package/dist/comments.cjs.js +10 -10
- package/dist/comments.esm.js +195 -177
- package/dist/conditional-content.cjs.js +626 -0
- package/dist/conditional-content.esm.js +1360 -0
- package/dist/content-rules.cjs.js +408 -0
- package/dist/content-rules.esm.js +1093 -0
- package/dist/data-binding.cjs.js +321 -0
- package/dist/data-binding.esm.js +913 -0
- package/dist/doc-schema.cjs.js +398 -0
- package/dist/doc-schema.esm.js +1310 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/embed-iframe.cjs.js +2 -2
- package/dist/embed-iframe.esm.js +8 -5
- package/dist/emojis.cjs.js +64 -39
- package/dist/emojis.esm.js +133 -104
- package/dist/enterprise.cjs.js +1 -0
- package/dist/enterprise.esm.js +56 -0
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
- package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
- package/dist/index-CvJk4DKa.js +221 -0
- package/dist/index-D3CycEFU.mjs +16543 -0
- package/dist/index-tqLTHcO6.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
- package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
- package/dist/index.esm.js +111 -75
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
- package/dist/link.cjs.js +6 -6
- package/dist/link.esm.js +41 -39
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +151 -112
- package/dist/media-manager.cjs.js +15 -15
- package/dist/media-manager.esm.js +227 -206
- package/dist/mentions.cjs.js +105 -0
- package/dist/mentions.esm.js +726 -0
- package/dist/merge-tag.cjs.js +44 -12
- package/dist/merge-tag.esm.js +368 -241
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +85 -77
- package/dist/pii-redaction.cjs.js +436 -0
- package/dist/pii-redaction.esm.js +1377 -0
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +29 -29
- package/dist/slash-commands.cjs.js +90 -0
- package/dist/slash-commands.esm.js +752 -0
- package/dist/smart-paste.cjs.js +398 -0
- package/dist/smart-paste.esm.js +1388 -0
- package/dist/special-characters.cjs.js +83 -45
- package/dist/special-characters.esm.js +149 -100
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +235 -216
- package/dist/template.cjs.js +14 -14
- package/dist/template.esm.js +157 -131
- package/dist/text-color.cjs.js +9 -9
- package/dist/text-color.esm.js +131 -115
- package/dist/track-changes.cjs.js +77 -0
- package/dist/track-changes.esm.js +755 -0
- package/dist/translation-workflow.cjs.js +626 -0
- package/dist/translation-workflow.esm.js +1718 -0
- package/dist/version-diff.cjs.js +362 -0
- package/dist/version-diff.esm.js +768 -0
- package/index.d.ts +849 -1
- package/package.json +105 -6
- package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
- package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
- package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
- package/dist/documentManager-_tQQfQi9.js +0 -317
- package/dist/index-D3pJyAsj.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ajay Kumar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -81,6 +81,15 @@ This package provides a complete set of plugins for building feature-rich text e
|
|
|
81
81
|
|
|
82
82
|
## 🚀 Quick Start
|
|
83
83
|
|
|
84
|
+
### Entry Paths (All Free + Customizable)
|
|
85
|
+
|
|
86
|
+
Every plugin entry path is MIT-licensed, free to use, and customizable:
|
|
87
|
+
|
|
88
|
+
- `@editora/plugins`: full plugin catalog
|
|
89
|
+
- `@editora/plugins/lite`: common/core plugin subset for lean bundles
|
|
90
|
+
- `@editora/plugins/enterprise`: advanced/specialized workflow plugins
|
|
91
|
+
- `@editora/plugins/<plugin-name>`: targeted per-plugin imports
|
|
92
|
+
|
|
84
93
|
### Recommended Imports For Smaller Bundles
|
|
85
94
|
|
|
86
95
|
For best bundle size, avoid importing everything from `@editora/plugins` in large apps.
|
|
@@ -91,6 +100,9 @@ Use one of these patterns:
|
|
|
91
100
|
// Lightweight preset entry
|
|
92
101
|
import { BoldPlugin, ItalicPlugin, HistoryPlugin } from '@editora/plugins/lite';
|
|
93
102
|
|
|
103
|
+
// Enterprise preset entry (advanced/specialized plugins)
|
|
104
|
+
import { MentionPlugin, TrackChangesPlugin, SmartPastePlugin } from '@editora/plugins/enterprise';
|
|
105
|
+
|
|
94
106
|
// Per-plugin subpath entry (most explicit)
|
|
95
107
|
import { BoldPlugin } from '@editora/plugins/bold';
|
|
96
108
|
import { ItalicPlugin } from '@editora/plugins/italic';
|
|
@@ -105,6 +117,16 @@ const { MediaManagerPlugin } = await import('@editora/plugins/media-manager');
|
|
|
105
117
|
const { SpellCheckPlugin } = await import('@editora/plugins/spell-check');
|
|
106
118
|
```
|
|
107
119
|
|
|
120
|
+
### Enterprise Preset Details
|
|
121
|
+
|
|
122
|
+
`@editora/plugins/enterprise` includes advanced plugins for governance, compliance, workflow, and QA:
|
|
123
|
+
|
|
124
|
+
- Collaboration/workflow: `TrackChangesPlugin`, `VersionDiffPlugin`, `CommentsPlugin`, `ApprovalWorkflowPlugin`
|
|
125
|
+
- Validation/compliance: `ContentRulesPlugin`, `DocSchemaPlugin`, `A11yCheckerPlugin`, `SpellCheckPlugin`, `PIIRedactionPlugin`
|
|
126
|
+
- Structured/dynamic authoring: `ConditionalContentPlugin`, `DataBindingPlugin`, `MergeTagPlugin`, `TemplatePlugin`, `CitationsPlugin`
|
|
127
|
+
- Productivity/runtime intelligence: `SmartPastePlugin`, `SlashCommandsPlugin`, `MentionPlugin`, `BlocksLibraryPlugin`, `TranslationWorkflowPlugin`
|
|
128
|
+
- Manager-backed advanced plugins: `MediaManagerPlugin`, `DocumentManagerPlugin`
|
|
129
|
+
|
|
108
130
|
### Basic Formatting
|
|
109
131
|
|
|
110
132
|
```typescript
|
|
@@ -595,15 +617,61 @@ const collaborativePlugins = [
|
|
|
595
617
|
}),
|
|
596
618
|
MergeTagPlugin({
|
|
597
619
|
tags: [
|
|
598
|
-
{ label: 'First Name', value: '{{firstName}}' },
|
|
599
|
-
{ label: 'Last Name', value: '{{lastName}}' },
|
|
600
|
-
{ label: 'Email', value: '{{email}}' }
|
|
601
|
-
]
|
|
620
|
+
{ label: 'First Name', value: '{{firstName}}', category: 'User' },
|
|
621
|
+
{ label: 'Last Name', value: '{{lastName}}', category: 'User' },
|
|
622
|
+
{ label: 'Email', value: '{{email}}', category: 'User' }
|
|
623
|
+
],
|
|
624
|
+
defaultCategory: 'User',
|
|
625
|
+
dialog: {
|
|
626
|
+
title: 'Insert Variable',
|
|
627
|
+
searchPlaceholder: 'Search variables...',
|
|
628
|
+
showPreview: true
|
|
629
|
+
},
|
|
630
|
+
tokenTemplate: '{value}'
|
|
602
631
|
}),
|
|
603
632
|
HistoryPlugin()
|
|
604
633
|
];
|
|
605
634
|
```
|
|
606
635
|
|
|
636
|
+
`MergeTagPlugin` supports functional customization:
|
|
637
|
+
|
|
638
|
+
- `tags`: flat list of tags (auto-grouped by `category`)
|
|
639
|
+
- `categories`: explicit grouped categories with custom order
|
|
640
|
+
- `defaultCategory`: initial tab
|
|
641
|
+
- `dialog`: labels/placeholders/preview toggle
|
|
642
|
+
- `tokenTemplate`: string template (`{key}`, `{label}`, `{category}`, `{value}`) or formatter function
|
|
643
|
+
|
|
644
|
+
### Custom Templates
|
|
645
|
+
|
|
646
|
+
You can register your own templates before initializing the editor:
|
|
647
|
+
|
|
648
|
+
```typescript
|
|
649
|
+
import { TemplatePlugin, addCustomTemplate } from '@editora/plugins';
|
|
650
|
+
|
|
651
|
+
addCustomTemplate({
|
|
652
|
+
id: 'invoice-basic',
|
|
653
|
+
name: 'Invoice (Basic)',
|
|
654
|
+
category: 'Billing',
|
|
655
|
+
description: 'Simple invoice template',
|
|
656
|
+
html: `
|
|
657
|
+
<h1>Invoice</h1>
|
|
658
|
+
<p><strong>Customer:</strong> {{customer.name}}</p>
|
|
659
|
+
<p><strong>Date:</strong> {{today}}</p>
|
|
660
|
+
<p><strong>Total:</strong> {{invoice.total}}</p>
|
|
661
|
+
`,
|
|
662
|
+
tags: ['invoice', 'billing']
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
const plugins = [
|
|
666
|
+
TemplatePlugin()
|
|
667
|
+
];
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
Notes:
|
|
671
|
+
- `id` must be unique.
|
|
672
|
+
- HTML is sanitized on insertion.
|
|
673
|
+
- Use `validateTemplate(template)` if you want to pre-check templates before registering.
|
|
674
|
+
|
|
607
675
|
## 🔧 TypeScript Support
|
|
608
676
|
|
|
609
677
|
All plugins include full TypeScript definitions:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var n=e.default;if(typeof n=="function"){var t=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}),t}exports.commonjsGlobal=u;exports.getAugmentedNamespace=l;exports.getDefaultExportFromCjs=f;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var u = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
2
|
+
function a(e) {
|
|
3
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
|
+
}
|
|
5
|
+
function f(e) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
|
|
7
|
+
var n = e.default;
|
|
8
|
+
if (typeof n == "function") {
|
|
9
|
+
var t = function r() {
|
|
10
|
+
var o = !1;
|
|
11
|
+
try {
|
|
12
|
+
o = this instanceof r;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
return o ? Reflect.construct(n, arguments, this.constructor) : n.apply(this, arguments);
|
|
16
|
+
};
|
|
17
|
+
t.prototype = n.prototype;
|
|
18
|
+
} else t = {};
|
|
19
|
+
return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
|
|
20
|
+
var o = Object.getOwnPropertyDescriptor(e, r);
|
|
21
|
+
Object.defineProperty(t, r, o.get ? o : {
|
|
22
|
+
enumerable: !0,
|
|
23
|
+
get: function() {
|
|
24
|
+
return e[r];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}), t;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
f as a,
|
|
31
|
+
u as c,
|
|
32
|
+
a as g
|
|
33
|
+
};
|
package/dist/anchor.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./editorContainerHelpers-CFbfiOJI.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./editorContainerHelpers-CFbfiOJI.js"),b=new Set,x='[data-theme="dark"], .dark, .editora-theme-dark';function $(t,c){if(c===t.innerHTML)return;const i=window.execEditorCommand||window.executeEditorCommand;if(typeof i=="function")try{i("recordDomTransaction",t,c,t.innerHTML)}catch{}}function z(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(c=>{c.forEach(i=>{i.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const d=r;if(d.classList?.contains("rte-anchor")){const n=d.id;n&&b.delete(n)}d.querySelectorAll?.(".rte-anchor")?.forEach(n=>{const u=n.id;u&&b.delete(u)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function S(t){return!t||t.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:t.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[a-z_]/.test(t)?/^[a-z0-9\-_]+$/.test(t)?{valid:!0,error:""}:{valid:!1,error:"Anchor ID can only contain letters, numbers, hyphens, and underscores"}:{valid:!1,error:"Anchor ID must start with a letter or underscore"}}function M(){const t=w.findEditorContainerFromSelection();if(!t)return;const c=w.getContentElement(t);if(!c)return;const i=c.querySelectorAll(".rte-anchor"),r=new Set;i.forEach(d=>{const e=d.id;e&&r.add(e)}),b.clear(),r.forEach(d=>b.add(d))}function R(t){if(t){const r=t.startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(x))return!0}const c=window.getSelection();if(c&&c.rangeCount>0){const r=c.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(x))return!0}return document.activeElement?.closest(x)?!0:document.body.matches(x)||document.documentElement.matches(x)}function H(t,c,i,r){M();const d=R(r),e=d?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",panelBg:"#222d3a",border:"#3b4657",text:"#e2e8f0",muted:"#94a3b8",closeHoverBg:"#334155",fieldBg:"#111827",fieldFocusBg:"#111827",fieldBorder:"#4b5563",fieldText:"#e2e8f0",fieldErrorBg:"#3f2124",fieldErrorBorder:"#ef4444",cancelBg:"#334155",cancelHover:"#475569",cancelText:"#e2e8f0",saveBg:"#3b82f6",saveHover:"#2563eb",saveDisabledBg:"#374151",saveDisabledText:"#7f8ca1",help:"#9fb0c6",focusRing:"rgba(88, 166, 255, 0.25)",errorRing:"rgba(239, 68, 68, 0.25)"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",panelBg:"#f9f9f9",border:"#e0e0e0",text:"#333333",muted:"#999999",closeHoverBg:"#e0e0e0",fieldBg:"#ffffff",fieldFocusBg:"#f9f9ff",fieldBorder:"#d0d0d0",fieldText:"#333333",fieldErrorBg:"#ffebee",fieldErrorBorder:"#d32f2f",cancelBg:"#f0f0f0",cancelHover:"#e0e0e0",cancelText:"#333333",saveBg:"#0066cc",saveHover:"#0052a3",saveDisabledBg:"#d0d0d0",saveDisabledText:"#999999",help:"#999999",focusRing:"rgba(0, 102, 204, 0.1)",errorRing:"rgba(211, 47, 47, 0.1)"},n=document.createElement("div");n.className="rte-anchor-dialog-overlay",n.style.cssText=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
max-width: 450px;
|
|
20
20
|
overflow: hidden;
|
|
21
21
|
animation: rte-anchor-dialog-appear 0.2s ease;
|
|
22
|
-
`,!document.getElementById("rte-anchor-dialog-styles")){const
|
|
22
|
+
`,!document.getElementById("rte-anchor-dialog-styles")){const s=document.createElement("style");s.id="rte-anchor-dialog-styles",s.textContent=`
|
|
23
23
|
@keyframes rte-anchor-dialog-appear {
|
|
24
24
|
from { opacity: 0; transform: scale(0.95); }
|
|
25
25
|
to { opacity: 1; transform: scale(1); }
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
.rte-anchor-dialog input:focus {
|
|
28
28
|
outline: none !important;
|
|
29
29
|
}
|
|
30
|
-
`,document.head.appendChild(
|
|
30
|
+
`,document.head.appendChild(s)}let l="";const h=document.createElement("div");h.style.cssText=`
|
|
31
31
|
display: flex;
|
|
32
32
|
align-items: center;
|
|
33
33
|
justify-content: space-between;
|
|
34
34
|
padding: 16px 20px;
|
|
35
35
|
border-bottom: 1px solid ${e.border};
|
|
36
36
|
background: ${e.panelBg};
|
|
37
|
-
`;const C=document.createElement("h3");C.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,C.textContent="Add Anchor";const
|
|
37
|
+
`;const C=document.createElement("h3");C.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,C.textContent="Add Anchor";const f=document.createElement("button");f.textContent="✕",f.style.cssText=`
|
|
38
38
|
background: none;
|
|
39
39
|
border: none;
|
|
40
40
|
font-size: 24px;
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
justify-content: center;
|
|
49
49
|
border-radius: 4px;
|
|
50
50
|
transition: all 0.2s ease;
|
|
51
|
-
`,
|
|
51
|
+
`,f.onmouseover=()=>{f.style.background=e.closeHoverBg,f.style.color="#f8fafc"},f.onmouseout=()=>{f.style.background="none",f.style.color=e.muted},h.appendChild(C),h.appendChild(f);const B=document.createElement("div");B.style.cssText="padding: 20px;";const m=document.createElement("div");m.style.cssText="margin-bottom: 0;";const y=document.createElement("label");y.textContent="Anchor ID",y.style.cssText=`display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`,y.setAttribute("for","anchor-id-input");const o=document.createElement("input");o.id="anchor-id-input",o.type="text",o.placeholder="e.g., section-introduction",o.value="",o.style.cssText=`
|
|
52
52
|
width: 100%;
|
|
53
53
|
padding: 10px 12px;
|
|
54
54
|
font-size: 14px;
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
background: ${e.fieldBg};
|
|
60
60
|
transition: all 0.2s ease;
|
|
61
61
|
box-sizing: border-box;
|
|
62
|
-
`,
|
|
62
|
+
`,o.style.setProperty("caret-color",e.fieldText);const p=document.createElement("div");p.style.cssText=`
|
|
63
63
|
color: #d32f2f;
|
|
64
64
|
font-size: 12px;
|
|
65
65
|
margin-top: 6px;
|
|
66
66
|
display: none;
|
|
67
|
-
`;const k=document.createElement("div");k.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",k.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,
|
|
67
|
+
`;const k=document.createElement("div");k.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",k.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,m.appendChild(y),m.appendChild(o),m.appendChild(p),m.appendChild(k),B.appendChild(m);const v=document.createElement("div");v.style.cssText=`
|
|
68
68
|
display: flex;
|
|
69
69
|
gap: 12px;
|
|
70
70
|
padding: 16px 20px;
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
transition: all 0.2s ease;
|
|
82
82
|
background: ${e.cancelBg};
|
|
83
83
|
color: ${e.cancelText};
|
|
84
|
-
`,g.onmouseover=()=>g.style.background=e.cancelHover,g.onmouseout=()=>g.style.background=e.cancelBg;const
|
|
84
|
+
`,g.onmouseover=()=>g.style.background=e.cancelHover,g.onmouseout=()=>g.style.background=e.cancelBg;const a=document.createElement("button");a.textContent="Add Anchor",a.style.cssText=`
|
|
85
85
|
padding: 8px 16px;
|
|
86
86
|
font-size: 14px;
|
|
87
87
|
font-weight: 500;
|
|
@@ -91,11 +91,11 @@
|
|
|
91
91
|
transition: all 0.2s ease;
|
|
92
92
|
background: ${e.saveBg};
|
|
93
93
|
color: white;
|
|
94
|
-
`,
|
|
94
|
+
`,a.disabled=!o.value.trim();const N=()=>{o.value.trim()?(a.disabled=!1,a.style.background=e.saveBg,a.style.color="white",a.style.cursor="pointer"):(a.disabled=!0,a.style.background=e.saveDisabledBg,a.style.color=e.saveDisabledText,a.style.cursor="not-allowed")};a.onmouseover=()=>{a.disabled||(a.style.background=e.saveHover,a.style.boxShadow=d?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},a.onmouseout=()=>{a.disabled||(a.style.background=e.saveBg,a.style.boxShadow="none")},v.appendChild(g),v.appendChild(a),o.oninput=()=>{const s=o.value;if(N(),s.trim()){const T=S(s);T.valid?b.has(s)?(l=`Anchor ID already exists: ${s}`,p.textContent="⚠ "+l,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg):(l="",p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg):(l=T.error,p.textContent="⚠ "+l,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg)}else p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg},o.onfocus=()=>{o.style.borderColor=l?e.fieldErrorBorder:e.saveBg,o.style.boxShadow=l?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,o.style.background=l?e.fieldErrorBg:e.fieldFocusBg},o.onblur=()=>{o.style.boxShadow="none",l||(o.style.background=e.fieldBg)};const A=()=>{const s=o.value.trim();!s||!S(s).valid||b.has(s)||(i&&i(s),n.remove())},E=()=>{n.remove()};a.onclick=A,g.onclick=E,f.onclick=E,o.onkeydown=s=>{s.key==="Enter"?(s.preventDefault(),A()):s.key==="Escape"&&(s.preventDefault(),E())},n.onclick=s=>{s.target===n&&E()},u.appendChild(h),u.appendChild(B),u.appendChild(v),n.appendChild(u),document.body.appendChild(n),setTimeout(()=>o.focus(),100)}function _(t,c){let i;if(c)i=c;else{const l=window.getSelection();if(!l||l.rangeCount===0)return;i=l.getRangeAt(0)}let r=null,d=i.startContainer;for(;d&&d!==document.body;){if(d.nodeType===Node.ELEMENT_NODE){const l=d;if(l.getAttribute("contenteditable")==="true"){r=l;break}}d=d.parentNode}const e=r?.innerHTML??"",n=document.createElement("span");n.id=t,n.className="rte-anchor",n.setAttribute("data-type","anchor"),n.setAttribute("data-anchor-id",t),n.setAttribute("title",`Anchor: ${t}`),n.style.cssText=`
|
|
95
95
|
display: inline;
|
|
96
96
|
position: relative;
|
|
97
97
|
cursor: pointer;
|
|
98
|
-
`,
|
|
98
|
+
`,i.insertNode(n),b.add(t),i.setStart(n.nextSibling||n.parentNode,0),i.collapse(!0);const u=window.getSelection();if(u&&(u.removeAllRanges(),u.addRange(i)),r)$(r,e),r.dispatchEvent(new Event("input",{bubbles:!0}));else{const l=w.findEditorContainerFromSelection();if(l){const h=w.getContentElement(l);h&&h.dispatchEvent(new Event("input",{bubbles:!0}))}}D()}function D(){if(document.getElementById("rte-anchor-styles"))return;const t=document.createElement("style");t.id="rte-anchor-styles",t.textContent=`
|
|
99
99
|
.rte-anchor {
|
|
100
100
|
display: inline;
|
|
101
101
|
position: relative;
|
|
@@ -173,4 +173,4 @@
|
|
|
173
173
|
outline: 2px solid #0066cc;
|
|
174
174
|
outline-offset: 2px;
|
|
175
175
|
}
|
|
176
|
-
`,document.head.appendChild(
|
|
176
|
+
`,document.head.appendChild(t)}const I=()=>(typeof window<"u"&&(z(),D()),{name:"anchor",toolbar:[{label:"Anchor",command:"insertAnchor",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-k"}],commands:{insertAnchor:()=>{try{const t=window.getSelection();if(!t||t.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const c=t.getRangeAt(0).cloneRange();return H("add","",i=>{_(i,c)},c),!0}catch(t){return console.error("Failed to insert anchor:",t),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});exports.AnchorPlugin=I;
|