@inkandswitch/patchwork-pkg-base 0.0.47 → 0.0.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkandswitch/patchwork-pkg-base",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "type": "module",
5
5
  "description": "Base packages for the Patchwork system",
6
6
  "repository": {
@@ -3070,34 +3070,52 @@ import { EditorView as EditorView4, keymap } from "@codemirror/view";
3070
3070
 
3071
3071
  // src/extensions/formatting.ts
3072
3072
  import { EditorSelection as EditorSelection3 } from "@codemirror/state";
3073
+ var MARKS = ["**", "__", "~~", "*", "_", "`"];
3073
3074
  var toggleWrap = (mark) => ({ state, dispatch }) => {
3074
3075
  const selection = state.changeByRange((range) => {
3075
- const before = state.sliceDoc(range.from - mark.length, range.from);
3076
- const after = state.sliceDoc(range.to, range.to + mark.length);
3077
- const inside = state.sliceDoc(range.from, range.from + mark.length) === mark && state.sliceDoc(range.to - mark.length, range.to) === mark && range.to - range.from >= mark.length * 2;
3078
- if (before === mark && after === mark) {
3079
- return {
3080
- changes: [
3081
- { from: range.from - mark.length, to: range.from },
3082
- { from: range.to, to: range.to + mark.length }
3083
- ],
3084
- range: EditorSelection3.range(
3085
- range.from - mark.length,
3086
- range.to - mark.length
3087
- )
3088
- };
3076
+ let from = range.from;
3077
+ let to = range.to;
3078
+ for (; ; ) {
3079
+ const found = MARKS.find(
3080
+ (m) => state.sliceDoc(from - m.length, from) === m && state.sliceDoc(to, to + m.length) === m
3081
+ );
3082
+ if (!found) break;
3083
+ if (found === mark) {
3084
+ return {
3085
+ changes: [
3086
+ { from: from - mark.length, to: from },
3087
+ { from: to, to: to + mark.length }
3088
+ ],
3089
+ range: EditorSelection3.range(
3090
+ range.from - mark.length,
3091
+ range.to - mark.length
3092
+ )
3093
+ };
3094
+ }
3095
+ from -= found.length;
3096
+ to += found.length;
3089
3097
  }
3090
- if (inside) {
3091
- return {
3092
- changes: [
3093
- { from: range.from, to: range.from + mark.length },
3094
- { from: range.to - mark.length, to: range.to }
3095
- ],
3096
- range: EditorSelection3.range(
3097
- range.from,
3098
- range.to - mark.length * 2
3099
- )
3100
- };
3098
+ from = range.from;
3099
+ to = range.to;
3100
+ for (; ; ) {
3101
+ const found = MARKS.find(
3102
+ (m) => to - from >= m.length * 2 && state.sliceDoc(from, from + m.length) === m && state.sliceDoc(to - m.length, to) === m
3103
+ );
3104
+ if (!found) break;
3105
+ if (found === mark) {
3106
+ return {
3107
+ changes: [
3108
+ { from, to: from + mark.length },
3109
+ { from: to - mark.length, to }
3110
+ ],
3111
+ range: EditorSelection3.range(
3112
+ range.from,
3113
+ range.to - mark.length * 2
3114
+ )
3115
+ };
3116
+ }
3117
+ from += found.length;
3118
+ to -= found.length;
3101
3119
  }
3102
3120
  return {
3103
3121
  changes: [
@@ -3173,6 +3191,20 @@ var markdownStyles = (style) => ({
3173
3191
  ".cm-content li": {
3174
3192
  marginBottom: 0
3175
3193
  },
3194
+ ".cm-bullet": {
3195
+ display: "inline-block",
3196
+ width: "1ch"
3197
+ },
3198
+ ".cm-bullet::before": {
3199
+ content: '""',
3200
+ display: "inline-block",
3201
+ width: "0.4em",
3202
+ height: "0.4em",
3203
+ borderRadius: "50%",
3204
+ background: "currentColor",
3205
+ color: "var(--text-editor-line)",
3206
+ verticalAlign: "0.15em"
3207
+ },
3176
3208
  ".cm-activeLine": {
3177
3209
  backgroundColor: "inherit"
3178
3210
  },
@@ -3370,7 +3402,6 @@ var bullets = ViewPlugin2.fromClass(
3370
3402
  var BulletWidget = class extends WidgetType {
3371
3403
  toDOM() {
3372
3404
  const span = document.createElement("span");
3373
- span.textContent = "\u2022";
3374
3405
  span.className = "cm-bullet";
3375
3406
  return span;
3376
3407
  }