(修正済み)New Page (Scrapbox)のバグ
2022-07-21 10:03:04 直ったようです
>indentが深い文章をnew pageで切り出すとindenが浅い部分が消える不具合の修正
↓のGIFと同じ範囲を切り出して、実際に直ったことを確認しました
おお~🎉


文字が切れる
背景が変わっているのは本件と無関係です
たまたま

さんがCSSを変えたタイミングだっただけ
発生条件
先頭行のインデントを2つ以上含めて切り出そうとすると発生する
インデント1つまでなら壊れない
他のページでも起きるかは不明
indent level 3くらいの場合
mjk

現状だとおま環の可能性もあるので
再現しました

Thanksです

となると、UserScriptなどの個人設定が悪さをしている線はないか
最初の行のインデントレベル:5
最大インデントレベル:10
テスト
ほげ 0
ほげ 1
ほげ 2
ほげ 3
ほげ 4
ほげ 5
ほげ 6
ほげ 7
ほげ 8
ほげ 9
ほげ 10
ほげ 11
ほげ 12
ほげ 13
ほげ14
ほげ 8
ほげ 10
ほげ11
ほげ 8
ほげ11
ほげ 9
ほげ 8
ほげ0
ほげ11
調査結果
2行のnew pageだと発生しない
正常にnew pageできた場合、最初の行はインデントレベル1になるはず?
9,10:発生する(ほげ 9のインデントレベルが0)

unofficial.js
3行をnew page
7,8,9:発生しない
8,9,10:発生する

unofficial.js
9,10,11:発生する

unofficial.js
10,11,12:発生しない!
11,12,13:発生しない
飛び飛びのインデントレベルの3行をnew page
8,10,11:発生する

unofficial.js
8,11,9:発生する

unofficial.js
8,0,11:発生しない
インデントレベル0の行以降は別扱い?
0の行以下に9以下と10以上が混在すると問題になる?
でも空行がないと .line section-n
は変わらないのか
new pageボタンの処理上の扱いの問題か
インデントレベル10以上の行を含む3行以上のnew pageが問題?
インデントレベル9以下と10以上の行が混ざったものをnew pageすると発生する?
何かが c-9
までしかない?(わからない)
調査ログとしてこのページを貼っておく
(まあインデント10も掘るなって話かもしれないけど…)
掘るのは別によくて、それを解消するためにNewPageすればいいわけだから、やっぱりNewPageがバグってると良くないな

報告した
ちょっと変えていいでしょうか

選択範囲の先頭行にインデントを含めて
NewPageを実行すると、切り出し後のページで全ての行の先頭部分が消えてしまう
バグが発生しています
→インデントレベル9以下と10以上の行が混ざった部分を選択して
NewPageを実行すると、切り出し後のページで全ての行の先頭部分が消えてしまう
バグが発生しています
直接編集していただいて構いません。むしろ大歓迎です

了解です

2021-02-08 01:41:31 うーん、まだ直っていないっぽい

重箱の隅 of 隅だからなあ

2022-03-12 14:28:49 また発生した

井戸端だと日記から切り出すケースが多いので発生しやすそう

jsfunction _onClick(i) {
var w = _(q);
if ("string" == typeof w) {
var P = A.default.Selection.getRange({
normalizeOrder: !0
});
A.default.Line.deleteRange(P), A.default.Line.addChar(w), A.default.Selection.clear(), A.default.Cursor.focus()
}
}
これだけじゃわからないな

このコードだとどうなんだろう
20:52:47 バグらなそう
ほんとだ、バグらない

公式の挙動だとインデントレベル1以上の先頭行はインデントレベル1になるようだけど、これだと0になる
そうだったっけ?
21:00:20 選択範囲にindent level 0以外の行しか入っていないときは、切り出し後の最小indent levelを1にするみたい
こっちの挙動に変更した
unofficial.jsscrapbox.PopupMenu.addButton({
title: 'Unofficial new page',
onClick: text => {
const texts = text.split('\n');
const title = texts[0].replace(/[\[\]\n]/g, '').trim();
// 余計なインデントを削る
const minIndentNum = Math.min(...texts.map(text => text.match(/^\s*/)[0].length));
const body = [`from [${scrapbox.Page.title}]`, ...texts.map(text => text.slice(
minIndentNum > 1 ? minIndentNum - 1 : minIndentNum
))];
// windowを開く
window.open(`https://scrapbox.io/${scrapbox.Project.name}/${title}?body=${encodeURIComponent(body.join('\n'))}`);
return `[${title}]`;
}
});
こんなのもあった
長い…
line 121197~
わーお
だんだんreverse engineeringじみてきた

