@estiva-app/ui 0.65.2 → 0.66.0
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/dist/BlockNodes.d.ts +33 -0
- package/dist/BlockNodes.d.ts.map +1 -1
- package/dist/ComposerTriggers.d.ts +11 -2
- package/dist/ComposerTriggers.d.ts.map +1 -1
- package/dist/RichText.d.ts +15 -1
- package/dist/RichText.d.ts.map +1 -1
- package/dist/editor.d.ts +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +198 -7
- package/dist/editor.js.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -7
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/registry.json +84 -2
- package/src/BlockNodes.mdx +32 -1
- package/src/BlockNodes.stories.tsx +29 -1
- package/src/BlockNodes.test.tsx +141 -2
- package/src/BlockNodes.tsx +227 -4
- package/src/ComposerTriggers.test.tsx +23 -0
- package/src/ComposerTriggers.tsx +61 -5
- package/src/RichText.mdx +12 -0
- package/src/RichText.stories.tsx +77 -0
- package/src/RichText.test.tsx +91 -0
- package/src/RichText.tsx +116 -12
- package/src/editor.ts +3 -0
- package/src/index.ts +1 -1
- package/src/registry/registry.test.ts +4 -4
package/dist/BlockNodes.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import { Extension, Node } from '@tiptap/core';
|
|
3
|
+
import { type Transaction } from '@tiptap/pm/state';
|
|
3
4
|
/**
|
|
4
5
|
* `id` on every block, carried as the `blockId` attribute.
|
|
5
6
|
*
|
|
@@ -101,4 +102,36 @@ export interface AttachmentNodeOptions {
|
|
|
101
102
|
* exists to prevent.
|
|
102
103
|
*/
|
|
103
104
|
export declare const AttachmentNode: Node<AttachmentNodeOptions, any>;
|
|
105
|
+
/**
|
|
106
|
+
* Whether a change is a click on a checklist item's box. The click does not
|
|
107
|
+
* focus the editor, so no blur follows it: an editor that saves on blur saves
|
|
108
|
+
* a tick straight away instead (RIC-19, Miky 2026-10-13: one click ticks).
|
|
109
|
+
*/
|
|
110
|
+
export declare function isChecklistTick(transaction: Transaction): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* A checklist item — SPEC §13.3's `checked` on a list item (RIC-19): `true`
|
|
113
|
+
* ticked, `false` not, absent a plain item. Add it beside `BlockId`.
|
|
114
|
+
*
|
|
115
|
+
* - **The box ticks with one click**, where the description is read, and the
|
|
116
|
+
* change says so (`isChecklistTick`), so the app saves it at once.
|
|
117
|
+
* - **`[ ] ` or `[] ` at the start of a line** makes it, `[x] ` ticked; in a
|
|
118
|
+
* list it turns that item into one.
|
|
119
|
+
* - **Enter** starts the next item unticked: a new item never takes the tick
|
|
120
|
+
* of the one it was split from. At the start of an item, the text moves down
|
|
121
|
+
* with its tick and the empty item above is unticked. On an empty item Enter
|
|
122
|
+
* leaves the list, as in any list.
|
|
123
|
+
* - **Backspace** at the start of a checklist item takes its box away first;
|
|
124
|
+
* the next one joins it to the item above, as in any list.
|
|
125
|
+
*
|
|
126
|
+
* An editor without it drops `checked` on save and keeps the item and its text.
|
|
127
|
+
*/
|
|
128
|
+
export declare const Checklist: Extension<any, any>;
|
|
129
|
+
/**
|
|
130
|
+
* A callout — SPEC §13.3's `tone` on a quote (RIC-19): a quote drawn to stand
|
|
131
|
+
* out, in one of GitHub's alert kinds (`note`, `tip`, `important`, `warning`,
|
|
132
|
+
* `caution`). Its look is `RichText`'s, by `data-tone`; a tone it does not
|
|
133
|
+
* know looks like `note`, and the editor keeps it as written. Add it beside
|
|
134
|
+
* `BlockId`.
|
|
135
|
+
*/
|
|
136
|
+
export declare const Callout: Extension<any, any>;
|
|
104
137
|
//# sourceMappingURL=BlockNodes.d.ts.map
|
package/dist/BlockNodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockNodes.d.ts","sourceRoot":"","sources":["../src/BlockNod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MAAM,OAAO,qBAkBlB,CAAA"}
|
|
@@ -163,12 +163,17 @@ export interface SlashCommand {
|
|
|
163
163
|
keywords?: readonly string[];
|
|
164
164
|
/** Runs once the `/query` that summoned the list has been removed. */
|
|
165
165
|
run: (editor: Editor) => void;
|
|
166
|
+
/**
|
|
167
|
+
* The extensions (by name) the row needs: an editor without one of them is
|
|
168
|
+
* not offered the row, so no row makes something the editor cannot hold.
|
|
169
|
+
*/
|
|
170
|
+
needs?: readonly string[];
|
|
166
171
|
}
|
|
167
172
|
export interface SlashSection {
|
|
168
173
|
label: string;
|
|
169
174
|
commands: readonly SlashCommand[];
|
|
170
175
|
}
|
|
171
|
-
export type FormatId = 'paragraph' | 'heading' | 'subheading' | 'quote' | 'bulletList' | 'orderedList' | 'code';
|
|
176
|
+
export type FormatId = 'paragraph' | 'heading' | 'subheading' | 'quote' | 'bulletList' | 'orderedList' | 'code' | 'checklist' | 'note' | 'warning';
|
|
172
177
|
export interface FormatDef {
|
|
173
178
|
id: FormatId;
|
|
174
179
|
label: string;
|
|
@@ -191,7 +196,11 @@ export type CodeFormat = 'inline' | 'block';
|
|
|
191
196
|
* nothing changed, not that anything failed.
|
|
192
197
|
*/
|
|
193
198
|
export declare function applyFormat(editor: Editor, id: FormatId, code?: CodeFormat): boolean;
|
|
194
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* The Format section every app's `/` opens with. A block editor's also offers
|
|
201
|
+
* a checklist and the callouts — only where the editor has the `Checklist` and
|
|
202
|
+
* `Callout` extensions (`SlashCommand.needs`).
|
|
203
|
+
*/
|
|
195
204
|
export declare function formatSection(code?: CodeFormat): SlashSection;
|
|
196
205
|
/** A row that types another trigger, so its own list opens — `@` from `/`. */
|
|
197
206
|
export declare function typeTrigger(input: string): SlashCommand['run'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerTriggers.d.ts","sourceRoot":"","sources":["../src/ComposerTriggers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK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A;IAChB,mGAAmG;IACnG,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,SAAS,SAAS,EAQvC,CAAA;AAeD,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE3C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAE,UAAqB,GAAG,OAAO,CA0C9F;AAgBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,UAAqB,GAAG,YAAY,CAavE;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAM9D;AAMD,4FAA4F;AAC5F,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAGpG;AAED,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,QAAQ,EAAE,SAAS,YAAY,EAAE,CAAA;CAClC;AAID;;;;GAIG;AACH,eAAO,MAAM,aAAa,sCAgCxB,CAAA"}
|
package/dist/RichText.d.ts
CHANGED
|
@@ -43,6 +43,12 @@ export interface RichTextBlock {
|
|
|
43
43
|
language?: string;
|
|
44
44
|
/** A numbered list's first number. */
|
|
45
45
|
start?: number;
|
|
46
|
+
/** How far a list item is indented under the items above it. A list's items stay flat; this draws them nested. */
|
|
47
|
+
indent?: number;
|
|
48
|
+
/** A checklist item's tick: `true` or `false`, absent on a plain item. */
|
|
49
|
+
checked?: boolean;
|
|
50
|
+
/** A callout's tone (`note`, `tip`, `important`, `warning`, `caution`), absent on a plain quote. */
|
|
51
|
+
tone?: string;
|
|
46
52
|
attrs?: Record<string, unknown>;
|
|
47
53
|
inline?: readonly RichTextRun[];
|
|
48
54
|
children?: readonly RichTextBlock[];
|
|
@@ -69,11 +75,19 @@ export interface RichTextProps {
|
|
|
69
75
|
* `undefined` to leave it to the part, which draws its words.
|
|
70
76
|
*/
|
|
71
77
|
renderBlock?: (block: RichTextBlock) => ReactNode | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Ticks or unticks a checklist item, by its block id: its box is then a
|
|
80
|
+
* control, one click where the text is read. Without it the box is a picture
|
|
81
|
+
* of the state — for someone who may not change the text.
|
|
82
|
+
*/
|
|
83
|
+
onTick?: (blockId: string, checked: boolean) => void;
|
|
72
84
|
}
|
|
73
85
|
/**
|
|
74
86
|
* RichText's look, for a box you draw yourself: an editor's, so that what is
|
|
75
87
|
* being written looks the same as what is read. Put it on the editor's root.
|
|
76
88
|
*/
|
|
77
89
|
export declare function richTextClassName(size?: RichTextSize, className?: string): string;
|
|
78
|
-
|
|
90
|
+
/** The tone a callout is drawn in: its own, or `note` for one this part does not know (§13.3). */
|
|
91
|
+
export declare function calloutLook(tone: string): string;
|
|
92
|
+
export declare function RichText({ blocks, size, renderText, renderReference, renderBlock, onTick, }: RichTextProps): import("react").JSX.Element | null;
|
|
79
93
|
//# sourceMappingURL=RichText.d.ts.map
|
package/dist/RichText.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../src/RichText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../src/RichText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAA;AAMlD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,C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;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,YAAwB,EAAE,SAAS,CAAC,EAAE,MAAM,UAGnF;AAkDD,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhD;AAuMD,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,IAAgB,EAChB,UAA2B,EAC3B,eAA+C,EAC/C,WAAW,EACX,MAAM,GACP,EAAE,aAAa,sCAQf"}
|
package/dist/editor.d.ts
CHANGED
|
@@ -13,5 +13,5 @@ export { CodeBlockColours } from './CodeBlockColours';
|
|
|
13
13
|
export { suggestionPopup, isSuggestionActive, isSuggestionOpen, type SuggestionPopupOptions } from './suggestionPopup';
|
|
14
14
|
export { EditorBlockHandle, blockDropCursor, deleteBlock, moveBlock, duplicateBlock, startBlockDrag, type EditorBlockHandleProps, type BlockTurnInto } from './EditorBlockHandle';
|
|
15
15
|
export { PersonMention, UrgentPersonMention, CaptionedReference, ReferenceTrigger, SlashCommands, peopleMenu, referenceMenu, filterPeople, urgentPubkeys, filterReferences, formatSection, applyFormat, typeTrigger, filterSlashSections, FORMATS, type MentionPerson, type PersonMentionOptions, type CaptionedItem, type CaptionedReferenceOptions, type ReferenceTriggerOptions, type ReferenceMenuOptions, type SlashCommand, type SlashSection, type SlashCommandsOptions, type FormatId, type FormatDef, type CodeFormat, } from './ComposerTriggers';
|
|
16
|
-
export { BlockId, UnknownBlock, ReferenceNode, AttachmentNode, type ReferenceNodeOptions, type ReferenceViewProps, type AttachmentNodeOptions, type AttachmentViewProps, } from './BlockNodes';
|
|
16
|
+
export { BlockId, Checklist, Callout, isChecklistTick, UnknownBlock, ReferenceNode, AttachmentNode, type ReferenceNodeOptions, type ReferenceViewProps, type AttachmentNodeOptions, type AttachmentViewProps, } from './BlockNodes';
|
|
17
17
|
//# sourceMappingURL=editor.d.ts.map
|
package/dist/editor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAA"}
|
package/dist/editor.js
CHANGED
|
@@ -793,6 +793,7 @@ var ReferenceTrigger = Extension3.create({
|
|
|
793
793
|
];
|
|
794
794
|
}
|
|
795
795
|
});
|
|
796
|
+
var offers = (editor, command) => !command.needs || command.needs.every((name) => editor.extensionManager.extensions.some((extension) => extension.name === name));
|
|
796
797
|
var FORMATS = [
|
|
797
798
|
{ id: "paragraph", label: "Text" },
|
|
798
799
|
{ id: "heading", label: "Heading", trigger: "#" },
|
|
@@ -802,11 +803,16 @@ var FORMATS = [
|
|
|
802
803
|
{ id: "bulletList", label: "Bulleted list", trigger: "-" },
|
|
803
804
|
{ id: "orderedList", label: "Numbered list", trigger: "1." }
|
|
804
805
|
];
|
|
806
|
+
var DOCUMENT_FORMATS = [
|
|
807
|
+
{ id: "checklist", label: "Checklist", trigger: "[]" },
|
|
808
|
+
{ id: "note", label: "Note" },
|
|
809
|
+
{ id: "warning", label: "Warning" }
|
|
810
|
+
];
|
|
805
811
|
function applyFormat(editor, id, code = "inline") {
|
|
806
812
|
const chain = editor.chain().focus();
|
|
807
813
|
const run = (command, ...args) => {
|
|
808
|
-
const
|
|
809
|
-
return
|
|
814
|
+
const named2 = chain[command];
|
|
815
|
+
return named2 ? named2(...args).run() : false;
|
|
810
816
|
};
|
|
811
817
|
switch (id) {
|
|
812
818
|
case "paragraph":
|
|
@@ -823,17 +829,38 @@ function applyFormat(editor, id, code = "inline") {
|
|
|
823
829
|
return run("toggleOrderedList");
|
|
824
830
|
case "code":
|
|
825
831
|
return run(code === "block" ? "toggleCodeBlock" : "toggleCode");
|
|
832
|
+
case "checklist": {
|
|
833
|
+
if (!editor.isActive("listItem") && !run("toggleBulletList")) return false;
|
|
834
|
+
if (typeof editor.getAttributes("listItem").checked === "boolean") return true;
|
|
835
|
+
return editor.chain().updateAttributes("listItem", { checked: false }).run();
|
|
836
|
+
}
|
|
837
|
+
case "note":
|
|
838
|
+
case "warning": {
|
|
839
|
+
if (!editor.isActive("blockquote") && !run("toggleBlockquote")) return false;
|
|
840
|
+
return editor.chain().updateAttributes("blockquote", { tone: id }).run();
|
|
841
|
+
}
|
|
826
842
|
default:
|
|
827
843
|
return false;
|
|
828
844
|
}
|
|
829
845
|
}
|
|
846
|
+
var KEYWORDS = {
|
|
847
|
+
checklist: ["todo", "task"],
|
|
848
|
+
note: ["callout"],
|
|
849
|
+
warning: ["callout"]
|
|
850
|
+
};
|
|
851
|
+
var NEEDS = {
|
|
852
|
+
checklist: ["checklist"],
|
|
853
|
+
note: ["callout"],
|
|
854
|
+
warning: ["callout"]
|
|
855
|
+
};
|
|
830
856
|
function formatSection(code = "inline") {
|
|
831
857
|
return {
|
|
832
858
|
label: "Format",
|
|
833
|
-
commands: FORMATS.map((format) => ({
|
|
859
|
+
commands: (code === "block" ? [...FORMATS, ...DOCUMENT_FORMATS] : FORMATS).map((format) => ({
|
|
834
860
|
key: `format-${format.id}`,
|
|
835
861
|
row: { label: format.label, shortcut: code === "block" && format.blockTrigger || format.trigger },
|
|
836
|
-
keywords: [format.id],
|
|
862
|
+
keywords: [format.id, ...KEYWORDS[format.id] ?? []],
|
|
863
|
+
...NEEDS[format.id] ? { needs: NEEDS[format.id] } : {},
|
|
837
864
|
run: (editor) => {
|
|
838
865
|
applyFormat(editor, format.id, code);
|
|
839
866
|
}
|
|
@@ -865,7 +892,9 @@ var SlashCommands = Extension3.create({
|
|
|
865
892
|
char: "/",
|
|
866
893
|
startOfLine: false,
|
|
867
894
|
pluginKey: new PluginKey3("slashCommands"),
|
|
868
|
-
items: ({ query }) => filterSlashSections(sections, query).flatMap(
|
|
895
|
+
items: ({ query, editor }) => filterSlashSections(sections, query).flatMap(
|
|
896
|
+
(section, at) => section.commands.filter((command) => offers(editor, command)).map((command) => ({ ...command, section: at }))
|
|
897
|
+
),
|
|
869
898
|
command: ({ editor, range, props }) => {
|
|
870
899
|
editor.chain().focus().deleteRange(range).run();
|
|
871
900
|
props.run(editor);
|
|
@@ -884,10 +913,13 @@ var SlashCommands = Extension3.create({
|
|
|
884
913
|
});
|
|
885
914
|
|
|
886
915
|
// src/BlockNodes.tsx
|
|
887
|
-
import { Extension as Extension4, Node as Node2 } from "@tiptap/core";
|
|
916
|
+
import { Extension as Extension4, InputRule, Node as Node2 } from "@tiptap/core";
|
|
917
|
+
import { DOMSerializer } from "@tiptap/pm/model";
|
|
888
918
|
import { Plugin as Plugin3, PluginKey as PluginKey4 } from "@tiptap/pm/state";
|
|
889
919
|
import { Mapping, ReplaceAroundStep } from "@tiptap/pm/transform";
|
|
890
|
-
import { NodeViewWrapper as NodeViewWrapper2, ReactNodeViewRenderer as ReactNodeViewRenderer2 } from "@tiptap/react";
|
|
920
|
+
import { NodeViewWrapper as NodeViewWrapper2, ReactNodeViewRenderer as ReactNodeViewRenderer2, ReactRenderer as ReactRenderer2 } from "@tiptap/react";
|
|
921
|
+
import { Checkbox } from "@estiva-app/ui";
|
|
922
|
+
import { calloutLook } from "@estiva-app/ui";
|
|
891
923
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
892
924
|
var BLOCK_TYPES = [
|
|
893
925
|
"paragraph",
|
|
@@ -1189,10 +1221,168 @@ var AttachmentNode = Node2.create({
|
|
|
1189
1221
|
return ReactNodeViewRenderer2(({ node }) => /* @__PURE__ */ jsx5(NodeViewWrapper2, { className: "my-2", children: /* @__PURE__ */ jsx5(View, { attrs: node.attrs }) }));
|
|
1190
1222
|
}
|
|
1191
1223
|
});
|
|
1224
|
+
var TICK = "checklistTick";
|
|
1225
|
+
function isChecklistTick(transaction) {
|
|
1226
|
+
return transaction.getMeta(TICK) === true;
|
|
1227
|
+
}
|
|
1228
|
+
function named(chain, command, ...args) {
|
|
1229
|
+
const own = chain[command];
|
|
1230
|
+
return own ? own(...args) : chain;
|
|
1231
|
+
}
|
|
1232
|
+
function itemAtCaret(state) {
|
|
1233
|
+
const { $from } = state.selection;
|
|
1234
|
+
if ($from.depth < 2) return null;
|
|
1235
|
+
const item = $from.node(-1);
|
|
1236
|
+
if (item.type.name !== "listItem" || $from.index(-1) !== 0) return null;
|
|
1237
|
+
return { node: item, pos: $from.before(-1) };
|
|
1238
|
+
}
|
|
1239
|
+
var sameAttrs = (a, b) => Object.keys({ ...a.attrs, ...b.attrs }).every((key) => a.attrs[key] === b.attrs[key]);
|
|
1240
|
+
function listItemView(editor, node, view, getPos) {
|
|
1241
|
+
const toDOM = node.type.spec.toDOM;
|
|
1242
|
+
const { dom, contentDOM } = toDOM ? DOMSerializer.renderSpec(document, toDOM(node)) : { dom: document.createElement("li"), contentDOM: void 0 };
|
|
1243
|
+
const checked = node.attrs.checked;
|
|
1244
|
+
if (typeof checked !== "boolean") return { dom, contentDOM: contentDOM ?? dom, update: (next) => next.type === node.type && sameAttrs(next, node) };
|
|
1245
|
+
const li = dom;
|
|
1246
|
+
const box = document.createElement("span");
|
|
1247
|
+
box.contentEditable = "false";
|
|
1248
|
+
box.setAttribute("data-checklist-box", "");
|
|
1249
|
+
const body = document.createElement("div");
|
|
1250
|
+
li.replaceChildren(box, body);
|
|
1251
|
+
const tick = (next) => {
|
|
1252
|
+
const pos = getPos();
|
|
1253
|
+
if (pos === void 0 || !view.editable) return;
|
|
1254
|
+
view.dispatch(view.state.tr.setNodeAttribute(pos, "checked", next).setMeta(TICK, true));
|
|
1255
|
+
};
|
|
1256
|
+
let words = node.firstChild?.textContent.trim() || "Item";
|
|
1257
|
+
const props = () => ({ checked, onChange: view.editable ? tick : void 0, "aria-label": words });
|
|
1258
|
+
const renderer = new ReactRenderer2(Checkbox, { editor, props: props(), as: "span" });
|
|
1259
|
+
box.appendChild(renderer.element);
|
|
1260
|
+
let drawn = "";
|
|
1261
|
+
const sync = () => {
|
|
1262
|
+
const now = `${view.editable}:${words}`;
|
|
1263
|
+
if (now === drawn) return;
|
|
1264
|
+
drawn = now;
|
|
1265
|
+
renderer.updateProps(props());
|
|
1266
|
+
for (const [name, value] of Object.entries({ role: "checkbox", "aria-checked": String(checked), "aria-readonly": "true", "aria-label": words })) {
|
|
1267
|
+
if (view.editable) box.removeAttribute(name);
|
|
1268
|
+
else box.setAttribute(name, value);
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
sync();
|
|
1272
|
+
editor.on("update", sync);
|
|
1273
|
+
return {
|
|
1274
|
+
dom: li,
|
|
1275
|
+
contentDOM: body,
|
|
1276
|
+
update: (next) => {
|
|
1277
|
+
if (next.type !== node.type || !sameAttrs(next, node)) return false;
|
|
1278
|
+
words = next.firstChild?.textContent.trim() || "Item";
|
|
1279
|
+
sync();
|
|
1280
|
+
return true;
|
|
1281
|
+
},
|
|
1282
|
+
stopEvent: (event) => box.contains(event.target),
|
|
1283
|
+
ignoreMutation: (mutation) => box.contains(mutation.target),
|
|
1284
|
+
destroy: () => {
|
|
1285
|
+
editor.off("update", sync);
|
|
1286
|
+
renderer.destroy();
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
var Checklist = Extension4.create({
|
|
1291
|
+
name: "checklist",
|
|
1292
|
+
// Before the list item's own Enter and Backspace.
|
|
1293
|
+
priority: 101,
|
|
1294
|
+
addGlobalAttributes() {
|
|
1295
|
+
return [
|
|
1296
|
+
{
|
|
1297
|
+
types: ["listItem"],
|
|
1298
|
+
attributes: {
|
|
1299
|
+
checked: {
|
|
1300
|
+
default: null,
|
|
1301
|
+
keepOnSplit: false,
|
|
1302
|
+
parseHTML: (element) => {
|
|
1303
|
+
const value = element.getAttribute("data-checked");
|
|
1304
|
+
return value === "true" ? true : value === "false" ? false : null;
|
|
1305
|
+
},
|
|
1306
|
+
renderHTML: (attributes) => typeof attributes.checked === "boolean" ? { "data-checked": String(attributes.checked) } : {}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
];
|
|
1311
|
+
},
|
|
1312
|
+
addInputRules() {
|
|
1313
|
+
return [
|
|
1314
|
+
new InputRule({
|
|
1315
|
+
find: /^\[([ xX]?)\]\s$/,
|
|
1316
|
+
handler: ({ state, range, match, chain }) => {
|
|
1317
|
+
const checked = match[1].toLowerCase() === "x";
|
|
1318
|
+
const inList = itemAtCaret(state) !== null;
|
|
1319
|
+
if (!inList && !chain().toggleBulletList) return null;
|
|
1320
|
+
const deleted = chain().deleteRange(range);
|
|
1321
|
+
const listed2 = inList ? deleted : named(deleted, "toggleBulletList");
|
|
1322
|
+
listed2.updateAttributes("listItem", { checked }).run();
|
|
1323
|
+
}
|
|
1324
|
+
})
|
|
1325
|
+
];
|
|
1326
|
+
},
|
|
1327
|
+
addKeyboardShortcuts() {
|
|
1328
|
+
return {
|
|
1329
|
+
Enter: () => {
|
|
1330
|
+
const { state } = this.editor;
|
|
1331
|
+
const item = itemAtCaret(state);
|
|
1332
|
+
const { $from, empty } = state.selection;
|
|
1333
|
+
if (!item || typeof item.node.attrs.checked !== "boolean") return false;
|
|
1334
|
+
if (!empty) return this.editor.chain().deleteSelection().splitListItem("listItem", { checked: false }).run();
|
|
1335
|
+
if ($from.parent.content.size === 0) return false;
|
|
1336
|
+
if ($from.parentOffset > 0) return this.editor.commands.splitListItem("listItem", { checked: false });
|
|
1337
|
+
return this.editor.chain().splitListItem("listItem", { checked: item.node.attrs.checked }).command(({ tr }) => {
|
|
1338
|
+
tr.setNodeAttribute(tr.mapping.map(item.pos), "checked", false);
|
|
1339
|
+
return true;
|
|
1340
|
+
}).run();
|
|
1341
|
+
},
|
|
1342
|
+
Backspace: () => {
|
|
1343
|
+
const { state } = this.editor;
|
|
1344
|
+
const item = itemAtCaret(state);
|
|
1345
|
+
const { $from, empty } = state.selection;
|
|
1346
|
+
if (!item || !empty || $from.parentOffset > 0 || typeof item.node.attrs.checked !== "boolean") return false;
|
|
1347
|
+
this.editor.view.dispatch(state.tr.setNodeAttribute(item.pos, "checked", null));
|
|
1348
|
+
return true;
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
},
|
|
1352
|
+
addProseMirrorPlugins() {
|
|
1353
|
+
const editor = this.editor;
|
|
1354
|
+
return [
|
|
1355
|
+
new Plugin3({
|
|
1356
|
+
key: new PluginKey4("checklist"),
|
|
1357
|
+
props: { nodeViews: { listItem: (node, view, getPos) => listItemView(editor, node, view, getPos) } }
|
|
1358
|
+
})
|
|
1359
|
+
];
|
|
1360
|
+
}
|
|
1361
|
+
});
|
|
1362
|
+
var Callout = Extension4.create({
|
|
1363
|
+
name: "callout",
|
|
1364
|
+
addGlobalAttributes() {
|
|
1365
|
+
return [
|
|
1366
|
+
{
|
|
1367
|
+
types: ["blockquote"],
|
|
1368
|
+
attributes: {
|
|
1369
|
+
tone: {
|
|
1370
|
+
default: null,
|
|
1371
|
+
parseHTML: (element) => element.getAttribute("data-tone"),
|
|
1372
|
+
// As `RichText` draws it: the tone as written, and the look it is drawn in.
|
|
1373
|
+
renderHTML: (attributes) => typeof attributes.tone === "string" ? { "data-tone": attributes.tone, "data-callout": calloutLook(attributes.tone) } : {}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
];
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1192
1380
|
export {
|
|
1193
1381
|
AttachmentNode,
|
|
1194
1382
|
BlockId,
|
|
1383
|
+
Callout,
|
|
1195
1384
|
CaptionedReference,
|
|
1385
|
+
Checklist,
|
|
1196
1386
|
CodeBlockColours,
|
|
1197
1387
|
EditorBlockHandle,
|
|
1198
1388
|
FORMATS,
|
|
@@ -1213,6 +1403,7 @@ export {
|
|
|
1213
1403
|
filterReferences,
|
|
1214
1404
|
filterSlashSections,
|
|
1215
1405
|
formatSection,
|
|
1406
|
+
isChecklistTick,
|
|
1216
1407
|
isSuggestionActive,
|
|
1217
1408
|
isSuggestionOpen,
|
|
1218
1409
|
moveBlock,
|