edytor 0.1.0-next.31 → 0.1.0-next.32
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
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Edytor contributors
|
|
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
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
|
|
16
16
|
Edytor aims to be for Svelte what Slate.js is for React: a heavily customizable editor with an API to build any kind of collaborative rich text editor.
|
|
17
17
|
|
|
18
|
-
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.
|
|
18
|
+
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.32`, `edytor@next` on npm) and not ready for production; the API changes between releases without a compatibility layer. The untagged `edytor@0.0.11` on npm predates the current API. Issues and PRs are welcome: when you report a bug, include the document's JSON value.
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
22
|
-
- **Notion-style editing out of the box.** `<Edytor />` alone is a rich text editor with images: headings, lists, to-dos, toggles, callouts, quotes, dividers, ten marks
|
|
22
|
+
- **Notion-style editing out of the box.** `<Edytor />` alone is a rich text editor with images and block handles: headings, lists, to-dos, toggles, callouts, quotes, dividers, ten marks and Notion's hotkeys. Add the Notion theme, a block menu (drag one block, or every block the selection covers), a slash menu, a selection toolbar, markdown shortcuts (`markdownShortcutsPlugin`) and code blocks.
|
|
23
23
|
- **Columns, opt-in.** List `columnsPlugin` for Notion's multi-column layouts: drag a block to the edge of another to put them side by side, or pick "2 columns" to "5 columns"; drag the gap to resize. Layouts converge across collaborators and the room ([Columns](https://edytor.dev/docs/plugins/columns)).
|
|
24
24
|
- **Your markup.** Blocks, marks and inline atoms render through your Svelte snippets; the slash menu, toolbar, block menu and handles take a snippet and keep their behavior.
|
|
25
25
|
- **Synced properties.** `block.data`, `atom.data` and `edytor.data` read and write like plain objects (`bind:value={block.data.title}`); each property and each array item syncs on its own, so concurrent edits of different properties, or of different items of one array, merge.
|
|
@@ -17,11 +17,11 @@ export declare const sanitizeCssColorValue: (value: unknown) => string | null;
|
|
|
17
17
|
/**
|
|
18
18
|
* Scheme allowlist for link hrefs. `javascript:`/`data:`/`vbscript:`
|
|
19
19
|
* payloads can arrive through native `insertLink`, pasted HTML, or a
|
|
20
|
-
* malicious collaborator — and Svelte renders `href` verbatim. The
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* malicious collaborator — and Svelte renders `href` verbatim. The href is
|
|
21
|
+
* read as the browser's URL parser reads it: it strips C0 controls and
|
|
22
|
+
* spaces at both ends and tab/newline/CR anywhere (`\u0001javascript:` is
|
|
23
|
+
* `javascript:` to a browser), then resolves it against a base; only an
|
|
24
|
+
* allowed scheme, or a relative href that stays relative, passes.
|
|
25
25
|
*/
|
|
26
26
|
export declare const sanitizeLinkHref: (href: unknown) => string | null;
|
|
27
27
|
/**
|
|
@@ -26,27 +26,26 @@ export const sanitizeCssColorValue = (value) => {
|
|
|
26
26
|
/**
|
|
27
27
|
* Scheme allowlist for link hrefs. `javascript:`/`data:`/`vbscript:`
|
|
28
28
|
* payloads can arrive through native `insertLink`, pasted HTML, or a
|
|
29
|
-
* malicious collaborator — and Svelte renders `href` verbatim. The
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* malicious collaborator — and Svelte renders `href` verbatim. The href is
|
|
30
|
+
* read as the browser's URL parser reads it: it strips C0 controls and
|
|
31
|
+
* spaces at both ends and tab/newline/CR anywhere (`\u0001javascript:` is
|
|
32
|
+
* `javascript:` to a browser), then resolves it against a base; only an
|
|
33
|
+
* allowed scheme, or a relative href that stays relative, passes.
|
|
34
34
|
*/
|
|
35
35
|
export const sanitizeLinkHref = (href) => {
|
|
36
36
|
// Marks arrive from untrusted sources too (synced peers, paste) —
|
|
37
37
|
// reject non-strings outright instead of throwing on `.replace`.
|
|
38
38
|
if (typeof href !== 'string')
|
|
39
39
|
return null;
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
// detectable scheme instead of slipping through as "scheme-less".
|
|
43
|
-
const trimmed = href.replace(/[\t\n\r]/g, '').trim();
|
|
40
|
+
// eslint-disable-next-line no-control-regex
|
|
41
|
+
const trimmed = href.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, '');
|
|
44
42
|
if (!trimmed)
|
|
45
43
|
return null;
|
|
46
|
-
if (!/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(trimmed))
|
|
47
|
-
return trimmed;
|
|
48
44
|
try {
|
|
49
|
-
|
|
45
|
+
// A relative href resolves to the base's `https:`: it names no scheme of its own.
|
|
46
|
+
return SAFE_LINK_PROTOCOLS.has(new URL(trimmed, 'https://relative.invalid/').protocol)
|
|
47
|
+
? trimmed
|
|
48
|
+
: null;
|
|
50
49
|
}
|
|
51
50
|
catch {
|
|
52
51
|
return null;
|