index.js_.default = function NewPageButton() {
return P.default.createElement(q.default, {
onClick: function createNewPage(i) {
やっぱりインデントの調節をしているか。
index.js var _ = function decreaseIndents(i) {
ここでインデントの最小数を計算してる
index.js var _ = function getMinIndent(i) {
return i.filter((function(i) {
return i
}
)).map((function(i) {
return i.match(/^(\s*)/)[0].length
}
)).sort()[0]
}(i);
substr
でindentを削っている
index.js return _ < 2 ? i : i.map((function(i) {
return i.substr(_ - 1)
}
))
}(i.split(/[\r\n]/))
タイトルの文字列を取得している?
ずいぶんと長いな
index.js , w = function findTitle(i) {
var _, w = function _createForOfIteratorHelper(i, _) {
var w;
if ("undefined" == typeof Symbol || null == i[Symbol.iterator]) {
if (Array.isArray(i) || (w = function _unsupportedIterableToArray(i, _) {
if (!i)
return;
if ("string" == typeof i)
return _arrayLikeToArray(i, _);
var w = Object.prototype.toString.call(i).slice(8, -1);
という行があるが、関係あるのかな

こうやって分割してコメントできるのか!

ほんとだ~いいですね

はよく使っています
コメントを除いてコピーできるのもいい
自分でやって自分で驚いたみたいになってる
当たり前だけどとても読みづらい

変数の使い回しとか
,
とか
怒涛の concat
ネストとか
index.js var w = Object.prototype.toString.call(i).slice(8, -1);
"Object" === w && i.constructor && (w = i.constructor.name);
if ("Map" === w || "Set" === w)
return Array.from(i);
if ("Arguments" === w || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))
return _arrayLikeToArray(i, _)
}(i)) || _ && i && "number" == typeof i.length) {
w && (i = w);
var P = 0
, E = function F() {};
return {
s: E,
n: function n() {
return P >= i.length ? {
done: !0
} : {
done: !1,
value: i[P++]
}
},
e: function e(i) {
throw i
},
f: E
}
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
}
var A, j = !0, q = !1;
return {
s: function s() {
w = i[Symbol.iterator]()
},
n: function n() {
var i = w.next();
return j = i.done,
i
},
e: function e(i) {
q = !0,
A = i
},
f: function f() {
try {
j || null == w.return || w.return()
} finally {
if (q)
throw A
}
}
}
}(i);
try {
for (w.s(); !(_ = w.n()).done; ) {
var P = _.value
, E = (0,
$.renderPageTitle)((0,
B.parseScrapboxSyntax)(P));
if ((0,
oe.validatePageTitle)(E).isValid)
return E
}
} catch (A) {
w.e(A)
} finally {
w.f()
}
}(_) || function getDefaultTitle() {
return "Untitled " + (new Date).toLocaleString()
}()
↑ここまでがタイトル取得処理かな
index.js , P = A.default.Line.lines.getTitle();
_.unshift("from [".concat(P, "]"));
var q = A.default.CurrentProject.get().name;
return j.default.set("appendPageBody", {
projectName: q,
lines: _
}),
E.When.standalone_app ? window.open("/".concat(q, "/").concat((0,
ne.encodeTitleURI)(w)), null, 1) : window.open("/".concat(q, "/").concat((0,
ne.encodeTitleURI)(w))),
"[".concat(w, "]")
},
className: "new-page-button"
}, "New page")
}
;
2022/5/6
こうなった

環境
mac
Chrome バージョン: 103.0.5044.0(Official Build)canary (arm64)
昔もあったらしい?
mergeしておきました
ありがとうございます

これはずっと前からあるバグだったのか
