@dou-ui/editor 0.1.0-alpha.2 → 0.1.0-alpha.20
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/code/code-editor-block.js.map +1 -1
- package/dist/code/code-editor-block.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/code/code-editor-block.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/collaboration/binding.js +371 -57
- package/dist/collaboration/binding.js.map +1 -1
- package/dist/collaboration/cursors.js +42 -10
- package/dist/collaboration/cursors.js.map +1 -1
- package/dist/collaboration/index.js +61 -11
- package/dist/collaboration/index.js.map +1 -1
- package/dist/collaboration/inline-diff.js +138 -0
- package/dist/collaboration/inline-diff.js.map +1 -0
- package/dist/collaboration/merged-props.js +152 -0
- package/dist/collaboration/merged-props.js.map +1 -0
- package/dist/collaboration/order.js +41 -1
- package/dist/collaboration/order.js.map +1 -1
- package/dist/collaboration/table.js +64 -25
- package/dist/collaboration/table.js.map +1 -1
- package/dist/collaboration/text.js +213 -1
- package/dist/collaboration/text.js.map +1 -1
- package/dist/components/block-handle.js.map +1 -1
- package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js +125 -17
- package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/bubble-toolbar.js.map +1 -1
- package/dist/components/bubble-toolbar.vue_vue_type_script_setup_true_lang.js +2 -1
- package/dist/components/bubble-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/comment-card.js.map +1 -1
- package/dist/components/comment-card.vue_vue_type_script_setup_true_lang.js +2 -1
- package/dist/components/comment-card.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/slash-choices.js +6 -0
- package/dist/components/slash-choices.js.map +1 -0
- package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js +56 -0
- package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/slash-menu.js.map +1 -1
- package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js +185 -20
- package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/core/block-selection.js +32 -4
- package/dist/core/block-selection.js.map +1 -1
- package/dist/core/blocks.js +21 -3
- package/dist/core/blocks.js.map +1 -1
- package/dist/core/commands.js +125 -13
- package/dist/core/commands.js.map +1 -1
- package/dist/core/comments.js +85 -3
- package/dist/core/comments.js.map +1 -1
- package/dist/core/convert.js +3 -3
- package/dist/core/convert.js.map +1 -1
- package/dist/core/editor.js +2 -1
- package/dist/core/editor.js.map +1 -1
- package/dist/core/extension.js +6 -2
- package/dist/core/extension.js.map +1 -1
- package/dist/core/model.js +10 -3
- package/dist/core/model.js.map +1 -1
- package/dist/core/plugins.js +108 -5
- package/dist/core/plugins.js.map +1 -1
- package/dist/core/prepare.js +12 -5
- package/dist/core/prepare.js.map +1 -1
- package/dist/core/schema.js.map +1 -1
- package/dist/core/transaction.js +19 -4
- package/dist/core/transaction.js.map +1 -1
- package/dist/define-block.js +8 -4
- package/dist/define-block.js.map +1 -1
- package/dist/document.js +59 -4
- package/dist/document.js.map +1 -1
- package/dist/dom.js +112 -13
- package/dist/dom.js.map +1 -1
- package/dist/editor.js.map +1 -1
- package/dist/editor.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/editor2.js.map +1 -1
- package/dist/extensions/align/align-menu.js.map +1 -1
- package/dist/extensions/align/align-menu.vue_vue_type_script_setup_true_lang.js +4 -6
- package/dist/extensions/align/align-menu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/extensions/callout/html.js +5 -4
- package/dist/extensions/callout/html.js.map +1 -1
- package/dist/extensions/colors/color-menu.js.map +1 -1
- package/dist/extensions/colors/color-menu.vue_vue_type_script_setup_true_lang.js +6 -8
- package/dist/extensions/colors/color-menu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/extensions/columns/column-picker.js +6 -0
- package/dist/extensions/columns/column-picker.js.map +1 -0
- package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/columns/columns-controls.js +6 -0
- package/dist/extensions/columns/columns-controls.js.map +1 -0
- package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js +341 -0
- package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/columns/html.js +34 -0
- package/dist/extensions/columns/html.js.map +1 -0
- package/dist/extensions/columns/index.js +57 -0
- package/dist/extensions/columns/index.js.map +1 -0
- package/dist/extensions/columns/keys.js +53 -0
- package/dist/extensions/columns/keys.js.map +1 -0
- package/dist/extensions/columns/plugin.js +213 -0
- package/dist/extensions/columns/plugin.js.map +1 -0
- package/dist/extensions/columns/schema.js +58 -0
- package/dist/extensions/columns/schema.js.map +1 -0
- package/dist/extensions/columns/select-columns.js +6 -0
- package/dist/extensions/columns/select-columns.js.map +1 -0
- package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/editor-kit.js +3 -1
- package/dist/extensions/editor-kit.js.map +1 -1
- package/dist/extensions/list-html.js +1 -1
- package/dist/extensions/list-html.js.map +1 -1
- package/dist/extensions/table/plugin.js +33 -1
- package/dist/extensions/table/plugin.js.map +1 -1
- package/dist/extensions/table/table-controls.js.map +1 -1
- package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/extensions/table/view.js +25 -1
- package/dist/extensions/table/view.js.map +1 -1
- package/dist/flow/board-block.js +6 -0
- package/dist/flow/board-block.js.map +1 -0
- package/dist/flow/board-block.vue_vue_type_script_setup_true_lang.js +659 -0
- package/dist/flow/board-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/flow/board.js +221 -0
- package/dist/flow/board.js.map +1 -0
- package/dist/flow/index.js +173 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/locale.js +78 -6
- package/dist/locale.js.map +1 -1
- package/dist/markdown/index.js +2 -2
- package/dist/markdown/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/style.js +2 -1
- package/dist/types/collaboration/binding.d.ts +12 -0
- package/dist/types/collaboration/cursors.d.ts +29 -1
- package/dist/types/collaboration/index.d.ts +53 -6
- package/dist/types/collaboration/inline-diff.d.ts +9 -0
- package/dist/types/collaboration/merged-props.d.ts +20 -0
- package/dist/types/collaboration/order.d.ts +5 -0
- package/dist/types/collaboration/table.d.ts +5 -1
- package/dist/types/collaboration/text.d.ts +20 -0
- package/dist/types/components/slash-choices.vue.d.ts +18 -0
- package/dist/types/core/blocks.d.ts +10 -0
- package/dist/types/core/commands.d.ts +17 -2
- package/dist/types/core/comments.d.ts +39 -3
- package/dist/types/core/convert.d.ts +10 -2
- package/dist/types/core/extension.d.ts +58 -4
- package/dist/types/core/model.d.ts +6 -1
- package/dist/types/core/plugins.d.ts +9 -0
- package/dist/types/core/prepare.d.ts +16 -2
- package/dist/types/core/schema.d.ts +1 -1
- package/dist/types/core/transaction.d.ts +6 -0
- package/dist/types/define-block.d.ts +16 -4
- package/dist/types/document.d.ts +5 -2
- package/dist/types/dom.d.ts +43 -4
- package/dist/types/editor.d.ts +9 -1
- package/dist/types/editor.vue.d.ts +24 -0
- package/dist/types/extensions/columns/column-picker.vue.d.ts +10 -0
- package/dist/types/extensions/columns/columns-controls.vue.d.ts +3 -0
- package/dist/types/extensions/columns/html.d.ts +10 -0
- package/dist/types/extensions/columns/index.d.ts +9 -0
- package/dist/types/extensions/columns/keys.d.ts +6 -0
- package/dist/types/extensions/columns/plugin.d.ts +28 -0
- package/dist/types/extensions/columns/schema.d.ts +17 -0
- package/dist/types/extensions/columns/select-columns.vue.d.ts +13 -0
- package/dist/types/extensions/editor-kit.d.ts +4 -1
- package/dist/types/extensions/table/view.d.ts +8 -1
- package/dist/types/flow/board-block.vue.d.ts +16 -0
- package/dist/types/flow/board.d.ts +53 -0
- package/dist/types/flow/index.d.ts +65 -0
- package/dist/types/index.d.ts +29 -4
- package/dist/types/locale.d.ts +34 -0
- package/dist/types/markdown/index.d.ts +8 -1
- package/dist/use-comments.js +2 -2
- package/dist/use-comments.js.map +1 -1
- package/package.json +14 -5
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useEditor, useToolbarMenu } from "../../editor.js";
|
|
2
2
|
import { currentAlign, setAlign } from "./commands.js";
|
|
3
3
|
import { DouButton, DouDropdown, DouDropdownItem, DouDropdownRadioGroup, DouTooltip } from "dou-ui";
|
|
4
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock,
|
|
4
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, isRef, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
|
|
5
5
|
import { TextAlignCenterIcon, TextAlignLeftIcon, TextAlignRightIcon } from "@dou-ui/icons";
|
|
6
6
|
// src/extensions/align/align-menu.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
-
var _hoisted_1 = { class: "dou-editor-bubble__trigger" };
|
|
8
7
|
var align_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
9
8
|
__name: "align-menu",
|
|
10
9
|
setup(__props) {
|
|
@@ -36,10 +35,9 @@ var align_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
36
35
|
return align.value !== void 0 ? (openBlock(), createBlock(unref(DouTooltip), {
|
|
37
36
|
key: 0,
|
|
38
37
|
content: unref(messages).align.label,
|
|
39
|
-
disabled: unref(open),
|
|
40
38
|
placement: "bottom"
|
|
41
39
|
}, {
|
|
42
|
-
default: withCtx(() => [
|
|
40
|
+
default: withCtx(() => [createVNode(unref(DouDropdown), {
|
|
43
41
|
open: unref(open),
|
|
44
42
|
"onUpdate:open": _cache[0] || (_cache[0] = ($event) => isRef(open) ? open.value = $event : null),
|
|
45
43
|
placement: "bottom-start",
|
|
@@ -71,9 +69,9 @@ var align_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
71
69
|
_: 1
|
|
72
70
|
}, 8, ["aria-label"])]),
|
|
73
71
|
_: 1
|
|
74
|
-
}, 8, ["open"])])
|
|
72
|
+
}, 8, ["open"])]),
|
|
75
73
|
_: 1
|
|
76
|
-
}, 8, ["content"
|
|
74
|
+
}, 8, ["content"])) : createCommentVNode("", true);
|
|
77
75
|
};
|
|
78
76
|
}
|
|
79
77
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"align-menu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","
|
|
1
|
+
{"version":3,"file":"align-menu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_createVNode","_isRef","_createElementBlock","_Fragment","_renderList","_resolveDynamicComponent","_createTextVNode","_toDisplayString","_createCommentVNode"],"sources":["../../../src/extensions/align/align-menu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TextAlignCenterIcon, TextAlignLeftIcon, TextAlignRightIcon } from '@dou-ui/icons'\nimport { DouButton, DouDropdown, DouDropdownItem, DouDropdownRadioGroup, DouTooltip } from 'dou-ui'\nimport { computed } from 'vue'\nimport type { BlockAlign } from '../../core/align'\nimport { useEditor, useToolbarMenu } from '../../editor'\nimport { currentAlign, setAlign } from './commands'\n\nconst { view, state, messages } = useEditor()\n\nconst icons = { left: TextAlignLeftIcon, center: TextAlignCenterIcon, right: TextAlignRightIcon }\nconst shortcuts = { left: 'mod+shift+l', center: 'mod+shift+e', right: 'mod+shift+r' }\nconst aligns = ['left', 'center', 'right'] as const\n\nconst align = computed(() => (state.value ? currentAlign(state.value) : undefined))\n\nfunction choose(value: unknown) {\n const current = view.value\n if (!current) return\n // left is the reading direction: store nothing\n const next = value === 'left' ? null : (value as BlockAlign)\n setAlign(next)(current.state, current.dispatch)\n current.focus()\n}\n\nconst open = useToolbarMenu()\n</script>\n\n<template>\n <DouTooltip v-if=\"align !== undefined\" :content=\"messages.align.label\" placement=\"bottom\">\n <DouDropdown v-model:open=\"open\" placement=\"bottom-start\" class=\"dou-editor-menu\">\n <DouButton size=\"sm\" variant=\"ghost\" :aria-label=\"messages.align.label\">\n <component :is=\"icons[align === 'mixed' || !align ? 'left' : align]\" />\n </DouButton>\n <template #menu>\n <DouDropdownRadioGroup\n :model-value=\"align === 'mixed' ? undefined : (align ?? 'left')\"\n @update:model-value=\"choose\"\n >\n <DouDropdownItem\n v-for=\"name in aligns\"\n :key=\"name\"\n :value=\"name\"\n :shortcut=\"shortcuts[name]\"\n >\n <template #prefix><component :is=\"icons[name]\" /></template>\n {{ messages.align[name] }}\n </DouDropdownItem>\n </DouDropdownRadioGroup>\n </template>\n </DouDropdown>\n </DouTooltip>\n</template>\n"],"mappings":";;;;;;;;;EAQA,MAAM,EAAE,MAAM,OAAO,aAAa,UAAU;EAE5C,MAAM,QAAQ;GAAE,MAAM;GAAmB,QAAQ;GAAqB,OAAO;EAAmB;EAChG,MAAM,YAAY;GAAE,MAAM;GAAe,QAAQ;GAAe,OAAO;EAAc;EACrF,MAAM,SAAS;GAAC;GAAQ;GAAU;EAAO;EAEzC,MAAM,QAAQ,eAAgB,MAAM,QAAQ,aAAa,MAAM,KAAK,IAAI,KAAA,CAAU;EAElF,SAAS,OAAO,OAAgB;GAC9B,MAAM,UAAU,KAAK;GACrB,IAAI,CAAC,SAAS;GAGd,SADa,UAAU,SAAS,OAAQ,KAC3B,CAAC,CAAC,QAAQ,OAAO,QAAQ,QAAQ;GAC9C,QAAQ,MAAM;EAChB;EAEA,MAAM,OAAO,eAAe;;GAIR,OAAA,MAAA,UAAU,KAAA,KAA5BA,UAAA,GAAAC,YAsBaC,MAAA,UAAA,GAAA;;IAtB2B,SAASA,MAAA,QAAA,CAAQ,CAAC,MAAM;IAAO,WAAU;;IAC/E,SAAAC,cAoBc,CApBdC,YAoBcF,MAAA,WAAA,GAAA;KApBO,MAAMA,MAAA,IAAA;KAAA,iBAAA,OAAA,OAAA,OAAA,MAAA,WAAAG,MAAA,IAAA,IAAA,KAAI,QAAA,SAAA;KAAE,WAAU;KAAe,OAAM;;KAInD,MAAIF,cAcW,CAbxBC,YAawBF,MAAA,qBAAA,GAAA;MAZrB,eAAa,MAAA,UAAK,UAAe,KAAA,IAAa,MAAA,SAAK;MACnD,uBAAoB;;MAGnB,SAAAC,cAAsB,EADxBH,UAAA,GAAAM,mBAQkBC,UAAA,MAAAC,WAPD,SAAR,SAAI;OADb,OAAAJ,YAQkBF,MAAA,eAAA,GAAA;QANf,KAAK;QACL,OAAO;QACP,UAAU,UAAU;;QAEV,QAAMC,cAAgC,EAA/BH,UAAA,GAAAC,YAA+BQ,wBAAf,MAAM,KAAI,CAAA,E;QAAgB,SAAAN,cAC5D,CAD4DO,gBAAA,MAC5DC,gBAAGT,MAAA,QAAA,CAAQ,CAAC,MAAM,KAAI,GAAA,CAAA,C;;;;;;KAf5B,SAAAC,cAEY,CAFZC,YAEYF,MAAA,SAAA,GAAA;MAFD,MAAK;MAAK,SAAQ;MAAS,cAAYA,MAAA,QAAA,CAAQ,CAAC,MAAM;;MAC/D,SAAAC,cAAuE,EAAvEH,UAAA,GAAAC,YAAuEQ,wBAAvD,MAAM,MAAA,UAAK,WAAA,CAAiB,MAAA,QAAK,SAAY,MAAA,MAAK,CAAA,E"}
|
|
@@ -28,12 +28,13 @@ var calloutOutput = {
|
|
|
28
28
|
/** Take the `[!TIP]` off the start of a quote's text; returns the tone, or null without one. */
|
|
29
29
|
function takeMarker(content) {
|
|
30
30
|
const first = content.find((node) => node.textContent?.trim());
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
31
|
+
if (first?.nodeType !== 3) return null;
|
|
32
|
+
const text = first;
|
|
33
|
+
const match = MARKER.exec(text.data);
|
|
33
34
|
if (!match) return null;
|
|
34
|
-
|
|
35
|
+
text.data = text.data.slice(match[0].length);
|
|
35
36
|
const next = content[content.indexOf(first) + 1];
|
|
36
|
-
if (!
|
|
37
|
+
if (!text.data.trim() && next?.nodeType === 1 && next.tagName === "BR") next.remove();
|
|
37
38
|
return ALERTS[match[1].toUpperCase()];
|
|
38
39
|
}
|
|
39
40
|
/** `<aside data-callout>` from `blocksToHTML`, and quotes that start with `[!TIP]` as Markdown writes them. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","names":[],"sources":["../../../src/extensions/callout/html.ts"],"sourcesContent":["import { indentLines, type BlockOutput } from '../../core/output'\nimport { blockElement, splitContainer } from '../../core/prepare'\nimport { calloutTones } from './tones'\n\n/** The alert labels of GitHub's Markdown, and the tone each one reads as. */\nconst ALERTS: Record<string, string> = {\n NOTE: 'info',\n IMPORTANT: 'info',\n TIP: 'tip',\n WARNING: 'warning',\n CAUTION: 'danger',\n}\nconst LABELS: Record<string, string> = {\n info: 'NOTE',\n tip: 'TIP',\n warning: 'WARNING',\n danger: 'CAUTION',\n}\nconst MARKER = /^\\s*\\[!(NOTE|IMPORTANT|TIP|WARNING|CAUTION)\\][ \\t]*\\n?/i\n\nconst toneOf = (tone: unknown) => (String(tone) in calloutTones ? String(tone) : 'info')\n\nexport const calloutOutput: BlockOutput = {\n html: (block, { content, children }) =>\n `<aside data-callout=\"${toneOf(block.props.tone)}\"><p>${content}</p>${children}</aside>`,\n // GitHub's alert syntax: a quote that starts with `[!TIP]`\n markdown: (block, { content, children }) => {\n const head = [`[!${LABELS[toneOf(block.props.tone)]}]`, content].filter(Boolean).join('\\n')\n return indentLines(children ? `${head}\\n\\n${children}` : head, '> ', '> ')\n },\n}\n\n/** Take the `[!TIP]` off the start of a quote's text; returns the tone, or null without one. */\nfunction takeMarker(content: Node[]): string | null {\n const first = content.find((node) => node.textContent?.trim())\n if (
|
|
1
|
+
{"version":3,"file":"html.js","names":[],"sources":["../../../src/extensions/callout/html.ts"],"sourcesContent":["import { indentLines, type BlockOutput } from '../../core/output'\nimport { blockElement, splitContainer } from '../../core/prepare'\nimport { calloutTones } from './tones'\n\n/** The alert labels of GitHub's Markdown, and the tone each one reads as. */\nconst ALERTS: Record<string, string> = {\n NOTE: 'info',\n IMPORTANT: 'info',\n TIP: 'tip',\n WARNING: 'warning',\n CAUTION: 'danger',\n}\nconst LABELS: Record<string, string> = {\n info: 'NOTE',\n tip: 'TIP',\n warning: 'WARNING',\n danger: 'CAUTION',\n}\nconst MARKER = /^\\s*\\[!(NOTE|IMPORTANT|TIP|WARNING|CAUTION)\\][ \\t]*\\n?/i\n\nconst toneOf = (tone: unknown) => (String(tone) in calloutTones ? String(tone) : 'info')\n\nexport const calloutOutput: BlockOutput = {\n html: (block, { content, children }) =>\n `<aside data-callout=\"${toneOf(block.props.tone)}\"><p>${content}</p>${children}</aside>`,\n // GitHub's alert syntax: a quote that starts with `[!TIP]`\n markdown: (block, { content, children }) => {\n const head = [`[!${LABELS[toneOf(block.props.tone)]}]`, content].filter(Boolean).join('\\n')\n return indentLines(children ? `${head}\\n\\n${children}` : head, '> ', '> ')\n },\n}\n\n/** Take the `[!TIP]` off the start of a quote's text; returns the tone, or null without one. */\nfunction takeMarker(content: Node[]): string | null {\n const first = content.find((node) => node.textContent?.trim())\n // by node type, not `instanceof`: the DOM may come from a library, without globals\n if (first?.nodeType !== 3) return null\n const text = first as Text\n const match = MARKER.exec(text.data)\n if (!match) return null\n text.data = text.data.slice(match[0].length)\n // the text after the marker starts on the next line\n const index = content.indexOf(first)\n const next = content[index + 1]\n if (!text.data.trim() && next?.nodeType === 1 && (next as Element).tagName === 'BR')\n (next as Element).remove()\n return ALERTS[match[1]!.toUpperCase()]!\n}\n\n/** `<aside data-callout>` from `blocksToHTML`, and quotes that start with `[!TIP]` as Markdown writes them. */\nexport function prepareCallouts(root: HTMLElement) {\n for (const element of Array.from(root.querySelectorAll('aside[data-callout]'))) {\n const { content, children } = splitContainer(element)\n const tone = toneOf((element as HTMLElement).dataset.callout)\n element.replaceWith(blockElement(element.ownerDocument, 'callout', content, children, { tone }))\n }\n for (const element of Array.from(root.querySelectorAll('blockquote'))) {\n const { content, children } = splitContainer(element)\n const tone = takeMarker(content)\n if (tone)\n element.replaceWith(\n blockElement(element.ownerDocument, 'callout', content, children, { tone }),\n )\n }\n // a quote another extension already turned into a block\n for (const element of Array.from(\n root.querySelectorAll<HTMLElement>('div[data-content-type=\"quote\"]'),\n )) {\n const tone = takeMarker(Array.from(element.childNodes))\n if (tone) {\n element.dataset.contentType = 'callout'\n element.dataset.tone = tone\n }\n }\n}\n"],"mappings":";;;;;AAKA,IAAM,SAAiC;CACrC,MAAM;CACN,WAAW;CACX,KAAK;CACL,SAAS;CACT,SAAS;AACX;AACA,IAAM,SAAiC;CACrC,MAAM;CACN,KAAK;CACL,SAAS;CACT,QAAQ;AACV;AACA,IAAM,SAAS;AAEf,IAAM,UAAU,SAAmB,OAAO,IAAI,KAAK,eAAe,OAAO,IAAI,IAAI;AAEjF,IAAa,gBAA6B;CACxC,OAAO,OAAO,EAAE,SAAS,eACvB,wBAAwB,OAAO,MAAM,MAAM,IAAI,EAAE,OAAO,QAAQ,MAAM,SAAS;CAEjF,WAAW,OAAO,EAAE,SAAS,eAAe;EAC1C,MAAM,OAAO,CAAC,KAAK,OAAO,OAAO,MAAM,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI;EAC1F,OAAO,YAAY,WAAW,GAAG,KAAK,MAAM,aAAa,MAAM,MAAM,IAAI;CAC3E;AACF;;AAGA,SAAS,WAAW,SAAgC;CAClD,MAAM,QAAQ,QAAQ,MAAM,SAAS,KAAK,aAAa,KAAK,CAAC;CAE7D,IAAI,OAAO,aAAa,GAAG,OAAO;CAClC,MAAM,OAAO;CACb,MAAM,QAAQ,OAAO,KAAK,KAAK,IAAI;CACnC,IAAI,CAAC,OAAO,OAAO;CACnB,KAAK,OAAO,KAAK,KAAK,MAAM,MAAM,EAAE,CAAC,MAAM;CAG3C,MAAM,OAAO,QADC,QAAQ,QAAQ,KACT,IAAQ;CAC7B,IAAI,CAAC,KAAK,KAAK,KAAK,KAAK,MAAM,aAAa,KAAM,KAAiB,YAAY,MAC7E,KAAkB,OAAO;CAC3B,OAAO,OAAO,MAAM,EAAE,CAAE,YAAY;AACtC;;AAGA,SAAgB,gBAAgB,MAAmB;CACjD,KAAK,MAAM,WAAW,MAAM,KAAK,KAAK,iBAAiB,qBAAqB,CAAC,GAAG;EAC9E,MAAM,EAAE,SAAS,aAAa,eAAe,OAAO;EACpD,MAAM,OAAO,OAAQ,QAAwB,QAAQ,OAAO;EAC5D,QAAQ,YAAY,aAAa,QAAQ,eAAe,WAAW,SAAS,UAAU,EAAE,KAAK,CAAC,CAAC;CACjG;CACA,KAAK,MAAM,WAAW,MAAM,KAAK,KAAK,iBAAiB,YAAY,CAAC,GAAG;EACrE,MAAM,EAAE,SAAS,aAAa,eAAe,OAAO;EACpD,MAAM,OAAO,WAAW,OAAO;EAC/B,IAAI,MACF,QAAQ,YACN,aAAa,QAAQ,eAAe,WAAW,SAAS,UAAU,EAAE,KAAK,CAAC,CAC5E;CACJ;CAEA,KAAK,MAAM,WAAW,MAAM,KAC1B,KAAK,iBAA8B,kCAAgC,CACrE,GAAG;EACD,MAAM,OAAO,WAAW,MAAM,KAAK,QAAQ,UAAU,CAAC;EACtD,IAAI,MAAM;GACR,QAAQ,QAAQ,cAAc;GAC9B,QAAQ,QAAQ,OAAO;EACzB;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-menu.js","names":["_sfc_main"],"sources":["../../../src/extensions/colors/color-menu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CheckIcon } from '@dou-ui/icons'\nimport { DouButton, DouDropdown, DouDropdownItem, DouDropdownSub, DouTooltip } from 'dou-ui'\nimport { computed } from 'vue'\nimport { useEditor, useToolbarMenu } from '../../editor'\nimport { setHighlight, setTextColor, textColors, type TextColor } from './palette'\n\nconst { view, state, messages } = useEditor()\n\n/** The color the whole selection has, `null` for none, `'mixed'` for several. */\nfunction current(name: string): string | null {\n const now = state.value\n const type = now?.schema.marks[name]\n if (!now || !type) return null\n const { from, to } = now.selection\n let value: string | null | undefined\n now.doc.nodesBetween(from, to, (node) => {\n if (!node.isText || value === 'mixed') return\n const found = (type.isInSet(node.marks)?.attrs.value as string | undefined) ?? null\n value = value === undefined || value === found ? found : 'mixed'\n })\n return value ?? null\n}\n\n/** The swatch shows one color; several show as the default. */\nconst shown = (value: string | null) => (value && value !== 'mixed' ? value : undefined)\n\nconst color = computed(() => current('textColor'))\nconst highlight = computed(() => current('highlight'))\n\nfunction apply(kind: 'text' | 'background', value: TextColor | null) {\n const target = view.value\n if (!target) return\n ;(kind === 'text' ? setTextColor : setHighlight)(value)(target.state, target.dispatch)\n target.focus()\n}\n\nconst open = useToolbarMenu()\n</script>\n\n<template>\n <DouTooltip :content=\"messages.colors.label\"
|
|
1
|
+
{"version":3,"file":"color-menu.js","names":["_sfc_main"],"sources":["../../../src/extensions/colors/color-menu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CheckIcon } from '@dou-ui/icons'\nimport { DouButton, DouDropdown, DouDropdownItem, DouDropdownSub, DouTooltip } from 'dou-ui'\nimport { computed } from 'vue'\nimport { useEditor, useToolbarMenu } from '../../editor'\nimport { setHighlight, setTextColor, textColors, type TextColor } from './palette'\n\nconst { view, state, messages } = useEditor()\n\n/** The color the whole selection has, `null` for none, `'mixed'` for several. */\nfunction current(name: string): string | null {\n const now = state.value\n const type = now?.schema.marks[name]\n if (!now || !type) return null\n const { from, to } = now.selection\n let value: string | null | undefined\n now.doc.nodesBetween(from, to, (node) => {\n if (!node.isText || value === 'mixed') return\n const found = (type.isInSet(node.marks)?.attrs.value as string | undefined) ?? null\n value = value === undefined || value === found ? found : 'mixed'\n })\n return value ?? null\n}\n\n/** The swatch shows one color; several show as the default. */\nconst shown = (value: string | null) => (value && value !== 'mixed' ? value : undefined)\n\nconst color = computed(() => current('textColor'))\nconst highlight = computed(() => current('highlight'))\n\nfunction apply(kind: 'text' | 'background', value: TextColor | null) {\n const target = view.value\n if (!target) return\n ;(kind === 'text' ? setTextColor : setHighlight)(value)(target.state, target.dispatch)\n target.focus()\n}\n\nconst open = useToolbarMenu()\n</script>\n\n<template>\n <DouTooltip :content=\"messages.colors.label\" placement=\"bottom\">\n <DouDropdown v-model:open=\"open\" placement=\"bottom-start\" class=\"dou-editor-menu\">\n <DouButton\n size=\"sm\"\n variant=\"ghost\"\n class=\"dou-editor-colors__button\"\n :aria-label=\"messages.colors.label\"\n >\n <template #leading>\n <span\n class=\"dou-editor-colors__swatch\"\n :data-color=\"shown(color)\"\n :data-highlight=\"shown(highlight)\"\n aria-hidden=\"true\"\n ><span class=\"dou-editor-colors__letter\">A</span></span\n >\n </template>\n </DouButton>\n <template #menu>\n <DouDropdownSub\n v-for=\"kind in ['text', 'background'] as const\"\n :key=\"kind\"\n :title=\"kind === 'text' ? messages.colors.text : messages.colors.background\"\n >\n <DouDropdownItem @click=\"apply(kind, null)\">\n <template #prefix>\n <span class=\"dou-editor-colors__swatch\" aria-hidden=\"true\"\n ><span class=\"dou-editor-colors__letter\">A</span></span\n >\n </template>\n {{ messages.colors.none }}\n <template v-if=\"!(kind === 'text' ? color : highlight)\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem v-for=\"name in textColors\" :key=\"name\" @click=\"apply(kind, name)\">\n <template #prefix>\n <span\n class=\"dou-editor-colors__swatch\"\n :data-color=\"kind === 'text' ? name : undefined\"\n :data-highlight=\"kind === 'background' ? name : undefined\"\n aria-hidden=\"true\"\n ><span class=\"dou-editor-colors__letter\">A</span></span\n >\n </template>\n {{ messages.colors.names[name] }}\n <template v-if=\"(kind === 'text' ? color : highlight) === name\" #suffix>\n <CheckIcon />\n </template>\n </DouDropdownItem>\n </DouDropdownSub>\n </template>\n </DouDropdown>\n </DouTooltip>\n</template>\n"],"mappings":""}
|
|
@@ -5,9 +5,8 @@ import { DouButton, DouDropdown, DouDropdownItem, DouDropdownSub, DouTooltip } f
|
|
|
5
5
|
import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, isRef, openBlock, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
6
6
|
import { CheckIcon } from "@dou-ui/icons";
|
|
7
7
|
// src/extensions/colors/color-menu.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
-
var _hoisted_1 =
|
|
8
|
+
var _hoisted_1 = ["data-color", "data-highlight"];
|
|
9
9
|
var _hoisted_2 = ["data-color", "data-highlight"];
|
|
10
|
-
var _hoisted_3 = ["data-color", "data-highlight"];
|
|
11
10
|
var color_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
12
11
|
__name: "color-menu",
|
|
13
12
|
setup(__props) {
|
|
@@ -40,10 +39,9 @@ var color_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
40
39
|
return (_ctx, _cache) => {
|
|
41
40
|
return openBlock(), createBlock(unref(DouTooltip), {
|
|
42
41
|
content: unref(messages).colors.label,
|
|
43
|
-
disabled: unref(open),
|
|
44
42
|
placement: "bottom"
|
|
45
43
|
}, {
|
|
46
|
-
default: withCtx(() => [
|
|
44
|
+
default: withCtx(() => [createVNode(unref(DouDropdown), {
|
|
47
45
|
open: unref(open),
|
|
48
46
|
"onUpdate:open": _cache[0] || (_cache[0] = ($event) => isRef(open) ? open.value = $event : null),
|
|
49
47
|
placement: "bottom-start",
|
|
@@ -75,7 +73,7 @@ var color_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
75
73
|
"data-color": kind === "text" ? name : void 0,
|
|
76
74
|
"data-highlight": kind === "background" ? name : void 0,
|
|
77
75
|
"aria-hidden": "true"
|
|
78
|
-
}, [..._cache[3] || (_cache[3] = [createElementVNode("span", { class: "dou-editor-colors__letter" }, "A", -1)])], 8,
|
|
76
|
+
}, [..._cache[3] || (_cache[3] = [createElementVNode("span", { class: "dou-editor-colors__letter" }, "A", -1)])], 8, _hoisted_2)]),
|
|
79
77
|
default: withCtx(() => [createTextVNode(" " + toDisplayString(unref(messages).colors.names[name]) + " ", 1)]),
|
|
80
78
|
_: 2
|
|
81
79
|
}, [(kind === "text" ? color.value : highlight.value) === name ? {
|
|
@@ -98,13 +96,13 @@ var color_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
|
|
|
98
96
|
"data-color": shown(color.value),
|
|
99
97
|
"data-highlight": shown(highlight.value),
|
|
100
98
|
"aria-hidden": "true"
|
|
101
|
-
}, [..._cache[1] || (_cache[1] = [createElementVNode("span", { class: "dou-editor-colors__letter" }, "A", -1)])], 8,
|
|
99
|
+
}, [..._cache[1] || (_cache[1] = [createElementVNode("span", { class: "dou-editor-colors__letter" }, "A", -1)])], 8, _hoisted_1)]),
|
|
102
100
|
_: 1
|
|
103
101
|
}, 8, ["aria-label"])]),
|
|
104
102
|
_: 1
|
|
105
|
-
}, 8, ["open"])])
|
|
103
|
+
}, 8, ["open"])]),
|
|
106
104
|
_: 1
|
|
107
|
-
}, 8, ["content"
|
|
105
|
+
}, 8, ["content"]);
|
|
108
106
|
};
|
|
109
107
|
}
|
|
110
108
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-menu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","
|
|
1
|
+
{"version":3,"file":"color-menu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_createVNode","_isRef","_createElementBlock","_Fragment","_renderList","_createSlots","_createElementVNode","_createTextVNode","_toDisplayString"],"sources":["../../../src/extensions/colors/color-menu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CheckIcon } from '@dou-ui/icons'\nimport { DouButton, DouDropdown, DouDropdownItem, DouDropdownSub, DouTooltip } from 'dou-ui'\nimport { computed } from 'vue'\nimport { useEditor, useToolbarMenu } from '../../editor'\nimport { setHighlight, setTextColor, textColors, type TextColor } from './palette'\n\nconst { view, state, messages } = useEditor()\n\n/** The color the whole selection has, `null` for none, `'mixed'` for several. */\nfunction current(name: string): string | null {\n const now = state.value\n const type = now?.schema.marks[name]\n if (!now || !type) return null\n const { from, to } = now.selection\n let value: string | null | undefined\n now.doc.nodesBetween(from, to, (node) => {\n if (!node.isText || value === 'mixed') return\n const found = (type.isInSet(node.marks)?.attrs.value as string | undefined) ?? null\n value = value === undefined || value === found ? found : 'mixed'\n })\n return value ?? null\n}\n\n/** The swatch shows one color; several show as the default. */\nconst shown = (value: string | null) => (value && value !== 'mixed' ? value : undefined)\n\nconst color = computed(() => current('textColor'))\nconst highlight = computed(() => current('highlight'))\n\nfunction apply(kind: 'text' | 'background', value: TextColor | null) {\n const target = view.value\n if (!target) return\n ;(kind === 'text' ? setTextColor : setHighlight)(value)(target.state, target.dispatch)\n target.focus()\n}\n\nconst open = useToolbarMenu()\n</script>\n\n<template>\n <DouTooltip :content=\"messages.colors.label\" placement=\"bottom\">\n <DouDropdown v-model:open=\"open\" placement=\"bottom-start\" class=\"dou-editor-menu\">\n <DouButton\n size=\"sm\"\n variant=\"ghost\"\n class=\"dou-editor-colors__button\"\n :aria-label=\"messages.colors.label\"\n >\n <template #leading>\n <span\n class=\"dou-editor-colors__swatch\"\n :data-color=\"shown(color)\"\n :data-highlight=\"shown(highlight)\"\n aria-hidden=\"true\"\n ><span class=\"dou-editor-colors__letter\">A</span></span\n >\n </template>\n </DouButton>\n <template #menu>\n <DouDropdownSub\n v-for=\"kind in ['text', 'background'] as const\"\n :key=\"kind\"\n :title=\"kind === 'text' ? messages.colors.text : messages.colors.background\"\n >\n <DouDropdownItem @click=\"apply(kind, null)\">\n <template #prefix>\n <span class=\"dou-editor-colors__swatch\" aria-hidden=\"true\"\n ><span class=\"dou-editor-colors__letter\">A</span></span\n >\n </template>\n {{ messages.colors.none }}\n <template v-if=\"!(kind === 'text' ? color : highlight)\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem v-for=\"name in textColors\" :key=\"name\" @click=\"apply(kind, name)\">\n <template #prefix>\n <span\n class=\"dou-editor-colors__swatch\"\n :data-color=\"kind === 'text' ? name : undefined\"\n :data-highlight=\"kind === 'background' ? name : undefined\"\n aria-hidden=\"true\"\n ><span class=\"dou-editor-colors__letter\">A</span></span\n >\n </template>\n {{ messages.colors.names[name] }}\n <template v-if=\"(kind === 'text' ? color : highlight) === name\" #suffix>\n <CheckIcon />\n </template>\n </DouDropdownItem>\n </DouDropdownSub>\n </template>\n </DouDropdown>\n </DouTooltip>\n</template>\n"],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import column_picker_vue_vue_type_script_setup_true_lang_default from "./column-picker.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
// src/extensions/columns/column-picker.vue
|
|
3
|
+
var column_picker_default = column_picker_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
export { column_picker_default as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=column-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-picker.js","names":["_sfc_main"],"sources":["../../../src/extensions/columns/column-picker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport {\n labelOf,\n type BlockOptionChoicesEmits,\n type BlockOptionChoicesProps,\n} from '../../core/extension'\n\n/**\n * The column count picker beside “Columns” in the slash menu: a row of\n * bars, as many as the most columns; pointing at one lights the bars up to\n * it, the count a click inserts.\n */\nconst props = defineProps<BlockOptionChoicesProps>()\nconst emit = defineEmits<BlockOptionChoicesEmits>()\n\nconst counts = computed(() => props.items.map((item) => Number(item.props.count)))\nconst bars = computed(() => Math.max(...counts.value))\n/** Bars lit up to here; none while the option itself is highlighted. */\nconst lit = computed(() => (props.active < 0 ? 0 : (counts.value[props.active] ?? 0)))\n\n/** The choice a bar stands for: its count, or the fewest there can be. */\nconst indexOf = (bar: number) => {\n const index = counts.value.indexOf(Math.max(bar, counts.value[0]!))\n return index < 0 ? 0 : index\n}\n</script>\n\n<template>\n <div class=\"dou-editor-column-picker\">\n <div\n v-for=\"bar in bars\"\n :id=\"bar >= counts[0]! ? `${idPrefix}-${indexOf(bar)}` : undefined\"\n :key=\"bar\"\n :role=\"bar >= counts[0]! ? 'option' : 'presentation'\"\n :aria-selected=\"bar >= counts[0]! ? bar === lit : undefined\"\n :aria-label=\"bar >= counts[0]! ? labelOf(items[indexOf(bar)]!.label, messages) : undefined\"\n :class=\"['dou-editor-column-picker__bar', { 'is-lit': bar <= lit }]\"\n @pointermove=\"emit('hover', indexOf(bar))\"\n @click=\"emit('choose', indexOf(bar))\"\n />\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { labelOf } from "../../core/extension.js";
|
|
2
|
+
import { Fragment, computed, createElementBlock, defineComponent, normalizeClass, openBlock, renderList, unref } from "vue";
|
|
3
|
+
// src/extensions/columns/column-picker.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var _hoisted_1 = { class: "dou-editor-column-picker" };
|
|
5
|
+
var _hoisted_2 = [
|
|
6
|
+
"id",
|
|
7
|
+
"role",
|
|
8
|
+
"aria-selected",
|
|
9
|
+
"aria-label",
|
|
10
|
+
"onPointermove",
|
|
11
|
+
"onClick"
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* The column count picker beside “Columns” in the slash menu: a row of
|
|
15
|
+
* bars, as many as the most columns; pointing at one lights the bars up to
|
|
16
|
+
* it, the count a click inserts.
|
|
17
|
+
*/
|
|
18
|
+
var column_picker_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
19
|
+
__name: "column-picker",
|
|
20
|
+
props: {
|
|
21
|
+
items: {},
|
|
22
|
+
active: {},
|
|
23
|
+
messages: {},
|
|
24
|
+
idPrefix: {}
|
|
25
|
+
},
|
|
26
|
+
emits: ["hover", "choose"],
|
|
27
|
+
setup(__props, { emit: __emit }) {
|
|
28
|
+
const props = __props;
|
|
29
|
+
const emit = __emit;
|
|
30
|
+
const counts = computed(() => props.items.map((item) => Number(item.props.count)));
|
|
31
|
+
const bars = computed(() => Math.max(...counts.value));
|
|
32
|
+
/** Bars lit up to here; none while the option itself is highlighted. */
|
|
33
|
+
const lit = computed(() => props.active < 0 ? 0 : counts.value[props.active] ?? 0);
|
|
34
|
+
/** The choice a bar stands for: its count, or the fewest there can be. */
|
|
35
|
+
const indexOf = (bar) => {
|
|
36
|
+
const index = counts.value.indexOf(Math.max(bar, counts.value[0]));
|
|
37
|
+
return index < 0 ? 0 : index;
|
|
38
|
+
};
|
|
39
|
+
return (_ctx, _cache) => {
|
|
40
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [(openBlock(true), createElementBlock(Fragment, null, renderList(bars.value, (bar) => {
|
|
41
|
+
return openBlock(), createElementBlock("div", {
|
|
42
|
+
id: bar >= counts.value[0] ? `${__props.idPrefix}-${indexOf(bar)}` : void 0,
|
|
43
|
+
key: bar,
|
|
44
|
+
role: bar >= counts.value[0] ? "option" : "presentation",
|
|
45
|
+
"aria-selected": bar >= counts.value[0] ? bar === lit.value : void 0,
|
|
46
|
+
"aria-label": bar >= counts.value[0] ? unref(labelOf)(__props.items[indexOf(bar)].label, __props.messages) : void 0,
|
|
47
|
+
class: normalizeClass(["dou-editor-column-picker__bar", { "is-lit": bar <= lit.value }]),
|
|
48
|
+
onPointermove: ($event) => emit("hover", indexOf(bar)),
|
|
49
|
+
onClick: ($event) => emit("choose", indexOf(bar))
|
|
50
|
+
}, null, 42, _hoisted_2);
|
|
51
|
+
}), 128))]);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
export { column_picker_vue_vue_type_script_setup_true_lang_default as default };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=column-picker.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-picker.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_renderList","_unref","_normalizeClass"],"sources":["../../../src/extensions/columns/column-picker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport {\n labelOf,\n type BlockOptionChoicesEmits,\n type BlockOptionChoicesProps,\n} from '../../core/extension'\n\n/**\n * The column count picker beside “Columns” in the slash menu: a row of\n * bars, as many as the most columns; pointing at one lights the bars up to\n * it, the count a click inserts.\n */\nconst props = defineProps<BlockOptionChoicesProps>()\nconst emit = defineEmits<BlockOptionChoicesEmits>()\n\nconst counts = computed(() => props.items.map((item) => Number(item.props.count)))\nconst bars = computed(() => Math.max(...counts.value))\n/** Bars lit up to here; none while the option itself is highlighted. */\nconst lit = computed(() => (props.active < 0 ? 0 : (counts.value[props.active] ?? 0)))\n\n/** The choice a bar stands for: its count, or the fewest there can be. */\nconst indexOf = (bar: number) => {\n const index = counts.value.indexOf(Math.max(bar, counts.value[0]!))\n return index < 0 ? 0 : index\n}\n</script>\n\n<template>\n <div class=\"dou-editor-column-picker\">\n <div\n v-for=\"bar in bars\"\n :id=\"bar >= counts[0]! ? `${idPrefix}-${indexOf(bar)}` : undefined\"\n :key=\"bar\"\n :role=\"bar >= counts[0]! ? 'option' : 'presentation'\"\n :aria-selected=\"bar >= counts[0]! ? bar === lit : undefined\"\n :aria-label=\"bar >= counts[0]! ? labelOf(items[indexOf(bar)]!.label, messages) : undefined\"\n :class=\"['dou-editor-column-picker__bar', { 'is-lit': bar <= lit }]\"\n @pointermove=\"emit('hover', indexOf(bar))\"\n @click=\"emit('choose', indexOf(bar))\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAaA,MAAM,QAAQ;EACd,MAAM,OAAO;EAEb,MAAM,SAAS,eAAe,MAAM,MAAM,KAAK,SAAS,OAAO,KAAK,MAAM,KAAK,CAAC,CAAC;EACjF,MAAM,OAAO,eAAe,KAAK,IAAI,GAAG,OAAO,KAAK,CAAC;;EAErD,MAAM,MAAM,eAAgB,MAAM,SAAS,IAAI,IAAK,OAAO,MAAM,MAAM,WAAW,CAAG;;EAGrF,MAAM,WAAW,QAAgB;GAC/B,MAAM,QAAQ,OAAO,MAAM,QAAQ,KAAK,IAAI,KAAK,OAAO,MAAM,EAAG,CAAC;GAClE,OAAO,QAAQ,IAAI,IAAI;EACzB;;GAIE,OAAAA,UAAA,GAAAC,mBAYM,OAZN,YAYM,EAXJD,UAAA,IAAA,GAAAC,mBAUEC,UAAA,MAAAC,WATc,KAAA,QAAP,QAAG;IADZ,OAAAH,UAAA,GAAAC,mBAUE,OAAA;KARC,IAAI,OAAO,OAAA,MAAM,KAAA,GAAU,QAAA,SAAQ,GAAI,QAAQ,GAAG,MAAM,KAAA;KACxD,KAAK;KACL,MAAM,OAAO,OAAA,MAAM,KAAA,WAAA;KACnB,iBAAe,OAAO,OAAA,MAAM,KAAO,QAAQ,IAAA,QAAM,KAAA;KACjD,cAAY,OAAO,OAAA,MAAM,KAAOG,MAAA,OAAA,CAAO,CAAC,QAAA,MAAM,QAAQ,GAAG,EAAA,CAAI,OAAO,QAAA,QAAQ,IAAI,KAAA;KAChF,OAAKC,eAAA,CAAA,iCAAA,EAAA,UAAgD,OAAO,IAAA,MAAG,CAAA,CAAA;KAC/D,gBAAW,WAAE,KAAI,SAAU,QAAQ,GAAG,CAAA;KACtC,UAAK,WAAE,KAAI,UAAW,QAAQ,GAAG,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import columns_controls_vue_vue_type_script_setup_true_lang_default from "./columns-controls.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
// src/extensions/columns/columns-controls.vue
|
|
3
|
+
var columns_controls_default = columns_controls_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
export { columns_controls_default as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=columns-controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns-controls.js","names":["_sfc_main"],"sources":["../../../src/extensions/columns/columns-controls.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, nextTick, onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\nimport { findBlockById, layoutOf, parentBlock, blockAround } from '../../core/blocks'\nimport { childBlocks, COLUMNS_GROUP, sideBySide } from '../../dom'\nimport { useEditor } from '../../editor'\nimport { previewColumns, refreshColumns, type ColumnPreview } from './plugin'\nimport { widthOf } from './schema'\n\n/**\n * The bars between columns. One shows when the pointer is in the middle of\n * the gap between two columns (on a touch screen, after a tap there);\n * dragging it moves width from one column to the other, `Esc` takes the\n * drag back, a double click makes all the columns of the set even. While\n * the cursor is in a set of columns, its bars can also be reached with\n * `Tab` and moved with `←` `→`. A drag is shown as it goes and written to\n * the document when it ends: one undo step.\n */\nconst { view, state, root, messages, dragging } = useEditor()\n\n/** How far from the middle of the gap the bar can be grabbed, and on a touch screen tapped. */\nconst REACH = 5\nconst TOUCH_REACH = 20\n/** The narrowest a column gets by resizing. */\nconst MIN_WIDTH = 96\n/** How much of the two columns' width a key press moves. */\nconst STEP = 0.05\n\ninterface Bar {\n /** The set of columns, by id, and the column left of the bar. */\n row: string\n index: number\n top: number\n left: number\n height: number\n /** The left column's share of the two, in percent, for screen readers. */\n value: number\n}\n\n/** The bar under the pointer. */\nconst bar = shallowRef<Bar | null>(null)\n/** The bars of the set of columns the cursor is in, for the keyboard. */\nconst keyBars = shallowRef<Bar[]>([])\nconst active = shallowRef(false)\n\n/** The column blocks of a set: where each block is, and its width. */\nfunction columnsInDoc(row: string) {\n const current = view.value\n const info = current && findBlockById(current.state.doc, row)\n if (!info?.group || layoutOf(info.node) !== 'row') return null\n const list: { pos: number; width: number }[] = []\n let pos = info.contentPos + info.content.nodeSize + 1\n info.group.forEach((column) => {\n list.push({ pos, width: widthOf(column.firstChild!.attrs.width) ?? 1 })\n pos += column.nodeSize\n })\n return list\n}\n\nfunction findGroup(row: string) {\n const block = view.value?.dom.querySelector(`[data-block-id=\"${CSS.escape(row)}\"]`)\n return block?.querySelector<HTMLElement>(`:scope > ${COLUMNS_GROUP}`) ?? null\n}\n\n/** The middle of the gap after column `index`, on the screen. */\nconst middleOf = (columns: HTMLElement[], index: number) =>\n (columns[index]!.getBoundingClientRect().right +\n columns[index + 1]!.getBoundingClientRect().left) /\n 2\n\nfunction barAt(group: HTMLElement, index: number): Bar | null {\n const host = root.value\n const columns = childBlocks(group)\n const id = (group.parentElement as HTMLElement | null)?.dataset.blockId\n const weights = id && columnsInDoc(id)\n if (!host || !id || !weights || !columns[index + 1]) return null\n const box = host.getBoundingClientRect()\n const rect = group.getBoundingClientRect()\n const left = weights[index]!.width\n const right = weights[index + 1]!.width\n return {\n row: id,\n index,\n top: rect.top - box.top,\n left: middleOf(columns, index) - box.left,\n height: rect.height,\n value: Math.round((left / (left + right)) * 100),\n }\n}\n\n/** The bar near `x` in the set of columns `target` is in, if any. */\nfunction barNear(target: Element, x: number, reach: number): Bar | null {\n const group = target.closest<HTMLElement>(COLUMNS_GROUP)\n const columns = group ? childBlocks(group) : []\n if (!group || !sideBySide(columns)) return null\n for (let index = 0; index < columns.length - 1; index++)\n if (Math.abs(x - middleOf(columns, index)) <= reach) return barAt(group, index)\n return null\n}\n\nfunction track(event: PointerEvent) {\n if (event.pointerType === 'touch' || resize || dragging.value) return\n const target = event.target as Element\n if (target.closest('.dou-editor-columns__bar')) return\n bar.value = barNear(target, event.clientX, REACH)\n}\n\n/** A tap in the middle of a gap shows the bar there, to drag next. */\nfunction tap(event: PointerEvent) {\n if (event.pointerType === 'mouse' || resize) return\n const target = event.target as Element\n if (target.closest('.dou-editor-columns__bar')) return\n bar.value = barNear(target, event.clientX, TOUCH_REACH)\n}\n\nfunction leave(event: PointerEvent) {\n if (!resize && event.pointerType === 'mouse') bar.value = null\n}\n\n/** The bars of the set of columns around the cursor. */\nfunction placeKeyBars() {\n const current = state.value\n const block = current && blockAround(current.selection.$from)\n let row = block && parentBlock(current.doc, block)\n while (row && layoutOf(row.node) !== 'row') row = parentBlock(current!.doc, row)\n const group = row && findGroup(row.node.attrs.id as string)\n const columns = group ? childBlocks(group) : []\n if (!group || !sideBySide(columns)) {\n keyBars.value = []\n return\n }\n keyBars.value = columns\n .slice(1)\n .map((_, index) => barAt(group, index))\n .filter((entry): entry is Bar => !!entry)\n}\n\nwatch(state, () => void nextTick(placeKeyBars), { flush: 'post' })\n// the columns' names follow the locale\nwatch(messages, () => {\n const current = view.value\n if (current) current.dispatch(refreshColumns(current.state.tr))\n})\n\n/* dragging */\n\nlet resize: {\n pointer: number\n bar: Bar\n /** The two columns' widths together, in pixels, and the gap between them. */\n start: number\n span: number\n gap: number\n /** Their weights together, shared out again. */\n total: number\n /** Where the two columns are in the document. */\n columns: [number, number]\n weights: [number, number]\n} | null = null\n\n/** The two columns beside a bar: where they are, their weights and their size on the screen. */\nfunction pairOf(current: Bar) {\n const group = findGroup(current.row)\n const columns = group ? childBlocks(group) : []\n const weights = columnsInDoc(current.row)\n const left = columns[current.index]\n const right = columns[current.index + 1]\n const a = weights?.[current.index]\n const b = weights?.[current.index + 1]\n if (!group || !left || !right || !a || !b) return null\n const first = left.getBoundingClientRect()\n const second = right.getBoundingClientRect()\n return {\n group,\n start: first.left,\n span: first.width + second.width,\n gap: second.left - first.right,\n columns: [a.pos, b.pos] as [number, number],\n weights: [a.width, b.width] as [number, number],\n }\n}\n\n/** The left column's weight for a width in pixels, the narrowest kept. */\nfunction share(total: number, span: number, width: number): [number, number] {\n const min = Math.min(MIN_WIDTH, span / 2)\n const clamped = Math.min(span - min, Math.max(min, width))\n const left = Math.round((total * clamped * 1000) / span) / 1000\n return [left, Math.round((total - left) * 1000) / 1000]\n}\n\nfunction show(preview: ColumnPreview[] | null) {\n const current = view.value\n if (current) current.dispatch(previewColumns(current.state.tr, preview))\n}\n\n/** Write the two columns' widths: one undo step. */\nfunction commit(columns: [number, number], weights: [number, number]) {\n const current = view.value\n if (!current) return\n const tr = previewColumns(current.state.tr, null).setMeta('addToHistory', true)\n columns.forEach((pos, offset) => {\n const weight = weights[offset]!\n tr.setNodeAttribute(pos + 1, 'width', weight === 1 ? null : widthOf(weight))\n })\n current.dispatch(tr)\n}\n\nfunction onDown(event: PointerEvent, current: Bar) {\n if (event.button !== 0) return\n const pair = pairOf(current)\n if (!pair) return\n event.preventDefault()\n ;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)\n resize = {\n pointer: event.pointerId,\n bar: current,\n start: pair.start,\n span: pair.span,\n gap: pair.gap,\n total: pair.weights[0] + pair.weights[1],\n columns: pair.columns,\n weights: pair.weights,\n }\n active.value = true\n window.addEventListener('keydown', onEscape, true)\n}\n\nfunction onMove(event: PointerEvent) {\n if (!resize || event.pointerId !== resize.pointer) return\n const { start, span, gap, total, columns } = resize\n resize.weights = share(total, span, event.clientX - gap / 2 - start)\n show(columns.map((pos, offset) => ({ pos, width: resize!.weights[offset]! })))\n const group = findGroup(resize.bar.row)\n const moved = group && barAt(group, resize.bar.index)\n if (moved) bar.value = moved\n}\n\nfunction end() {\n resize = null\n active.value = false\n window.removeEventListener('keydown', onEscape, true)\n}\n\nfunction onUp(event: PointerEvent) {\n if (!resize || event.pointerId !== resize.pointer) return\n const { columns, weights } = resize\n end()\n commit(columns, weights)\n}\n\n/** `Esc` or a cancelled pointer: the widths as they were. */\nfunction cancel() {\n if (!resize) return\n end()\n show(null)\n const current = bar.value\n const group = current && findGroup(current.row)\n if (current && group) bar.value = barAt(group, current.index)\n}\n\nfunction onEscape(event: KeyboardEvent) {\n if (event.key !== 'Escape') return\n event.preventDefault()\n event.stopPropagation()\n cancel()\n}\n\n/** `←` `→` on a bar: move a little width from one column to the other; `Esc` or `Shift+Tab` back to the text. */\nfunction onKey(event: KeyboardEvent, current: Bar) {\n if (event.key === 'Escape' || (event.key === 'Tab' && event.shiftKey)) {\n event.preventDefault()\n view.value?.focus()\n return\n }\n const direction = { ArrowLeft: -1, ArrowRight: 1 }[event.key]\n if (!direction) return\n event.preventDefault()\n const pair = pairOf(current)\n if (!pair) return\n const total = pair.weights[0] + pair.weights[1]\n const width = (pair.weights[0] / total) * pair.span + direction * STEP * pair.span\n commit(pair.columns, share(total, pair.span, width))\n void nextTick(placeKeyBars)\n}\n\n/** A double click: every column of the set as wide as the others. */\nfunction even(current: Bar) {\n const columns = columnsInDoc(current.row)\n const instance = view.value\n if (!columns || !instance) return\n const tr = instance.state.tr\n for (const column of columns)\n if (column.width !== 1) tr.setNodeAttribute(column.pos + 1, 'width', null)\n if (tr.docChanged) instance.dispatch(tr)\n}\n\n/** The bars to draw: the keyboard's, and the pointer's when it is at another gap. */\nconst bars = computed(() => {\n const list = keyBars.value.map((entry) => ({ ...entry, key: true, shown: false }))\n const pointed = bar.value\n if (!pointed) return list\n const same = list.findIndex((entry) => entry.row === pointed.row && entry.index === pointed.index)\n if (same < 0) return [...list, { ...pointed, key: false, shown: true }]\n list[same] = { ...pointed, key: true, shown: true }\n return list\n})\n\nconst onScroll = () => {\n if (!resize) bar.value = null\n}\n\n// the editor narrower or wider (a window resized, a tablet turned): the bars move with the columns\nlet observer: ResizeObserver | undefined\n\nonMounted(() => {\n if (typeof ResizeObserver !== 'undefined' && root.value) {\n observer = new ResizeObserver(() => {\n if (!resize) bar.value = null\n placeKeyBars()\n })\n observer.observe(root.value)\n }\n root.value?.addEventListener('pointermove', track)\n root.value?.addEventListener('pointerdown', tap)\n root.value?.addEventListener('pointerleave', leave)\n window.addEventListener('scroll', onScroll, true)\n placeKeyBars()\n})\nonBeforeUnmount(() => {\n observer?.disconnect()\n root.value?.removeEventListener('pointermove', track)\n root.value?.removeEventListener('pointerdown', tap)\n root.value?.removeEventListener('pointerleave', leave)\n window.removeEventListener('scroll', onScroll, true)\n window.removeEventListener('keydown', onEscape, true)\n})\n</script>\n\n<template>\n <div\n v-for=\"entry in bars\"\n :key=\"`${entry.row}-${entry.index}`\"\n :class=\"[\n 'dou-editor-columns__bar',\n { 'is-key': entry.key, 'is-shown': entry.shown, 'is-active': active && entry.shown },\n ]\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n :tabindex=\"entry.key ? 0 : -1\"\n :aria-label=\"messages.columns.resize\"\n :aria-valuenow=\"entry.value\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n :title=\"messages.columns.resize\"\n :style=\"{ top: `${entry.top}px`, left: `${entry.left}px`, height: `${entry.height}px` }\"\n @mousedown.prevent\n @pointerdown=\"onDown($event, entry)\"\n @pointermove=\"onMove\"\n @pointerup=\"onUp\"\n @pointercancel=\"cancel\"\n @lostpointercapture=\"cancel\"\n @keydown=\"onKey($event, entry)\"\n @focus=\"placeKeyBars\"\n @dblclick=\"even(entry)\"\n />\n</template>\n"],"mappings":""}
|