wiki-formant 0.27.0 → 0.27.1
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/README.md +2 -0
- package/dist/editor.d.ts +13 -0
- package/dist/editor.js +19 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -541,6 +541,8 @@ The ones that take config take it because that is exactly where the two copies d
|
|
|
541
541
|
|
|
542
542
|
`TOOLBAR_ACTIONS` are the formatting commands with the labels a screen reader announces — two toolbars titled buttons with the internal key, so one said "codeBlock". Pick yours in order with `toolbarActions([...])`, render each through `ToolbarButton` (named, and `aria-pressed`, since these are toggles), and run a table command with `runTableAction`. Upload and embed stay with the caller; they are the parts that differ.
|
|
543
543
|
|
|
544
|
+
A link is stored as its `href` and the `link` class, nothing else (`wikiLink`). Stock Tiptap writes `target="_blank" rel="noopener noreferrer nofollow"` onto every link, internal ones included, which on a site throws away its own link equity and opens in-site navigation in new tabs. Whether a link is external depends on the host serving the page, so `normaliseLinks` decides it at render time. A legacy link loses both attributes the next time its page is saved.
|
|
545
|
+
|
|
544
546
|
The redirect resolves through the wiki's own route, because the editor cannot read it cross-origin. `resolveMapUrl` is the client half and `resolveMapHandler` the whole route: exact shortener hosts, one hop, an allowlisted landing host, a timeout, and your sign-in check as `authorize`. One of the two copies it replaced matched `goo.gl` as a substring and followed every redirect for anyone who asked.
|
|
545
547
|
|
|
546
548
|
```ts
|
package/dist/editor.d.ts
CHANGED
|
@@ -15,6 +15,19 @@ export type { StarterKitOptions } from '@tiptap/starter-kit';
|
|
|
15
15
|
export type { LinkOptions } from '@tiptap/extension-link';
|
|
16
16
|
export type { ImageOptions } from '@tiptap/extension-image';
|
|
17
17
|
export type { TableOptions } from '@tiptap/extension-table';
|
|
18
|
+
/**
|
|
19
|
+
* Tiptap's Link, storing an href and the `link` class and nothing else.
|
|
20
|
+
*
|
|
21
|
+
* Stock Link writes `target="_blank" rel="noopener noreferrer nofollow"` onto
|
|
22
|
+
* every link, internal ones included, and the schema then reads both back from
|
|
23
|
+
* stored HTML, so a page edited once kept them for good. Nofollow on a site's
|
|
24
|
+
* own links throws away its link equity, and a new tab for in-site navigation
|
|
25
|
+
* is a bug. Whether a link is external depends on the host it is served from,
|
|
26
|
+
* which the editor cannot know, so the render path decides: `normaliseLinks`
|
|
27
|
+
* from `wiki-formant/links`. Dropping both attributes from the mark also cleans
|
|
28
|
+
* a legacy link the next time its page is saved.
|
|
29
|
+
*/
|
|
30
|
+
export declare const wikiLink: import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any>;
|
|
18
31
|
export interface WikiEditorExtensionOptions {
|
|
19
32
|
/** Empty-document prompt. */
|
|
20
33
|
placeholder?: string;
|
package/dist/editor.js
CHANGED
|
@@ -56,6 +56,24 @@ function cleanPastedHtml(html) {
|
|
|
56
56
|
});
|
|
57
57
|
return doc.body.innerHTML;
|
|
58
58
|
}
|
|
59
|
+
// ---- extensions -------------------------------------------------------------
|
|
60
|
+
/**
|
|
61
|
+
* Tiptap's Link, storing an href and the `link` class and nothing else.
|
|
62
|
+
*
|
|
63
|
+
* Stock Link writes `target="_blank" rel="noopener noreferrer nofollow"` onto
|
|
64
|
+
* every link, internal ones included, and the schema then reads both back from
|
|
65
|
+
* stored HTML, so a page edited once kept them for good. Nofollow on a site's
|
|
66
|
+
* own links throws away its link equity, and a new tab for in-site navigation
|
|
67
|
+
* is a bug. Whether a link is external depends on the host it is served from,
|
|
68
|
+
* which the editor cannot know, so the render path decides: `normaliseLinks`
|
|
69
|
+
* from `wiki-formant/links`. Dropping both attributes from the mark also cleans
|
|
70
|
+
* a legacy link the next time its page is saved.
|
|
71
|
+
*/
|
|
72
|
+
export const wikiLink = TiptapLink.extend({
|
|
73
|
+
addAttributes() {
|
|
74
|
+
return Object.fromEntries(Object.entries(this.parent?.() ?? {}).filter(([name]) => name !== 'target' && name !== 'rel'));
|
|
75
|
+
},
|
|
76
|
+
}).configure({ openOnClick: false, HTMLAttributes: { class: 'link', target: null, rel: null } });
|
|
59
77
|
/**
|
|
60
78
|
* The editor's extension set.
|
|
61
79
|
*
|
|
@@ -67,7 +85,7 @@ function cleanPastedHtml(html) {
|
|
|
67
85
|
function wikiEditorExtensions({ placeholder = '', nodes = [], } = {}) {
|
|
68
86
|
return [
|
|
69
87
|
StarterKit.configure({ heading: { levels: [2, 3, 4] }, codeBlock: false }),
|
|
70
|
-
|
|
88
|
+
wikiLink,
|
|
71
89
|
TiptapImage.configure({
|
|
72
90
|
inline: false,
|
|
73
91
|
allowBase64: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-formant",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "The portable half of a wiki: derived taxonomy and facet controls, a version-negotiating MCP transport, markdown twins, block rendering, a rich-text editor engine, and conditional-GET plumbing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -193,7 +193,8 @@
|
|
|
193
193
|
},
|
|
194
194
|
"scripts": {
|
|
195
195
|
"build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/base.css dist/base.css",
|
|
196
|
-
"test": "npm run build && node --test 'test/*.test.js'"
|
|
196
|
+
"test": "npm run build && node --test 'test/*.test.js'",
|
|
197
|
+
"prepare": "git config core.hooksPath .githooks || true"
|
|
197
198
|
},
|
|
198
199
|
"devDependencies": {
|
|
199
200
|
"@radixdlt/rola": "^2.1.0",
|