Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

記事を編集して位置を変えても翻訳を維持したい #171

Closed
ttizze opened this issue Aug 12, 2024 · 12 comments · Fixed by #185
Closed

記事を編集して位置を変えても翻訳を維持したい #171

ttizze opened this issue Aug 12, 2024 · 12 comments · Fixed by #185
Assignees
Labels
enhancement Improvement to existing features

Comments

@ttizze
Copy link
Owner

ttizze commented Aug 12, 2024

過去の翻訳も保存しておきたい
pageid, numberのuniqueはいらない
保存のとき常にすべて保存
取得のときtexthash比較で取得

@ttizze ttizze added the bug Something isn't working as expected label Aug 13, 2024
@ttizze ttizze self-assigned this Aug 13, 2024
Copy link

Created branch ttizze/fix-issue-171

@ttizze
Copy link
Owner Author

ttizze commented Aug 14, 2024

翻訳をランク付けする必要があるので、sourcetextに対してtranslate textsは一意の集合でなければならない

@ttizze
Copy link
Owner Author

ttizze commented Aug 15, 2024

pageのcontentにsTのidを振ればずれてもいける

以下現状

作成
number振る
content保存
number text取り出す
createST

翻訳
contentからnumber text取り出す
翻訳
numberを元にsourcetext探す
STのidでTT保存

表示
textにnumberを元に翻訳を割り当てる

以下に変える

作成 編集
number振る
content保存
number text STIDを取り出す
createST STIDあるなら更新
STIDをつけてcontentに保存

翻訳
STからpageの最新を取る
翻訳
STのidでTT保存

表示
STのIDを元に翻訳を割り当てる

@ttizze
Copy link
Owner Author

ttizze commented Aug 15, 2024

number pageidをユニークにするかどうか?
しなければ過去のやつもそのまま保存しておける

versionテーブル作るならそっちに保存
number pageidをユニークにしないでおいて、バージョンつけたら考えよう

@ttizze
Copy link
Owner Author

ttizze commented Aug 16, 2024

number pageidでユニークにする
過去の保存は価値が出るほど人気が出てから考えよう
バージョン管理もその時導入

@ttizze
Copy link
Owner Author

ttizze commented Aug 16, 2024

tiptapが勝手に消す
つけると新規パラグラフが勝手に引き継ぐ

@ttizze
Copy link
Owner Author

ttizze commented Aug 17, 2024

同じ番号被ってたら後処理で消すか

@ttizze
Copy link
Owner Author

ttizze commented Aug 17, 2024

  • 作成
    tiptapからcontent受け取る
    number振る
    numberdContent保存
    number textを取り出す
    createSourceText
    SourceTextIdをつけてcontentに保存

  • 編集
    tiptapからcontent受け取る
    number振る
    numberdContent保存
    tiptapが引き継いで勝手につけたsourceTextId削除
    number text sourceTextIdを取り出す
    createOrUpdateSourceText SourceTextIdあるなら更新
    SourceTextIdをつけてcontentに保存

  • 翻訳
    pageからnumber content SourceTextId取得
    翻訳
    SourceTextIdでtranslateText保存

  • 表示
    SourceTextIdを元に翻訳を割り当てる

@ttizze ttizze added enhancement Improvement to existing features and removed bug Something isn't working as expected labels Aug 17, 2024
@ttizze ttizze assigned ttizze and unassigned ttizze Aug 17, 2024
Copy link

Created branch ttizze/enhance-issue-171

Copy link

PR #185 has been linked to this issue

@ttizze ttizze added this to eveeve Aug 17, 2024
@ttizze ttizze moved this to Backlog in eveeve Aug 17, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in eveeve Aug 17, 2024
@ttizze
Copy link
Owner Author

ttizze commented Aug 17, 2024

以下で属性引き継がずにできる、けどrenderのたびに全IDに走ってしまう
onUpdateでcontent設定してるからそのたびに以下が走ることになるため、処理として重いので保存後に削除するやつのままにした。挙動は同じはず

const CustomDataAttribute = Extension.create({
	name: "customDataAttribute",

	addStorage() {
		return {
			renderedIds: new Set<string>(),
		};
	},

	addGlobalAttributes() {
		return [
			{
				types: ["paragraph", "heading"],
				attributes: {
					"data-source-text-id": {
						default: null,
						parseHTML: (element) => element.getAttribute("data-source-text-id"),
						renderHTML: (attributes) => {
							const id = attributes["data-source-text-id"];
							if (id) {
								if (!this.storage.renderedIds.has(id)) {
									this.storage.renderedIds.add(id);
									return { "data-source-text-id": id };
								}
								return {};
							}
							return {};
						},
					},
				},
			},
		];
	},
	onUpdate() {
		this.storage.renderedIds.clear();
	},
});

@ttizze ttizze changed the title 記事を編集して位置を変えても翻訳を維持するためにnumberの管理を考える 記事を編集して位置を変えても翻訳を維持したい Aug 17, 2024
@ttizze
Copy link
Owner Author

ttizze commented Aug 17, 2024

残ってる問題として既存のデータの上に追加されるとその新しく追加されたほうにソーステクストIDがつく

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to existing features
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant